Class: EzClient::Request
- Inherits:
-
Object
show all
- Defined in:
- lib/ezclient/request.rb
Defined Under Namespace
Classes: RedirectCookieState
Constant Summary
collapse
- OPTION_KEYS =
%i[
body
form
json
metadata
params
query
].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(verb, url, options) ⇒ Request
Returns a new instance of Request.
Instance Attribute Details
#elapsed_seconds ⇒ Object
Returns the value of attribute elapsed_seconds.
58
59
60
|
# File 'lib/ezclient/request.rb', line 58
def elapsed_seconds
@elapsed_seconds
end
|
#options ⇒ Object
Returns the value of attribute options.
58
59
60
|
# File 'lib/ezclient/request.rb', line 58
def options
@options
end
|
#url ⇒ Object
Returns the value of attribute url.
58
59
60
|
# File 'lib/ezclient/request.rb', line 58
def url
@url
end
|
#verb ⇒ Object
Returns the value of attribute verb.
58
59
60
|
# File 'lib/ezclient/request.rb', line 58
def verb
@verb
end
|
Instance Method Details
110
111
112
|
# File 'lib/ezclient/request.rb', line 110
def ()
http_request..merge!()
end
|
#api_auth!(*args) ⇒ Object
89
90
91
92
93
94
|
# File 'lib/ezclient/request.rb', line 89
def api_auth!(*args)
raise "ApiAuth gem is not loaded" unless defined?(ApiAuth)
ApiAuth.sign!(api_auth_request, *args)
self
end
|
#body ⇒ Object
100
101
102
103
104
|
# File 'lib/ezclient/request.rb', line 100
def body
body = +""
http_request.body.each { |chunk| body << chunk }
body
end
|
106
107
108
|
# File 'lib/ezclient/request.rb', line 106
def
http_request..to_h
end
|
#http_options ⇒ Object
114
115
116
|
# File 'lib/ezclient/request.rb', line 114
def http_options
@http_options ||= http_client.default_options.merge(ssl_context: options[:ssl_context])
end
|
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/ezclient/request.rb', line 68
def perform
http_response = perform_request
EzClient::Response.new(http_response, http_request).tap do |response|
on_complete.call(self, response, options[:metadata])
end
rescue => error
on_error.call(self, error, options[:metadata])
error_wrapper.call(self, error, options[:metadata])
end
|
79
80
81
82
83
84
85
86
87
|
# File 'lib/ezclient/request.rb', line 79
def perform!
response = perform
if response.error?
raise EzClient::ResponseStatusError, response
else
response
end
end
|
#uri ⇒ Object
96
97
98
|
# File 'lib/ezclient/request.rb', line 96
def uri
http_request.uri
end
|