square.rb 13.0.0.20210721 → 13.1.0.20210818

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f0db97e9e88ea1a9f5f7f9db716b8f2ce36473400c34f57ec01622e2b0b584b
4
- data.tar.gz: 999b75d8c4ded30c3895d6cecf97d18883a6018ec9b79a53b85f1bed20f56de4
3
+ metadata.gz: a624808dd5bb0375fef64adf65cbe8203c6b582bd38e34afb69b4b0c0f4fd8a4
4
+ data.tar.gz: 849966858b71f5a2b2f4abb9811561156172b591cf2a3c93886bee88c5ecff83
5
5
  SHA512:
6
- metadata.gz: 2a74a9814e8d3d9edb5f9a36439c85f41c593f91941a3938c869b602b8fa65f2cf1ce6b115f43ed65c6a76ec6d36c8e237a5f855e3d12dbe90f6c906c9c7390d
7
- data.tar.gz: a9d2ecd07e5616d2341b095519414007ab0e4bfc5159a90e3fb7e4b9d6337add73859641da52ccda4ee4bffb8ea39a59a37f487638c931f75c0ab1c77bb4dbce
6
+ metadata.gz: bcb9330214a8a813a1d6bf405db19dcd2264f70f1745b793c9cf7c844f340dc056cf7a141a0e12ca65187ee02d1c856ee59621ab2143f18e518bdc734bc9f35c
7
+ data.tar.gz: 5a93c48a1751fae253c1819fd0c4925b47e3998be01ad9af2acae45cbac6c4a6d9979bf4e0e36baa9475bd54c396135c5d136981fc4b87ec0c04d507cf259698
data/README.md CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  Use this gem to integrate Square payments into your app and grow your business with Square APIs including Catalog, Customers, Employees, Inventory, Labor, Locations, and Orders.
10
10
 
11
+ ## Requirements
12
+
13
+ We support Ruby 2.5.x, 2.6.x, and 2.7.x.
14
+
11
15
  ## Installation
12
16
 
13
17
  Install the gem from the command line:
@@ -8,21 +8,19 @@ module Square
8
8
  @http_call_back = http_call_back
9
9
 
10
10
  @global_headers = {
11
- 'user-agent' => 'Square-Ruby-SDK/13.0.0.20210721',
11
+ 'user-agent' => 'Square-Ruby-SDK/13.1.0.20210818',
12
12
  'Square-Version' => config.square_version
13
13
  }
14
14
  end
15
15
 
16
16
  def validate_parameters(args)
17
17
  args.each do |_name, value|
18
- if value.nil?
19
- raise ArgumentError, "Required parameter #{_name} cannot be nil."
20
- end
18
+ raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil?
21
19
  end
22
20
  end
23
21
 
24
22
  def execute_request(request, binary: false)
25
- @http_call_back.on_before_request(request) if @http_call_back
23
+ @http_call_back&.on_before_request(request)
26
24
 
27
25
  APIHelper.clean_hash(request.headers)
28
26
  request.headers.merge!(@global_headers)
@@ -35,7 +33,7 @@ module Square
35
33
  else
36
34
  config.http_client.execute_as_string(request)
37
35
  end
38
- @http_call_back.on_after_response(response) if @http_call_back
36
+ @http_call_back&.on_after_response(response)
39
37
 
40
38
  response
41
39
  end
@@ -11,14 +11,22 @@ module Square
11
11
  # set of results for your original query. For more information, see
12
12
  # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
13
13
  # ion).
14
+ # @param [Integer] limit Optional parameter: The maximum number of results
15
+ # to return in a single page. This limit is advisory. The response might
16
+ # contain more or fewer results. The limit is ignored if it is less than 1
17
+ # or greater than 50. The default value is 50. For more information, see
18
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
+ # ion).
14
20
  # @return [ListCustomerGroupsResponse Hash] response from the API call
15
- def list_customer_groups(cursor: nil)
21
+ def list_customer_groups(cursor: nil,
22
+ limit: nil)
16
23
  # Prepare query url.
