square.rb 17.1.0.20220120 → 19.0.0.20220420

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,8 +41,10 @@ module Square
41
41
  )
42
42
  end
43
43
 
44
- # Retrieves a filtered list of Terminal checkout requests created by the
45
- # account making the request.
44
+ # Returns a filtered list of Terminal checkout requests created by the
45
+ # application making the request. Only Terminal checkout requests created
46
+ # for the merchant scoped to the OAuth token are returned. Terminal checkout
47
+ # requests are available for 30 days.
46
48
  # @param [SearchTerminalCheckoutsRequest] body Required parameter: An object
47
49
  # containing the fields to POST for the request. See the corresponding
48
50
  # object definition for field details.
@@ -76,7 +78,8 @@ module Square
76
78
  )
77
79
  end
78
80
 
79
- # Retrieves a Terminal checkout request by `checkout_id`.
81
+ # Retrieves a Terminal checkout request by `checkout_id`. Terminal checkout
82
+ # requests are available for 30 days.
80
83
  # @param [String] checkout_id Required parameter: The unique ID for the
81
84
  # desired `TerminalCheckout`.
82
85
  # @return [GetTerminalCheckoutResponse Hash] response from the API call
@@ -148,7 +151,10 @@ module Square
148
151
  end
149
152
 
150
153
  # Creates a request to refund an Interac payment completed on a Square
151
- # Terminal.
154
+ # Terminal. Refunds for Interac payments on a Square Terminal are supported
155
+ # only for Interac debit cards in Canada. Other refunds for Terminal
156
+ # payments should use the Refunds API. For more information, see [Refunds
157
+ # API]($e/Refunds).
152
158
  # @param [CreateTerminalRefundRequest] body Required parameter: An object
153
159
  # containing the fields to POST for the request. See the corresponding
154
160
  # object definition for field details.
@@ -183,7 +189,8 @@ module Square
183
189
  end
184
190
 
185
191
  # Retrieves a filtered list of Interac Terminal refund requests created by
186
- # the seller making the request.
192
+ # the seller making the request. Terminal refund requests are available for
193
+ # 30 days.
187
194
  # @param [SearchTerminalRefundsRequest] body Required parameter: An object
188
195
  # containing the fields to POST for the request. See the corresponding
189
196
  # object definition for field details.
@@ -217,7 +224,8 @@ module Square
217
224
  )
218
225
  end
219
226
 
220
- # Retrieves an Interac Terminal refund object by ID.
227
+ # Retrieves an Interac Terminal refund object by ID. Terminal refund objects
228
+ # are available for 30 days.
221
229
  # @param [String] terminal_refund_id Required parameter: The unique ID for
222
230
  # the desired `TerminalRefund`.
223
231
  # @return [GetTerminalRefundResponse Hash] response from the API call
