square.rb 26.1.0.20230119 → 26.2.0.20230315

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/square/api/apple_pay_api.rb +14 -30
  3. data/lib/square/api/bank_accounts_api.rb +40 -90
  4. data/lib/square/api/base_api.rb +42 -42
  5. data/lib/square/api/booking_custom_attributes_api.rb +164 -329
  6. data/lib/square/api/bookings_api.rb +135 -260
  7. data/lib/square/api/cards_api.rb +56 -118
  8. data/lib/square/api/cash_drawers_api.rb +47 -103
  9. data/lib/square/api/catalog_api.rb +197 -423
  10. data/lib/square/api/checkout_api.rb +85 -175
  11. data/lib/square/api/customer_custom_attributes_api.rb +150 -303
  12. data/lib/square/api/customer_groups_api.rb +69 -145
  13. data/lib/square/api/customer_segments_api.rb +26 -61
  14. data/lib/square/api/customers_api.rb +147 -294
  15. data/lib/square/api/devices_api.rb +42 -89
  16. data/lib/square/api/disputes_api.rb +130 -288
  17. data/lib/square/api/employees_api.rb +28 -63
  18. data/lib/square/api/gift_card_activities_api.rb +33 -65
  19. data/lib/square/api/gift_cards_api.rb +103 -202
  20. data/lib/square/api/inventory_api.rb +179 -366
  21. data/lib/square/api/invoices_api.rb +118 -237
  22. data/lib/square/api/labor_api.rb +223 -459
  23. data/lib/square/api/location_custom_attributes_api.rb +166 -331
  24. data/lib/square/api/locations_api.rb +54 -112
  25. data/lib/square/api/loyalty_api.rb +259 -512
  26. data/lib/square/api/merchants_api.rb +25 -60
  27. data/lib/square/api/mobile_authorization_api.rb +14 -30
  28. data/lib/square/api/o_auth_api.rb +54 -109
  29. data/lib/square/api/order_custom_attributes_api.rb +168 -333
  30. data/lib/square/api/orders_api.rb +115 -222
  31. data/lib/square/api/payments_api.rb +106 -208
  32. data/lib/square/api/payouts_api.rb +47 -100
  33. data/lib/square/api/refunds_api.rb +46 -93
  34. data/lib/square/api/sites_api.rb +11 -28
  35. data/lib/square/api/snippets_api.rb +42 -90
  36. data/lib/square/api/subscriptions_api.rb +150 -299
  37. data/lib/square/api/team_api.rb +114 -224
  38. data/lib/square/api/terminal_api.rb +162 -328
  39. data/lib/square/api/transactions_api.rb +62 -126
  40. data/lib/square/api/v1_transactions_api.rb +155 -296
  41. data/lib/square/api/vendors_api.rb +99 -192
  42. data/lib/square/api/webhook_subscriptions_api.rb +115 -235
  43. data/lib/square/api_helper.rb +1 -437
  44. data/lib/square/client.rb +77 -47
  45. data/lib/square/configuration.rb +28 -53
  46. data/lib/square/exceptions/api_exception.rb +1 -11
  47. data/lib/square/http/api_response.rb +13 -19
  48. data/lib/square/http/auth/o_auth2.rb +14 -7
  49. data/lib/square/http/http_call_back.rb +1 -15
  50. data/lib/square/http/http_method_enum.rb +1 -4
  51. data/lib/square/http/http_request.rb +1 -45
  52. data/lib/square/http/http_response.rb +1 -20
  53. data/lib/square/utilities/date_time_helper.rb +1 -146
  54. data/lib/square/utilities/file_wrapper.rb +5 -5
  55. data/lib/square.rb +6 -6
  56. data/spec/user_journey_spec.rb +2 -2
  57. data/test/api/api_test_base.rb +13 -5
  58. data/test/api/test_catalog_api.rb +5 -4
  59. data/test/api/test_customers_api.rb +3 -2
  60. data/test/api/test_employees_api.rb +4 -3
  61. data/test/api/test_labor_api.rb +6 -5
  62. data/test/api/test_locations_api.rb +3 -2
  63. data/test/api/test_merchants_api.rb +4 -3
  64. data/test/api/test_payments_api.rb +4 -3
  65. data/test/api/test_refunds_api.rb +4 -3
  66. metadata +11 -111
  67. data/lib/square/exceptions/validation_exception.rb +0 -13
  68. data/lib/square/http/faraday_client.rb +0 -93
  69. data/lib/square/http/http_client.rb +0 -118
  70. data/test/test_helper.rb +0 -89
