square.rb 33.0.0.20231018 → 42.1.0.20250416

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/lib/square/api/apple_pay_api.rb +15 -11
  4. data/lib/square/api/bank_accounts_api.rb +12 -12
  5. data/lib/square/api/base_api.rb +2 -1
  6. data/lib/square/api/booking_custom_attributes_api.rb +44 -44
  7. data/lib/square/api/bookings_api.rb +53 -53
  8. data/lib/square/api/cards_api.rb +16 -16
  9. data/lib/square/api/cash_drawers_api.rb +12 -12
  10. data/lib/square/api/catalog_api.rb +67 -57
  11. data/lib/square/api/checkout_api.rb +111 -26
  12. data/lib/square/api/customer_custom_attributes_api.rb +40 -40
  13. data/lib/square/api/customer_groups_api.rb +20 -20
  14. data/lib/square/api/customer_segments_api.rb +8 -8
  15. data/lib/square/api/customers_api.rb +144 -54
  16. data/lib/square/api/devices_api.rb +20 -20
  17. data/lib/square/api/disputes_api.rb +36 -36
  18. data/lib/square/api/employees_api.rb +8 -8
  19. data/lib/square/api/events_api.rb +84 -0
  20. data/lib/square/api/gift_card_activities_api.rb +10 -11
  21. data/lib/square/api/gift_cards_api.rb +36 -33
  22. data/lib/square/api/inventory_api.rb +52 -52
  23. data/lib/square/api/invoices_api.rb +109 -41
  24. data/lib/square/api/labor_api.rb +81 -80
  25. data/lib/square/api/location_custom_attributes_api.rb +44 -44
  26. data/lib/square/api/locations_api.rb +18 -17
  27. data/lib/square/api/loyalty_api.rb +72 -72
  28. data/lib/square/api/merchant_custom_attributes_api.rb +44 -44
  29. data/lib/square/api/merchants_api.rb +8 -8
  30. data/lib/square/api/mobile_authorization_api.rb +4 -4
  31. data/lib/square/api/o_auth_api.rb +15 -69
  32. data/lib/square/api/order_custom_attributes_api.rb +44 -44
  33. data/lib/square/api/orders_api.rb +32 -32
  34. data/lib/square/api/payments_api.rb +67 -31
  35. data/lib/square/api/payouts_api.rb +12 -12
  36. data/lib/square/api/refunds_api.rb +31 -13
  37. data/lib/square/api/sites_api.rb +4 -4
  38. data/lib/square/api/snippets_api.rb +12 -12
  39. data/lib/square/api/subscriptions_api.rb +48 -48
  40. data/lib/square/api/team_api.rb +146 -40
  41. data/lib/square/api/terminal_api.rb +95 -53
  42. data/lib/square/api/transactions_api.rb +16 -16
  43. data/lib/square/api/v1_transactions_api.rb +13 -292
  44. data/lib/square/api/vendors_api.rb +28 -28
  45. data/lib/square/api/webhook_subscriptions_api.rb +32 -32
  46. data/lib/square/client.rb +32 -24
  47. data/lib/square/configuration.rb +43 -15
  48. data/lib/square/http/api_response.rb +1 -1
  49. data/lib/square/http/auth/o_auth2.rb +21 -2
  50. data/lib/square.rb +4 -3
  51. data/test/api/api_test_base.rb +1 -1
  52. data/test/api/test_locations_api.rb +1 -1
  53. data/test/api/test_refunds_api.rb +4 -1
  54. data/test/webhooks/test_webhooks_helper.rb +17 -0
  55. metadata +12 -17
@@ -5,7 +5,7 @@ module Square
5
5
  # @param [String] api_version Optional parameter: The API version for which
6
6
  # to list event types. Setting this field overrides the default version used
7
7
  # by the application.
8
- # @return [ListWebhookEventTypesResponse Hash] response from the API call
8
+ # @return [ApiResponse] the complete http response with raw body and status code.
9
9
  def list_webhook_event_types(api_version: nil)
10
10
  new_api_call_builder
