ubiquity-envoi 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,282 @@
1
+ require 'json'
2
+ require 'net/https'
3
+
4
+ module Ubiquity
5
+ module Envoi
6
+ module API
7
+ class Client
8
+
9
+ class HTTPClient
10
+
11
+ attr_accessor :logger, :http, :http_host_address, :http_host_port, :base_uri
12
+ attr_accessor :username, :password
13
+
14
+ attr_accessor :default_request_headers,
15
+ :authorization_header_key, :authorization_header_value
16
+
17
+ attr_accessor :log_request_body, :log_response_body, :log_pretty_print_body
18
+
19
+ attr_accessor :request, :response
20
+
21
+ DEFAULT_HTTP_HOST_ADDRESS = 'localhost'
22
+ DEFAULT_HTTP_HOST_PORT = 80
23
+
24
+ DEFAULT_BASE_PATH = '/api/'
25
+
26
+ DEFAULT_HEADER_CONTENT_TYPE = 'application/json; charset=utf-8'
27
+ DEFAULT_HEADER_ACCEPTS = 'application/json'
28
+
29
+ def initialize(args = {})
30
+ args = args.dup
31
+ initialize_logger(args)
32
+ initialize_http(args)
33
+
34
+ logger.debug { "#{self.class.name}::#{__method__} Arguments: #{args.inspect}" }
35
+
36
+ @username = args[:api_key] || args[:username]
37
+ @password = args[:api_password] || args[:password]
38
+
39
+ @base_uri = args[:base_uri] || "http#{http.use_ssl? ? 's' : ''}://#{http.address}:#{http.port}"
40
+ @default_base_path = args[:default_base_path] || DEFAULT_BASE_PATH
41
+
42
+ # @user_agent_default = "#{@hostname}:#{@username} Ruby SDK Version #{Vidispine::VERSION}"
43
+
44
+ @authorization_header_key ||= 'Authorization'
45
+ @authorization_header_value ||= %(Basic #{["#{username}:#{password}"].pack('m').delete("\r\n")})
46
+
47
+ content_type = args[:content_type_header] ||= DEFAULT_HEADER_CONTENT_TYPE
48
+ accepts = args[:accepts_header] ||= args[:accept_header] || DEFAULT_HEADER_ACCEPTS
49
+
50
+ @default_request_headers = {
51
+ 'Content-Type' => content_type,
52
+ 'Accept' => accepts,
53
+ authorization_header_key => authorization_header_value,
54
+ }
55
+
56
+ @log_request_body = args.fetch(:log_request_body, true)
57
+ @log_response_body = args.fetch(:log_response_body, true)
58
+ @log_pretty_print_body = args.fetch(:log_pretty_print_body, true)
59
+
60
+ @parse_response = args.fetch(:parse_response, true)
61
+ end
62
+
63
+ def initialize_logger(args = {})
64
+ @logger = args[:logger] ||= Logger.new(args[:log_to] || STDOUT)
65
+ log_level = args[:log_level]
66
+ if log_level
67
+ @logger.level = log_level
68
+ args[:logger] = @logger
69
+ end
70
+ @logger
71
+ end
72
+
73
+ def initialize_http(args = {})
74
+ @http_host_address = args[:http_host_address] ||= DEFAULT_HTTP_HOST_ADDRESS
75
+ @http_host_port = args[:http_host_port] ||= DEFAULT_HTTP_HOST_PORT
76
+ @http = Net::HTTP.new(@http_host_address, @http_host_port)
77
+
78
+ use_ssl = args[:http_host_use_ssl]
79
+ @http.use_ssl = true if use_ssl
80
+
81
+ @http
82
+ end
83
+
84
+ # Formats a HTTPRequest or HTTPResponse body for log output.
85
+ # @param [HTTPRequest|HTTPResponse] obj
86
+ # @return [String]
87
+ def format_body_for_log_output(obj)
88
+ if obj.content_type == 'application/json'
89
+ if @log_pretty_print_body
90
+ _body = obj.body
91
+ output = JSON.pretty_generate(JSON.parse(_body)) rescue _body
92
+ return output
93
+ else
94
+ return obj.body
95
+ end
96
+ elsif obj.content_type == 'application/xml'
97
+ return obj.body
98
+ else
99
+ return obj.body.inspect
100
+ end
101
+ end
102
+
103
+ # @param [HTTPRequest] request
104
+ def send_request(request)
105
+ @response_parsed = nil
106
+ @request = request
107
+ logger.debug { %(REQUEST: #{request.method} http#{http.use_ssl? ? 's' : ''}://#{http.address}:#{http.port}#{request.path} HEADERS: #{request.to_hash.inspect} #{log_request_body and request.request_body_permitted? ? "\n-- BODY BEGIN --\n#{format_body_for_log_output(request)}\n-- BODY END --" : ''}) }
108
+
109
+ @response = http.request(request)
110
+ logger.debug { %(RESPONSE: #{response.inspect} HEADERS: #{response.to_hash.inspect} #{log_response_body and response.respond_to?(:body) ? "\n-- BODY BEGIN --\n#{format_body_for_log_output(response)}\n-- BODY END--" : ''}) }
111
+ #logger.debug { "Parse Response? #{@parse_response}" }
112
+ @parse_response ? response_parsed : response.body
113
+ end
114
+
115
+ def response_parsed
116
+ @response_parsed ||= begin
117
+ logger.debug { "Parsing Response. #{response.body.inspect}" }
118
+ case response.content_type
119
+ when 'application/json'
120
+ JSON.parse(response.body) # rescue response
121
+ else
122
+ response.body
123
+ end
124
+ end
125
+ end
126
+
127
+ # @param [String] path
128
+ # @param [Hash|String|Nil] query
129
+ # @return [URI]
130
+ def build_uri(path = '', query = nil)
131
+ _query = query.is_a?(Hash) ? query.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.respond_to?(:to_s) ? v.to_s : v)}" }.join('&') : query
132
+ _path = "#{path}#{_query and _query.respond_to?(:empty?) and !_query.empty? ? "?#{_query}" : ''}"
133
+ URI.parse(File.join(base_uri, @default_base_path, _path))
134
+ end
135
+
136
+ if RUBY_VERSION.start_with? '1.8.'
137
+ def request_method_name_to_class_name(method_name)
138
+ method_name.to_s.capitalize
139
+ end
140
+ else
141
+ def request_method_name_to_class_name(method_name)
142
+ method_name.to_s.capitalize.to_sym
143
+ end
144
+ end
145
+
146
+ # @param [Symbol] method_name (:get)
147
+ # @param [Hash] args
148
+ # @option args [Hash] :headers ({})
149
+ # @option args [String] :path ('')
150
+ # @option args [Hash] :query ({})
151
+ # @option args [Any] :body (nil)
152
+ # @param [Hash] options
153
+ # @option options [Hash] :default_request_headers (@default_request_headers)
154
+ def call_method(method_name = :get, args = {}, options = {})
155
+ headers = args[:headers] || options[:headers] || {}
156
+ path = args[:path] || ''
157
+ query = args[:query] || {}
158
+ body = args[:body]
159
+
160
+ # Allow the default request headers to be overridden
161
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers)
162
+ _default_request_headers ||= {}
163
+ _headers = _default_request_headers.merge(headers)
164
+
165
+ @uri = build_uri(path, query)
166
+ klass_name = request_method_name_to_class_name(method_name)
167
+ klass = Net::HTTP.const_get(klass_name)
168
+
169
+ request = klass.new(@uri.request_uri, _headers)
170
+
171
+ if request.request_body_permitted?
172
+ _body = (body and !body.is_a?(String)) ? JSON.generate(body) : body
173
+ logger.debug { "Processing Body: '#{_body}'" }
174
+ request.body = _body if _body
175
+ end
176
+
177
+ send_request(request)
178
+ end
179
+
180
+ def delete(path, options = {})
181
+ query = options.fetch(:query, {})
182
+ # base_path = options[:base_path] || @default_base_path
183
+ # _path = File.join(base_path, path)
184
+ @uri = build_uri(path, query)
185
+ request = Net::HTTP::Delete.new(@uri.request_uri, default_request_headers)
186
+ send_request(request)
187
+ end
188
+
189
+ def get(path, options = {})
190
+ # Allow the default request headers to be overridden
191
+ headers = options[:headers] || {}
192
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
193
+ _headers = _default_request_headers.merge(headers)
194
+
195
+ query ||= options.fetch(:query, {})
196
+ # base_path = options[:base_path] || @default_base_path
197
+ # _path = File.join(base_path, path)
198
+ @uri = build_uri(path, query)
199
+ request = Net::HTTP::Get.new(@uri.request_uri, _headers)
200
+ send_request(request)
201
+ end
202
+
203
+ def head(path, options = {})
204
+ # Allow the default request headers to be overridden
205
+ headers = options[:headers] || {}
206
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
207
+ _headers = _default_request_headers.merge(headers)
208
+
209
+ query ||= options.fetch(:query, {})
210
+ # base_path = options[:base_path] || @default_base_path
211
+ # _path = File.join(base_path, path)
212
+ @uri = build_uri(path, query)
213
+
214
+ request = Net::HTTP::Head.new(@uri.request_uri, _headers)
215
+ send_request(request)
216
+ end
217
+
218
+ def options(path, options = {})
219
+ # Allow the default request headers to be overridden
220
+ headers = options[:headers] || {}
221
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
222
+ _headers = _default_request_headers.merge(headers)
223
+
224
+ query ||= options.fetch(:query, {})
225
+ # base_path = options[:base_path] || @default_base_path
226
+ # _path = File.join(base_path, path)
227
+ @uri = build_uri(path, query)
228
+ request = Net::HTTP::Options.new(@uri.request_uri, _headers)
229
+ send_request(request)
230
+ end
231
+
232
+ def put(path, body, options = {})
233
+ # Allow the default request headers to be overridden
234
+ headers = options[:headers] || {}
235
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
236
+ _headers = _default_request_headers.merge(headers)
237
+
238
+ query = options.fetch(:query, {})
239
+ # base_path = options[:base_path] || @default_base_path
240
+ # _path = File.join(base_path, path)
241
+ @uri = build_uri(path, query)
242
+ request = Net::HTTP::Put.new(@uri.request_uri, _headers)
243
+
244
+ body = JSON.generate(body) if body and !body.is_a?(String)
245
+
246
+ request.body = body if body
247
+ send_request(request)
248
+ end
249
+
250
+ def post(path, body, options = {})
251
+ # Allow the default request headers to be overridden
252
+ headers = options[:headers] || {}
253
+ _default_request_headers = options.fetch(:default_request_headers, default_request_headers) || {}
254
+ _headers = _default_request_headers.merge(headers)
255
+
256
+ query = options.fetch(:query, {})
257
+ # base_path = options[:base_path] || @default_base_path
258
+ # _path = File.join(base_path, path)
259
+ @uri = build_uri(path, query)
260
+
261
+ request = Net::HTTP::Post.new(@uri.request_uri, _headers)
262
+
263
+ body = JSON.generate(body) if body and !body.is_a?(String)
264
+
265
+ request.body = body if body
266
+ send_request(request)
267
+ end
268
+
269
+ # HTTPClient
270
+ end
271
+
272
+ # Client
273
+ end
274
+
275
+ # API
276
+ end
277
+
278
+ # Envoi
279
+ end
280
+
281
+ # Ubiquity
282
+ end
@@ -0,0 +1,143 @@
1
+ class Ubiquity::Envoi::API::Client::Paginator
2
+
3
+ attr_accessor :api_client, :logger
4
+
5
+ def initialize(api_client, options = { })
6
+ @api_client = api_client
7
+ initialize_logger(options)
8
+ end
9
+
10
+ def initialize_logger(args = {})
11
+ @logger = args[:logger] ||= Logger.new(args[:log_to] || STDOUT)
12
+ log_level = args[:log_level]
13
+ if log_level
14
+ _logger = @logger.dup
15
+ _logger.level = log_level
16
+ @logger = _logger
17
+ end
18
+ @logger
19
+ end
20
+
21
+ def current_page
22
+ @current_page ||= last_response['page']
23
+ end
24
+
25
+ def http_client
26
+ api_client.http_client
27
+ end
28
+
29
+ def include_remaining_pages
30
+ # response = api_client.response.dup
31
+ @first_page = current_page
32
+ _results = last_results
33
+ _results.concat(remaining_pages_get)
34
+ _per_page = _results.length
35
+ last_response.merge({ 'page' => @first_page, 'perPage' => _per_page, 'results' => _results })
36
+ end
37
+
38
+ def last_response
39
+ @last_response ||= api_client.http_client.response_parsed
40
+ end
41
+
42
+ def last_results
43
+ @last_results ||= last_response['results']
44
+ end
45
+
46
+ def next_page?
47
+ current_page < total_pages
48
+ end
49
+
50
+ def next_page_get(_next_page_number = nil)
51
+ _next_page_number ||= next_page_number
52
+ page_get(_next_page_number)
53
+ end
54
+
55
+ def next_page_number
56
+ @next_page_number ||= current_page + 1
57
+ end
58
+
59
+ def page_size
60
+ @page_size ||= last_response['perPage']
61
+ end
62
+
63
+ def page_get(page_number)
64
+ logger.debug { "Getting Page #{page_number} of #{total_pages}" }
65
+ new_request = request.class.new(request_args_out.merge('_page' => page_number), request_options_out)
66
+ _response = new_request.execute
67
+ process_response
68
+ end
69
+
70
+ def pages_get(pages, options = { })
71
+ consolidate = options.fetch(:consolidate, true)
72
+ pages = pages.to_a if pages.respond_to?(:to_a)
73
+ pages_out = pages.map { |v| page_get(v) }
74
+ pages_out.flatten! if consolidate
75
+ pages_out
76
+ end
77
+
78
+ def paginated?
79
+ @paginated = !!total_results
80
+ end
81
+
82
+ def process_request
83
+ @current_page = nil
84
+ @total_results = nil
85
+ @has_next_page = nill
86
+ end
87
+
88
+ def process_response
89
+ @current_page = nil
90
+ @last_response = nil
91
+ @next_page_number = nil
92
+ @page_size = nil
93
+ @total_pages = nil
94
+ @total_results = nil
95
+ @paginated = !!total_results
96
+
97
+ @last_results = last_response['results']
98
+ end
99
+
100
+ def request
101
+ api_client.request
102
+ end
103
+
104
+ def request_args_out
105
+ @request_args_out ||= request.initial_arguments.dup
106
+ end
107
+
108
+ def request_options_out
109
+ @request_options_out ||= { :client => api_client }.merge request.initial_options.dup
110
+ end
111
+
112
+ def total_pages
113
+ @total_pages ||= begin
114
+ logger.debug { "Page Size: #{page_size}" }
115
+ logger.debug { "Total Results: #{total_results}" }
116
+
117
+ div = total_results / page_size
118
+ mod = total_results % page_size
119
+ remainder = div == mod ? 0 : 1
120
+ _total_pages = div + remainder
121
+ logger.debug { "Total Pages: #{_total_pages}" }
122
+ _total_pages
123
+ end
124
+ end
125
+
126
+ def total_results
127
+ @total_results ||= last_response['total']
128
+ end
129
+
130
+ def remaining_pages_get
131
+ return [ ] unless paginated? && next_page?
132
+ remaining_results = [ ]
133
+
134
+ loop do
135
+ response = next_page_get
136
+ remaining_results.concat(response)
137
+
138
+ break unless next_page?
139
+ end
140
+ remaining_results
141
+ end
142
+
143
+ end
@@ -0,0 +1,7 @@
1
+ require 'ubiquity/envoi/api/client/requests/base_request'
2
+
3
+ require 'ubiquity/envoi/api/client/requests/media_file_create'
4
+ require 'ubiquity/envoi/api/client/requests/media_file_add_file'
5
+ require 'ubiquity/envoi/api/client/requests/media_file_update'
6
+
7
+
@@ -0,0 +1,245 @@
1
+ require 'cgi'
2
+
3
+ module Ubiquity
4
+ module Envoi
5
+ module API
6
+ class Client
7
+ module Requests
8
+ class BaseRequest
9
+
10
+ HTTP_METHOD = :get
11
+ HTTP_BASE_PATH = ''
12
+ HTTP_PATH = ''
13
+ HTTP_SUCCESS_CODE = 200
14
+
15
+ DEFAULT_PARAMETER_SEND_IN_VALUE = :query
16
+
17
+ PARAMETERS = [ ]
18
+
19
+ attr_accessor :client, :arguments, :options, :initial_arguments, :initial_options, :missing_required_arguments,
20
+ :default_parameter_send_in_value, :processed_parameters, :initialized, :response
21
+
22
+ attr_writer :parameters, :path, :body, :query
23
+
24
+ def self.normalize_argument_hash_keys(hash)
25
+ return hash unless hash.is_a?(Hash)
26
+ Hash[ hash.dup.map { |k,v| [ normalize_parameter_name(k), v ] } ]
27
+ end
28
+
29
+ def self.normalize_parameter_name(name)
30
+ (name || '').respond_to?(:to_s) ? name.to_s.gsub('_', '').gsub('-', '').downcase : name
31
+ end
32
+
33
+ def self.process_parameter(param, args = { }, args_out = { }, missing_required_arguments = [ ], processed_parameters = { }, default_parameter_send_in_value = DEFAULT_PARAMETER_SEND_IN_VALUE, options = { })
34
+ args = normalize_argument_hash_keys(args) || { } if options.fetch(:normalize_argument_hash_keys, false)
35
+
36
+ _k = param.is_a?(Hash) ? param : { :name => param, :required => false, :send_in => default_parameter_send_in_value }
37
+ _k[:send_in] ||= default_parameter_send_in_value
38
+
39
+ proper_parameter_name = _k[:name]
40
+ param_name = normalize_parameter_name(proper_parameter_name)
41
+ arg_key = (has_key = args.has_key?(param_name)) ?
42
+ param_name :
43
+ ( (_k[:aliases] || [ ]).map { |a| normalize_parameter_name(a) }.find { |a| has_key = args.has_key?(a) } || param_name )
44
+
45
+ value = has_key ? args[arg_key] : _k[:default_value]
46
+ is_set = has_key || _k.has_key?(:default_value)
47
+
48
+ processed_parameters[proper_parameter_name] = _k.merge(:value => value, :is_set => is_set)
49
+
50
+ unless is_set
51
+ missing_required_arguments << proper_parameter_name if _k[:required]
52
+ else
53
+ args_out[proper_parameter_name] = value
54
+ end
55
+
56
+ { :arguments_out => args_out, :processed_parameters => processed_parameters, :missing_required_arguments => missing_required_arguments }
57
+ rescue => e
58
+ raise e, "Error Processing Parameter: #{param.inspect} Args: #{args.inspect}. #{e.message}"
59
+ end
60
+
61
+ def self.process_parameters(params, args, options = { })
62
+ args = normalize_argument_hash_keys(args) || { }
63
+ args_out = options[:arguments_out] || { }
64
+ default_parameter_send_in_value = options[:default_parameter_send_in_value] || DEFAULT_PARAMETER_SEND_IN_VALUE
65
+ processed_parameters = options[:processed_parameters] || { }
66
+ missing_required_arguments = options[:missing_required_arguments] || [ ]
67
+
68
+ params.each do |param|
69
+ process_parameter(param, args, args_out, missing_required_arguments, processed_parameters, default_parameter_send_in_value)
70
+ end
71
+ { :arguments_out => args_out, :processed_parameters => processed_parameters, :missing_required_arguments => missing_required_arguments }
72
+ end
73
+
74
+ def initialize(args = { }, options = { })
75
+ @initial_arguments = args.dup
76
+ @initial_options = options.dup
77
+
78
+ @options = options.dup
79
+
80
+ initialize_attributes if options.fetch(:initialize_attributes, true)
81
+ after_initialize
82
+ end
83
+
84
+ def after_initialize
85
+ process_parameters if initialized
86
+ end
87
+
88
+ def initialize_attributes
89
+ @client = options[:client]
90
+ @missing_required_arguments = [ ]
91
+ @default_parameter_send_in_value = options[:default_parameter_send_in_value] || self.class::DEFAULT_PARAMETER_SEND_IN_VALUE
92
+ @processed_parameters = { }
93
+ @arguments = { }
94
+ @eval_http_path = options.fetch(:eval_http_path, true)
95
+ @base_path = options[:base_path]
96
+
97
+ @parameters = options[:parameters]
98
+ @http_method = options[:http_method]
99
+ @http_path = options[:http_path] ||= options[:path_raw]
100
+ @http_success_code = options[:http_success_code] || HTTP_SUCCESS_CODE
101
+
102
+ @path = options[:path]
103
+ @path_arguments = nil
104
+ @path_only = nil
105
+
106
+ @query = options[:query]
107
+ @query_arguments = nil
108
+
109
+ @body = options[:body]
110
+ @body_arguments = nil
111
+
112
+ @response = nil
113
+
114
+
115
+ @relative_path = nil
116
+
117
+ @initialized = true
118
+ end
119
+ alias :reset_attributes :initialize_attributes
120
+
121
+ def process_parameters(params = parameters, args = @initial_arguments, _options = @options)
122
+ before_process_parameters unless _options.fetch(:skip_before_process_parameters, false)
123
+ self.class.process_parameters(params, args, _options.merge(:processed_parameters => processed_parameters, :missing_required_arguments => missing_required_arguments, :default_parameter_send_in_value => default_parameter_send_in_value, :arguments_out => arguments))
124
+ after_process_parameters unless _options.fetch(:skip_after_process_parameters, false)
125
+ end
126
+
127
+ def before_process_parameters
128
+ # TO BE IMPLEMENTED IN CHILD CLASS
129
+ end
130
+ alias :pre_process_arguments :before_process_parameters
131
+
132
+ def after_process_parameters
133
+ # TO BE IMPLEMENTED IN CHILD CLASS
134
+ end
135
+ alias :post_process_arguments :after_process_parameters
136
+
137
+ # @!group Attribute Readers
138
+
139
+ def http_success_code
140
+ @http_success_code
141
+ end
142
+
143
+ def arguments
144
+ @arguments ||= { }
145
+ end
146
+
147
+ def base_path
148
+ @base_path ||= self.class::HTTP_BASE_PATH
149
+ end
150
+
151
+ def body_arguments
152
+ @body_arguments ||= arguments.dup.delete_if { |k,_| processed_parameters[k][:send_in] != :body }
153
+ end
154
+
155
+ def body
156
+ # body_arguments.empty? ? @body : body_arguments
157
+
158
+ _body = @body
159
+ _body_arguments = body_arguments
160
+ return _body unless _body_arguments
161
+ if _body.is_a?(Hash) && _body_arguments.is_a?(Hash)
162
+ return _body.merge(_body_arguments)
163
+ end
164
+ _body_arguments
165
+ end
166
+
167
+ def client
168
+ @client ||= options[:client]
169
+ end
170
+
171
+ def eval_http_path?
172
+ @eval_http_path
173
+ end
174
+
175
+ def http_path
176
+ @http_path ||= self.class::HTTP_PATH
177
+ end
178
+
179
+ def http_method
180
+ @http_method ||= self.class::HTTP_METHOD
181
+ end
182
+
183
+ def parameters
184
+ @parameters ||= self.class::PARAMETERS.dup
185
+ end
186
+
187
+ def relative_path
188
+ @relative_path ||= (path.start_with?('/') ? path[1..-1] : path)
189
+ end
190
+
191
+ # The URI Path
192
+ def path
193
+ @path ||= File.join(base_path, (eval_http_path? ? eval(%("#{http_path}"), binding, __FILE__, __LINE__) : http_path))
194
+ end
195
+
196
+ def path_arguments
197
+ @path_arguments ||= Hash[
198
+ arguments.dup.delete_if { |k, _| processed_parameters[k][:send_in] != :path }.
199
+ map { |k,v| [ k, CGI.escape(v.respond_to?(:to_s) ? v.to_s : '').gsub('+', '%20') ] }
200
+ ]
201
+ end
202
+
203
+ def query
204
+ @query ||= begin
205
+ query_arguments.is_a?(Hash) ? query_arguments.map { |k,v| "#{CGI.escape(k.to_s).gsub('+', '%20')}=#{CGI.escape(v.respond_to?(:to_s) ? v.to_s : v).gsub('+', '%20')}" }.join('&') : query_arguments
206
+ end
207
+ end
208
+
209
+ def query_arguments
210
+ @query_arguments ||= arguments.dup.delete_if { |k,_| processed_parameters[k][:send_in] != :query }
211
+ end
212
+
213
+ def uri_request_path
214
+ [ path ].concat( [*query].delete_if { |v| v.respond_to?(:empty?) and v.empty? } ).join('?')
215
+ end
216
+
217
+ # @!endgroup
218
+
219
+ # def response
220
+ # client.response if client
221
+ # end
222
+
223
+ def http_client
224
+ client.http_client
225
+ end
226
+
227
+ def http_response
228
+ @http_response ||= http_client.response.dup rescue nil
229
+ end
230
+
231
+ def execute
232
+ @response = http_client.call_method(http_method, { :path => relative_path, :query => query, :body => body }, options) if client
233
+ end
234
+
235
+ def success?
236
+ _response = http_response and ([*http_success_code].include?(http_response.code))
237
+ _response
238
+ end
239
+
240
+ end
241
+ end
242
+ end
243
+ end
244
+ end
245
+ end