17
24
  _query_builder = config.get_base_uri
18
25
  _query_builder << '/v2/customers/groups'
19
26
  _query_builder = APIHelper.append_url_with_query_parameters(
20
27
  _query_builder,
21
- 'cursor' => cursor
28
+ 'cursor' => cursor,
29
+ 'limit' => limit
22
30
  )
23
31
  _query_url = APIHelper.clean_url _query_builder
24
32
 
@@ -11,14 +11,22 @@ module Square
11
11
  # the next set of query results. For more information, see
12
12
  # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
13
13
  # ion).
14
+ # @param [Integer] limit Optional parameter: The maximum number of results
15
+ # to return in a single page. This limit is advisory. The response might
16
+ # contain more or fewer results. The limit is ignored if it is less than 1
17
+ # or greater than 50. The default value is 50. For more information, see
18
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
+ # ion).
14
20
  # @return [ListCustomerSegmentsResponse Hash] response from the API call
15
- def list_customer_segments(cursor: nil)
21
+ def list_customer_segments(cursor: nil,
22
+ limit: nil)
16
23
  # Prepare query url.
17
24
  _query_builder = config.get_base_uri
18
25
  _query_builder << '/v2/customers/segments'
19
26
  _query_builder = APIHelper.append_url_with_query_parameters(
20
27
  _query_builder,
21
- 'cursor' => cursor
28
+ 'cursor' => cursor,
29
+ 'limit' => limit
22
30
  )
23
31
  _query_url = APIHelper.clean_url _query_builder
24
32
 
@@ -17,13 +17,20 @@ module Square
17
17
  # set of results for your original query. For more information, see
18
18
  # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
19
19
  # ion).
20
+ # @param [Integer] limit Optional parameter: The maximum number of results
21
+ # to return in a single page. This limit is advisory. The response might
22
+ # contain more or fewer results. The limit is ignored if it is less than 1
23
+ # or greater than 100. The default value is 100. For more information, see
24
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
25
+ # ion).
20
26
  # @param [CustomerSortField] sort_field Optional parameter: Indicates how
21
- # customers should be sorted. Default: `DEFAULT`.
27
+ # customers should be sorted. The default value is `DEFAULT`.
22
28
  # @param [SortOrder] sort_order Optional parameter: Indicates whether
23
29
  # customers should be sorted in ascending (`ASC`) or descending (`DESC`)
24
- # order. Default: `ASC`.
30
+ # order. The default value is `ASC`.
25
31
  # @return [ListCustomersResponse Hash] response from the API call
26
32
  def list_customers(cursor: nil,
33
+ limit: nil,
27
34
  sort_field: nil,
28
35
  sort_order: nil)
29
36
  # Prepare query url.
@@ -32,6 +39,7 @@ module Square
32
39
  _query_builder = APIHelper.append_url_with_query_parameters(
33
40
  _query_builder,
34
41
  'cursor' => cursor,
42
+ 'limit' => limit,
35
43
  'sort_field' => sort_field,
36
44
  'sort_order' => sort_order
37
45
  )
@@ -156,7 +164,7 @@ module Square
156
164
  # @param [String] customer_id Required parameter: The ID of the customer to
157
165
  # delete.
158
166
  # @param [Long] version Optional parameter: The current version of the
159
- # customer profile. As a best practice, you should include this parameter
167
+ # customer profile. As a best practice, you should include this parameter
160
168
  # to enable [optimistic
161
169
  # concurrency](https://developer.squareup.com/docs/working-with-apis/optimis
162
170
  # tic-concurrency) control. For more information, see [Delete a customer
@@ -65,8 +65,9 @@ module Square
65
65
  )
66
66
  end
67
67
 
68
- # Creates a digital gift card. You must activate the gift card before
69
- # it can be used. For more information, see
68
+ # Creates a digital gift card or registers a physical (plastic) gift card.
69
+ # You must activate the gift card before
70
+ # it can be used for payment. For more information, see
70
71
  # [Selling gift
71
72
  # cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api
72
73
  # #selling-square-gift-cards).