11
11
  .request(new_request_builder(HttpMethodEnum::GET,
@@ -15,9 +15,9 @@ module Square
15
15
  .header_param(new_parameter('application/json', key: 'accept'))
16
16
  .auth(Single.new('global')))
17
17
  .response(new_response_handler
18
- .deserializer(APIHelper.method(:json_deserialize))
19
- .is_api_response(true)
20
- .convertor(ApiResponse.method(:create)))
18
+ .deserializer(APIHelper.method(:json_deserialize))
19
+ .is_api_response(true)
20
+ .convertor(ApiResponse.method(:create)))
21
21
  .execute
22
22
  end
23
23
 
@@ -37,7 +37,7 @@ module Square
37
37
  # to be returned in a single page. It is possible to receive fewer results
38
38
  # than the specified limit on a given page. The default value of 100 is also
39
39
  # the maximum allowed value. Default: 100
40
- # @return [ListWebhookSubscriptionsResponse Hash] response from the API call
40
+ # @return [ApiResponse] the complete http response with raw body and status code.
41
41
  def list_webhook_subscriptions(cursor: nil,
42
42
  include_disabled: false,
43
43
  sort_order: nil,
@@ -53,9 +53,9 @@ module Square
53
53
  .header_param(new_parameter('application/json', key: 'accept'))
54
54
  .auth(Single.new('global')))
55
55
  .response(new_response_handler
56
- .deserializer(APIHelper.method(:json_deserialize))
57
- .is_api_response(true)
58
- .convertor(ApiResponse.method(:create)))
56
+ .deserializer(APIHelper.method(:json_deserialize))
57
+ .is_api_response(true)
58
+ .convertor(ApiResponse.method(:create)))
59
59
  .execute
60
60
  end
61
61
 
@@ -63,7 +63,7 @@ module Square
63
63
  # @param [CreateWebhookSubscriptionRequest] body Required parameter: An
64
64
  # object containing the fields to POST for the request. See the
65
65
  # corresponding object definition for field details.
66
- # @return [CreateWebhookSubscriptionResponse Hash] response from the API call
66
+ # @return [ApiResponse] the complete http response with raw body and status code.
67
67
  def create_webhook_subscription(body:)
68
68
  new_api_call_builder
69
69
  .request(new_request_builder(HttpMethodEnum::POST,
@@ -75,16 +75,16 @@ module Square
75
75
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
76
76
  .auth(Single.new('global')))
77
77
  .response(new_response_handler
78
- .deserializer(APIHelper.method(:json_deserialize))
79
- .is_api_response(true)
80
- .convertor(ApiResponse.method(:create)))
78
+ .deserializer(APIHelper.method(:json_deserialize))
79
+ .is_api_response(true)
80
+ .convertor(ApiResponse.method(:create)))
81
81
  .execute
82
82
  end
83
83
 
84
84
  # Deletes a webhook subscription.
85
85
  # @param [String] subscription_id Required parameter: [REQUIRED] The ID of
86
86
  # the [Subscription](entity:WebhookSubscription) to delete.
87
- # @return [DeleteWebhookSubscriptionResponse Hash] response from the API call
87
+ # @return [ApiResponse] the complete http response with raw body and status code.
88
88
  def delete_webhook_subscription(subscription_id:)
89
89
  new_api_call_builder
90
90
  .request(new_request_builder(HttpMethodEnum::DELETE,
@@ -95,16 +95,16 @@ module Square
95
95
  .header_param(new_parameter('application/json', key: 'accept'))
96
96
  .auth(Single.new('global')))
97
97
  .response(new_response_handler
98
- .deserializer(APIHelper.method(:json_deserialize))
99
- .is_api_response(true)
100
- .convertor(ApiResponse.method(:create)))
98
+ .deserializer(APIHelper.method(:json_deserialize))
99
+ .is_api_response(true)
100
+ .convertor(ApiResponse.method(:create)))
101
101
  .execute
102
102
  end
103
103
 
104
104
  # Retrieves a webhook subscription identified by its ID.
105
105
  # @param [String] subscription_id Required parameter: [REQUIRED] The ID of
106
106
  # the [Subscription](entity:WebhookSubscription) to retrieve.
107
- # @return [RetrieveWebhookSubscriptionResponse Hash] response from the API call
107
+ # @return [ApiResponse] the complete http response with raw body and status code.
108
108
  def retrieve_webhook_subscription(subscription_id:)
