square.rb 5.0.0.20200226 → 5.3.0.20200528
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/lib/square.rb +5 -0
- data/lib/square/api/base_api.rb +2 -2
- data/lib/square/api/customer_groups_api.rb +182 -0
- data/lib/square/api/customer_segments_api.rb +78 -0
- data/lib/square/api/customers_api.rb +94 -3
- data/lib/square/api/devices_api.rb +120 -0
- data/lib/square/api/loyalty_api.rb +543 -0
- data/lib/square/api/orders_api.rb +32 -0
- data/lib/square/api/payments_api.rb +10 -4
- data/lib/square/api/terminal_api.rb +141 -0
- data/lib/square/client.rb +32 -2
- data/lib/square/configuration.rb +4 -4
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4df584cf8656280c84a929e33d017ae45261bb30afdfed941a8e7c775995ea45
|
4
|
+
data.tar.gz: c87a6cbd1d57921bc3b3251135ebdc40d02dd007d16a59bab366e6f10123b8eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5acce30bed99da12a50425ee308932eeab669e3791a5f849224f49a2ffa3dc91bcdbff296a011f21d2c03d31104a6bfbf5d5f11da93658c44d270db9e21b85a
|
7
|
+
data.tar.gz: 063afe2bce7b09d25bfe6941c63de99d03ededbea209f67cba6e89096f573650c099e76486d69a39466c639a58b20afccbc330a3ef5231eeeeafa9892bcdcb03
|
data/LICENSE
CHANGED
data/lib/square.rb
CHANGED
@@ -40,6 +40,9 @@ require_relative 'square/api/bank_accounts_api.rb'
|
|
40
40
|
require_relative 'square/api/cash_drawers_api.rb'
|
41
41
|
require_relative 'square/api/catalog_api.rb'
|
42
42
|
require_relative 'square/api/customers_api.rb'
|
43
|
+
require_relative 'square/api/customer_groups_api.rb'
|
44
|
+
require_relative 'square/api/customer_segments_api.rb'
|
45
|
+
require_relative 'square/api/devices_api.rb'
|
43
46
|
require_relative 'square/api/disputes_api.rb'
|
44
47
|
require_relative 'square/api/employees_api.rb'
|
45
48
|
require_relative 'square/api/inventory_api.rb'
|
@@ -49,6 +52,8 @@ require_relative 'square/api/reporting_api.rb'
|
|
49
52
|
require_relative 'square/api/checkout_api.rb'
|
50
53
|
require_relative 'square/api/orders_api.rb'
|
51
54
|
require_relative 'square/api/transactions_api.rb'
|
55
|
+
require_relative 'square/api/loyalty_api.rb'
|
52
56
|
require_relative 'square/api/merchants_api.rb'
|
53
57
|
require_relative 'square/api/payments_api.rb'
|
54
58
|
require_relative 'square/api/refunds_api.rb'
|
59
|
+
require_relative 'square/api/terminal_api.rb'
|
data/lib/square/api/base_api.rb
CHANGED
@@ -8,8 +8,8 @@ module Square
|
|
8
8
|
@http_call_back = http_call_back
|
9
9
|
|
10
10
|
@global_headers = {
|
11
|
-
'user-agent' => 'Square-Ruby-SDK/5.
|
12
|
-
'Square-Version' => '2020-
|
11
|
+
'user-agent' => 'Square-Ruby-SDK/5.3.0.20200528',
|
12
|
+
'Square-Version' => '2020-05-28'
|
13
13
|
}
|
14
14
|
end
|
15
15
|
|
@@ -0,0 +1,182 @@
|
|
1
|
+
module Square
|
2
|
+
# CustomerGroupsApi
|
3
|
+
class CustomerGroupsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Retrieves the list of customer groups of a business.
|
9
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
11
|
+
# results for your original query. See the [Pagination
|
12
|
+
# guide](https://developer.squareup.com/docs/working-with-apis/pagination)
|
13
|
+
# for more information.
|
14
|
+
# @return [ListCustomerGroupsResponse Hash] response from the API call
|
15
|
+
def list_customer_groups(cursor: nil)
|
16
|
+
# Prepare query url.
|
17
|
+
_query_builder = config.get_base_uri
|
18
|
+
_query_builder << '/v2/customers/groups'
|
19
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
|
+
_query_builder,
|
21
|
+
'cursor' => cursor
|
22
|
+
)
|
23
|
+
_query_url = APIHelper.clean_url _query_builder
|
24
|
+
|
25
|
+
# Prepare headers.
|
26
|
+
_headers = {
|
27
|
+
'accept' => 'application/json'
|
28
|
+
}
|
29
|
+
|
30
|
+
# Prepare and execute HttpRequest.
|
31
|
+
_request = config.http_client.get(
|
32
|
+
_query_url,
|
33
|
+
headers: _headers
|
34
|
+
)
|
35
|
+
OAuth2.apply(config, _request)
|
36
|
+
_response = execute_request(_request)
|
37
|
+
|
38
|
+
# Return appropriate response type.
|
39
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
40
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
41
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Creates a new customer group for a business.
|
45
|
+
# The request must include the `name` value of the group.
|
46
|
+
# @param [CreateCustomerGroupRequest] body Required parameter: An object
|
47
|
+
# containing the fields to POST for the request. See the corresponding
|
48
|
+
# object definition for field details.
|
49
|
+
# @return [CreateCustomerGroupResponse Hash] response from the API call
|
50
|
+
def create_customer_group(body:)
|
51
|
+
# Prepare query url.
|
52
|
+
_query_builder = config.get_base_uri
|
53
|
+
_query_builder << '/v2/customers/groups'
|
54
|
+
_query_url = APIHelper.clean_url _query_builder
|
55
|
+
|
56
|
+
# Prepare headers.
|
57
|
+
_headers = {
|
58
|
+
'accept' => 'application/json',
|
59
|
+
'content-type' => 'application/json; charset=utf-8'
|
60
|
+
}
|
61
|
+
|
62
|
+
# Prepare and execute HttpRequest.
|
63
|
+
_request = config.http_client.post(
|
64
|
+
_query_url,
|
65
|
+
headers: _headers,
|
66
|
+
parameters: body.to_json
|
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(_response, data: decoded, errors: _errors)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Deletes a customer group as identified by the `group_id` value.
|
78
|
+
# @param [String] group_id Required parameter: The ID of the customer group
|
79
|
+
# to delete.
|
80
|
+
# @return [DeleteCustomerGroupResponse Hash] response from the API call
|
81
|
+
def delete_customer_group(group_id:)
|
82
|
+
# Prepare query url.
|
83
|
+
_query_builder = config.get_base_uri
|
84
|
+
_query_builder << '/v2/customers/groups/{group_id}'
|
85
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
86
|
+
_query_builder,
|
87
|
+
'group_id' => group_id
|
88
|
+
)
|
89
|
+
_query_url = APIHelper.clean_url _query_builder
|
90
|
+
|
91
|
+
# Prepare headers.
|
92
|
+
_headers = {
|
93
|
+
'accept' => 'application/json'
|
94
|
+
}
|
95
|
+
|
96
|
+
# Prepare and execute HttpRequest.
|
97
|
+
_request = config.http_client.delete(
|
98
|
+
_query_url,
|
99
|
+
headers: _headers
|
100
|
+
)
|
101
|
+
OAuth2.apply(config, _request)
|
102
|
+
_response = execute_request(_request)
|
103
|
+
|
104
|
+
# Return appropriate response type.
|
105
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
106
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
107
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Retrieves a specific customer group as identified by the `group_id` value.
|
111
|
+
# @param [String] group_id Required parameter: The ID of the customer group
|
112
|
+
# to retrieve.
|
113
|
+
# @return [RetrieveCustomerGroupResponse Hash] response from the API call
|
114
|
+
def retrieve_customer_group(group_id:)
|
115
|
+
# Prepare query url.
|
116
|
+
_query_builder = config.get_base_uri
|
117
|
+
_query_builder << '/v2/customers/groups/{group_id}'
|
118
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
119
|
+
_query_builder,
|
120
|
+
'group_id' => group_id
|
121
|
+
)
|
122
|
+
_query_url = APIHelper.clean_url _query_builder
|
123
|
+
|
124
|
+
# Prepare headers.
|
125
|
+
_headers = {
|
126
|
+
'accept' => 'application/json'
|
127
|
+
}
|
128
|
+
|
129
|
+
# Prepare and execute HttpRequest.
|
130
|
+
_request = config.http_client.get(
|
131
|
+
_query_url,
|
132
|
+
headers: _headers
|
133
|
+
)
|
134
|
+
OAuth2.apply(config, _request)
|
135
|
+
_response = execute_request(_request)
|
136
|
+
|
137
|
+
# Return appropriate response type.
|
138
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
139
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
140
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
141
|
+
end
|
142
|
+
|
143
|
+
# Updates a customer group as identified by the `group_id` value.
|
144
|
+
# @param [String] group_id Required parameter: The ID of the customer group
|
145
|
+
# to update.
|
146
|
+
# @param [UpdateCustomerGroupRequest] body Required parameter: An object
|
147
|
+
# containing the fields to POST for the request. See the corresponding
|
148
|
+
# object definition for field details.
|
149
|
+
# @return [UpdateCustomerGroupResponse Hash] response from the API call
|
150
|
+
def update_customer_group(group_id:,
|
151
|
+
body:)
|
152
|
+
# Prepare query url.
|
153
|
+
_query_builder = config.get_base_uri
|
154
|
+
_query_builder << '/v2/customers/groups/{group_id}'
|
155
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
156
|
+
_query_builder,
|
157
|
+
'group_id' => group_id
|
158
|
+
)
|
159
|
+
_query_url = APIHelper.clean_url _query_builder
|
160
|
+
|
161
|
+
# Prepare headers.
|
162
|
+
_headers = {
|
163
|
+
'accept' => 'application/json',
|
164
|
+
'content-type' => 'application/json; charset=utf-8'
|
165
|
+
}
|
166
|
+
|
167
|
+
# Prepare and execute HttpRequest.
|
168
|
+
_request = config.http_client.put(
|
169
|
+
_query_url,
|
170
|
+
headers: _headers,
|
171
|
+
parameters: body.to_json
|
172
|
+
)
|
173
|
+
OAuth2.apply(config, _request)
|
174
|
+
_response = execute_request(_request)
|
175
|
+
|
176
|
+
# Return appropriate response type.
|
177
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
178
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
179
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Square
|
2
|
+
# CustomerSegmentsApi
|
3
|
+
class CustomerSegmentsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Retrieves the list of customer segments of a business.
|
9
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
|
+
# previous calls to __ListCustomerSegments__. Used to retrieve the next set
|
11
|
+
# of query results. See the [Pagination
|
12
|
+
# guide](https://developer.squareup.com/docs/docs/working-with-apis/paginati
|
13
|
+
# on) for more information.
|
14
|
+
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
15
|
+
def list_customer_segments(cursor: nil)
|
16
|
+
# Prepare query url.
|
17
|
+
_query_builder = config.get_base_uri
|
18
|
+
_query_builder << '/v2/customers/segments'
|
19
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
20
|
+
_query_builder,
|
21
|
+
'cursor' => cursor
|
22
|
+
)
|
23
|
+
_query_url = APIHelper.clean_url _query_builder
|
24
|
+
|
25
|
+
# Prepare headers.
|
26
|
+
_headers = {
|
27
|
+
'accept' => 'application/json'
|
28
|
+
}
|
29
|
+
|
30
|
+
# Prepare and execute HttpRequest.
|
31
|
+
_request = config.http_client.get(
|
32
|
+
_query_url,
|
33
|
+
headers: _headers
|
34
|
+
)
|
35
|
+
OAuth2.apply(config, _request)
|
36
|
+
_response = execute_request(_request)
|
37
|
+
|
38
|
+
# Return appropriate response type.
|
39
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
40
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
41
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Retrieves a specific customer segment as identified by the `segment_id`
|
45
|
+
# value.
|
46
|
+
# @param [String] segment_id Required parameter: The Square-issued ID of the
|
47
|
+
# customer segment.
|
48
|
+
# @return [RetrieveCustomerSegmentResponse Hash] response from the API call
|
49
|
+
def retrieve_customer_segment(segment_id:)
|
50
|
+
# Prepare query url.
|
51
|
+
_query_builder = config.get_base_uri
|
52
|
+
_query_builder << '/v2/customers/segments/{segment_id}'
|
53
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
54
|
+
_query_builder,
|
55
|
+
'segment_id' => segment_id
|
56
|
+
)
|
57
|
+
_query_url = APIHelper.clean_url _query_builder
|
58
|
+
|
59
|
+
# Prepare headers.
|
60
|
+
_headers = {
|
61
|
+
'accept' => 'application/json'
|
62
|
+
}
|
63
|
+
|
64
|
+
# Prepare and execute HttpRequest.
|
65
|
+
_request = config.http_client.get(
|
66
|
+
_query_url,
|
67
|
+
headers: _headers
|
68
|
+
)
|
69
|
+
OAuth2.apply(config, _request)
|
70
|
+
_response = execute_request(_request)
|
71
|
+
|
72
|
+
# Return appropriate response type.
|
73
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
74
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
75
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -5,7 +5,13 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Lists a
|
8
|
+
# Lists customer profiles associated with a Square account.
|
9
|
+
# Under normal operating conditions, newly created or updated customer
|
10
|
+
# profiles become available
|
11
|
+
# for the listing operation in well under 30 seconds. Occasionally,
|
12
|
+
# propagation of the new or updated
|
13
|
+
# profiles can take closer to one minute or longer, espeically during
|
14
|
+
# network incidents and outages.
|
9
15
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
16
|
# a previous call to this endpoint. Provide this to retrieve the next set of
|
11
17
|
# results for your original query. See the [Pagination
|
@@ -91,10 +97,17 @@ module Square
|
|
91
97
|
ApiResponse.new(_response, data: decoded, errors: _errors)
|
92
98
|
end
|
93
99
|
|
94
|
-
# Searches the customer profiles associated with a Square account
|
95
|
-
#
|
100
|
+
# Searches the customer profiles associated with a Square account using
|
101
|
+
# one or more supported query filters.
|
102
|
+
# Calling `SearchCustomers` without any explicit query filter returns all
|
96
103
|
# customer profiles ordered alphabetically based on `given_name` and
|
97
104
|
# `family_name`.
|
105
|
+
# Under normal operating conditions, newly created or updated customer
|
106
|
+
# profiles become available
|
107
|
+
# for the search operation in well under 30 seconds. Occasionally,
|
108
|
+
# propagation of the new or updated
|
109
|
+
# profiles can take closer to one minute or longer, espeically during
|
110
|
+
# network incidents and outages.
|
98
111
|
# @param [SearchCustomersRequest] body Required parameter: An object
|
99
112
|
# containing the fields to POST for the request. See the corresponding
|
100
113
|
# object definition for field details.
|
@@ -323,5 +336,83 @@ module Square
|
|
323
336
|
_errors = APIHelper.map_response(decoded, ['errors'])
|
324
337
|
ApiResponse.new(_response, data: decoded, errors: _errors)
|
325
338
|
end
|
339
|
+
|
340
|
+
# Removes a group membership from a customer.
|
341
|
+
# The customer is identified by the `customer_id` value
|
342
|
+
# and the customer group is identified by the `group_id` value.
|
343
|
+
# @param [String] customer_id Required parameter: The ID of the customer to
|
344
|
+
# remove from the group.
|
345
|
+
# @param [String] group_id Required parameter: The ID of the customer group
|
346
|
+
# to remove the customer from.
|
347
|
+
# @return [RemoveGroupFromCustomerResponse Hash] response from the API call
|
348
|
+
def remove_group_from_customer(customer_id:,
|
349
|
+
group_id:)
|
350
|
+
# Prepare query url.
|
351
|
+
_query_builder = config.get_base_uri
|
352
|
+
_query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
|
353
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
354
|
+
_query_builder,
|
355
|
+
'customer_id' => customer_id,
|
356
|
+
'group_id' => group_id
|
357
|
+
)
|
358
|
+
_query_url = APIHelper.clean_url _query_builder
|
359
|
+
|
360
|
+
# Prepare headers.
|
361
|
+
_headers = {
|
362
|
+
'accept' => 'application/json'
|
363
|
+
}
|
364
|
+
|
365
|
+
# Prepare and execute HttpRequest.
|
366
|
+
_request = config.http_client.delete(
|
367
|
+
_query_url,
|
368
|
+
headers: _headers
|
369
|
+
)
|
370
|
+
OAuth2.apply(config, _request)
|
371
|
+
_response = execute_request(_request)
|
372
|
+
|
373
|
+
# Return appropriate response type.
|
374
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
375
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
376
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
377
|
+
end
|
378
|
+
|
379
|
+
# Adds a group membership to a customer.
|
380
|
+
# The customer is identified by the `customer_id` value
|
381
|
+
# and the customer group is identified by the `group_id` value.
|
382
|
+
# @param [String] customer_id Required parameter: The ID of the customer to
|
383
|
+
# add to a group.
|
384
|
+
# @param [String] group_id Required parameter: The ID of the customer group
|
385
|
+
# to add the customer to.
|
386
|
+
# @return [AddGroupToCustomerResponse Hash] response from the API call
|
387
|
+
def add_group_to_customer(customer_id:,
|
388
|
+
group_id:)
|
389
|
+
# Prepare query url.
|
390
|
+
_query_builder = config.get_base_uri
|
391
|
+
_query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
|
392
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
393
|
+
_query_builder,
|
394
|
+
'customer_id' => customer_id,
|
395
|
+
'group_id' => group_id
|
396
|
+
)
|
397
|
+
_query_url = APIHelper.clean_url _query_builder
|
398
|
+
|
399
|
+
# Prepare headers.
|
400
|
+
_headers = {
|
401
|
+
'accept' => 'application/json'
|
402
|
+
}
|
403
|
+
|
404
|
+
# Prepare and execute HttpRequest.
|
405
|
+
_request = config.http_client.put(
|
406
|
+
_query_url,
|
407
|
+
headers: _headers
|
408
|
+
)
|
409
|
+
OAuth2.apply(config, _request)
|
410
|
+
_response = execute_request(_request)
|
411
|
+
|
412
|
+
# Return appropriate response type.
|
413
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
414
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
415
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
416
|
+
end
|
326
417
|
end
|
327
418
|
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Square
|
2
|
+
# DevicesApi
|
3
|
+
class DevicesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists all DeviceCodes associated with the merchant.
|
9
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
11
|
+
# results for your original query. See [Paginating
|
12
|
+
# results](#paginatingresults) for more information.
|
13
|
+
# @param [String] location_id Optional parameter: If specified, only returns
|
14
|
+
# DeviceCodes of the specified location. Returns DeviceCodes of all
|
15
|
+
# locations if empty.
|
16
|
+
# @param [ProductType] product_type Optional parameter: If specified, only
|
17
|
+
# returns DeviceCodes targeting the specified product type. Returns
|
18
|
+
# DeviceCodes of all product types if empty.
|
19
|
+
# @return [ListDeviceCodesResponse Hash] response from the API call
|
20
|
+
def list_device_codes(cursor: nil,
|
21
|
+
location_id: nil,
|
22
|
+
product_type: nil)
|
23
|
+
# Prepare query url.
|
24
|
+
_query_builder = config.get_base_uri
|
25
|
+
_query_builder << '/v2/devices/codes'
|
26
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
27
|
+
_query_builder,
|
28
|
+
'cursor' => cursor,
|
29
|
+
'location_id' => location_id,
|
30
|
+
'product_type' => product_type
|
31
|
+
)
|
32
|
+
_query_url = APIHelper.clean_url _query_builder
|
33
|
+
|
34
|
+
# Prepare headers.
|
35
|
+
_headers = {
|
36
|
+
'accept' => 'application/json'
|
37
|
+
}
|
38
|
+
|
39
|
+
# Prepare and execute HttpRequest.
|
40
|
+
_request = config.http_client.get(
|
41
|
+
_query_url,
|
42
|
+
headers: _headers
|
43
|
+
)
|
44
|
+
OAuth2.apply(config, _request)
|
45
|
+
_response = execute_request(_request)
|
46
|
+
|
47
|
+
# Return appropriate response type.
|
48
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
49
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
50
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Creates a DeviceCode that can be used to login to a Square Terminal device
|
54
|
+
# to enter the connected
|
55
|
+
# terminal mode.
|
56
|
+
# @param [CreateDeviceCodeRequest] body Required parameter: An object
|
57
|
+
# containing the fields to POST for the request. See the corresponding
|
58
|
+
# object definition for field details.
|
59
|
+
# @return [CreateDeviceCodeResponse Hash] response from the API call
|
60
|
+
def create_device_code(body:)
|
61
|
+
# Prepare query url.
|
62
|
+
_query_builder = config.get_base_uri
|
63
|
+
_query_builder << '/v2/devices/codes'
|
64
|
+
_query_url = APIHelper.clean_url _query_builder
|
65
|
+
|
66
|
+
# Prepare headers.
|
67
|
+
_headers = {
|
68
|
+
'accept' => 'application/json',
|
69
|
+
'content-type' => 'application/json; charset=utf-8'
|
70
|
+
}
|
71
|
+
|
72
|
+
# Prepare and execute HttpRequest.
|
73
|
+
_request = config.http_client.post(
|
74
|
+
_query_url,
|
75
|
+
headers: _headers,
|
76
|
+
parameters: body.to_json
|
77
|
+
)
|
78
|
+
OAuth2.apply(config, _request)
|
79
|
+
_response = execute_request(_request)
|
80
|
+
|
81
|
+
# Return appropriate response type.
|
82
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
83
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
84
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Retrieves DeviceCode with the associated ID.
|
88
|
+
# @param [String] id Required parameter: The unique identifier for the
|
89
|
+
# device code.
|
90
|
+
# @return [GetDeviceCodeResponse Hash] response from the API call
|
91
|
+
def get_device_code(id:)
|
92
|
+
# Prepare query url.
|
93
|
+
_query_builder = config.get_base_uri
|
94
|
+
_query_builder << '/v2/devices/codes/{id}'
|
95
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
96
|
+
_query_builder,
|
97
|
+
'id' => id
|
98
|
+
)
|
99
|
+
_query_url = APIHelper.clean_url _query_builder
|
100
|
+
|
101
|
+
# Prepare headers.
|
102
|
+
_headers = {
|
103
|
+
'accept' => 'application/json'
|
104
|
+
}
|
105
|
+
|
106
|
+
# Prepare and execute HttpRequest.
|
107
|
+
_request = config.http_client.get(
|
108
|
+
_query_url,
|
109
|
+
headers: _headers
|
110
|
+
)
|
111
|
+
OAuth2.apply(config, _request)
|
112
|
+
_response = execute_request(_request)
|
113
|
+
|
114
|
+
# Return appropriate response type.
|
115
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
116
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
117
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|