@@ -0,0 +1,257 @@
1
+ module Square
2
+ # VendorsApi
3
+ class VendorsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Creates one or more [Vendor]($m/Vendor) objects to represent suppliers to
9
+ # a seller.
10
+ # @param [BulkCreateVendorsRequest] body Required parameter: An object
11
+ # containing the fields to POST for the request. See the corresponding
12
+ # object definition for field details.
13
+ # @return [BulkCreateVendorsResponse Hash] response from the API call
14
+ def bulk_create_vendors(body:)
15
+ # Prepare query url.
16
+ _query_builder = config.get_base_uri
17
+ _query_builder << '/v2/vendors/bulk-create'
18
+ _query_url = APIHelper.clean_url _query_builder
19
+
20
+ # Prepare headers.
21
+ _headers = {
22
+ 'accept' => 'application/json',
23
+ 'Content-Type' => 'application/json'
24
+ }
25
+
26
+ # Prepare and execute HttpRequest.
27
+ _request = config.http_client.post(
28
+ _query_url,
29
+ headers: _headers,
30
+ parameters: body.to_json
31
+ )
32
+ OAuth2.apply(config, _request)
33
+ _response = execute_request(_request)
34
+
35
+ # Return appropriate response type.
36
+ decoded = APIHelper.json_deserialize(_response.raw_body)
37
+ _errors = APIHelper.map_response(decoded, ['errors'])
38
+ ApiResponse.new(
39
+ _response, data: decoded, errors: _errors
40
+ )
41
+ end
42
+
43
+ # Retrieves one or more vendors of specified [Vendor]($m/Vendor) IDs.
44
+ # @param [BulkRetrieveVendorsRequest] body Required parameter: An object
45
+ # containing the fields to POST for the request. See the corresponding
46
+ # object definition for field details.
47
+ # @return [BulkRetrieveVendorsResponse Hash] response from the API call
48
+ def bulk_retrieve_vendors(body:)
49
+ # Prepare query url.
50
+ _query_builder = config.get_base_uri
51
+ _query_builder << '/v2/vendors/bulk-retrieve'
52
+ _query_url = APIHelper.clean_url _query_builder
53
+
54
+ # Prepare headers.
55
+ _headers = {
56
+ 'accept' => 'application/json',
57
+ 'Content-Type' => 'application/json'
58
+ }
59
+
60
+ # Prepare and execute HttpRequest.
61
+ _request = config.http_client.post(
62
+ _query_url,
63
+ headers: _headers,
64
+ parameters: body.to_json
65
+ )
66
+ OAuth2.apply(config, _request)
67
+ _response = execute_request(_request)
68
+
69
+ # Return appropriate response type.
70
+ decoded = APIHelper.json_deserialize(_response.raw_body)
71
+ _errors = APIHelper.map_response(decoded, ['errors'])
72
+ ApiResponse.new(
73
+ _response, data: decoded, errors: _errors
74
+ )
75
+ end
76
+
77
+ # Updates one or more of existing [Vendor]($m/Vendor) objects as suppliers
78
+ # to a seller.
79
+ # @param [BulkUpdateVendorsRequest] body Required parameter: An object
80
+ # containing the fields to POST for the request. See the corresponding
81
+ # object definition for field details.
82
+ # @return [BulkUpdateVendorsResponse Hash] response from the API call
83
+ def bulk_update_vendors(body:)
84
+ # Prepare query url.
85
+ _query_builder = config.get_base_uri
86
+ _query_builder << '/v2/vendors/bulk-update'
87
+ _query_url = APIHelper.clean_url _query_builder
88
+
89
+ # Prepare headers.
90
+ _headers = {
91
+ 'accept' => 'application/json',
92
+ 'Content-Type' => 'application/json'
93
+ }
94
+
95
+ # Prepare and execute HttpRequest.
96
+ _request = config.http_client.put(
97
+ _query_url,
98
+ headers: _headers,
99
+ parameters: body.to_json
100
+ )
101
+ OAuth2.apply(config, _request)
102
+ _response = execute_request(_request)
103
+
104
+ # Return appropriate response type.
105
+ decoded = APIHelper.json_deserialize(_response.raw_body)
106
+ _errors = APIHelper.map_response(decoded, ['errors'])
107
+ ApiResponse.new(
108
+ _response, data: decoded, errors: _errors
109
+ )
110
+ end
111
+
112
+ # Creates a single [Vendor]($m/Vendor) object to represent a supplier to a
113
+ # seller.
114
+ # @param [CreateVendorRequest] body Required parameter: An object containing
115
+ # the fields to POST for the request. See the corresponding object
116
+ # definition for field details.
117
+ # @return [CreateVendorResponse Hash] response from the API call
118
+ def create_vendor(body:)
119
+ # Prepare query url.
120
+ _query_builder = config.get_base_uri
121
+ _query_builder << '/v2/vendors/create'
122
+ _query_url = APIHelper.clean_url _query_builder
123
+
124
+ # Prepare headers.
125
+ _headers = {
126
+ 'accept' => 'application/json',
127
+ 'Content-Type' => 'application/json'
128
+ }
129
+
130
+ # Prepare and execute HttpRequest.
131
+ _request = config.http_client.post(
132
+ _query_url,
133
+ headers: _headers,
134
+ parameters: body.to_json
135
+ )
136
+ OAuth2.apply(config, _request)
137
+ _response = execute_request(_request)
138
+
139
+ # Return appropriate response type.
140
+ decoded = APIHelper.json_deserialize(_response.raw_body)
141
+ _errors = APIHelper.map_response(decoded, ['errors'])
142
+ ApiResponse.new(
143
+ _response, data: decoded, errors: _errors
144
+ )
145
+ end
146
+
147
+ # Searches for vendors using a filter against supported [Vendor]($m/Vendor)
148
+ # properties and a supported sorter.
149
+ # @param [SearchVendorsRequest] body Required parameter: An object
150
+ # containing the fields to POST for the request. See the corresponding
151
+ # object definition for field details.
152
+ # @return [SearchVendorsResponse Hash] response from the API call
153
+ def search_vendors(body:)
154
+ # Prepare query url.
155
+ _query_builder = config.get_base_uri
156
+ _query_builder << '/v2/vendors/search'
157
+ _query_url = APIHelper.clean_url _query_builder
158
+
159
+ # Prepare headers.
160
+ _headers = {
161
+ 'accept' => 'application/json',
162
+ 'Content-Type' => 'application/json'
163
+ }
164
+
165
+ # Prepare and execute HttpRequest.
166
+ _request = config.http_client.post(
167
+ _query_url,
168
+ headers: _headers,
169
+ parameters: body.to_json
170
+ )
171
+ OAuth2.apply(config, _request)
172
+ _response = execute_request(_request)
173
+
174
+ # Return appropriate response type.
175
+ decoded = APIHelper.json_deserialize(_response.raw_body)
176
+ _errors = APIHelper.map_response(decoded, ['errors'])
177
+ ApiResponse.new(
178
+ _response, data: decoded, errors: _errors
179
+ )
180
+ end
181
+
182
+ # Retrieves the vendor of a specified [Vendor]($m/Vendor) ID.
183
+ # @param [String] vendor_id Required parameter: ID of the
184
+ # [Vendor]($m/Vendor) to retrieve.
185
+ # @return [RetrieveVendorResponse Hash] response from the API call
186
+ def retrieve_vendor(vendor_id:)
187
+ # Prepare query url.
188
+ _query_builder = config.get_base_uri
189
+ _query_builder << '/v2/vendors/{vendor_id}'
190
+ _query_builder = APIHelper.append_url_with_template_parameters(
191
+ _query_builder,
192
+ 'vendor_id' => { 'value' => vendor_id, 'encode' => true }
193
+ )
194
+ _query_url = APIHelper.clean_url _query_builder
195
+
196
+ # Prepare headers.
197
+ _headers = {
198
+ 'accept' => 'application/json'
199
+ }
200
+
201
+ # Prepare and execute HttpRequest.
202
+ _request = config.http_client.get(
203
+ _query_url,
204
+ headers: _headers
205
+ )
206
+ OAuth2.apply(config, _request)
207
+ _response = execute_request(_request)
208
+
209
+ # Return appropriate response type.
210
+ decoded = APIHelper.json_deserialize(_response.raw_body)
211
+ _errors = APIHelper.map_response(decoded, ['errors'])
212
+ ApiResponse.new(
213
+ _response, data: decoded, errors: _errors
214
+ )
215
+ end
216
+
217
+ # Updates an existing [Vendor]($m/Vendor) object as a supplier to a seller.
218
+ # @param [UpdateVendorRequest] body Required parameter: An object containing
219
+ # the fields to POST for the request. See the corresponding object
220
+ # definition for field details.
221
+ # @param [String] vendor_id Required parameter: Example:
222
+ # @return [UpdateVendorResponse Hash] response from the API call
223
+ def update_vendor(body:,
224
+ vendor_id:)
225
+ # Prepare query url.
226
+ _query_builder = config.get_base_uri
227
+ _query_builder << '/v2/vendors/{vendor_id}'
228
+ _query_builder = APIHelper.append_url_with_template_parameters(
229
+ _query_builder,
230
+ 'vendor_id' => { 'value' => vendor_id, 'encode' => true }
231
+ )
232
+ _query_url = APIHelper.clean_url _query_builder
233
+
234
+ # Prepare headers.
235
+ _headers = {
236
+ 'accept' => 'application/json',
237
+ 'Content-Type' => 'application/json'
238
+ }
239
+
240
+ # Prepare and execute HttpRequest.
241
+ _request = config.http_client.put(
242
+ _query_url,
243
+ headers: _headers,
244
+ parameters: body.to_json
245
+ )
246
+ OAuth2.apply(config, _request)
247
+ _response = execute_request(_request)
248
+
249
+ # Return appropriate response type.
250
+ decoded = APIHelper.json_deserialize(_response.raw_body)
251
+ _errors = APIHelper.map_response(decoded, ['errors'])
252
+ ApiResponse.new(
253
+ _response, data: decoded, errors: _errors
254
+ )
255
+ end
256
+ end
257
+ end
@@ -8,18 +8,16 @@ module Square
8
8
  def self.serialize_array(key, array, formatting: 'indexed')