109
109
  new_api_call_builder
110
110
  .request(new_request_builder(HttpMethodEnum::GET,
@@ -115,9 +115,9 @@ module Square
115
115
  .header_param(new_parameter('application/json', key: 'accept'))
116
116
  .auth(Single.new('global')))
117
117
  .response(new_response_handler
118
- .deserializer(APIHelper.method(:json_deserialize))
119
- .is_api_response(true)
120
- .convertor(ApiResponse.method(:create)))
118
+ .deserializer(APIHelper.method(:json_deserialize))
119
+ .is_api_response(true)
120
+ .convertor(ApiResponse.method(:create)))
121
121
  .execute
122
122
  end
123
123
 
@@ -127,7 +127,7 @@ module Square
127
127
  # @param [UpdateWebhookSubscriptionRequest] body Required parameter: An
128
128
  # object containing the fields to POST for the request. See the
129
129
  # corresponding object definition for field details.
130
- # @return [UpdateWebhookSubscriptionResponse Hash] response from the API call
130
+ # @return [ApiResponse] the complete http response with raw body and status code.
131
131
  def update_webhook_subscription(subscription_id:,
132
132
  body:)
133
133
  new_api_call_builder
@@ -142,9 +142,9 @@ module Square
142
142
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
143
143
  .auth(Single.new('global')))
144
144
  .response(new_response_handler
145
- .deserializer(APIHelper.method(:json_deserialize))
146
- .is_api_response(true)
147
- .convertor(ApiResponse.method(:create)))
145
+ .deserializer(APIHelper.method(:json_deserialize))
146
+ .is_api_response(true)
147
+ .convertor(ApiResponse.method(:create)))
148
148
  .execute
149
149
  end
150
150
 
@@ -155,7 +155,7 @@ module Square
155
155
  # @param [UpdateWebhookSubscriptionSignatureKeyRequest] body Required
156
156
  # parameter: An object containing the fields to POST for the request. See
157
157
  # the corresponding object definition for field details.
158
- # @return [UpdateWebhookSubscriptionSignatureKeyResponse Hash] response from the API call
158
+ # @return [ApiResponse] the complete http response with raw body and status code.
159
159
  def update_webhook_subscription_signature_key(subscription_id:,
160
160
  body:)
161
161
  new_api_call_builder
@@ -170,9 +170,9 @@ module Square
170
170
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
171
171
  .auth(Single.new('global')))
172
172
  .response(new_response_handler
173
- .deserializer(APIHelper.method(:json_deserialize))
174
- .is_api_response(true)
175
- .convertor(ApiResponse.method(:create)))
173
+ .deserializer(APIHelper.method(:json_deserialize))
174
+ .is_api_response(true)
175
+ .convertor(ApiResponse.method(:create)))
176
176
  .execute
177
177
  end
178
178
 
@@ -183,7 +183,7 @@ module Square
183
183
  # @param [TestWebhookSubscriptionRequest] body Required parameter: An object
184
184
  # containing the fields to POST for the request. See the corresponding
185
185
  # object definition for field details.
186
- # @return [TestWebhookSubscriptionResponse Hash] response from the API call
186
+ # @return [ApiResponse] the complete http response with raw body and status code.
187
187
  def test_webhook_subscription(subscription_id:,
188
188
  body:)
189
189
  new_api_call_builder
@@ -198,9 +198,9 @@ module Square
198
198
  .body_serializer(proc do |param| param.to_json unless param.nil? end)
199
199
  .auth(Single.new('global')))
200
200
  .response(new_response_handler
201
- .deserializer(APIHelper.method(:json_deserialize))
202
- .is_api_response(true)
203
- .convertor(ApiResponse.method(:create)))
201
+ .deserializer(APIHelper.method(:json_deserialize))
202
+ .is_api_response(true)
203
+ .convertor(ApiResponse.method(:create)))
204
204
  .execute
205
205
  end
206
206
  end
data/lib/square/client.rb CHANGED
@@ -1,10 +1,11 @@
1
1
  module Square
2
2
  # square client class.
3
3
  class Client