@@ -1,10 +1,6 @@
1
1
  module Square
2
2
  # TransactionsApi
3
3
  class TransactionsApi < BaseApi
4
- def initialize(config, http_call_back: nil)
5
- super(config, http_call_back: http_call_back)
6
- end
7
-
8
4
  # Lists transactions for a particular location.
9
5
  # Transactions include payment information from sales and exchanges and
10
6
  # refund
@@ -39,41 +35,23 @@ module Square
39
35
  sort_order: nil,
40
36
  cursor: nil)
41
37
  warn 'Endpoint list_transactions in TransactionsApi is deprecated'
42
- # Prepare query url.
43
- _query_builder = config.get_base_uri
44
- _query_builder << '/v2/locations/{location_id}/transactions'
45
- _query_builder = APIHelper.append_url_with_template_parameters(
46
- _query_builder,
47
- 'location_id' => { 'value' => location_id, 'encode' => true }
48
- )
49
- _query_builder = APIHelper.append_url_with_query_parameters(
50
- _query_builder,
51
- 'begin_time' => begin_time,
52
- 'end_time' => end_time,
53
- 'sort_order' => sort_order,
54
- 'cursor' => cursor
55
- )
56
- _query_url = APIHelper.clean_url _query_builder
57
-
58
- # Prepare headers.
59
- _headers = {
60
- 'accept' => 'application/json'
61
- }
62
-
63
- # Prepare and execute HttpRequest.
64
- _request = config.http_client.get(
65
- _query_url,
66
- headers: _headers
67
- )
68
- OAuth2.apply(config, _request)
69
- _response = execute_request(_request)
70
-
71
- # Return appropriate response type.
72
- decoded = APIHelper.json_deserialize(_response.raw_body)
73
- _errors = APIHelper.map_response(decoded, ['errors'])
74
- ApiResponse.new(
75
- _response, data: decoded, errors: _errors
76
- )
38
+ new_api_call_builder
39
+ .request(new_request_builder(HttpMethodEnum::GET,
40
+ '/v2/locations/{location_id}/transactions',
41
+ 'default')
42
+ .template_param(new_parameter(location_id, key: 'location_id')
43
+ .should_encode(true))
44
+ .query_param(new_parameter(begin_time, key: 'begin_time'))
45
+ .query_param(new_parameter(end_time, key: 'end_time'))
46
+ .query_param(new_parameter(sort_order, key: 'sort_order'))
47
+ .query_param(new_parameter(cursor, key: 'cursor'))
48
+ .header_param(new_parameter('application/json', key: 'accept'))
49
+ .auth(Single.new('global')))
50
+ .response(new_response_handler
51
+ .deserializer(APIHelper.method(:json_deserialize))
52
+ .is_api_response(true)
53
+ .convertor(ApiResponse.method(:create)))
54
+ .execute
77
55
  end
78
56
 
79
57
  # Retrieves details for a single transaction.
@@ -85,35 +63,21 @@ module Square
85
63
  def retrieve_transaction(location_id:,
86
64
  transaction_id:)
87
65
  warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated'
88
- # Prepare query url.
89
- _query_builder = config.get_base_uri
90
- _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}'
91
- _query_builder = APIHelper.append_url_with_template_parameters(
92
- _query_builder,
93
- 'location_id' => { 'value' => location_id, 'encode' => true },
94
- 'transaction_id' => { 'value' => transaction_id, 'encode' => true }
95
- )
96
- _query_url = APIHelper.clean_url _query_builder
97
-
98
- # Prepare headers.
99
- _headers = {
100
- 'accept' => 'application/json'
101
- }
102
-
103
- # Prepare and execute HttpRequest.
104
- _request = config.http_client.get(
105
- _query_url,
106
- headers: _headers
107
- )
108
- OAuth2.apply(config, _request)
109
- _response = execute_request(_request)
110
-
111
- # Return appropriate response type.
112
- decoded = APIHelper.json_deserialize(_response.raw_body)
113
- _errors = APIHelper.map_response(decoded, ['errors'])
114
- ApiResponse.new(
115
- _response, data: decoded, errors: _errors
116
- )
66
+ new_api_call_builder
67
+ .request(new_request_builder(HttpMethodEnum::GET,
68
+ '/v2/locations/{location_id}/transactions/{transaction_id}',
69
+ 'default')
70
+ .template_param(new_parameter(location_id, key: 'location_id')
71
+ .should_encode(true))
72
+ .template_param(new_parameter(transaction_id, key: 'transaction_id')
73
+ .should_encode(true))
74
+ .header_param(new_parameter('application/json', key: 'accept'))
75
+ .auth(Single.new('global')))
76
+ .response(new_response_handler
77
+ .deserializer(APIHelper.method(:json_deserialize))
78
+ .is_api_response(true)
79
+ .convertor(ApiResponse.method(:create)))
80
+ .execute
117
81
  end