9
9
  tuples = []
10
10
 
11
- case formatting
12
- when 'unindexed'
13
- tuples += array.map { |element| ["#{key}[]", element] }
14
- when 'indexed'
15
- tuples += array.map.with_index do |element, index|
16
- ["#{key}[#{index}]", element]
17
- end
18
- when 'plain'
19
- tuples += array.map { |element| [key, element] }
20
- else
21
- raise ArgumentError, 'Invalid format provided.'
22
- end
11
+ tuples += case formatting
12
+ when 'csv'
13
+ [[key, array.map { |element| CGI.escape(element.to_s) }.join(',')]]
14
+ when 'psv'
15
+ [[key, array.map { |element| CGI.escape(element.to_s) }.join('|')]]
16
+ when 'tsv'
17
+ [[key, array.map { |element| CGI.escape(element.to_s) }.join("\t")]]
18
+ else
19
+ array.map { |element| [key, element] }
20
+ end
23
21
  tuples
24
22
  end
25
23
 
@@ -75,31 +73,19 @@ module Square
75
73
  return query_builder if parameters.nil?
76
74
 
77
75
  array_serialization = 'indexed'
76
+ parameters = process_complex_types_parameters(parameters, array_serialization)
78
77
 
79
78
  parameters.each do |key, value|