@@ -6,13 +6,14 @@ module Square
6
6
  end
7
7
 
8
8
  # Returns a paginated list of `BreakType` instances for a business.
9
- # @param [String] location_id Optional parameter: Filter Break Types
10
- # returned to only those that are associated with the specified location.
11
- # @param [Integer] limit Optional parameter: Maximum number of Break Types
12
- # to return per page. Can range between 1 and 200. The default is the
13
- # maximum at 200.
14
- # @param [String] cursor Optional parameter: Pointer to the next page of
15
- # Break Type results to fetch.
9
+ # @param [String] location_id Optional parameter: Filter the returned
10
+ # `BreakType` results to only those that are associated with the specified
11
+ # location.
12
+ # @param [Integer] limit Optional parameter: The maximum number of
13
+ # `BreakType` results to return per page. The number can range between 1 and
14
+ # 200. The default is 200.
15
+ # @param [String] cursor Optional parameter: A pointer to the next page of
16
+ # `BreakType` results to fetch.
16
17
  # @return [ListBreakTypesResponse Hash] response from the API call
17
18
  def list_break_types(location_id: nil,
18
19
  limit: nil,
@@ -57,8 +58,8 @@ module Square
57
58
  # - `break_name`
58
59
  # - `expected_duration`
59
60
  # - `is_paid`
60
- # You can only have 3 `BreakType` instances per location. If you attempt to
61
- # add a 4th
61
+ # You can only have three `BreakType` instances per location. If you attempt
62
+ # to add a fourth
62
63
  # `BreakType` for a location, an `INVALID_REQUEST_ERROR` "Exceeded limit of
63
64
  # 3 breaks per location."
64
65
  # is returned.
@@ -97,7 +98,7 @@ module Square
97
98
 
98
99
  # Deletes an existing `BreakType`.
99
100
  # A `BreakType` can be deleted even if it is referenced from a `Shift`.
100
- # @param [String] id Required parameter: UUID for the `BreakType` being
101
+ # @param [String] id Required parameter: The UUID for the `BreakType` being
101
102
  # deleted.
102
103
  # @return [DeleteBreakTypeResponse Hash] response from the API call
103
104
  def delete_break_type(id:)
@@ -131,8 +132,8 @@ module Square
131
132
  )
132
133
  end
133
134
 
134
- # Returns a single `BreakType` specified by id.
135
- # @param [String] id Required parameter: UUID for the `BreakType` being
135
+ # Returns a single `BreakType` specified by `id`.
136
+ # @param [String] id Required parameter: The UUID for the `BreakType` being
136
137
  # retrieved.
137
138
  # @return [GetBreakTypeResponse Hash] response from the API call
138
139
  def get_break_type(id:)
@@ -167,7 +168,7 @@ module Square
167
168
  end
168
169
 
169
170
  # Updates an existing `BreakType`.
170
- # @param [String] id Required parameter: UUID for the `BreakType` being
171
+ # @param [String] id Required parameter: The UUID for the `BreakType` being
171
172
  # updated.
172
173
  # @param [UpdateBreakTypeRequest] body Required parameter: An object
173
174
  # containing the fields to POST for the request. See the corresponding
@@ -208,13 +209,13 @@ module Square
208
209
  end
209
210
 
210
211
  # Returns a paginated list of `EmployeeWage` instances for a business.
211
- # @param [String] employee_id Optional parameter: Filter wages returned to
212
- # only those that are associated with the specified employee.
213
- # @param [Integer] limit Optional parameter: Maximum number of Employee
214
- # Wages to return per page. Can range between 1 and 200. The default is the
215
- # maximum at 200.
216
- # @param [String] cursor Optional parameter: Pointer to the next page of
217
- # Employee Wage results to fetch.
212
+ # @param [String] employee_id Optional parameter: Filter the returned wages
213
+ # to only those that are associated with the specified employee.
214
+ # @param [Integer] limit Optional parameter: The maximum number of
215
+ # `EmployeeWage` results to return per page. The number can range between 1
216
+ # and 200. The default is 200.
217
+ # @param [String] cursor Optional parameter: A pointer to the next page of
218
+ # `EmployeeWage` results to fetch.
218
219
  # @return [ListEmployeeWagesResponse Hash] response from the API call
