square.rb 13.1.0.20210818 → 16.0.1.20211117

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +35 -22
  4. data/lib/square/api/apple_pay_api.rb +1 -1
  5. data/lib/square/api/base_api.rb +2 -4
  6. data/lib/square/api/bookings_api.rb +64 -4
  7. data/lib/square/api/cards_api.rb +1 -1
  8. data/lib/square/api/catalog_api.rb +10 -10
  9. data/lib/square/api/checkout_api.rb +1 -1
  10. data/lib/square/api/customer_groups_api.rb +3 -3
  11. data/lib/square/api/customer_segments_api.rb +1 -1
  12. data/lib/square/api/customers_api.rb +5 -5
  13. data/lib/square/api/devices_api.rb +1 -1
  14. data/lib/square/api/disputes_api.rb +1 -1
  15. data/lib/square/api/gift_card_activities_api.rb +26 -20
  16. data/lib/square/api/gift_cards_api.rb +29 -24
  17. data/lib/square/api/inventory_api.rb +6 -6
  18. data/lib/square/api/invoices_api.rb +5 -5
  19. data/lib/square/api/labor_api.rb +6 -6
  20. data/lib/square/api/locations_api.rb +2 -2
  21. data/lib/square/api/loyalty_api.rb +9 -9
  22. data/lib/square/api/mobile_authorization_api.rb +1 -1
  23. data/lib/square/api/o_auth_api.rb +22 -15
  24. data/lib/square/api/orders_api.rb +43 -6
  25. data/lib/square/api/payments_api.rb +12 -6
  26. data/lib/square/api/refunds_api.rb +1 -1
  27. data/lib/square/api/sites_api.rb +2 -1
  28. data/lib/square/api/snippets_api.rb +1 -1
  29. data/lib/square/api/subscriptions_api.rb +159 -16
  30. data/lib/square/api/team_api.rb +6 -6
  31. data/lib/square/api/terminal_api.rb +4 -4
  32. data/lib/square/api/transactions_api.rb +0 -188
  33. data/lib/square/api/v1_transactions_api.rb +2 -2
  34. data/lib/square/api_helper.rb +1 -0
  35. data/lib/square/client.rb +6 -11
  36. data/lib/square/configuration.rb +19 -20
  37. data/lib/square/http/api_response.rb +1 -1
  38. data/lib/square/http/faraday_client.rb +20 -1
  39. data/lib/square/utilities/file_wrapper.rb +1 -2
  40. data/lib/square.rb +48 -49
  41. data/test/test_helper.rb +1 -1
  42. metadata +7 -11
  43. data/lib/square/api/v1_employees_api.rb +0 -362
