square.rb 26.0.0.20221214 → 26.2.0.20230315
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +419 -0
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +82 -46
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +7 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +12 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
data/lib/square/api/team_api.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# TeamApi
|
3
3
|
class TeamApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Creates a single `TeamMember` object. The `TeamMember` object is returned
|
9
5
|
# on successful creates.
|
10
6
|
# You must provide the following values in your request to this endpoint:
|
@@ -18,32 +14,20 @@ module Square
|
|
18
14
|
# object definition for field details.
|
19
15
|
# @return [CreateTeamMemberResponse Hash] response from the API call
|
20
16
|
def create_team_member(body:)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
headers: _headers,
|
36
|
-
parameters: body.to_json
|
37
|
-
)
|
38
|
-
OAuth2.apply(config, _request)
|
39
|
-
_response = execute_request(_request)
|
40
|
-
|
41
|
-
# Return appropriate response type.
|
42
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
43
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
44
|
-
ApiResponse.new(
|
45
|
-
_response, data: decoded, errors: _errors
|
46
|
-
)
|
17
|
+
new_api_call_builder
|
18
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
19
|
+
'/v2/team-members',
|
20
|
+
'default')
|
21
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
22
|
+
.body_param(new_parameter(body))
|
23
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
24
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
25
|
+
.auth(Single.new('global')))
|
26
|
+
.response(new_response_handler
|
27
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
28
|
+
.is_api_response(true)
|
29
|
+
.convertor(ApiResponse.method(:create)))
|
30
|
+
.execute
|
47
31
|
end
|
48
32
|
|
49
33
|
# Creates multiple `TeamMember` objects. The created `TeamMember` objects
|
@@ -61,32 +45,20 @@ module Square
|
|
61
45
|
# object definition for field details.
|
62
46
|
# @return [BulkCreateTeamMembersResponse Hash] response from the API call
|
63
47
|
def bulk_create_team_members(body:)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
headers: _headers,
|
79
|
-
parameters: body.to_json
|
80
|
-
)
|
81
|
-
OAuth2.apply(config, _request)
|
82
|
-
_response = execute_request(_request)
|
83
|
-
|
84
|
-
# Return appropriate response type.
|
85
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
86
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
87
|
-
ApiResponse.new(
|
88
|
-
_response, data: decoded, errors: _errors
|
89
|
-
)
|
48
|
+
new_api_call_builder
|
49
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
50
|
+
'/v2/team-members/bulk-create',
|
51
|
+
'default')
|
52
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
53
|
+
.body_param(new_parameter(body))
|
54
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
55
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
56
|
+
.auth(Single.new('global')))
|
57
|
+
.response(new_response_handler
|
58
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
59
|
+
.is_api_response(true)
|
60
|
+
.convertor(ApiResponse.method(:create)))
|
61
|
+
.execute
|
90
62
|
end
|
91
63
|
|
92
64
|
# Updates multiple `TeamMember` objects. The updated `TeamMember` objects
|
@@ -104,32 +76,20 @@ module Square
|
|
104
76
|
# object definition for field details.
|
105
77
|
# @return [BulkUpdateTeamMembersResponse Hash] response from the API call
|
106
78
|
def bulk_update_team_members(body:)
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
headers: _headers,
|
122
|
-
parameters: body.to_json
|
123
|
-
)
|
124
|
-
OAuth2.apply(config, _request)
|
125
|
-
_response = execute_request(_request)
|
126
|
-
|
127
|
-
# Return appropriate response type.
|
128
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
129
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
130
|
-
ApiResponse.new(
|
131
|
-
_response, data: decoded, errors: _errors
|
132
|
-
)
|
79
|
+
new_api_call_builder
|
80
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
81
|
+
'/v2/team-members/bulk-update',
|
82
|
+
'default')
|
83
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
84
|
+
.body_param(new_parameter(body))
|
85
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
86
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
87
|
+
.auth(Single.new('global')))
|
88
|
+
.response(new_response_handler
|
89
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
90
|
+
.is_api_response(true)
|
91
|
+
.convertor(ApiResponse.method(:create)))
|
92
|
+
.execute
|
133
93
|
end
|
134
94
|
|
135
95
|
# Returns a paginated list of `TeamMember` objects for a business.
|
@@ -141,32 +101,20 @@ module Square
|
|
141
101
|
# object definition for field details.
|
142
102
|
# @return [SearchTeamMembersResponse Hash] response from the API call
|
143
103
|
def search_team_members(body:)
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
headers: _headers,
|
159
|
-
parameters: body.to_json
|
160
|
-
)
|
161
|
-
OAuth2.apply(config, _request)
|
162
|
-
_response = execute_request(_request)
|
163
|
-
|
164
|
-
# Return appropriate response type.
|
165
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
166
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
167
|
-
ApiResponse.new(
|
168
|
-
_response, data: decoded, errors: _errors
|
169
|
-
)
|
104
|
+
new_api_call_builder
|
105
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
106
|
+
'/v2/team-members/search',
|
107
|
+
'default')
|
108
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
109
|
+
.body_param(new_parameter(body))
|
110
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
111
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
112
|
+
.auth(Single.new('global')))
|
113
|
+
.response(new_response_handler
|
114
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
115
|
+
.is_api_response(true)
|
116
|
+
.convertor(ApiResponse.method(:create)))
|
117
|
+
.execute
|
170
118
|
end
|
171
119
|
|
172
120
|
# Retrieves a `TeamMember` object for the given `TeamMember.id`.
|
@@ -177,34 +125,19 @@ module Square
|
|
177
125
|
# member to retrieve.
|
178
126
|
# @return [RetrieveTeamMemberResponse Hash] response from the API call
|
179
127
|
def retrieve_team_member(team_member_id:)
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
# Prepare and execute HttpRequest.
|
195
|
-
_request = config.http_client.get(
|
196
|
-
_query_url,
|
197
|
-
headers: _headers
|
198
|
-
)
|
199
|
-
OAuth2.apply(config, _request)
|
200
|
-
_response = execute_request(_request)
|
201
|
-
|
202
|
-
# Return appropriate response type.
|
203
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
204
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
205
|
-
ApiResponse.new(
|
206
|
-
_response, data: decoded, errors: _errors
|
207
|
-
)
|
128
|
+
new_api_call_builder
|
129
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
130
|
+
'/v2/team-members/{team_member_id}',
|
131
|
+
'default')
|
132
|
+
.template_param(new_parameter(team_member_id, key: 'team_member_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
|
208
141
|
end
|
209
142
|
|
210
143
|
# Updates a single `TeamMember` object. The `TeamMember` object is returned
|
@@ -220,36 +153,22 @@ module Square
|
|
220
153
|
# @return [UpdateTeamMemberResponse Hash] response from the API call
|
221
154
|
def update_team_member(team_member_id:,
|
222
155
|
body:)
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
_request = config.http_client.put(
|
240
|
-
_query_url,
|
241
|
-
headers: _headers,
|
242
|
-
parameters: body.to_json
|
243
|
-
)
|
244
|
-
OAuth2.apply(config, _request)
|
245
|
-
_response = execute_request(_request)
|
246
|
-
|
247
|
-
# Return appropriate response type.
|
248
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
249
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
250
|
-
ApiResponse.new(
|
251
|
-
_response, data: decoded, errors: _errors
|
252
|
-
)
|
156
|
+
new_api_call_builder
|
157
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
158
|
+
'/v2/team-members/{team_member_id}',
|
159
|
+
'default')
|
160
|
+
.template_param(new_parameter(team_member_id, key: 'team_member_id')
|
161
|
+
.should_encode(true))
|
162
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
163
|
+
.body_param(new_parameter(body))
|
164
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
165
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
166
|
+
.auth(Single.new('global')))
|
167
|
+
.response(new_response_handler
|
168
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
169
|
+
.is_api_response(true)
|
170
|
+
.convertor(ApiResponse.method(:create)))
|
171
|
+
.execute
|
253
172
|
end
|
254
173
|
|
255
174
|
# Retrieves a `WageSetting` object for a team member specified
|
@@ -261,34 +180,19 @@ module Square
|
|
261
180
|
# member for which to retrieve the wage setting.
|
262
181
|
# @return [RetrieveWageSettingResponse Hash] response from the API call
|
263
182
|
def retrieve_wage_setting(team_member_id:)
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
# Prepare and execute HttpRequest.
|
279
|
-
_request = config.http_client.get(
|
280
|
-
_query_url,
|
281
|
-
headers: _headers
|
282
|
-
)
|
283
|
-
OAuth2.apply(config, _request)
|
284
|
-
_response = execute_request(_request)
|
285
|
-
|
286
|
-
# Return appropriate response type.
|
287
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
288
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
289
|
-
ApiResponse.new(
|
290
|
-
_response, data: decoded, errors: _errors
|
291
|
-
)
|
183
|
+
new_api_call_builder
|
184
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
185
|
+
'/v2/team-members/{team_member_id}/wage-setting',
|
186
|
+
'default')
|
187
|
+
.template_param(new_parameter(team_member_id, key: 'team_member_id')
|
188
|
+
.should_encode(true))
|
189
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
190
|
+
.auth(Single.new('global')))
|
191
|
+
.response(new_response_handler
|
192
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
193
|
+
.is_api_response(true)
|
194
|
+
.convertor(ApiResponse.method(:create)))
|
195
|
+
.execute
|
292
196
|
end
|
293
197
|
|
294
198
|
# Creates or updates a `WageSetting` object. The object is created if a
|
@@ -307,36 +211,22 @@ module Square
|
|
307
211
|
# @return [UpdateWageSettingResponse Hash] response from the API call
|
308
212
|
def update_wage_setting(team_member_id:,
|
309
213
|
body:)
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
_request = config.http_client.put(
|
327
|
-
_query_url,
|
328
|
-
headers: _headers,
|
329
|
-
parameters: body.to_json
|
330
|
-
)
|
331
|
-
OAuth2.apply(config, _request)
|
332
|
-
_response = execute_request(_request)
|
333
|
-
|
334
|
-
# Return appropriate response type.
|
335
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
336
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
337
|
-
ApiResponse.new(
|
338
|
-
_response, data: decoded, errors: _errors
|
339
|
-
)
|
214
|
+
new_api_call_builder
|
215
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
216
|
+
'/v2/team-members/{team_member_id}/wage-setting',
|
217
|
+
'default')
|
218
|
+
.template_param(new_parameter(team_member_id, key: 'team_member_id')
|
219
|
+
.should_encode(true))
|
220
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
221
|
+
.body_param(new_parameter(body))
|
222
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
223
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
224
|
+
.auth(Single.new('global')))
|
225
|
+
.response(new_response_handler
|
226
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
227
|
+
.is_api_response(true)
|
228
|
+
.convertor(ApiResponse.method(:create)))
|
229
|
+
.execute
|
340
230
|
end
|
341
231
|
end
|
342
232
|
end
|