219
220
  def list_employee_wages(employee_id: nil,
220
221
  limit: nil,
@@ -252,9 +253,9 @@ module Square
252
253
  )
253
254
  end
254
255
 
255
- # Returns a single `EmployeeWage` specified by id.
256
- # @param [String] id Required parameter: UUID for the `EmployeeWage` being
257
- # retrieved.
256
+ # Returns a single `EmployeeWage` specified by `id`.
257
+ # @param [String] id Required parameter: The UUID for the `EmployeeWage`
258
+ # being retrieved.
258
259
  # @return [GetEmployeeWageResponse Hash] response from the API call
259
260
  def get_employee_wage(id:)
260
261
  warn 'Endpoint get_employee_wage in LaborApi is deprecated'
@@ -289,7 +290,7 @@ module Square
289
290
  end
290
291
 
291
292
  # Creates a new `Shift`.
292
- # A `Shift` represents a complete work day for a single employee.
293
+ # A `Shift` represents a complete workday for a single employee.
293
294
  # You must provide the following values in your request to this
294
295
  # endpoint:
295
296
  # - `location_id`
@@ -299,12 +300,12 @@ module Square
299
300
  # when:
300
301
  # - The `status` of the new `Shift` is `OPEN` and the employee has another
301
302
  # shift with an `OPEN` status.
302
- # - The `start_at` date is in the future
303
- # - the `start_at` or `end_at` overlaps another shift for the same employee
304
- # - If `Break`s are set in the request, a break `start_at`
305
- # must not be before the `Shift.start_at`. A break `end_at` must not be
306
- # after
307
- # the `Shift.end_at`
303
+ # - The `start_at` date is in the future.
304
+ # - The `start_at` or `end_at` date overlaps another shift for the same
305
+ # employee.
306
+ # - The `Break` instances are set in the request and a break `start_at`
307
+ # is before the `Shift.start_at`, a break `end_at` is after
308
+ # the `Shift.end_at`, or both.
308
309
  # @param [CreateShiftRequest] body Required parameter: An object containing
309
310
  # the fields to POST for the request. See the corresponding object
310
311
  # definition for field details.
@@ -340,17 +341,17 @@ module Square
340
341
 
341
342
  # Returns a paginated list of `Shift` records for a business.
342
343
  # The list to be returned can be filtered by:
343
- # - Location IDs **and**
344
- # - employee IDs **and**
345
- # - shift status (`OPEN`, `CLOSED`) **and**
346
- # - shift start **and**
347
- # - shift end **and**
348
- # - work day details
344
+ # - Location IDs.
345
+ # - Employee IDs.
346
+ # - Shift status (`OPEN` and `CLOSED`).
347
+ # - Shift start.
348
+ # - Shift end.
349
+ # - Workday details.
349
350
  # The list can be sorted by:
350
- # - `start_at`
351
- # - `end_at`
352
- # - `created_at`
353
- # - `updated_at`
351
+ # - `start_at`.
352
+ # - `end_at`.
353
+ # - `created_at`.
354
+ # - `updated_at`.
354
355
  # @param [SearchShiftsRequest] body Required parameter: An object containing
355
356
  # the fields to POST for the request. See the corresponding object
356
357
  # definition for field details.
@@ -385,7 +386,7 @@ module Square
385
386
  end
386
387
 
387
388
  # Deletes a `Shift`.
388
- # @param [String] id Required parameter: UUID for the `Shift` being
389
+ # @param [String] id Required parameter: The UUID for the `Shift` being
389
390
  # deleted.
390
391
  # @return [DeleteShiftResponse Hash] response from the API call
391
392
  def delete_shift(id:)
@@ -419,8 +420,8 @@ module Square
419
420
  )
420
421
  end
421
422
 