@@ -1,362 +0,0 @@
1
- module Square
2
- # V1EmployeesApi
3
- class V1EmployeesApi < BaseApi
4
- def initialize(config, http_call_back: nil)
5
- super(config, http_call_back: http_call_back)
6
- end
7
-
8
- # Provides summary information for all of a business's employees.
9
- # @param [SortOrder] order Optional parameter: The order in which employees
10
- # are listed in the response, based on their created_at field. Default
11
- # value: ASC
12
- # @param [String] begin_updated_at Optional parameter: If filtering results
13
- # by their updated_at field, the beginning of the requested reporting
14
- # period, in ISO 8601 format
15
- # @param [String] end_updated_at Optional parameter: If filtering results by
16
- # there updated_at field, the end of the requested reporting period, in ISO
17
- # 8601 format.
18
- # @param [String] begin_created_at Optional parameter: If filtering results
19
- # by their created_at field, the beginning of the requested reporting
20
- # period, in ISO 8601 format.
21
- # @param [String] end_created_at Optional parameter: If filtering results by
22
- # their created_at field, the end of the requested reporting period, in ISO
23
- # 8601 format.
24
- # @param [V1ListEmployeesRequestStatus] status Optional parameter: If
25
- # provided, the endpoint returns only employee entities with the specified
26
- # status (ACTIVE or INACTIVE).
27
- # @param [String] external_id Optional parameter: If provided, the endpoint
28
- # returns only employee entities with the specified external_id.
29
- # @param [Integer] limit Optional parameter: The maximum integer number of
30
- # employee entities to return in a single response. Default 100, maximum
31
- # 200.
32
- # @param [String] batch_token Optional parameter: A pagination cursor to
33
- # retrieve the next set of results for your original query to the
34
- # endpoint.
35
- # @return [List of V1Employee Hash] response from the API call
36
- def list_employees(order: nil,
37
- begin_updated_at: nil,
38
- end_updated_at: nil,
39
- begin_created_at: nil,
40
- end_created_at: nil,
41
- status: nil,
42
- external_id: nil,
43
- limit: nil,
44
- batch_token: nil)
45
- # Prepare query url.
46
- _query_builder = config.get_base_uri
47
- _query_builder << '/v1/me/employees'
48
- _query_builder = APIHelper.append_url_with_query_parameters(
49
- _query_builder,
50
- 'order' => order,
51
- 'begin_updated_at' => begin_updated_at,
52
- 'end_updated_at' => end_updated_at,
53
- 'begin_created_at' => begin_created_at,
54
- 'end_created_at' => end_created_at,
55
- 'status' => status,
56
- 'external_id' => external_id,
57
- 'limit' => limit,
58
- 'batch_token' => batch_token
59
- )
60
- _query_url = APIHelper.clean_url _query_builder
61
-
62
- # Prepare headers.
63
- _headers = {
64
- 'accept' => 'application/json'
65
- }
66
-
67
- # Prepare and execute HttpRequest.
68
- _request = config.http_client.get(
69
- _query_url,
70
- headers: _headers
71
- )
72
- OAuth2.apply(config, _request)
73
- _response = execute_request(_request)
74
-
75
- # Return appropriate response type.
76
- decoded = APIHelper.json_deserialize(_response.raw_body)
77
- _errors = APIHelper.map_response(decoded, ['errors'])
78
- ApiResponse.new(
79
- _response, data: decoded, errors: _errors
80
- )
81
- end
82
-
83
- # Use the CreateEmployee endpoint to add an employee to a Square
84
- # account. Employees created with the Connect API have an initial status
85
- # of `INACTIVE`. Inactive employees cannot sign in to Square Point of Sale
86
- # until they are activated from the Square Dashboard. Employee status
87
- # cannot be changed with the Connect API.
88
- # Employee entities cannot be deleted. To disable employee profiles,
89
- # set the employee's status to <code>INACTIVE</code>
90
- # @param [V1Employee] body Required parameter: An object containing the
91
- # fields to POST for the request. See the corresponding object definition
92
- # for field details.
93
- # @return [V1Employee Hash] response from the API call
94
- def create_employee(body:)
95
- # Prepare query url.
96
- _query_builder = config.get_base_uri
97
- _query_builder << '/v1/me/employees'
98
- _query_url = APIHelper.clean_url _query_builder
99
-
100
- # Prepare headers.
101
- _headers = {
102
- 'accept' => 'application/json',
103
- 'content-type' => 'application/json; charset=utf-8'
104
- }
105
-
106
- # Prepare and execute HttpRequest.
107
- _request = config.http_client.post(
108
- _query_url,
109
- headers: _headers,
110
- parameters: body.to_json
111
- )
112
- OAuth2.apply(config, _request)
113
- _response = execute_request(_request)
114
-
115
- # Return appropriate response type.
116
- decoded = APIHelper.json_deserialize(_response.raw_body)
117
- _errors = APIHelper.map_response(decoded, ['errors'])
118
- ApiResponse.new(
119
- _response, data: decoded, errors: _errors
120
- )
121
- end
122
-
123
- # Provides the details for a single employee.
124
- # @param [String] employee_id Required parameter: The employee's ID.
125
- # @return [V1Employee Hash] response from the API call
126
- def retrieve_employee(employee_id:)
127
- # Prepare query url.
128
- _query_builder = config.get_base_uri
129
- _query_builder << '/v1/me/employees/{employee_id}'
130
- _query_builder = APIHelper.append_url_with_template_parameters(
131
- _query_builder,
132
- 'employee_id' => { 'value' => employee_id, 'encode' => true }
133
- )
134
- _query_url = APIHelper.clean_url _query_builder
135
-
136
- # Prepare headers.
137
- _headers = {
138
- 'accept' => 'application/json'
139
- }
140
-
141
- # Prepare and execute HttpRequest.
142
- _request = config.http_client.get(
143
- _query_url,
144
- headers: _headers
145
- )
146
- OAuth2.apply(config, _request)
147
- _response = execute_request(_request)
148
-
149
- # Return appropriate response type.
150
- decoded = APIHelper.json_deserialize(_response.raw_body)
151
- _errors = APIHelper.map_response(decoded, ['errors'])
152
- ApiResponse.new(
153
- _response, data: decoded, errors: _errors
154
- )
155
- end
156
-
157
- # UpdateEmployee
158
- # @param [String] employee_id Required parameter: The ID of the role to
159
- # modify.
160
- # @param [V1Employee] body Required parameter: An object containing the
161
- # fields to POST for the request. See the corresponding object definition
162
- # for field details.
163
- # @return [V1Employee Hash] response from the API call
164
- def update_employee(employee_id:,
165
- body:)
166
- # Prepare query url.
167
- _query_builder = config.get_base_uri
168
- _query_builder << '/v1/me/employees/{employee_id}'
169
- _query_builder = APIHelper.append_url_with_template_parameters(
170
- _query_builder,
171
- 'employee_id' => { 'value' => employee_id, 'encode' => true }
172
- )
173
- _query_url = APIHelper.clean_url _query_builder
174
-
175
- # Prepare headers.
176
- _headers = {
177
- 'accept' => 'application/json',
178
- 'content-type' => 'application/json; charset=utf-8'
179
- }
180
-
181
- # Prepare and execute HttpRequest.
182
- _request = config.http_client.put(
183
- _query_url,
184
- headers: _headers,
185
- parameters: body.to_json
186
- )
187
- OAuth2.apply(config, _request)
188
- _response = execute_request(_request)
189
-
190
- # Return appropriate response type.
191
- decoded = APIHelper.json_deserialize(_response.raw_body)
192
- _errors = APIHelper.map_response(decoded, ['errors'])
193
- ApiResponse.new(
194
- _response, data: decoded, errors: _errors
195
- )
196
- end
197
-
198
- # Provides summary information for all of a business's employee roles.
199
- # @param [SortOrder] order Optional parameter: The order in which employees
200
- # are listed in the response, based on their created_at field.Default value:
201
- # ASC
202
- # @param [Integer] limit Optional parameter: The maximum integer number of
203
- # employee entities to return in a single response. Default 100, maximum
204
- # 200.
205
- # @param [String] batch_token Optional parameter: A pagination cursor to
206
- # retrieve the next set of results for your original query to the
207
- # endpoint.
208
- # @return [List of V1EmployeeRole Hash] response from the API call
209
- def list_employee_roles(order: nil,
210
- limit: nil,
211
- batch_token: nil)
212
- # Prepare query url.
213
- _query_builder = config.get_base_uri
214
- _query_builder << '/v1/me/roles'
215
- _query_builder = APIHelper.append_url_with_query_parameters(
216
- _query_builder,
217
- 'order' => order,
218
- 'limit' => limit,
219
- 'batch_token' => batch_token
220
- )
221
- _query_url = APIHelper.clean_url _query_builder
222
-
223
- # Prepare headers.
224
- _headers = {
225
- 'accept' => 'application/json'
226
- }
227
-
228
- # Prepare and execute HttpRequest.
229
- _request = config.http_client.get(
230
- _query_url,
231
- headers: _headers
232
- )
233
- OAuth2.apply(config, _request)
234
- _response = execute_request(_request)
235
-
236
- # Return appropriate response type.
237
- decoded = APIHelper.json_deserialize(_response.raw_body)
238
- _errors = APIHelper.map_response(decoded, ['errors'])
239
- ApiResponse.new(
240
- _response, data: decoded, errors: _errors
241
- )
242
- end
243
-
244
- # Creates an employee role you can then assign to employees.
245
- # Square accounts can include any number of roles that can be assigned to
246
- # employees. These roles define the actions and permissions granted to an
247
- # employee with that role. For example, an employee with a "Shift Manager"
248
- # role might be able to issue refunds in Square Point of Sale, whereas an
249
- # employee with a "Clerk" role might not.
250
- # Roles are assigned with the
251
- # [V1UpdateEmployee]($e/V1Employees/UpdateEmployeeRole)
252
- # endpoint. An employee can have only one role at a time.
253
- # If an employee has no role, they have none of the permissions associated
254
- # with roles. All employees can accept payments with Square Point of Sale.
255
- # @param [V1EmployeeRole] body Required parameter: An EmployeeRole object
256
- # with a name and permissions, and an optional owner flag.
257
- # @return [V1EmployeeRole Hash] response from the API call
258
- def create_employee_role(body:)
259
- # Prepare query url.
260
- _query_builder = config.get_base_uri
261
- _query_builder << '/v1/me/roles'
262
- _query_url = APIHelper.clean_url _query_builder
263
-
264
- # Prepare headers.
265
- _headers = {
266
- 'accept' => 'application/json',
267
- 'content-type' => 'application/json; charset=utf-8'
268
- }
269
-
270
- # Prepare and execute HttpRequest.
271
- _request = config.http_client.post(
272
- _query_url,
273
- headers: _headers,
274
- parameters: body.to_json
275
- )
276
- OAuth2.apply(config, _request)
277
- _response = execute_request(_request)
278
-
279
- # Return appropriate response type.
280
- decoded = APIHelper.json_deserialize(_response.raw_body)
281
- _errors = APIHelper.map_response(decoded, ['errors'])
282
- ApiResponse.new(
283
- _response, data: decoded, errors: _errors
284
- )
285
- end
286
-
287
- # Provides the details for a single employee role.
288
- # @param [String] role_id Required parameter: The role's ID.
289
- # @return [V1EmployeeRole Hash] response from the API call
290
- def retrieve_employee_role(role_id:)
291
- # Prepare query url.
292
- _query_builder = config.get_base_uri
293
- _query_builder << '/v1/me/roles/{role_id}'
294
- _query_builder = APIHelper.append_url_with_template_parameters(
295
- _query_builder,
296
- 'role_id' => { 'value' => role_id, 'encode' => true }
297
- )
298
- _query_url = APIHelper.clean_url _query_builder
299
-
300
- # Prepare headers.
301
- _headers = {
302
- 'accept' => 'application/json'
303
- }
304
-
305
- # Prepare and execute HttpRequest.
306
- _request = config.http_client.get(
307
- _query_url,
308
- headers: _headers
309
- )
310
- OAuth2.apply(config, _request)
311
- _response = execute_request(_request)
312
-
313
- # Return appropriate response type.
314
- decoded = APIHelper.json_deserialize(_response.raw_body)
315
- _errors = APIHelper.map_response(decoded, ['errors'])
316
- ApiResponse.new(
317
- _response, data: decoded, errors: _errors
318
- )
319
- end
320
-
321
- # Modifies the details of an employee role.
322
- # @param [String] role_id Required parameter: The ID of the role to
323
- # modify.
324
- # @param [V1EmployeeRole] body Required parameter: An object containing the
325
- # fields to POST for the request. See the corresponding object definition
326
- # for field details.
327
- # @return [V1EmployeeRole Hash] response from the API call
328
- def update_employee_role(role_id:,
329
- body:)
330
- # Prepare query url.
331
- _query_builder = config.get_base_uri
332
- _query_builder << '/v1/me/roles/{role_id}'
333
- _query_builder = APIHelper.append_url_with_template_parameters(
334
- _query_builder,
335
- 'role_id' => { 'value' => role_id, 'encode' => true }
336
- )
337
- _query_url = APIHelper.clean_url _query_builder
338
-
339
- # Prepare headers.
340
- _headers = {
341
- 'accept' => 'application/json',
342
- 'content-type' => 'application/json; charset=utf-8'
343
- }
344
-
345
- # Prepare and execute HttpRequest.
346
- _request = config.http_client.put(
347
- _query_url,
348
- headers: _headers,
349
- parameters: body.to_json
350
- )
351
- OAuth2.apply(config, _request)
352
- _response = execute_request(_request)
353
-
354
- # Return appropriate response type.
355
- decoded = APIHelper.json_deserialize(_response.raw_body)
356
- _errors = APIHelper.map_response(decoded, ['errors'])
357
- ApiResponse.new(
358
- _response, data: decoded, errors: _errors
359
- )
360
- end
361
- end
362
- end