square.rb 8.1.0.20210121 → 18.1.0.20220316
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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +59 -213
- data/lib/square/api/apple_pay_api.rb +9 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +20 -9
- data/lib/square/api/bookings_api.rb +95 -12
- data/lib/square/api/cards_api.rb +170 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +140 -66
- data/lib/square/api/checkout_api.rb +3 -3
- data/lib/square/api/customer_groups_api.rb +17 -8
- data/lib/square/api/customer_segments_api.rb +15 -6
- data/lib/square/api/customers_api.rb +61 -31
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +101 -92
- data/lib/square/api/gift_card_activities_api.rb +133 -0
- data/lib/square/api/gift_cards_api.rb +297 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +19 -19
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/locations_api.rb +22 -14
- data/lib/square/api/loyalty_api.rb +86 -32
- data/lib/square/api/merchants_api.rb +11 -9
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +31 -25
- data/lib/square/api/orders_api.rb +78 -39
- data/lib/square/api/payments_api.rb +71 -23
- data/lib/square/api/refunds_api.rb +18 -7
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +190 -12
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +19 -18
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +13 -85
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api_helper.rb +45 -57
- data/lib/square/client.rb +54 -18
- data/lib/square/configuration.rb +59 -20
- data/lib/square/http/api_response.rb +1 -1
- data/lib/square/http/faraday_client.rb +24 -4
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +49 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +1 -1
- metadata +11 -6
- data/lib/square/api/v1_employees_api.rb +0 -749
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -1,749 +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 [V1UpdateEmployee](#endpoint-v1updateemployee)
|
251
|
-
# endpoint. An employee can have only one role at a time.
|
252
|
-
# If an employee has no role, they have none of the permissions associated
|
253
|
-
# with roles. All employees can accept payments with Square Point of Sale.
|
254
|
-
# @param [V1EmployeeRole] body Required parameter: An EmployeeRole object
|
255
|
-
# with a name and permissions, and an optional owner flag.
|
256
|
-
# @return [V1EmployeeRole Hash] response from the API call
|
257
|
-
def create_employee_role(body:)
|
258
|
-
# Prepare query url.
|
259
|
-
_query_builder = config.get_base_uri
|
260
|
-
_query_builder << '/v1/me/roles'
|
261
|
-
_query_url = APIHelper.clean_url _query_builder
|
262
|
-
|
263
|
-
# Prepare headers.
|
264
|
-
_headers = {
|
265
|
-
'accept' => 'application/json',
|
266
|
-
'content-type' => 'application/json; charset=utf-8'
|
267
|
-
}
|
268
|
-
|
269
|
-
# Prepare and execute HttpRequest.
|
270
|
-
_request = config.http_client.post(
|
271
|
-
_query_url,
|
272
|
-
headers: _headers,
|
273
|
-
parameters: body.to_json
|
274
|
-
)
|
275
|
-
OAuth2.apply(config, _request)
|
276
|
-
_response = execute_request(_request)
|
277
|
-
|
278
|
-
# Return appropriate response type.
|
279
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
280
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
281
|
-
ApiResponse.new(
|
282
|
-
_response, data: decoded, errors: _errors
|
283
|
-
)
|
284
|
-
end
|
285
|
-
|
286
|
-
# Provides the details for a single employee role.
|
287
|
-
# @param [String] role_id Required parameter: The role's ID.
|
288
|
-
# @return [V1EmployeeRole Hash] response from the API call
|
289
|
-
def retrieve_employee_role(role_id:)
|
290
|
-
# Prepare query url.
|
291
|
-
_query_builder = config.get_base_uri
|
292
|
-
_query_builder << '/v1/me/roles/{role_id}'
|
293
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
294
|
-
_query_builder,
|
295
|
-
'role_id' => { 'value' => role_id, 'encode' => true }
|
296
|
-
)
|
297
|
-
_query_url = APIHelper.clean_url _query_builder
|
298
|
-
|
299
|
-
# Prepare headers.
|
300
|
-
_headers = {
|
301
|
-
'accept' => 'application/json'
|
302
|
-
}
|
303
|
-
|
304
|
-
# Prepare and execute HttpRequest.
|
305
|
-
_request = config.http_client.get(
|
306
|
-
_query_url,
|
307
|
-
headers: _headers
|
308
|
-
)
|
309
|
-
OAuth2.apply(config, _request)
|
310
|
-
_response = execute_request(_request)
|
311
|
-
|
312
|
-
# Return appropriate response type.
|
313
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
314
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
315
|
-
ApiResponse.new(
|
316
|
-
_response, data: decoded, errors: _errors
|
317
|
-
)
|
318
|
-
end
|
319
|
-
|
320
|
-
# Modifies the details of an employee role.
|
321
|
-
# @param [String] role_id Required parameter: The ID of the role to
|
322
|
-
# modify.
|
323
|
-
# @param [V1EmployeeRole] body Required parameter: An object containing the
|
324
|
-
# fields to POST for the request. See the corresponding object definition
|
325
|
-
# for field details.
|
326
|
-
# @return [V1EmployeeRole Hash] response from the API call
|
327
|
-
def update_employee_role(role_id:,
|
328
|
-
body:)
|
329
|
-
# Prepare query url.
|
330
|
-
_query_builder = config.get_base_uri
|
331
|
-
_query_builder << '/v1/me/roles/{role_id}'
|
332
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
333
|
-
_query_builder,
|
334
|
-
'role_id' => { 'value' => role_id, 'encode' => true }
|
335
|
-
)
|
336
|
-
_query_url = APIHelper.clean_url _query_builder
|
337
|
-
|
338
|
-
# Prepare headers.
|
339
|
-
_headers = {
|
340
|
-
'accept' => 'application/json',
|
341
|
-
'content-type' => 'application/json; charset=utf-8'
|
342
|
-
}
|
343
|
-
|
344
|
-
# Prepare and execute HttpRequest.
|
345
|
-
_request = config.http_client.put(
|
346
|
-
_query_url,
|
347
|
-
headers: _headers,
|
348
|
-
parameters: body.to_json
|
349
|
-
)
|
350
|
-
OAuth2.apply(config, _request)
|
351
|
-
_response = execute_request(_request)
|
352
|
-
|
353
|
-
# Return appropriate response type.
|
354
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
355
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
356
|
-
ApiResponse.new(
|
357
|
-
_response, data: decoded, errors: _errors
|
358
|
-
)
|
359
|
-
end
|
360
|
-
|
361
|
-
# Provides summary information for all of a business's employee timecards.
|
362
|
-
# @param [SortOrder] order Optional parameter: The order in which timecards
|
363
|
-
# are listed in the response, based on their created_at field.
|
364
|
-
# @param [String] employee_id Optional parameter: If provided, the endpoint
|
365
|
-
# returns only timecards for the employee with the specified ID.
|
366
|
-
# @param [String] begin_clockin_time Optional parameter: If filtering
|
367
|
-
# results by their clockin_time field, the beginning of the requested
|
368
|
-
# reporting period, in ISO 8601 format.
|
369
|
-
# @param [String] end_clockin_time Optional parameter: If filtering results
|
370
|
-
# by their clockin_time field, the end of the requested reporting period, in
|
371
|
-
# ISO 8601 format.
|
372
|
-
# @param [String] begin_clockout_time Optional parameter: If filtering
|
373
|
-
# results by their clockout_time field, the beginning of the requested
|
374
|
-
# reporting period, in ISO 8601 format.
|
375
|
-
# @param [String] end_clockout_time Optional parameter: If filtering results
|
376
|
-
# by their clockout_time field, the end of the requested reporting period,
|
377
|
-
# in ISO 8601 format.
|
378
|
-
# @param [String] begin_updated_at Optional parameter: If filtering results
|
379
|
-
# by their updated_at field, the beginning of the requested reporting
|
380
|
-
# period, in ISO 8601 format.
|
381
|
-
# @param [String] end_updated_at Optional parameter: If filtering results by
|
382
|
-
# their updated_at field, the end of the requested reporting period, in ISO
|
383
|
-
# 8601 format.
|
384
|
-
# @param [Boolean] deleted Optional parameter: If true, only deleted
|
385
|
-
# timecards are returned. If false, only valid timecards are returned.If you
|
386
|
-
# don't provide this parameter, both valid and deleted timecards are
|
387
|
-
# returned.
|
388
|
-
# @param [Integer] limit Optional parameter: The maximum integer number of
|
389
|
-
# employee entities to return in a single response. Default 100, maximum
|
390
|
-
# 200.
|
391
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
392
|
-
# retrieve the next set of results for your original query to the
|
393
|
-
# endpoint.
|
394
|
-
# @return [List of V1Timecard Hash] response from the API call
|
395
|
-
def list_timecards(order: nil,
|
396
|
-
employee_id: nil,
|
397
|
-
begin_clockin_time: nil,
|
398
|
-
end_clockin_time: nil,
|
399
|
-
begin_clockout_time: nil,
|
400
|
-
end_clockout_time: nil,
|
401
|
-
begin_updated_at: nil,
|
402
|
-
end_updated_at: nil,
|
403
|
-
deleted: false,
|
404
|
-
limit: nil,
|
405
|
-
batch_token: nil)
|
406
|
-
warn 'Endpoint list_timecards in V1EmployeesApi is deprecated'
|
407
|
-
# Prepare query url.
|
408
|
-
_query_builder = config.get_base_uri
|
409
|
-
_query_builder << '/v1/me/timecards'
|
410
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
411
|
-
_query_builder,
|
412
|
-
'order' => order,
|
413
|
-
'employee_id' => employee_id,
|
414
|
-
'begin_clockin_time' => begin_clockin_time,
|
415
|
-
'end_clockin_time' => end_clockin_time,
|
416
|
-
'begin_clockout_time' => begin_clockout_time,
|
417
|
-
'end_clockout_time' => end_clockout_time,
|
418
|
-
'begin_updated_at' => begin_updated_at,
|
419
|
-
'end_updated_at' => end_updated_at,
|
420
|
-
'deleted' => deleted,
|
421
|
-
'limit' => limit,
|
422
|
-
'batch_token' => batch_token
|
423
|
-
)
|
424
|
-
_query_url = APIHelper.clean_url _query_builder
|
425
|
-
|
426
|
-
# Prepare headers.
|
427
|
-
_headers = {
|
428
|
-
'accept' => 'application/json'
|
429
|
-
}
|
430
|
-
|
431
|
-
# Prepare and execute HttpRequest.
|
432
|
-
_request = config.http_client.get(
|
433
|
-
_query_url,
|
434
|
-
headers: _headers
|
435
|
-
)
|
436
|
-
OAuth2.apply(config, _request)
|
437
|
-
_response = execute_request(_request)
|
438
|
-
|
439
|
-
# Return appropriate response type.
|
440
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
441
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
442
|
-
ApiResponse.new(
|
443
|
-
_response, data: decoded, errors: _errors
|
444
|
-
)
|
445
|
-
end
|
446
|
-
|
447
|
-
# Creates a timecard for an employee and clocks them in with an
|
448
|
-
# `API_CREATE` event and a `clockin_time` set to the current time unless
|
449
|
-
# the request provides a different value.
|
450
|
-
# To import timecards from another
|
451
|
-
# system (rather than clocking someone in). Specify the `clockin_time`
|
452
|
-
# and* `clockout_time` in the request.
|
453
|
-
# Timecards correspond to exactly one shift for a given employee, bounded
|
454
|
-
# by the `clockin_time` and `clockout_time` fields. An employee is
|
455
|
-
# considered clocked in if they have a timecard that doesn't have a
|
456
|
-
# `clockout_time` set. An employee that is currently clocked in cannot
|
457
|
-
# be clocked in a second time.
|
458
|
-
# @param [V1Timecard] body Required parameter: An object containing the
|
459
|
-
# fields to POST for the request. See the corresponding object definition
|
460
|
-
# for field details.
|
461
|
-
# @return [V1Timecard Hash] response from the API call
|
462
|
-
def create_timecard(body:)
|
463
|
-
warn 'Endpoint create_timecard in V1EmployeesApi is deprecated'
|
464
|
-
# Prepare query url.
|
465
|
-
_query_builder = config.get_base_uri
|
466
|
-
_query_builder << '/v1/me/timecards'
|
467
|
-
_query_url = APIHelper.clean_url _query_builder
|
468
|
-
|
469
|
-
# Prepare headers.
|
470
|
-
_headers = {
|
471
|
-
'accept' => 'application/json',
|
472
|
-
'content-type' => 'application/json; charset=utf-8'
|
473
|
-
}
|
474
|
-
|
475
|
-
# Prepare and execute HttpRequest.
|
476
|
-
_request = config.http_client.post(
|
477
|
-
_query_url,
|
478
|
-
headers: _headers,
|
479
|
-
parameters: body.to_json
|
480
|
-
)
|
481
|
-
OAuth2.apply(config, _request)
|
482
|
-
_response = execute_request(_request)
|
483
|
-
|
484
|
-
# Return appropriate response type.
|
485
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
486
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
487
|
-
ApiResponse.new(
|
488
|
-
_response, data: decoded, errors: _errors
|
489
|
-
)
|
490
|
-
end
|
491
|
-
|
492
|
-
# Deletes a timecard. Timecards can also be deleted through the
|
493
|
-
# Square Dashboard. Deleted timecards are still accessible through
|
494
|
-
# Connect API endpoints, but cannot be modified. The `deleted` field of
|
495
|
-
# the `Timecard` object indicates whether the timecard has been deleted.
|
496
|
-
# __Note__: By default, deleted timecards appear alongside valid timecards
|
497
|
-
# in
|
498
|
-
# results returned by the
|
499
|
-
# [ListTimecards](#endpoint-v1employees-listtimecards)
|
500
|
-
# endpoint. To filter deleted timecards, include the `deleted` query
|
501
|
-
# parameter in the list request.
|
502
|
-
# Only approved accounts can manage their employees with Square.
|
503
|
-
# Unapproved accounts cannot use employee management features with the
|
504
|
-
# API.
|
505
|
-
# @param [String] timecard_id Required parameter: The ID of the timecard to
|
506
|
-
# delete.
|
507
|
-
# @return [Object] response from the API call
|
508
|
-
def delete_timecard(timecard_id:)
|
509
|
-
warn 'Endpoint delete_timecard in V1EmployeesApi is deprecated'
|
510
|
-
# Prepare query url.
|
511
|
-
_query_builder = config.get_base_uri
|
512
|
-
_query_builder << '/v1/me/timecards/{timecard_id}'
|
513
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
514
|
-
_query_builder,
|
515
|
-
'timecard_id' => { 'value' => timecard_id, 'encode' => true }
|
516
|
-
)
|
517
|
-
_query_url = APIHelper.clean_url _query_builder
|
518
|
-
|
519
|
-
# Prepare and execute HttpRequest.
|
520
|
-
_request = config.http_client.delete(
|
521
|
-
_query_url
|
522
|
-
)
|
523
|
-
OAuth2.apply(config, _request)
|
524
|
-
_response = execute_request(_request)
|
525
|
-
|
526
|
-
# Return appropriate response type.
|
527
|
-
ApiResponse.new(
|
528
|
-
_response, data: _response.raw_body
|
529
|
-
)
|
530
|
-
end
|
531
|
-
|
532
|
-
# Provides the details for a single timecard.
|
533
|
-
# Only approved accounts can manage their employees with Square.
|
534
|
-
# Unapproved accounts cannot use employee management features with the
|
535
|
-
# API.
|
536
|
-
# @param [String] timecard_id Required parameter: The timecard's ID.
|
537
|
-
# @return [V1Timecard Hash] response from the API call
|
538
|
-
def retrieve_timecard(timecard_id:)
|
539
|
-
warn 'Endpoint retrieve_timecard in V1EmployeesApi is deprecated'
|
540
|
-
# Prepare query url.
|
541
|
-
_query_builder = config.get_base_uri
|
542
|
-
_query_builder << '/v1/me/timecards/{timecard_id}'
|
543
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
544
|
-
_query_builder,
|
545
|
-
'timecard_id' => { 'value' => timecard_id, 'encode' => true }
|
546
|
-
)
|
547
|
-
_query_url = APIHelper.clean_url _query_builder
|
548
|
-
|
549
|
-
# Prepare headers.
|
550
|
-
_headers = {
|
551
|
-
'accept' => 'application/json'
|
552
|
-
}
|
553
|
-
|
554
|
-
# Prepare and execute HttpRequest.
|
555
|
-
_request = config.http_client.get(
|
556
|
-
_query_url,
|
557
|
-
headers: _headers
|
558
|
-
)
|
559
|
-
OAuth2.apply(config, _request)
|
560
|
-
_response = execute_request(_request)
|
561
|
-
|
562
|
-
# Return appropriate response type.
|
563
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
564
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
565
|
-
ApiResponse.new(
|
566
|
-
_response, data: decoded, errors: _errors
|
567
|
-
)
|
568
|
-
end
|
569
|
-
|
570
|
-
# Modifies the details of a timecard with an `API_EDIT` event for
|
571
|
-
# the timecard. Updating an active timecard with a `clockout_time`
|
572
|
-
# clocks the employee out.
|
573
|
-
# @param [String] timecard_id Required parameter: TThe ID of the timecard to
|
574
|
-
# modify.
|
575
|
-
# @param [V1Timecard] body Required parameter: An object containing the
|
576
|
-
# fields to POST for the request. See the corresponding object definition
|
577
|
-
# for field details.
|
578
|
-
# @return [V1Timecard Hash] response from the API call
|
579
|
-
def update_timecard(timecard_id:,
|
580
|
-
body:)
|
581
|
-
warn 'Endpoint update_timecard in V1EmployeesApi is deprecated'
|
582
|
-
# Prepare query url.
|
583
|
-
_query_builder = config.get_base_uri
|
584
|
-
_query_builder << '/v1/me/timecards/{timecard_id}'
|
585
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
586
|
-
_query_builder,
|
587
|
-
'timecard_id' => { 'value' => timecard_id, 'encode' => true }
|
588
|
-
)
|
589
|
-
_query_url = APIHelper.clean_url _query_builder
|
590
|
-
|
591
|
-
# Prepare headers.
|
592
|
-
_headers = {
|
593
|
-
'accept' => 'application/json',
|
594
|
-
'content-type' => 'application/json; charset=utf-8'
|
595
|
-
}
|
596
|
-
|
597
|
-
# Prepare and execute HttpRequest.
|
598
|
-
_request = config.http_client.put(
|
599
|
-
_query_url,
|
600
|
-
headers: _headers,
|
601
|
-
parameters: body.to_json
|
602
|
-
)
|
603
|
-
OAuth2.apply(config, _request)
|
604
|
-
_response = execute_request(_request)
|
605
|
-
|
606
|
-
# Return appropriate response type.
|
607
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
608
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
609
|
-
ApiResponse.new(
|
610
|
-
_response, data: decoded, errors: _errors
|
611
|
-
)
|
612
|
-
end
|
613
|
-
|
614
|
-
# Provides summary information for all events associated with a
|
615
|
-
# particular timecard.
|
616
|
-
# Only approved accounts can manage their employees with Square.
|
617
|
-
# Unapproved accounts cannot use employee management features with the
|
618
|
-
# API.
|
619
|
-
# @param [String] timecard_id Required parameter: The ID of the timecard to
|
620
|
-
# list events for.
|
621
|
-
# @return [List of V1TimecardEvent Hash] response from the API call
|
622
|
-
def list_timecard_events(timecard_id:)
|
623
|
-
warn 'Endpoint list_timecard_events in V1EmployeesApi is deprecated'
|
624
|
-
# Prepare query url.
|
625
|
-
_query_builder = config.get_base_uri
|
626
|
-
_query_builder << '/v1/me/timecards/{timecard_id}/events'
|
627
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
628
|
-
_query_builder,
|
629
|
-
'timecard_id' => { 'value' => timecard_id, 'encode' => true }
|
630
|
-
)
|
631
|
-
_query_url = APIHelper.clean_url _query_builder
|
632
|
-
|
633
|
-
# Prepare headers.
|
634
|
-
_headers = {
|
635
|
-
'accept' => 'application/json'
|
636
|
-
}
|
637
|
-
|
638
|
-
# Prepare and execute HttpRequest.
|
639
|
-
_request = config.http_client.get(
|
640
|
-
_query_url,
|
641
|
-
headers: _headers
|
642
|
-
)
|
643
|
-
OAuth2.apply(config, _request)
|
644
|
-
_response = execute_request(_request)
|
645
|
-
|
646
|
-
# Return appropriate response type.
|
647
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
648
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
649
|
-
ApiResponse.new(
|
650
|
-
_response, data: decoded, errors: _errors
|
651
|
-
)
|
652
|
-
end
|
653
|
-
|
654
|
-
# Provides the details for all of a location's cash drawer shifts during a
|
655
|
-
# date range. The date range you specify cannot exceed 90 days.
|
656
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
657
|
-
# list cash drawer shifts for.
|
658
|
-
# @param [SortOrder] order Optional parameter: The order in which cash
|
659
|
-
# drawer shifts are listed in the response, based on their created_at field.
|
660
|
-
# Default value: ASC
|
661
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
662
|
-
# requested reporting period, in ISO 8601 format. Default value: The current
|
663
|
-
# time minus 90 days.
|
664
|
-
# @param [String] end_time Optional parameter: The beginning of the
|
665
|
-
# requested reporting period, in ISO 8601 format. Default value: The current
|
666
|
-
# time.
|
667
|
-
# @return [List of V1CashDrawerShift Hash] response from the API call
|
668
|
-
def list_cash_drawer_shifts(location_id:,
|
669
|
-
order: nil,
|
670
|
-
begin_time: nil,
|
671
|
-
end_time: nil)
|
672
|
-
warn 'Endpoint list_cash_drawer_shifts in V1EmployeesApi is deprecated'
|
673
|
-
# Prepare query url.
|
674
|
-
_query_builder = config.get_base_uri
|
675
|
-
_query_builder << '/v1/{location_id}/cash-drawer-shifts'
|
676
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
677
|
-
_query_builder,
|
678
|
-
'location_id' => { 'value' => location_id, 'encode' => true }
|
679
|
-
)
|
680
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
681
|
-
_query_builder,
|
682
|
-
'order' => order,
|
683
|
-
'begin_time' => begin_time,
|
684
|
-
'end_time' => end_time
|
685
|
-
)
|
686
|
-
_query_url = APIHelper.clean_url _query_builder
|
687
|
-
|
688
|
-
# Prepare headers.
|
689
|
-
_headers = {
|
690
|
-
'accept' => 'application/json'
|
691
|
-
}
|
692
|
-
|
693
|
-
# Prepare and execute HttpRequest.
|
694
|
-
_request = config.http_client.get(
|
695
|
-
_query_url,
|
696
|
-
headers: _headers
|
697
|
-
)
|
698
|
-
OAuth2.apply(config, _request)
|
699
|
-
_response = execute_request(_request)
|
700
|
-
|
701
|
-
# Return appropriate response type.
|
702
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
703
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
704
|
-
ApiResponse.new(
|
705
|
-
_response, data: decoded, errors: _errors
|
706
|
-
)
|
707
|
-
end
|
708
|
-
|
709
|
-
# Provides the details for a single cash drawer shift, including all events
|
710
|
-
# that occurred during the shift.
|
711
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
712
|
-
# list cash drawer shifts for.
|
713
|
-
# @param [String] shift_id Required parameter: The shift's ID.
|
714
|
-
# @return [V1CashDrawerShift Hash] response from the API call
|
715
|
-
def retrieve_cash_drawer_shift(location_id:,
|
716
|
-
shift_id:)
|
717
|
-
warn 'Endpoint retrieve_cash_drawer_shift in V1EmployeesApi is deprecated'
|
718
|
-
# Prepare query url.
|
719
|
-
_query_builder = config.get_base_uri
|
720
|
-
_query_builder << '/v1/{location_id}/cash-drawer-shifts/{shift_id}'
|
721
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
722
|
-
_query_builder,
|
723
|
-
'location_id' => { 'value' => location_id, 'encode' => true },
|
724
|
-
'shift_id' => { 'value' => shift_id, 'encode' => true }
|
725
|
-
)
|
726
|
-
_query_url = APIHelper.clean_url _query_builder
|
727
|
-
|
728
|
-
# Prepare headers.
|
729
|
-
_headers = {
|
730
|
-
'accept' => 'application/json'
|
731
|
-
}
|
732
|
-
|
733
|
-
# Prepare and execute HttpRequest.
|
734
|
-
_request = config.http_client.get(
|
735
|
-
_query_url,
|
736
|
-
headers: _headers
|
737
|
-
)
|
738
|
-
OAuth2.apply(config, _request)
|
739
|
-
_response = execute_request(_request)
|
740
|
-
|
741
|
-
# Return appropriate response type.
|
742
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
743
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
744
|
-
ApiResponse.new(
|
745
|
-
_response, data: decoded, errors: _errors
|
746
|
-
)
|
747
|
-
end
|
748
|
-
end
|
749
|
-
end
|