422
- # Returns a single `Shift` specified by id.
423
- # @param [String] id Required parameter: UUID for the `Shift` being
423
+ # Returns a single `Shift` specified by `id`.
424
+ # @param [String] id Required parameter: The UUID for the `Shift` being
424
425
  # retrieved.
425
426
  # @return [GetShiftResponse Hash] response from the API call
426
427
  def get_shift(id:)
@@ -455,13 +456,14 @@ module Square
455
456
  end
456
457
 
457
458
  # Updates an existing `Shift`.
458
- # When adding a `Break` to a `Shift`, any earlier `Breaks` in the `Shift`
459
- # have
459
+ # When adding a `Break` to a `Shift`, any earlier `Break` instances in the
460
+ # `Shift` have
460
461
  # the `end_at` property set to a valid RFC-3339 datetime string.
461
- # When closing a `Shift`, all `Break` instances in the shift must be
462
+ # When closing a `Shift`, all `Break` instances in the `Shift` must be
462
463
  # complete with `end_at`
463
464
  # set on each `Break`.
464
- # @param [String] id Required parameter: ID of the object being updated.
465
+ # @param [String] id Required parameter: The ID of the object being
466
+ # updated.
465
467
  # @param [UpdateShiftRequest] body Required parameter: An object containing
466
468
  # the fields to POST for the request. See the corresponding object
467
469
  # definition for field details.
@@ -501,13 +503,13 @@ module Square
501
503
  end
502
504
 
503
505
  # Returns a paginated list of `TeamMemberWage` instances for a business.
504
- # @param [String] team_member_id Optional parameter: Filter wages returned
505
- # to only those that are associated with the specified team member.
506
- # @param [Integer] limit Optional parameter: Maximum number of Team Member
507
- # Wages to return per page. Can range between 1 and 200. The default is the
508
- # maximum at 200.
509
- # @param [String] cursor Optional parameter: Pointer to the next page of
510
- # Employee Wage results to fetch.
506
+ # @param [String] team_member_id Optional parameter: Filter the returned
507
+ # wages to only those that are associated with the specified team member.
508
+ # @param [Integer] limit Optional parameter: The maximum number of
509
+ # `TeamMemberWage` results to return per page. The number can range between
510
+ # 1 and 200. The default is 200.
511
+ # @param [String] cursor Optional parameter: A pointer to the next page of
512
+ # `EmployeeWage` results to fetch.
511
513
  # @return [ListTeamMemberWagesResponse Hash] response from the API call
512
514
  def list_team_member_wages(team_member_id: nil,
513
515
  limit: nil,
@@ -544,9 +546,9 @@ module Square
544
546
  )
545
547
  end
546
548
 
547
- # Returns a single `TeamMemberWage` specified by id.
548
- # @param [String] id Required parameter: UUID for the `TeamMemberWage` being
549
- # retrieved.
549
+ # Returns a single `TeamMemberWage` specified by `id `.
550
+ # @param [String] id Required parameter: The UUID for the `TeamMemberWage`
551
+ # being retrieved.
550
552
  # @return [GetTeamMemberWageResponse Hash] response from the API call
551
553
  def get_team_member_wage(id:)
552
554
  # Prepare query url.
@@ -580,10 +582,10 @@ module Square
580
582
  end
581
583
 
582
584
  # Returns a list of `WorkweekConfig` instances for a business.
583
- # @param [Integer] limit Optional parameter: Maximum number of Workweek
584
- # Configs to return per page.
585
- # @param [String] cursor Optional parameter: Pointer to the next page of
586
- # Workweek Config results to fetch.
585
+ # @param [Integer] limit Optional parameter: The maximum number of
586
+ # `WorkweekConfigs` results to return per page.
587
+ # @param [String] cursor Optional parameter: A pointer to the next page of
588
+ # `WorkweekConfig` results to fetch.
587
589
  # @return [ListWorkweekConfigsResponse Hash] response from the API call
588
590
  def list_workweek_configs(limit: nil,
589
591
  cursor: nil)
@@ -619,7 +621,7 @@ module Square
619
621
  end
