Module: Fakturoid::Oauth::Request::Base
Constant Summary collapse
- HTTP_METHODS =
[:get, :post, :patch, :delete].freeze
- REQUEST_TIMEOUT =
10
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
7 8 9 |
# File 'lib/fakturoid/oauth/request/base.rb', line 7 def client @client end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/fakturoid/oauth/request/base.rb', line 7 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/fakturoid/oauth/request/base.rb', line 7 def path @path end |
Instance Method Details
#call(params = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fakturoid/oauth/request/base.rb', line 18 def call(params = {}) raise ArgumentError, "Unknown http method: #{method}" unless HTTP_METHODS.include?(method.to_sym) request_params = params[:request_params] || {} http_connection = connection(params) http_connection.send(method) do |req| req.url path, request_params req.body = MultiJson.dump(params[:payload]) if params.key?(:payload) end end |
#initialize(method, path, client) ⇒ Object
12 13 14 15 16 |
# File 'lib/fakturoid/oauth/request/base.rb', line 12 def initialize(method, path, client) @method = method @path = path @client = client end |