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
@@ -157,6 +157,38 @@ module Square
|
|
157
157
|
ApiResponse.new(_response, data: decoded, errors: _errors)
|
158
158
|
end
|
159
159
|
|
160
|
+
# Calculates an [Order](#type-order).
|
161
|
+
# @param [CalculateOrderRequest] body Required parameter: An object
|
162
|
+
# containing the fields to POST for the request. See the corresponding
|
163
|
+
# object definition for field details.
|
164
|
+
# @return [CalculateOrderResponse Hash] response from the API call
|
165
|
+
def calculate_order(body:)
|
166
|
+
# Prepare query url.
|
167
|
+
_query_builder = config.get_base_uri
|
168
|
+
_query_builder << '/v2/orders/calculate'
|
169
|
+
_query_url = APIHelper.clean_url _query_builder
|
170
|
+
|
171
|
+
# Prepare headers.
|
172
|
+
_headers = {
|
173
|
+
'accept' => 'application/json',
|
174
|
+
'content-type' => 'application/json; charset=utf-8'
|
175
|
+
}
|
176
|
+
|
177
|
+
# Prepare and execute HttpRequest.
|
178
|
+
_request = config.http_client.post(
|
179
|
+
_query_url,
|
180
|
+
headers: _headers,
|
181
|
+
parameters: body.to_json
|
182
|
+
)
|
183
|
+
OAuth2.apply(config, _request)
|
184
|
+
_response = execute_request(_request)
|
185
|
+
|
186
|
+
# Return appropriate response type.
|
187
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
188
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
189
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
190
|
+
end
|
191
|
+
|
160
192
|
# Search all orders for one or more locations. Orders include all sales,
|
161
193
|
# returns, and exchanges regardless of how or when they entered the Square
|
162
194
|
# Ecosystem (e.g. Point of Sale, Invoices, Connect APIs, etc).
|
@@ -127,7 +127,7 @@ module Square
|
|
127
127
|
# In this case, you can
|
128
128
|
# direct Square to cancel the payment using this endpoint. In the request,
|
129
129
|
# you provide the same
|
130
|
-
# idempotency key that you provided in your CreatePayment request you want
|
130
|
+
# idempotency key that you provided in your CreatePayment request you want
|
131
131
|
# to cancel. After
|
132
132
|
# cancelling the payment, you can submit your CreatePayment request again.
|
133
133
|
# Note that if no payment with the specified idempotency key is found, no
|
@@ -246,8 +246,12 @@ module Square
|
|
246
246
|
# elayed-payments).
|
247
247
|
# @param [String] payment_id Required parameter: Unique ID identifying the
|
248
248
|
# payment to be completed.
|
249
|
+
# @param [Object] body Required parameter: An object containing the fields
|
250
|
+
# to POST for the request. See the corresponding object definition for
|
251
|
+
# field details.
|
249
252
|
# @return [CompletePaymentResponse Hash] response from the API call
|
250
|
-
def complete_payment(payment_id
|
253
|
+
def complete_payment(payment_id:,
|
254
|
+
body:)
|
251
255
|
# Prepare query url.
|
252
256
|
_query_builder = config.get_base_uri
|
253
257
|
_query_builder << '/v2/payments/{payment_id}/complete'
|
@@ -259,13 +263,15 @@ module Square
|
|
259
263
|
|
260
264
|
# Prepare headers.
|
261
265
|
_headers = {
|
262
|
-
'accept' => 'application/json'
|
266
|
+
'accept' => 'application/json',
|
267
|
+
'content-type' => 'application/json; charset=utf-8'
|
263
268
|
}
|
264
269
|
|
265
270
|
# Prepare and execute HttpRequest.
|
266
271
|
_request = config.http_client.post(
|
267
272
|
_query_url,
|
268
|
-
headers: _headers
|
273
|
+
headers: _headers,
|
274
|
+
parameters: body.to_json
|
269
275
|
)
|
270
276
|
OAuth2.apply(config, _request)
|
271
277
|
_response = execute_request(_request)
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module Square
|
2
|
+
# TerminalApi
|
3
|
+
class TerminalApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Creates a new Terminal checkout request and sends it to the specified
|
9
|
+
# device to take a payment for the requested amount.
|
10
|
+
# @param [CreateTerminalCheckoutRequest] body Required parameter: An object
|
11
|
+
# containing the fields to POST for the request. See the corresponding
|
12
|
+
# object definition for field details.
|
13
|
+
# @return [CreateTerminalCheckoutResponse Hash] response from the API call
|
14
|
+
def create_terminal_checkout(body:)
|
15
|
+
# Prepare query url.
|
16
|
+
_query_builder = config.get_base_uri
|
17
|
+
_query_builder << '/v2/terminals/checkouts'
|
18
|
+
_query_url = APIHelper.clean_url _query_builder
|
19
|
+
|
20
|
+
# Prepare headers.
|
21
|
+
_headers = {
|
22
|
+
'accept' => 'application/json',
|
23
|
+
'content-type' => 'application/json; charset=utf-8'
|
24
|
+
}
|
25
|
+
|
26
|
+
# Prepare and execute HttpRequest.
|
27
|
+
_request = config.http_client.post(
|
28
|
+
_query_url,
|
29
|
+
headers: _headers,
|
30
|
+
parameters: body.to_json
|
31
|
+
)
|
32
|
+
OAuth2.apply(config, _request)
|
33
|
+
_response = execute_request(_request)
|
34
|
+
|
35
|
+
# Return appropriate response type.
|
36
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
37
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
38
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Retrieves a filtered list of Terminal checkout requests created by the
|
42
|
+
# account making the request.
|
43
|
+
# @param [SearchTerminalCheckoutsRequest] body Required parameter: An object
|
44
|
+
# containing the fields to POST for the request. See the corresponding
|
45
|
+
# object definition for field details.
|
46
|
+
# @return [SearchTerminalCheckoutsResponse Hash] response from the API call
|
47
|
+
def search_terminal_checkouts(body:)
|
48
|
+
# Prepare query url.
|
49
|
+
_query_builder = config.get_base_uri
|
50
|
+
_query_builder << '/v2/terminals/checkouts/search'
|
51
|
+
_query_url = APIHelper.clean_url _query_builder
|
52
|
+
|
53
|
+
# Prepare headers.
|
54
|
+
_headers = {
|
55
|
+
'accept' => 'application/json',
|
56
|
+
'content-type' => 'application/json; charset=utf-8'
|
57
|
+
}
|
58
|
+
|
59
|
+
# Prepare and execute HttpRequest.
|
60
|
+
_request = config.http_client.post(
|
61
|
+
_query_url,
|
62
|
+
headers: _headers,
|
63
|
+
parameters: body.to_json
|
64
|
+
)
|
65
|
+
OAuth2.apply(config, _request)
|
66
|
+
_response = execute_request(_request)
|
67
|
+
|
68
|
+
# Return appropriate response type.
|
69
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
70
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
71
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Retrieves a Terminal checkout request by checkout_id.
|
75
|
+
# @param [String] checkout_id Required parameter: Unique ID for the desired
|
76
|
+
# `TerminalCheckout`
|
77
|
+
# @return [GetTerminalCheckoutResponse Hash] response from the API call
|
78
|
+
def get_terminal_checkout(checkout_id:)
|
79
|
+
# Prepare query url.
|
80
|
+
_query_builder = config.get_base_uri
|
81
|
+
_query_builder << '/v2/terminals/checkouts/{checkout_id}'
|
82
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
83
|
+
_query_builder,
|
84
|
+
'checkout_id' => checkout_id
|
85
|
+
)
|
86
|
+
_query_url = APIHelper.clean_url _query_builder
|
87
|
+
|
88
|
+
# Prepare headers.
|
89
|
+
_headers = {
|
90
|
+
'accept' => 'application/json'
|
91
|
+
}
|
92
|
+
|
93
|
+
# Prepare and execute HttpRequest.
|
94
|
+
_request = config.http_client.get(
|
95
|
+
_query_url,
|
96
|
+
headers: _headers
|
97
|
+
)
|
98
|
+
OAuth2.apply(config, _request)
|
99
|
+
_response = execute_request(_request)
|
100
|
+
|
101
|
+
# Return appropriate response type.
|
102
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
103
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
104
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Cancels a Terminal checkout request, if the status of the request permits
|
108
|
+
# it.
|
109
|
+
# @param [String] checkout_id Required parameter: Unique ID for the desired
|
110
|
+
# `TerminalCheckout`
|
111
|
+
# @return [CancelTerminalCheckoutResponse Hash] response from the API call
|
112
|
+
def cancel_terminal_checkout(checkout_id:)
|
113
|
+
# Prepare query url.
|
114
|
+
_query_builder = config.get_base_uri
|
115
|
+
_query_builder << '/v2/terminals/checkouts/{checkout_id}/cancel'
|
116
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
117
|
+
_query_builder,
|
118
|
+
'checkout_id' => checkout_id
|
119
|
+
)
|
120
|
+
_query_url = APIHelper.clean_url _query_builder
|
121
|
+
|
122
|
+
# Prepare headers.
|
123
|
+
_headers = {
|
124
|
+
'accept' => 'application/json'
|
125
|
+
}
|
126
|
+
|
127
|
+
# Prepare and execute HttpRequest.
|
128
|
+
_request = config.http_client.post(
|
129
|
+
_query_url,
|
130
|
+
headers: _headers
|
131
|
+
)
|
132
|
+
OAuth2.apply(config, _request)
|
133
|
+
_response = execute_request(_request)
|
134
|
+
|
135
|
+
# Return appropriate response type.
|
136
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
137
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
138
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/lib/square/client.rb
CHANGED
@@ -4,11 +4,11 @@ module Square
|
|
4
4
|
attr_reader :config
|
5
5
|
|
6
6
|
def sdk_version
|
7
|
-
'5.
|
7
|
+
'5.3.0.20200528'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
11
|
-
'2020-
|
11
|
+
'2020-05-28'
|
12
12
|
end
|
13
13
|
|
14
14
|
# Access to mobile_authorization controller.
|
@@ -77,6 +77,24 @@ module Square
|
|
77
77
|
@customers ||= CustomersApi.new config
|
78
78
|
end
|
79
79
|
|
80
|
+
# Access to customer_groups controller.
|
81
|
+
# @return [CustomerGroupsApi] Returns the controller instance.
|
82
|
+
def customer_groups
|
83
|
+
@customer_groups ||= CustomerGroupsApi.new config
|
84
|
+
end
|
85
|
+
|
86
|
+
# Access to customer_segments controller.
|
87
|
+
# @return [CustomerSegmentsApi] Returns the controller instance.
|
88
|
+
def customer_segments
|
89
|
+
@customer_segments ||= CustomerSegmentsApi.new config
|
90
|
+
end
|
91
|
+
|
92
|
+
# Access to devices controller.
|
93
|
+
# @return [DevicesApi] Returns the controller instance.
|
94
|
+
def devices
|
95
|
+
@devices ||= DevicesApi.new config
|
96
|
+
end
|
97
|
+
|
80
98
|
# Access to disputes controller.
|
81
99
|
# @return [DisputesApi] Returns the controller instance.
|
82
100
|
def disputes
|
@@ -131,6 +149,12 @@ module Square
|
|
131
149
|
@transactions ||= TransactionsApi.new config
|
132
150
|
end
|
133
151
|
|
152
|
+
# Access to loyalty controller.
|
153
|
+
# @return [LoyaltyApi] Returns the controller instance.
|
154
|
+
def loyalty
|
155
|
+
@loyalty ||= LoyaltyApi.new config
|
156
|
+
end
|
157
|
+
|
134
158
|
# Access to merchants controller.
|
135
159
|
# @return [MerchantsApi] Returns the controller instance.
|
136
160
|
def merchants
|
@@ -149,6 +173,12 @@ module Square
|
|
149
173
|
@refunds ||= RefundsApi.new config
|
150
174
|
end
|
151
175
|
|
176
|
+
# Access to terminal controller.
|
177
|
+
# @return [TerminalApi] Returns the controller instance.
|
178
|
+
def terminal
|
179
|
+
@terminal ||= TerminalApi.new config
|
180
|
+
end
|
181
|
+
|
152
182
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
153
183
|
backoff_factor: 1, environment: 'production',
|
154
184
|
access_token: 'TODO: Replace', additional_headers: {},
|
data/lib/square/configuration.rb
CHANGED
@@ -36,7 +36,7 @@ module Square
|
|
36
36
|
@backoff_factor = backoff_factor
|
37
37
|
|
38
38
|
# Current API environment
|
39
|
-
@environment = environment
|
39
|
+
@environment = String(environment)
|
40
40
|
|
41
41
|
# OAuth 2.0 Access Token
|
42
42
|
@access_token = access_token
|
@@ -73,21 +73,21 @@ module Square
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# All the environments the SDK can run in.
|
76
|
-
|
76
|
+
ENVIRONMENTS = {
|
77
77
|
'production' => {
|
78
78
|
'default' => 'https://connect.squareup.com'
|
79
79
|
},
|
80
80
|
'sandbox' => {
|
81
81
|
'default' => 'https://connect.squareupsandbox.com'
|
82
82
|
}
|
83
|
-
}
|
83
|
+
}.freeze
|
84
84
|
|
85
85
|
# Generates the appropriate base URI for the environment and the server.
|
86
86
|
# @param [Configuration::Server] The server enum for which the base URI is
|
87
87
|
# required.
|
88
88
|
# @return [String] The base URI.
|
89
89
|
def get_base_uri(server = 'default')
|
90
|
-
|
90
|
+
ENVIRONMENTS[environment][server].clone
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: square.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0.20200528
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Square Developer Platform
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -124,12 +124,16 @@ files:
|
|
124
124
|
- lib/square/api/cash_drawers_api.rb
|
125
125
|
- lib/square/api/catalog_api.rb
|
126
126
|
- lib/square/api/checkout_api.rb
|
127
|
+
- lib/square/api/customer_groups_api.rb
|
128
|
+
- lib/square/api/customer_segments_api.rb
|
127
129
|
- lib/square/api/customers_api.rb
|
130
|
+
- lib/square/api/devices_api.rb
|
128
131
|
- lib/square/api/disputes_api.rb
|
129
132
|
- lib/square/api/employees_api.rb
|
130
133
|
- lib/square/api/inventory_api.rb
|
131
134
|
- lib/square/api/labor_api.rb
|
132
135
|
- lib/square/api/locations_api.rb
|
136
|
+
- lib/square/api/loyalty_api.rb
|
133
137
|
- lib/square/api/merchants_api.rb
|
134
138
|
- lib/square/api/mobile_authorization_api.rb
|
135
139
|
- lib/square/api/o_auth_api.rb
|
@@ -137,6 +141,7 @@ files:
|
|
137
141
|
- lib/square/api/payments_api.rb
|
138
142
|
- lib/square/api/refunds_api.rb
|
139
143
|
- lib/square/api/reporting_api.rb
|
144
|
+
- lib/square/api/terminal_api.rb
|
140
145
|
- lib/square/api/transactions_api.rb
|
141
146
|
- lib/square/api/v1_employees_api.rb
|
142
147
|
- lib/square/api/v1_items_api.rb
|
@@ -186,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
191
|
- !ruby/object:Gem::Version
|
187
192
|
version: '0'
|
188
193
|
requirements: []
|
189
|
-
rubygems_version: 3.0.
|
194
|
+
rubygems_version: 3.0.8
|
190
195
|
signing_key:
|
191
196
|
specification_version: 4
|
192
197
|
summary: square
|