80
79
  seperator = query_builder.include?('?') ? '&' : '?'
81
80
  unless value.nil?
82
81
  if value.instance_of? Array
83
82
  value.compact!
84
- query_builder += case array_serialization
85
- when 'csv'
86
- "#{seperator}#{key}=#{value.map do |element|
87
- CGI.escape(element.to_s)
88
- end.join(',')}"
89
- when 'psv'
90
- "#{seperator}#{key}=#{value.map do |element|
91
- CGI.escape(element.to_s)
92
- end.join('|')}"
93
- when 'tsv'
94
- "#{seperator}#{key}=#{value.map do |element|
95
- CGI.escape(element.to_s)
96
- end.join("\t")}"
97
- else
98
- "#{seperator}#{APIHelper.serialize_array(
99
- key, value, formatting: array_serialization
100
- ).map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }
101
- .join('&')}"
102
- end
83
+ APIHelper.serialize_array(
84
+ key, value, formatting: array_serialization
85
+ ).each do |element|
86
+ seperator = query_builder.include?('?') ? '&' : '?'
87
+ query_builder += "#{seperator}#{element[0]}=#{element[1]}"
88
+ end
103
89
  else
104
90
  query_builder += "#{seperator}#{key}=#{CGI.escape(value.to_s)}"
105
91
  end
@@ -163,6 +149,18 @@ module Square
163
149
  encoded
164
150
  end
165
151
 
152
+ # Process complex types in query_params.
153
+ # @param [Hash] The hash of query parameters.
154
+ # @return [Hash] A hash with the processed query parameters.
155
+ def self.process_complex_types_parameters(query_parameters, array_serialization)
156
+ processed_params = {}
157
+ query_parameters.each do |key, value|
158
+ processed_params.merge!(APIHelper.form_encode(value, key, formatting:
159
+ array_serialization))
160
+ end
161
+ processed_params
162
+ end
163
+
166
164
  def self.custom_merge(a, b)
167
165
  x = {}
168
166
  a.each do |key, value_a|
data/lib/square/client.rb CHANGED
@@ -4,7 +4,7 @@ module Square
4
4
  attr_reader :config
5
5
 
6
6
  def sdk_version
7
- '17.1.0.20220120'
7
+ '19.0.0.20220420'
8
8
  end
9
9
 
10
10
  def square_version
@@ -177,6 +177,12 @@ module Square
177
177
  @payments ||= PaymentsApi.new config
178
178
  end
179
179
 
180
+ # Access to payouts controller.
181
+ # @return [PayoutsApi] Returns the controller instance.
182
+ def payouts
183
+ @payouts ||= PayoutsApi.new config
184
+ end
185
+
180
186
  # Access to refunds controller.
181
187
  # @return [RefundsApi] Returns the controller instance.
182
188
  def refunds
@@ -213,16 +219,22 @@ module Square
213
219
  @terminal ||= TerminalApi.new config
214
220
  end
215
221
 