4
+ include CoreLibrary
4
5
  attr_reader :config, :auth_managers
5
6
 
6
7
  def sdk_version
7
- '33.0.0.20231018'
8
+ '42.1.0.20250416'
8
9
  end
9
10
 
10
11
  def square_version
@@ -117,6 +118,12 @@ module Square
117
118
  @employees ||= EmployeesApi.new @global_configuration
118
119
  end
119
120
 
121
+ # Access to events controller.
122
+ # @return [EventsApi] Returns the controller instance.
123
+ def events
124
+ @events ||= EventsApi.new @global_configuration
125
+ end
126
+
120
127
  # Access to gift_cards controller.
121
128
  # @return [GiftCardsApi] Returns the controller instance.
122
129
  def gift_cards
@@ -261,28 +268,29 @@ module Square
261
268
  @webhook_subscriptions ||= WebhookSubscriptionsApi.new @global_configuration
262
269
  end
263
270
 
264
- def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
265
- max_retries: 0, retry_interval: 1, backoff_factor: 2,
266
- retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
267
- retry_methods: %i[get put], http_callback: nil,
268
- environment: 'production',
269
- custom_url: 'https://connect.squareup.com', access_token: '',
270
- square_version: '2023-10-18', user_agent_detail: '',
271
- additional_headers: {}, config: nil)
271
+ def initialize(
272
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
273
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
274
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
275
+ retry_methods: %i[get put], http_callback: nil, environment: 'production',
276
+ custom_url: 'https://connect.squareup.com', access_token: nil,
277
+ bearer_auth_credentials: nil, square_version: '2025-04-16',
278
+ user_agent_detail: '', additional_headers: {}, config: nil
279
+ )
272
280
  @config = if config.nil?
273
- Configuration.new(connection: connection, adapter: adapter,
274
- timeout: timeout, max_retries: max_retries,
275
- retry_interval: retry_interval,
276
- backoff_factor: backoff_factor,
277
- retry_statuses: retry_statuses,
278
- retry_methods: retry_methods,
279
- http_callback: http_callback,
280
- environment: environment,
281
- custom_url: custom_url,
282
- access_token: access_token,
283
- square_version: square_version,
284
- user_agent_detail: user_agent_detail,
285
- additional_headers: additional_headers)
281
+ Configuration.new(
282
+ connection: connection, adapter: adapter, timeout: timeout,
283
+ max_retries: max_retries, retry_interval: retry_interval,
284
+ backoff_factor: backoff_factor,
285
+ retry_statuses: retry_statuses,
286
+ retry_methods: retry_methods, http_callback: http_callback,
287
+ environment: environment, custom_url: custom_url,
288
+ access_token: access_token,
289
+ bearer_auth_credentials: bearer_auth_credentials,
290
+ square_version: square_version,
291
+ user_agent_detail: user_agent_detail,
292
+ additional_headers: additional_headers
293
+ )
286
294
  else
287
295
  config
288
296
  end
@@ -311,8 +319,8 @@ module Square
311
319
  def initialize_auth_managers(global_config)
312
320
  @auth_managers = {}
313
321
  http_client_config = global_config.client_configuration
314
- ['global'].each { |auth| @auth_managers[auth] = nil }
315
- @auth_managers['global'] = OAuth2.new(http_client_config.access_token)
322
+ %w[global].each { |auth| @auth_managers[auth] = nil }
323
+ @auth_managers['global'] = OAuth2.new(http_client_config.bearer_auth_credentials)
316
324
  end
317
325
  end
318
326
  end
@@ -2,8 +2,13 @@ module Square
2
2
  # All configuration including auth info and base URI for the API access
3
3
  # are configured in this class.
4
4
  class Configuration < CoreLibrary::HttpClientConfiguration
5
+ def access_token
6
+ @bearer_auth_credentials.access_token
7
+ end
8
+
5
9
  # The attribute readers for properties.
6
- attr_reader :environment, :custom_url, :access_token, :square_version, :user_agent_detail
10
+ attr_reader :environment, :custom_url, :bearer_auth_credentials,
11
+ :square_version, :user_agent_detail
7
12
 
8
13
  def additional_headers
9
14
  @additional_headers.clone