118
82
 
119
83
  # Captures a transaction that was created with the
@@ -129,35 +93,21 @@ module Square
129
93
  def capture_transaction(location_id:,
130
94
  transaction_id:)
131
95
  warn 'Endpoint capture_transaction in TransactionsApi is deprecated'
132
- # Prepare query url.
133
- _query_builder = config.get_base_uri
134
- _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/capture'
135
- _query_builder = APIHelper.append_url_with_template_parameters(
136
- _query_builder,
137
- 'location_id' => { 'value' => location_id, 'encode' => true },
138
- 'transaction_id' => { 'value' => transaction_id, 'encode' => true }
139
- )
140
- _query_url = APIHelper.clean_url _query_builder
141
-
142
- # Prepare headers.
143
- _headers = {
144
- 'accept' => 'application/json'
145
- }
146
-
147
- # Prepare and execute HttpRequest.
148
- _request = config.http_client.post(
149
- _query_url,
150
- headers: _headers
151
- )
152
- OAuth2.apply(config, _request)
153
- _response = execute_request(_request)
154
-
155
- # Return appropriate response type.
156
- decoded = APIHelper.json_deserialize(_response.raw_body)
157
- _errors = APIHelper.map_response(decoded, ['errors'])
158
- ApiResponse.new(
159
- _response, data: decoded, errors: _errors
160
- )
96
+ new_api_call_builder
97
+ .request(new_request_builder(HttpMethodEnum::POST,
98
+ '/v2/locations/{location_id}/transactions/{transaction_id}/capture',
99
+ 'default')
100
+ .template_param(new_parameter(location_id, key: 'location_id')
101
+ .should_encode(true))
102
+ .template_param(new_parameter(transaction_id, key: 'transaction_id')
103
+ .should_encode(true))
104
+ .header_param(new_parameter('application/json', key: 'accept'))
105
+ .auth(Single.new('global')))
106
+ .response(new_response_handler
107
+ .deserializer(APIHelper.method(:json_deserialize))
108
+ .is_api_response(true)
109
+ .convertor(ApiResponse.method(:create)))
110
+ .execute
161
111
  end
162
112
 
163
113
  # Cancels a transaction that was created with the
@@ -173,35 +123,21 @@ module Square
173
123
  def void_transaction(location_id:,
174
124
  transaction_id:)
175
125
  warn 'Endpoint void_transaction in TransactionsApi is deprecated'
176
- # Prepare query url.
177
- _query_builder = config.get_base_uri
178
- _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/void'
179
- _query_builder = APIHelper.append_url_with_template_parameters(
180
- _query_builder,
181
- 'location_id' => { 'value' => location_id, 'encode' => true },
182
- 'transaction_id' => { 'value' => transaction_id, 'encode' => true }
183
- )
184
- _query_url = APIHelper.clean_url _query_builder
185
-
186
- # Prepare headers.
187
- _headers = {
188
- 'accept' => 'application/json'
189
- }
190
-
191
- # Prepare and execute HttpRequest.
192
- _request = config.http_client.post(
193
- _query_url,
194
- headers: _headers
195
- )
196
- OAuth2.apply(config, _request)
197
- _response = execute_request(_request)
198
-
199
- # Return appropriate response type.
200
- decoded = APIHelper.json_deserialize(_response.raw_body)
201
- _errors = APIHelper.map_response(decoded, ['errors'])
202
- ApiResponse.new(
203
- _response, data: decoded, errors: _errors
204
- )
126
+ new_api_call_builder
127
+ .request(new_request_builder(HttpMethodEnum::POST,
128
+ '/v2/locations/{location_id}/transactions/{transaction_id}/void',
129
+ 'default')
130
+ .template_param(new_parameter(location_id, key: 'location_id')
131
+ .should_encode(true))
132
+ .template_param(new_parameter(transaction_id, key: 'transaction_id')
133
+ .should_encode(true))
134
+ .header_param(new_parameter('application/json', key: 'accept'))
135
+ .auth(Single.new('global')))
136
+ .response(new_response_handler
137
+ .deserializer(APIHelper.method(:json_deserialize))
138
+ .is_api_response(true)
139
+ .convertor(ApiResponse.method(:create)))
140
+ .execute
205
141
  end
206
142
  end
207
143
  end