620
622
 
621
623
  # Updates a `WorkweekConfig`.
622
- # @param [String] id Required parameter: UUID for the `WorkweekConfig`
624
+ # @param [String] id Required parameter: The UUID for the `WorkweekConfig`
623
625
  # object being updated.
624
626
  # @param [UpdateWorkweekConfigRequest] body Required parameter: An object
625
627
  # containing the fields to POST for the request. See the corresponding
@@ -8,13 +8,14 @@ module Square
8
8
  def self.serialize_array(key, array, formatting: 'indexed')
9
9
  tuples = []
10
10
 
11
- if formatting == 'unindexed'
11
+ case formatting
12
+ when 'unindexed'
12
13
  tuples += array.map { |element| ["#{key}[]", element] }
13
- elsif formatting == 'indexed'
14
+ when 'indexed'
14
15
  tuples += array.map.with_index do |element, index|
15
16
  ["#{key}[#{index}]", element]
16
17
  end
17
- elsif formatting == 'plain'
18
+ when 'plain'
18
19
  tuples += array.map { |element| [key, element] }
19
20
  else
20
21
  raise ArgumentError, 'Invalid format provided.'
@@ -55,7 +56,7 @@ module Square
55
56
  end
56
57
 
57
58
  # Find the template parameter and replace it with its value.
58
- query_builder = query_builder.gsub('{' + key.to_s + '}', replace_value)
59
+ query_builder = query_builder.gsub("{#{key}}", replace_value)
59
60
  end
60
61
  query_builder
61
62
  end
@@ -80,15 +81,16 @@ module Square
80
81
  unless value.nil?
81
82
  if value.instance_of? Array
82
83
  value.compact!
83
- query_builder += if array_serialization == 'csv'
84
+ query_builder += case array_serialization
85
+ when 'csv'
84
86
  "#{seperator}#{key}=#{value.map do |element|
85
87
  CGI.escape(element.to_s)
86
88
  end.join(',')}"
87
- elsif array_serialization == 'psv'
89
+ when 'psv'
88
90
  "#{seperator}#{key}=#{value.map do |element|
89
91
  CGI.escape(element.to_s)
90
92
  end.join('|')}"
91
- elsif array_serialization == 'tsv'
93
+ when 'tsv'
92
94
  "#{seperator}#{key}=#{value.map do |element|
93
95
  CGI.escape(element.to_s)
94
96
  end.join("\t")}"
@@ -114,7 +116,7 @@ module Square
114
116
  raise ArgumentError, 'Invalid Url.' unless url.instance_of? String
115
117
 
116
118
  # Ensure that the urls are absolute.
117
- matches = url.match(%r{^(https?:\/\/[^\/]+)})
119
+ matches = url.match(%r{^(https?://[^/]+)})
118
120
  raise ArgumentError, 'Invalid Url format.' if matches.nil?
119
121
 
120
122
  # Get the http protocol match.
@@ -125,7 +127,7 @@ module Square
125
127
 
126
128
  # Remove redundant forward slashes.
127
129
  query = url[protocol.length...(!index.nil? ? index : url.length)]
128
- query.gsub!(%r{\/\/+}, '/')
130
+ query.gsub!(%r{//+}, '/')
129
131
 
130
132
  # Get the parameters.
131
133
  parameters = !index.nil? ? url[url.index('?')...url.length] : ''
@@ -137,7 +139,7 @@ module Square
137
139
  # Parses JSON string.
138
140
  # @param [String] A JSON string.
139
141
  def self.json_deserialize(json)
140
- return JSON.parse(json, symbolize_names: true)
142
+ JSON.parse(json, symbolize_names: true)
141
143
  rescue StandardError
142
144
  raise TypeError, 'Server responded with invalid JSON.'
143
145
  end
@@ -207,13 +209,12 @@ module Square
207
209
  elsif obj.instance_of? Array
208
210
  if formatting == 'indexed'
209
211
  obj.each_with_index do |value, index|
210
- retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
211
- index.to_s + ']'))
212
+ retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]"))
212
213
  end
213
214
  elsif serializable_types.map { |x| obj[0].is_a? x }.any?
214
215
  obj.each do |value|
215
216
  abc = if formatting == 'unindexed'
216
- APIHelper.form_encode(value, instance_name + '[]',
217
+ APIHelper.form_encode(value, "#{instance_name}[]",
217
218
  formatting: formatting)
218
219
  else
219
220
  APIHelper.form_encode(value, instance_name,
@@ -223,14 +224,14 @@ module Square
223
224
  end
224
225
  else
225
226
  obj.each_with_index do |value, index|
226
- retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
227
- index.to_s + ']', formatting: formatting))
227
+ retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]",
228
+ formatting: formatting))
228
229
  end