@@ -13,14 +18,15 @@ module Square
13
18
  attr_reader :environments
14
19
  end
15
20
 
16
- def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
17
- max_retries: 0, retry_interval: 1, backoff_factor: 2,
18
- retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
19
- retry_methods: %i[get put], http_callback: nil,
20
- environment: 'production',
21
- custom_url: 'https://connect.squareup.com', access_token: '',
22
- square_version: '2023-10-18', user_agent_detail: '',
23
- additional_headers: {})
21
+ def initialize(
22
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
23
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
24
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
25
+ retry_methods: %i[get put], http_callback: nil, environment: 'production',
26
+ custom_url: 'https://connect.squareup.com', access_token: nil,
27
+ bearer_auth_credentials: nil, square_version: '2025-04-16',
28
+ user_agent_detail: '', additional_headers: {}
29
+ )
24
30
 
25
31
  super connection: connection, adapter: adapter, timeout: timeout,
26
32
  max_retries: max_retries, retry_interval: retry_interval,
@@ -42,6 +48,11 @@ module Square
42
48
  # Additional headers to add to each API request
43
49
  @additional_headers = additional_headers.clone
44
50
 
51
+ # Initializing OAuth 2 Bearer token credentials with the provided auth parameters
52
+ @bearer_auth_credentials = create_auth_credentials_object(
53
+ access_token, bearer_auth_credentials
54
+ )
55
+
45
56
  # The Http Client to use for making requests.
46
57
  set_http_client CoreLibrary::FaradayClient.new(self)
47
58
 
@@ -53,8 +64,8 @@ module Square
53
64
  max_retries: nil, retry_interval: nil, backoff_factor: nil,
54
65
  retry_statuses: nil, retry_methods: nil, http_callback: nil,
55
66
  environment: nil, custom_url: nil, access_token: nil,
56
- square_version: nil, user_agent_detail: nil,
57
- additional_headers: nil)
67
+ bearer_auth_credentials: nil, square_version: nil,
68
+ user_agent_detail: nil, additional_headers: nil)
58
69
  connection ||= self.connection
59
70
  adapter ||= self.adapter
60
71
  timeout ||= self.timeout
@@ -66,10 +77,12 @@ module Square
66
77
  http_callback ||= self.http_callback
67
78
  environment ||= self.environment
68
79
  custom_url ||= self.custom_url
69
- access_token ||= self.access_token
70
80
  square_version ||= self.square_version
71
81
  user_agent_detail ||= self.user_agent_detail
72
82
  additional_headers ||= self.additional_headers
83
+ bearer_auth_credentials = create_auth_credentials_object(
84
+ access_token, bearer_auth_credentials || self.bearer_auth_credentials
85
+ )
73
86
 
74
87
  Configuration.new(connection: connection, adapter: adapter,
75
88
  timeout: timeout, max_retries: max_retries,
@@ -78,10 +91,10 @@ module Square
78
91
  retry_statuses: retry_statuses,
79
92
  retry_methods: retry_methods,
80
93
  http_callback: http_callback, environment: environment,
81
- custom_url: custom_url, access_token: access_token,
82
- square_version: square_version,
94
+ custom_url: custom_url, square_version: square_version,
83
95
  user_agent_detail: user_agent_detail,
84
- additional_headers: additional_headers)
96
+ additional_headers: additional_headers,
97
+ bearer_auth_credentials: bearer_auth_credentials)
85
98
  end
86
99
 
87
100
  def get_user_agent(user_agent_detail)
@@ -91,6 +104,21 @@ module Square
91
104
  user_agent_detail
92
105
  end
93
106
 
107
+ def create_auth_credentials_object(access_token, bearer_auth_credentials)
108
+ return bearer_auth_credentials if access_token.nil?
109
+
110
+ warn('The \'access_token\' params are deprecated. Use \'bearer_auth_cred'\
111
+ 'entials\' param instead.')
112
+
113
+ unless bearer_auth_credentials.nil?
114
+ return bearer_auth_credentials.clone_with(
115
+ access_token: access_token
116
+ )
117
+ end
118
+
119
+ BearerAuthCredentials.new(access_token: access_token)
120
+ end
121
+
94
122
  # All the environments the SDK can run in.
