Class: Webspicy::HttpClient
- Defined in:
- lib/webspicy/client/http_client.rb
Defined Under Namespace
Classes: Api
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
Attributes inherited from Client
Instance Method Summary collapse
- #call(test_case) ⇒ Object
-
#initialize(scope) ⇒ HttpClient
constructor
class ::HTTP::Request.
Methods inherited from Client
#after, #around, #before, #config
Constructor Details
#initialize(scope) ⇒ HttpClient
class ::HTTP::Request
15 16 17 18 |
# File 'lib/webspicy/client/http_client.rb', line 15 def initialize(scope) super(scope) @api = Api.new end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
19 20 21 |
# File 'lib/webspicy/client/http_client.rb', line 19 def api @api end |
Instance Method Details
#call(test_case) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/webspicy/client/http_client.rb', line 21 def call(test_case) service, resource = test_case.service, test_case.resource # Instantiate the parameters headers = test_case.headers params = test_case.dress_params? ? service.dress_params(test_case.params) : test_case.params body = test_case.body || test_case.located_file_upload # Instantiate the url and strip parameters url, params = resource.instantiate_url(params) # Globalize the URL if required url = scope.to_real_url(url, test_case) # Invoke the service now api.public_send(service.method.to_s.downcase.to_sym, url, params, headers, body) # Return the result Resource::Service::Invocation.new(service, test_case, api.last_response, self) end |