229
230
  end
230
231
  elsif obj.instance_of? Hash
231
232
  obj.each do |key, value|
232
- retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
233
- key.to_s + ']', formatting: formatting))
233
+ retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{key}]",
234
+ formatting: formatting))
234
235
  end
235
236
  elsif obj.instance_of? File
236
237
  retval[instance_name] = UploadIO.new(
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
- '13.0.0.20210721'
7
+ '13.1.0.20210818'
8
8
  end
9
9
 
10
10
  def square_version
@@ -220,7 +220,7 @@ module Square
220
220
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
221
221
  retry_methods: %i[get put], environment: 'production',
222
222
  custom_url: 'https://connect.squareup.com',
223
- square_version: '2021-07-21', access_token: 'TODO: Replace',
223
+ square_version: '2021-08-18', access_token: 'TODO: Replace',
224
224
  additional_headers: {}, config: nil)
225
225
  @config = if config.nil?
226
226
  Configuration.new(timeout: timeout, max_retries: max_retries,
@@ -28,7 +28,7 @@ module Square
28
28
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
29
29
  retry_methods: %i[get put], environment: 'production',
30
30
  custom_url: 'https://connect.squareup.com',
31
- square_version: '2021-07-21', access_token: 'TODO: Replace',
31
+ square_version: '2021-08-18', access_token: 'TODO: Replace',
32
32
  additional_headers: {})
33
33
  # The value to use for connection timeout
34
34
  @timeout = timeout
@@ -22,7 +22,7 @@ module Square
22
22
  methods: retry_methods
23
23
  faraday.adapter Faraday.default_adapter
24
24
  faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
25
- faraday.options[:timeout] = timeout if timeout > 0
25
+ faraday.options[:timeout] = timeout if timeout.positive?
26
26
  end
27
27
  end
28
28
 
@@ -6,7 +6,7 @@ module Square
6
6
  # @param [DateTime] The DateTime object
7
7
  # @return [String] The rfc1123 formatted datetime string
8
8
  def self.to_rfc1123(date_time)
9
- date_time.httpdate unless date_time.nil?
9
+ date_time&.httpdate
10
10
  end
11
11
 
12
12
  # Safely converts a map of DateTime objects into a map of rfc1123 format string
@@ -86,7 +86,7 @@ module Square
86
86
  # @param [DateTime] The DateTime object
87
87
  # @return [String] The rfc3339 formatted datetime string
88
88
  def self.to_rfc3339(date_time)
89
- date_time.rfc3339 unless date_time.nil?
89
+ date_time&.rfc3339
90
90
  end
91
91
 
92
92
  # Safely converts a map of DateTime objects into a map of rfc1123 format string
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: square.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.0.0.20210721
4
+ version: 13.1.0.20210818
5
5
  platform: ruby
6
6
  authors:
7
7
  - Square Developer Platform
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-21 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -209,7 +209,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
209
  requirements:
210
210
  - - ">="
211
211
  - !ruby/object:Gem::Version
212
- version: '2.0'
212
+ version: '2.5'
213
+ - - "<"
214
+ - !ruby/object:Gem::Version
215
+ version: '3.0'
213
216
  required_rubygems_version: !ruby/object:Gem::Requirement
214
217
  requirements:
215
218
  - - ">="