95
123
  ENVIRONMENTS = {
96
124
  'production' => {
@@ -20,7 +20,7 @@ module Square
20
20
 
21
21
  @cursor = data.fetch(:cursor, nil)
22
22
  data.reject! { |k| %i[cursor errors].include?(k) }
23
- @data = Struct.new(*data.keys).new(*data.values) if data.keys.any?
23
+ @data = data.keys.any? ? Struct.new(*data.keys).new(*data.values) : nil
24
24
  else
25
25
  @data = data
26
26
  @body = data
@@ -1,6 +1,7 @@
1
1
  module Square
2
2
  # Utility class for OAuth 2 authorization and token management.
3
3
  class OAuth2 < CoreLibrary::HeaderAuth
4
+ include CoreLibrary
4
5
  # Display error message on occurrence of authentication failure.
5
6
  # @returns [String] The oAuth error message.
6
7
  def error_message
@@ -8,12 +9,30 @@ module Square
8
9
  end
9
10
 
10
11
  # Initialization constructor.
11
- def initialize(access_token)
12
+ def initialize(bearer_auth_credentials)
12
13
  auth_params = {}
13
- @_access_token = access_token
14
+ @_access_token = bearer_auth_credentials.access_token unless
15
+ bearer_auth_credentials.nil? || bearer_auth_credentials.access_token.nil?
14
16
  auth_params['Authorization'] = "Bearer #{@_access_token}" unless @_access_token.nil?
15
17
 
16
18
  super auth_params
17
19
  end
18
20
  end
21
+
22
+ # Data class for BearerAuthCredentials.
23
+ class BearerAuthCredentials
24
+ attr_reader :access_token
25
+
26
+ def initialize(access_token:)
27
+ raise ArgumentError, 'access_token cannot be nil' if access_token.nil?
28
+
29
+ @access_token = access_token
30
+ end
31
+
32
+ def clone_with(access_token: nil)
33
+ access_token ||= self.access_token
34
+
35
+ BearerAuthCredentials.new(access_token: access_token)
36
+ end
37
+ end
19
38
  end
data/lib/square.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  require 'date'
2
2
  require 'json'
3
+
3
4
  require 'apimatic_core_interfaces'
4
5
  require 'apimatic_core'
5
6
  require 'apimatic_faraday_client_adapter'
6
- # rubocop:disable Style/MixinUsage
7
- include CoreLibrary
8
- # rubocop:enable Style/MixinUsage
9
7
 
10
8
  require_relative 'square/api_helper'
11
9
  require_relative 'square/client'
@@ -20,6 +18,8 @@ require_relative 'square/http/http_call_back'
20
18
  require_relative 'square/http/http_method_enum'
21
19
  require_relative 'square/http/http_request'
22
20
  require_relative 'square/http/http_response'
21
+
22
+ # Logger
23
23
  require_relative 'square/http/auth/o_auth2'
24
24
 
25
25
  # Models
@@ -48,6 +48,7 @@ require_relative 'square/api/customer_segments_api'
48
48
  require_relative 'square/api/devices_api'
49
49
  require_relative 'square/api/disputes_api'
50
50
  require_relative 'square/api/employees_api'
51
+ require_relative 'square/api/events_api'
51
52
  require_relative 'square/api/gift_cards_api'
52
53
  require_relative 'square/api/gift_card_activities_api'
53
54
  require_relative 'square/api/inventory_api'
@@ -9,6 +9,7 @@ require_relative '../http_response_catcher'
9
9
  class ApiTestBase < Minitest::Test
10
10
  parallelize_me!
11
11
  include Square
12
+ include CoreLibrary
12
13
 
13
14
  # Create configuration and set any test parameters
14
15
  def create_configuration
@@ -22,6 +23,5 @@ class ApiTestBase < Minitest::Test
22
23
  def setup_class
23
24
  _config = create_configuration
24
25
  @client = Client.new(config: _config)
25
- _auth_managers = @client.auth_managers
26
26
  end
27
27
  end
@@ -9,7 +9,7 @@ class LocationsApiTests < ApiTestBase
9
9
  end
10
10
 
11
11
  # Provides details about all of the seller's [locations](https://developer.squareup.com/docs/locations-api),
12
- #including those with an inactive status.
12
+ #including those with an inactive status. Locations are listed alphabetically by `name`.
13
13
  def test_list_locations
14
14
 
15
15
  # Perform the API call through the SDK function
@@ -22,9 +22,12 @@ class RefundsApiTests < ApiTestBase
22
22
  location_id = nil
23
23
  status = nil
24
24
  source_type = nil
25
+ updated_at_begin_time = nil
26
+ updated_at_end_time = nil
27
+ sort_field = nil
25
28
 
26
29
  # Perform the API call through the SDK function
27
- result = @controller.list_payment_refunds(begin_time: begin_time, end_time: end_time, sort_order: sort_order, cursor: cursor, location_id: location_id, status: status, source_type: source_type)
30
+ result = @controller.list_payment_refunds(begin_time: begin_time, end_time: end_time, sort_order: sort_order, cursor: cursor, location_id: location_id, status: status, source_type: source_type, updated_at_begin_time: updated_at_begin_time, updated_at_end_time: updated_at_end_time, sort_field: sort_field)
28
31
 
29
32
  # Test response code
30
33
  assert_equal(200, @response_catcher.response.status_code)
@@ -27,6 +27,23 @@ class WebhooksHelperTest < Minitest::Test
27
27
  assert_equal true, is_valid
28
28
  end
29
29
 
30
+ def test_signature_validation_escaped_pass
31
+ @logger.info('Running test_signature_validation_pass') # Log a message
32
+
33
+ escpaedRequestBody = '{"data":{"type":"webhooks","id":">id<"}}';
34
+ newSignatureHeader = "Cxt7+aTi4rKgcA0bC4g9EHdVtLSDWdqccmL5MvihU4U=";
35
+ signatureKey = "signature-key";
36
+ url = "https://webhook.site/webhooks";
37
+
38
+ is_valid = Square::WebhooksHelper.is_valid_webhook_event_signature(
39
+ escpaedRequestBody,
40
+ newSignatureHeader,
41
+ signatureKey,
42
+ url
43
+ )
44
+ assert_equal true, is_valid
45
+ end
46
+
30
47
  def test_signature_validation_fails_on_notification_url_mismatch
31
48
  @logger.info('Running test_signature_validation_fails_on_notification_url_mismatch') # Log a message
32
49
  is_valid = Square::WebhooksHelper.is_valid_webhook_event_signature(
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: 33.0.0.20231018
4
+ version: 42.1.0.20250416
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: 2023-10-17 00:00:00.000000000 Z
11
+ date: 2025-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apimatic_core_interfaces
@@ -16,62 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.0
19
+ version: 0.2.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.0
26
+ version: 0.2.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: apimatic_core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.0
33
+ version: 0.3.11
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.3.0
40
+ version: 0.3.11
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: apimatic_faraday_client_adapter
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.0
47
+ version: 0.1.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.0
54
+ version: 0.1.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: minitest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '5.14'
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: 5.14.1
61
+ version: 5.24.0
65
62
  type: :development
66
63
  prerelease: false
67
64
  version_requirements: !ruby/object:Gem::Requirement
68
65
  requirements:
69
66
  - - "~>"
70
67
  - !ruby/object:Gem::Version
71
- version: '5.14'
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: 5.14.1
68
+ version: 5.24.0
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: minitest-proveit
77
71
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +106,7 @@ files:
112
106
  - lib/square/api/devices_api.rb
113
107
  - lib/square/api/disputes_api.rb
114
108
  - lib/square/api/employees_api.rb
109
+ - lib/square/api/events_api.rb
115
110
  - lib/square/api/gift_card_activities_api.rb
116
111
  - lib/square/api/gift_cards_api.rb
117
112
  - lib/square/api/inventory_api.rb
@@ -163,7 +158,7 @@ files:
163
158
  - test/api/test_refunds_api.rb
164
159
  - test/http_response_catcher.rb
165
160
  - test/webhooks/test_webhooks_helper.rb
166
- homepage: ''
161
+ homepage: https://squareup.com/developers
167
162
  licenses:
168
163
  - Apache-2.0
169
164
  metadata: {}