Class: Crowdin::Web::Request
- Inherits:
-
Object
- Object
- Crowdin::Web::Request
- Defined in:
- lib/crowdin-api/core/request.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #delete ⇒ Object
- #delete? ⇒ Boolean
- #get ⇒ Object
- #get? ⇒ Boolean
-
#initialize(connection, method, url, payload = {}) ⇒ Request
constructor
A new instance of Request.
- #patch? ⇒ Boolean
- #post? ⇒ Boolean
- #process_with_body ⇒ Object (also: #post, #patch, #put)
- #put? ⇒ Boolean
Constructor Details
#initialize(connection, method, url, payload = {}) ⇒ Request
Returns a new instance of Request.
10 11 12 13 14 |
# File 'lib/crowdin-api/core/request.rb', line 10 def initialize(connection, method, url, payload = {}) @connection = connection[url] @method = method @payload = build_payload(payload) end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/crowdin-api/core/request.rb', line 6 def connection @connection end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/crowdin-api/core/request.rb', line 7 def method @method end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
8 9 10 |
# File 'lib/crowdin-api/core/request.rb', line 8 def payload @payload end |
Instance Method Details
#delete ⇒ Object
28 29 30 |
# File 'lib/crowdin-api/core/request.rb', line 28 def delete connection.delete end |
#delete? ⇒ Boolean
24 25 26 |
# File 'lib/crowdin-api/core/request.rb', line 24 def delete? method.eql?(:delete) end |
#get ⇒ Object
20 21 22 |
# File 'lib/crowdin-api/core/request.rb', line 20 def get connection.get(prepare_payload(payload[:params])) end |
#get? ⇒ Boolean
16 17 18 |
# File 'lib/crowdin-api/core/request.rb', line 16 def get? method.eql?(:get) end |
#patch? ⇒ Boolean
41 42 43 |
# File 'lib/crowdin-api/core/request.rb', line 41 def patch? method.eql?(:patch) end |
#post? ⇒ Boolean
36 37 38 |
# File 'lib/crowdin-api/core/request.rb', line 36 def post? method.eql?(:post) end |
#process_with_body ⇒ Object Also known as: post, patch, put
32 33 34 |
# File 'lib/crowdin-api/core/request.rb', line 32 def process_with_body connection.send(method, prepare_payload(payload[:params]), payload[:headers]) { |response, _, _| response } end |
#put? ⇒ Boolean
46 47 48 |
# File 'lib/crowdin-api/core/request.rb', line 46 def put? method.eql?(:put) end |