216
- def initialize(http_client_instance: nil, timeout: 60, max_retries: 0,
222
+ # Access to vendors controller.
223
+ # @return [VendorsApi] Returns the controller instance.
224
+ def vendors
225
+ @vendors ||= VendorsApi.new config
226
+ end
227
+
228
+ def initialize(connection: nil, timeout: 60, max_retries: 0,
217
229
  retry_interval: 1, backoff_factor: 2,
218
230
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
219
231
  retry_methods: %i[get put], environment: 'production',
220
232
  custom_url: 'https://connect.squareup.com',
221
- square_version: '2022-01-20', access_token: '',
233
+ square_version: '2022-04-20', access_token: '',
222
234
  user_agent_detail: '', additional_headers: {}, config: nil)
223
235
  @config = if config.nil?
224
- Configuration.new(http_client_instance: http_client_instance,
225
- timeout: timeout, max_retries: max_retries,
236
+ Configuration.new(connection: connection, timeout: timeout,
237
+ max_retries: max_retries,
226
238
  retry_interval: retry_interval,
227
239
  backoff_factor: backoff_factor,
228
240
  retry_statuses: retry_statuses,
@@ -3,9 +3,9 @@ module Square
3
3
  # are configured in this class.
4
4
  class Configuration
5
5
  # The attribute readers for properties.
6
- attr_reader :http_client, :http_client_instance, :timeout, :max_retries, :retry_interval,
7
- :backoff_factor, :retry_statuses, :retry_methods, :environment, :custom_url,
8
- :square_version, :access_token, :user_agent_detail
6
+ attr_reader :http_client, :connection, :timeout, :max_retries, :retry_interval, :backoff_factor,
7
+ :retry_statuses, :retry_methods, :environment, :custom_url, :square_version,
8
+ :access_token, :user_agent_detail
9
9
 
10
10
  def additional_headers
11
11
  @additional_headers.clone
@@ -15,15 +15,15 @@ module Square
15
15
  attr_reader :environments
16
16
  end
17
17
 
18
- def initialize(http_client_instance: nil, timeout: 60, max_retries: 0,
18
+ def initialize(connection: nil, timeout: 60, max_retries: 0,
19
19
  retry_interval: 1, backoff_factor: 2,
20
20
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
21
21
  retry_methods: %i[get put], environment: 'production',
22
22
  custom_url: 'https://connect.squareup.com',
23
- square_version: '2022-01-20', access_token: '',
23
+ square_version: '2022-04-20', access_token: '',
24
24
  user_agent_detail: '', additional_headers: {})
25
- # The Http Client passed from the sdk user for making requests
26
- @http_client_instance = http_client_instance
25
+ # The Faraday connection object passed by the SDK user for making requests
26
+ @connection = connection
27
27
 
28
28
  # The value to use for connection timeout
29
29
  @timeout = timeout
@@ -66,12 +66,12 @@ module Square
66
66
  @user_agent_detail = get_user_agent(user_agent_detail)
67
67
  end
68
68
 
69
- def clone_with(http_client_instance: nil, timeout: nil, max_retries: nil,
69
+ def clone_with(connection: nil, timeout: nil, max_retries: nil,
70
70
  retry_interval: nil, backoff_factor: nil,
71
71
  retry_statuses: nil, retry_methods: nil, environment: nil,
72
72
  custom_url: nil, square_version: nil, access_token: nil,
73
73
  user_agent_detail: nil, additional_headers: nil)
74
- http_client_instance ||= self.http_client_instance
74
+ connection ||= self.connection
75
75
  timeout ||= self.timeout
76
76
  max_retries ||= self.max_retries
77
77
  retry_interval ||= self.retry_interval
@@ -85,8 +85,8 @@ module Square
85
85
  user_agent_detail ||= self.user_agent_detail
86
86
  additional_headers ||= self.additional_headers
87
87
 
88
- Configuration.new(http_client_instance: http_client_instance,
89
- timeout: timeout, max_retries: max_retries,
88
+ Configuration.new(connection: connection, timeout: timeout,
89
+ max_retries: max_retries,
90
90
  retry_interval: retry_interval,
91
91
  backoff_factor: backoff_factor,
92
92
  retry_statuses: retry_statuses,
@@ -102,8 +102,7 @@ module Square
102
102
  retry_interval: retry_interval,
103
103
  backoff_factor: backoff_factor,
104
104
  retry_statuses: retry_statuses,
105
- retry_methods: retry_methods,
106
- http_client_instance: http_client_instance)
105
+ retry_methods: retry_methods, connection: connection)
107
106
  end
108
107
 
109
108
  def get_user_agent(user_agent_detail)
@@ -1,35 +1,37 @@
1
1
  require 'faraday/http_cache'
2
- require 'faraday_middleware'
2
+ require 'faraday/retry'
3
+ require 'faraday/multipart'
4
+ require 'faraday/follow_redirects'
5
+ require 'faraday/gzip'
3
6
 
4
7
  module Square
5
8
  # An implementation of HttpClient.
6
9
  class FaradayClient < HttpClient
10
+ # The attribute readers for properties.
11
+ attr_reader :connection
12
+
7
13
  # The constructor.
8
14
  def initialize(timeout:, max_retries:, retry_interval:,
9
15
  backoff_factor:, retry_statuses:, retry_methods:,
10
- http_client_instance: nil, cache: false, verify: true)
11
- if http_client_instance.nil?
12
- create_connection(timeout: timeout, max_retries: max_retries,
13
- retry_interval: retry_interval, backoff_factor: backoff_factor,
14
- retry_statuses: retry_statuses, retry_methods: retry_methods,
15
- cache: cache, verify: verify)
16
- else
17
- if http_client_instance.instance_variable_get('@connection').nil?
18
- raise ArgumentError,
19
- "`connection` cannot be nil in `#{self.class}`. Please specify a valid value."
20
- end
21
- @connection = http_client_instance.instance_variable_get('@connection')
22
- end
16
+ connection: nil, cache: false, verify: true)
17
+ @connection = if connection.nil?
18
+ create_connection(timeout: timeout, max_retries: max_retries,
19
+ retry_interval: retry_interval, backoff_factor: backoff_factor,
20
+ retry_statuses: retry_statuses, retry_methods: retry_methods,
21
+ cache: cache, verify: verify)
22
+ else
23
+ connection
24
+ end
23
25
  end
24
26
 
25
27
  # Method to initialize connection.
26
28
  def create_connection(timeout:, max_retries:, retry_interval:,
27
29
  backoff_factor:, retry_statuses:, retry_methods:,
28
30
  cache: false, verify: true)
29
- @connection = Faraday.new do |faraday|
31
+ Faraday.new do |faraday|
30
32
  faraday.use Faraday::HttpCache, serializer: Marshal if cache
31
- faraday.use FaradayMiddleware::FollowRedirects
32
- faraday.use :gzip
33
+ faraday.use Faraday::FollowRedirects::Middleware
34
+ faraday.request :gzip
33
35
  faraday.request :multipart
34
36
  faraday.request :url_encoded
35
37
  faraday.ssl[:ca_file] = Certifi.where
@@ -37,12 +39,14 @@ module Square
37
39
  faraday.request :retry, max: max_retries, interval: retry_interval,
38
40
  backoff_factor: backoff_factor,
39
41
  retry_statuses: retry_statuses,
40
- methods: retry_methods
42
+ methods: retry_methods,
43
+ retry_if: proc { |env, _exc|
44
+ env.request.context['forced_retry'] ||= false
45
+ }
41
46
  faraday.adapter Faraday.default_adapter
42
47
  faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
43
48
  faraday.options[:timeout] = timeout if timeout.positive?
44
49
  end
45
- @connection
46
50
  end
47
51
 
48
52
  # Method overridden from HttpClient.
@@ -51,7 +55,9 @@ module Square
51
55
  http_request.http_method.downcase,
52
56
  http_request.query_url
53
57
  ) do |request|
54
- request.headers = http_request.headers
58
+ request.headers = http_request.headers.map { |k, v| [k.to_s, v.to_s] }
59
+ request.options.context ||= {}
60
+ request.options.context.merge!(http_request.context)
55
61
  unless http_request.http_method == HttpMethodEnum::GET &&
56
62
  http_request.parameters.empty?
57
63
  request.body = http_request.parameters
@@ -67,6 +73,8 @@ module Square
67
73
  http_request.query_url
68
74
  ) do |request|
69
75
  request.headers = http_request.headers
76
+ request.options.context ||= {}
77
+ request.options.context.merge!(http_request.context)
70
78
  unless http_request.http_method == HttpMethodEnum::GET &&
71
79
  http_request.parameters.empty?
72
80
  request.body = http_request.parameters