square.rb 5.2.2.20200422 → 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 +1 -0
- data/lib/square/api/base_api.rb +2 -2
- data/lib/square/api/customers_api.rb +16 -3
- data/lib/square/api/loyalty_api.rb +543 -0
- data/lib/square/api/orders_api.rb +32 -0
- data/lib/square/client.rb +8 -2
- metadata +4 -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
@@ -52,6 +52,7 @@ require_relative 'square/api/reporting_api.rb'
|
|
52
52
|
require_relative 'square/api/checkout_api.rb'
|
53
53
|
require_relative 'square/api/orders_api.rb'
|
54
54
|
require_relative 'square/api/transactions_api.rb'
|
55
|
+
require_relative 'square/api/loyalty_api.rb'
|
55
56
|
require_relative 'square/api/merchants_api.rb'
|
56
57
|
require_relative 'square/api/payments_api.rb'
|
57
58
|
require_relative 'square/api/refunds_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
|
|
@@ -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.
|
@@ -0,0 +1,543 @@
|
|
1
|
+
module Square
|
2
|
+
# LoyaltyApi
|
3
|
+
class LoyaltyApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Creates a loyalty account. For more information, see
|
9
|
+
# [Create a loyalty
|
10
|
+
# account](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
|
11
|
+
# yalty-overview-create-account).
|
12
|
+
# @param [CreateLoyaltyAccountRequest] body Required parameter: An object
|
13
|
+
# containing the fields to POST for the request. See the corresponding
|
14
|
+
# object definition for field details.
|
15
|
+
# @return [CreateLoyaltyAccountResponse Hash] response from the API call
|
16
|
+
def create_loyalty_account(body:)
|
17
|
+
# Prepare query url.
|
18
|
+
_query_builder = config.get_base_uri
|
19
|
+
_query_builder << '/v2/loyalty/accounts'
|
20
|
+
_query_url = APIHelper.clean_url _query_builder
|
21
|
+
|
22
|
+
# Prepare headers.
|
23
|
+
_headers = {
|
24
|
+
'accept' => 'application/json',
|
25
|
+
'content-type' => 'application/json; charset=utf-8'
|
26
|
+
}
|
27
|
+
|
28
|
+
# Prepare and execute HttpRequest.
|
29
|
+
_request = config.http_client.post(
|
30
|
+
_query_url,
|
31
|
+
headers: _headers,
|
32
|
+
parameters: body.to_json
|
33
|
+
)
|
34
|
+
OAuth2.apply(config, _request)
|
35
|
+
_response = execute_request(_request)
|
36
|
+
|
37
|
+
# Return appropriate response type.
|
38
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
39
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
40
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
41
|
+
end
|
42
|
+
|
43
|
+
# Searches for loyalty accounts.
|
44
|
+
# In the current implementation, you can search for a loyalty account using
|
45
|
+
# the phone number associated with the account.
|
46
|
+
# If no phone number is provided, all loyalty accounts are returned.
|
47
|
+
# @param [SearchLoyaltyAccountsRequest] body Required parameter: An object
|
48
|
+
# containing the fields to POST for the request. See the corresponding
|
49
|
+
# object definition for field details.
|
50
|
+
# @return [SearchLoyaltyAccountsResponse Hash] response from the API call
|
51
|
+
def search_loyalty_accounts(body:)
|
52
|
+
# Prepare query url.
|
53
|
+
_query_builder = config.get_base_uri
|
54
|
+
_query_builder << '/v2/loyalty/accounts/search'
|
55
|
+
_query_url = APIHelper.clean_url _query_builder
|
56
|
+
|
57
|
+
# Prepare headers.
|
58
|
+
_headers = {
|
59
|
+
'accept' => 'application/json',
|
60
|
+
'content-type' => 'application/json; charset=utf-8'
|
61
|
+
}
|
62
|
+
|
63
|
+
# Prepare and execute HttpRequest.
|
64
|
+
_request = config.http_client.post(
|
65
|
+
_query_url,
|
66
|
+
headers: _headers,
|
67
|
+
parameters: body.to_json
|
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
|
+
|
78
|
+
# Retrieves a loyalty account.
|
79
|
+
# @param [String] account_id Required parameter: The ID of the [loyalty
|
80
|
+
# account](#type-LoyaltyAccount) to retrieve.
|
81
|
+
# @return [RetrieveLoyaltyAccountResponse Hash] response from the API call
|
82
|
+
def retrieve_loyalty_account(account_id:)
|
83
|
+
# Prepare query url.
|
84
|
+
_query_builder = config.get_base_uri
|
85
|
+
_query_builder << '/v2/loyalty/accounts/{account_id}'
|
86
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
87
|
+
_query_builder,
|
88
|
+
'account_id' => account_id
|
89
|
+
)
|
90
|
+
_query_url = APIHelper.clean_url _query_builder
|
91
|
+
|
92
|
+
# Prepare headers.
|
93
|
+
_headers = {
|
94
|
+
'accept' => 'application/json'
|
95
|
+
}
|
96
|
+
|
97
|
+
# Prepare and execute HttpRequest.
|
98
|
+
_request = config.http_client.get(
|
99
|
+
_query_url,
|
100
|
+
headers: _headers
|
101
|
+
)
|
102
|
+
OAuth2.apply(config, _request)
|
103
|
+
_response = execute_request(_request)
|
104
|
+
|
105
|
+
# Return appropriate response type.
|
106
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
107
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
108
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Adds points to a loyalty account.
|
112
|
+
# - If you are using the Orders API to manage orders, you only provide the
|
113
|
+
# `order_id`.
|
114
|
+
# The endpoint reads the order to compute points to add to the buyer's
|
115
|
+
# account.
|
116
|
+
# - If you are not using the Orders API to manage orders,
|
117
|
+
# you first perform a client-side computation to compute the points.
|
118
|
+
# For spend-based and visit-based programs, you can call
|
119
|
+
# `CalculateLoyaltyPoints` to compute the points. For more information,
|
120
|
+
# see [Loyalty Program
|
121
|
+
# Overview](https://developer.squareup.com/docs/docs/loyalty/overview).
|
122
|
+
# You then provide the points in a request to this endpoint.
|
123
|
+
# For more information, see [Accumulate
|
124
|
+
# points](https://developer.squareup.com/docs/docs/loyalty-api/overview/#acc
|
125
|
+
# umulate-points).
|
126
|
+
# @param [String] account_id Required parameter: The [loyalty
|
127
|
+
# account](#type-LoyaltyAccount) ID to which to add the points.
|
128
|
+
# @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
|
129
|
+
# containing the fields to POST for the request. See the corresponding
|
130
|
+
# object definition for field details.
|
131
|
+
# @return [AccumulateLoyaltyPointsResponse Hash] response from the API call
|
132
|
+
def accumulate_loyalty_points(account_id:,
|
133
|
+
body:)
|
134
|
+
# Prepare query url.
|
135
|
+
_query_builder = config.get_base_uri
|
136
|
+
_query_builder << '/v2/loyalty/accounts/{account_id}/accumulate'
|
137
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
138
|
+
_query_builder,
|
139
|
+
'account_id' => account_id
|
140
|
+
)
|
141
|
+
_query_url = APIHelper.clean_url _query_builder
|
142
|
+
|
143
|
+
# Prepare headers.
|
144
|
+
_headers = {
|
145
|
+
'accept' => 'application/json',
|
146
|
+
'content-type' => 'application/json; charset=utf-8'
|
147
|
+
}
|
148
|
+
|
149
|
+
# Prepare and execute HttpRequest.
|
150
|
+
_request = config.http_client.post(
|
151
|
+
_query_url,
|
152
|
+
headers: _headers,
|
153
|
+
parameters: body.to_json
|
154
|
+
)
|
155
|
+
OAuth2.apply(config, _request)
|
156
|
+
_response = execute_request(_request)
|
157
|
+
|
158
|
+
# Return appropriate response type.
|
159
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
160
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
161
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
162
|
+
end
|
163
|
+
|
164
|
+
# Adds points to or subtracts points from a buyer's account.
|
165
|
+
# Use this endpoint only when you need to manually adjust points. Otherwise,
|
166
|
+
# in your application flow, you call
|
167
|
+
# [AccumulateLoyaltyPoints](https://developer.squareup.com/docs/reference/sq
|
168
|
+
# uare/loyalty-api/accumulate-loyalty-points)
|
169
|
+
# to add points when a buyer pays for the purchase.
|
170
|
+
# @param [String] account_id Required parameter: The ID of the [loyalty
|
171
|
+
# account](#type-LoyaltyAccount) in which to adjust the points.
|
172
|
+
# @param [AdjustLoyaltyPointsRequest] body Required parameter: An object
|
173
|
+
# containing the fields to POST for the request. See the corresponding
|
174
|
+
# object definition for field details.
|
175
|
+
# @return [AdjustLoyaltyPointsResponse Hash] response from the API call
|
176
|
+
def adjust_loyalty_points(account_id:,
|
177
|
+
body:)
|
178
|
+
# Prepare query url.
|
179
|
+
_query_builder = config.get_base_uri
|
180
|
+
_query_builder << '/v2/loyalty/accounts/{account_id}/adjust'
|
181
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
182
|
+
_query_builder,
|
183
|
+
'account_id' => account_id
|
184
|
+
)
|
185
|
+
_query_url = APIHelper.clean_url _query_builder
|
186
|
+
|
187
|
+
# Prepare headers.
|
188
|
+
_headers = {
|
189
|
+
'accept' => 'application/json',
|
190
|
+
'content-type' => 'application/json; charset=utf-8'
|
191
|
+
}
|
192
|
+
|
193
|
+
# Prepare and execute HttpRequest.
|
194
|
+
_request = config.http_client.post(
|
195
|
+
_query_url,
|
196
|
+
headers: _headers,
|
197
|
+
parameters: body.to_json
|
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(_response, data: decoded, errors: _errors)
|
206
|
+
end
|
207
|
+
|
208
|
+
# Searches for loyalty events.
|
209
|
+
# A Square loyalty program maintains a ledger of events that occur during
|
210
|
+
# the lifetime of a
|
211
|
+
# buyer's loyalty account. Each change in the point balance
|
212
|
+
# (for example, points earned, points redeemed, and points expired) is
|
213
|
+
# recorded in the ledger. Using this endpoint, you can search the ledger for
|
214
|
+
# events.
|
215
|
+
# For more information, see
|
216
|
+
# [Loyalty
|
217
|
+
# events](https://developer.squareup.com/docs/docs/loyalty-api/overview/#loy
|
218
|
+
# alty-events).
|
219
|
+
# @param [SearchLoyaltyEventsRequest] body Required parameter: An object
|
220
|
+
# containing the fields to POST for the request. See the corresponding
|
221
|
+
# object definition for field details.
|
222
|
+
# @return [SearchLoyaltyEventsResponse Hash] response from the API call
|
223
|
+
def search_loyalty_events(body:)
|
224
|
+
# Prepare query url.
|
225
|
+
_query_builder = config.get_base_uri
|
226
|
+
_query_builder << '/v2/loyalty/events/search'
|
227
|
+
_query_url = APIHelper.clean_url _query_builder
|
228
|
+
|
229
|
+
# Prepare headers.
|
230
|
+
_headers = {
|
231
|
+
'accept' => 'application/json',
|
232
|
+
'content-type' => 'application/json; charset=utf-8'
|
233
|
+
}
|
234
|
+
|
235
|
+
# Prepare and execute HttpRequest.
|
236
|
+
_request = config.http_client.post(
|
237
|
+
_query_url,
|
238
|
+
headers: _headers,
|
239
|
+
parameters: body.to_json
|
240
|
+
)
|
241
|
+
OAuth2.apply(config, _request)
|
242
|
+
_response = execute_request(_request)
|
243
|
+
|
244
|
+
# Return appropriate response type.
|
245
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
246
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
247
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
248
|
+
end
|
249
|
+
|
250
|
+
# Returns a list of loyalty programs in the seller's account.
|
251
|
+
# Currently, a seller can only have one loyalty program. For more
|
252
|
+
# information, see
|
253
|
+
# [Loyalty
|
254
|
+
# Overview](https://developer.squareup.com/docs/docs/loyalty/overview).
|
255
|
+
# .
|
256
|
+
# @return [ListLoyaltyProgramsResponse Hash] response from the API call
|
257
|
+
def list_loyalty_programs
|
258
|
+
# Prepare query url.
|
259
|
+
_query_builder = config.get_base_uri
|
260
|
+
_query_builder << '/v2/loyalty/programs'
|
261
|
+
_query_url = APIHelper.clean_url _query_builder
|
262
|
+
|
263
|
+
# Prepare headers.
|
264
|
+
_headers = {
|
265
|
+
'accept' => 'application/json'
|
266
|
+
}
|
267
|
+
|
268
|
+
# Prepare and execute HttpRequest.
|
269
|
+
_request = config.http_client.get(
|
270
|
+
_query_url,
|
271
|
+
headers: _headers
|
272
|
+
)
|
273
|
+
OAuth2.apply(config, _request)
|
274
|
+
_response = execute_request(_request)
|
275
|
+
|
276
|
+
# Return appropriate response type.
|
277
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
278
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
279
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
280
|
+
end
|
281
|
+
|
282
|
+
# Calculates the points a purchase earns.
|
283
|
+
# - If you are using the Orders API to manage orders, you provide `order_id`
|
284
|
+
# in the request. The
|
285
|
+
# endpoint calculates the points by reading the order.
|
286
|
+
# - If you are not using the Orders API to manage orders, you provide the
|
287
|
+
# purchase amount in
|
288
|
+
# the request for the endpoint to calculate the points.
|
289
|
+
# An application might call this endpoint to show the points that a buyer
|
290
|
+
# can earn with the
|
291
|
+
# specific purchase.
|
292
|
+
# @param [String] program_id Required parameter: The [loyalty
|
293
|
+
# program](#type-LoyaltyProgram) ID, which defines the rules for accruing
|
294
|
+
# points.
|
295
|
+
# @param [CalculateLoyaltyPointsRequest] body Required parameter: An object
|
296
|
+
# containing the fields to POST for the request. See the corresponding
|
297
|
+
# object definition for field details.
|
298
|
+
# @return [CalculateLoyaltyPointsResponse Hash] response from the API call
|
299
|
+
def calculate_loyalty_points(program_id:,
|
300
|
+
body:)
|
301
|
+
# Prepare query url.
|
302
|
+
_query_builder = config.get_base_uri
|
303
|
+
_query_builder << '/v2/loyalty/programs/{program_id}/calculate'
|
304
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
305
|
+
_query_builder,
|
306
|
+
'program_id' => program_id
|
307
|
+
)
|
308
|
+
_query_url = APIHelper.clean_url _query_builder
|
309
|
+
|
310
|
+
# Prepare headers.
|
311
|
+
_headers = {
|
312
|
+
'accept' => 'application/json',
|
313
|
+
'content-type' => 'application/json; charset=utf-8'
|
314
|
+
}
|
315
|
+
|
316
|
+
# Prepare and execute HttpRequest.
|
317
|
+
_request = config.http_client.post(
|
318
|
+
_query_url,
|
319
|
+
headers: _headers,
|
320
|
+
parameters: body.to_json
|
321
|
+
)
|
322
|
+
OAuth2.apply(config, _request)
|
323
|
+
_response = execute_request(_request)
|
324
|
+
|
325
|
+
# Return appropriate response type.
|
326
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
327
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
328
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
329
|
+
end
|
330
|
+
|
331
|
+
# Creates a loyalty reward. In the process, the endpoint does following:
|
332
|
+
# - Uses the `reward_tier_id` in the request to determine the number of
|
333
|
+
# points
|
334
|
+
# to lock for this reward.
|
335
|
+
# - If the request includes `order_id`, it adds the reward and related
|
336
|
+
# discount to the order.
|
337
|
+
# After a reward is created, the points are locked and
|
338
|
+
# not available for the buyer to redeem another reward.
|
339
|
+
# For more information, see
|
340
|
+
# [Loyalty
|
341
|
+
# rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
|
342
|
+
# yalty-overview-loyalty-rewards).
|
343
|
+
# @param [CreateLoyaltyRewardRequest] body Required parameter: An object
|
344
|
+
# containing the fields to POST for the request. See the corresponding
|
345
|
+
# object definition for field details.
|
346
|
+
# @return [CreateLoyaltyRewardResponse Hash] response from the API call
|
347
|
+
def create_loyalty_reward(body:)
|
348
|
+
# Prepare query url.
|
349
|
+
_query_builder = config.get_base_uri
|
350
|
+
_query_builder << '/v2/loyalty/rewards'
|
351
|
+
_query_url = APIHelper.clean_url _query_builder
|
352
|
+
|
353
|
+
# Prepare headers.
|
354
|
+
_headers = {
|
355
|
+
'accept' => 'application/json',
|
356
|
+
'content-type' => 'application/json; charset=utf-8'
|
357
|
+
}
|
358
|
+
|
359
|
+
# Prepare and execute HttpRequest.
|
360
|
+
_request = config.http_client.post(
|
361
|
+
_query_url,
|
362
|
+
headers: _headers,
|
363
|
+
parameters: body.to_json
|
364
|
+
)
|
365
|
+
OAuth2.apply(config, _request)
|
366
|
+
_response = execute_request(_request)
|
367
|
+
|
368
|
+
# Return appropriate response type.
|
369
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
370
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
371
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
372
|
+
end
|
373
|
+
|
374
|
+
# Searches for loyalty rewards in a loyalty account.
|
375
|
+
# In the current implementation, the endpoint supports search by the reward
|
376
|
+
# `status`.
|
377
|
+
# If you know a reward ID, use the
|
378
|
+
# [RetrieveLoyaltyReward](https://developer.squareup.com/docs/reference/squa
|
379
|
+
# re/loyalty-api/retrieve-loyalty-reward) endpoint.
|
380
|
+
# For more information about loyalty rewards, see
|
381
|
+
# [Loyalty
|
382
|
+
# Rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
|
383
|
+
# yalty-rewards).
|
384
|
+
# @param [SearchLoyaltyRewardsRequest] body Required parameter: An object
|
385
|
+
# containing the fields to POST for the request. See the corresponding
|
386
|
+
# object definition for field details.
|
387
|
+
# @return [SearchLoyaltyRewardsResponse Hash] response from the API call
|
388
|
+
def search_loyalty_rewards(body:)
|
389
|
+
# Prepare query url.
|
390
|
+
_query_builder = config.get_base_uri
|
391
|
+
_query_builder << '/v2/loyalty/rewards/search'
|
392
|
+
_query_url = APIHelper.clean_url _query_builder
|
393
|
+
|
394
|
+
# Prepare headers.
|
395
|
+
_headers = {
|
396
|
+
'accept' => 'application/json',
|
397
|
+
'content-type' => 'application/json; charset=utf-8'
|
398
|
+
}
|
399
|
+
|
400
|
+
# Prepare and execute HttpRequest.
|
401
|
+
_request = config.http_client.post(
|
402
|
+
_query_url,
|
403
|
+
headers: _headers,
|
404
|
+
parameters: body.to_json
|
405
|
+
)
|
406
|
+
OAuth2.apply(config, _request)
|
407
|
+
_response = execute_request(_request)
|
408
|
+
|
409
|
+
# Return appropriate response type.
|
410
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
411
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
412
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
413
|
+
end
|
414
|
+
|
415
|
+
# Deletes a loyalty reward by doing the following:
|
416
|
+
# - Returns the loyalty points back to the loyalty account.
|
417
|
+
# - If an order ID was specified when the reward was created
|
418
|
+
# (see
|
419
|
+
# [CreateLoyaltyReward](https://developer.squareup.com/docs/reference/square
|
420
|
+
# /loyalty-api/create-loyalty-reward)),
|
421
|
+
# it updates the order by removing the reward and related
|
422
|
+
# discounts.
|
423
|
+
# You cannot delete a reward that has reached the terminal state (REDEEMED).
|
424
|
+
# For more information, see
|
425
|
+
# [Loyalty
|
426
|
+
# rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
|
427
|
+
# yalty-overview-loyalty-rewards).
|
428
|
+
# @param [String] reward_id Required parameter: The ID of the [loyalty
|
429
|
+
# reward](#type-LoyaltyReward) to delete.
|
430
|
+
# @return [DeleteLoyaltyRewardResponse Hash] response from the API call
|
431
|
+
def delete_loyalty_reward(reward_id:)
|
432
|
+
# Prepare query url.
|
433
|
+
_query_builder = config.get_base_uri
|
434
|
+
_query_builder << '/v2/loyalty/rewards/{reward_id}'
|
435
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
436
|
+
_query_builder,
|
437
|
+
'reward_id' => reward_id
|
438
|
+
)
|
439
|
+
_query_url = APIHelper.clean_url _query_builder
|
440
|
+
|
441
|
+
# Prepare headers.
|
442
|
+
_headers = {
|
443
|
+
'accept' => 'application/json'
|
444
|
+
}
|
445
|
+
|
446
|
+
# Prepare and execute HttpRequest.
|
447
|
+
_request = config.http_client.delete(
|
448
|
+
_query_url,
|
449
|
+
headers: _headers
|
450
|
+
)
|
451
|
+
OAuth2.apply(config, _request)
|
452
|
+
_response = execute_request(_request)
|
453
|
+
|
454
|
+
# Return appropriate response type.
|
455
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
456
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
457
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
458
|
+
end
|
459
|
+
|
460
|
+
# Retrieves a loyalty reward.
|
461
|
+
# @param [String] reward_id Required parameter: The ID of the [loyalty
|
462
|
+
# reward](#type-LoyaltyReward) to retrieve.
|
463
|
+
# @return [RetrieveLoyaltyRewardResponse Hash] response from the API call
|
464
|
+
def retrieve_loyalty_reward(reward_id:)
|
465
|
+
# Prepare query url.
|
466
|
+
_query_builder = config.get_base_uri
|
467
|
+
_query_builder << '/v2/loyalty/rewards/{reward_id}'
|
468
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
469
|
+
_query_builder,
|
470
|
+
'reward_id' => reward_id
|
471
|
+
)
|
472
|
+
_query_url = APIHelper.clean_url _query_builder
|
473
|
+
|
474
|
+
# Prepare headers.
|
475
|
+
_headers = {
|
476
|
+
'accept' => 'application/json'
|
477
|
+
}
|
478
|
+
|
479
|
+
# Prepare and execute HttpRequest.
|
480
|
+
_request = config.http_client.get(
|
481
|
+
_query_url,
|
482
|
+
headers: _headers
|
483
|
+
)
|
484
|
+
OAuth2.apply(config, _request)
|
485
|
+
_response = execute_request(_request)
|
486
|
+
|
487
|
+
# Return appropriate response type.
|
488
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
489
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
490
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
491
|
+
end
|
492
|
+
|
493
|
+
# Redeems a loyalty reward.
|
494
|
+
# The endpoint sets the reward to the terminal state (`REDEEMED`).
|
495
|
+
# If you are using your own order processing system (not using the
|
496
|
+
# Orders API), you call this endpoint after the buyer paid for the
|
497
|
+
# purchase.
|
498
|
+
# After the reward reaches the terminal state, it cannot be deleted.
|
499
|
+
# In other words, points used for the reward cannot be returned
|
500
|
+
# to the account.
|
501
|
+
# For more information, see
|
502
|
+
# [Loyalty
|
503
|
+
# rewards](https://developer.squareup.com/docs/docs/loyalty-api/overview/#lo
|
504
|
+
# yalty-overview-loyalty-rewards).
|
505
|
+
# @param [String] reward_id Required parameter: The ID of the [loyalty
|
506
|
+
# reward](#type-LoyaltyReward) to redeem.
|
507
|
+
# @param [RedeemLoyaltyRewardRequest] body Required parameter: An object
|
508
|
+
# containing the fields to POST for the request. See the corresponding
|
509
|
+
# object definition for field details.
|
510
|
+
# @return [RedeemLoyaltyRewardResponse Hash] response from the API call
|
511
|
+
def redeem_loyalty_reward(reward_id:,
|
512
|
+
body:)
|
513
|
+
# Prepare query url.
|
514
|
+
_query_builder = config.get_base_uri
|
515
|
+
_query_builder << '/v2/loyalty/rewards/{reward_id}/redeem'
|
516
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
517
|
+
_query_builder,
|
518
|
+
'reward_id' => reward_id
|
519
|
+
)
|
520
|
+
_query_url = APIHelper.clean_url _query_builder
|
521
|
+
|
522
|
+
# Prepare headers.
|
523
|
+
_headers = {
|
524
|
+
'accept' => 'application/json',
|
525
|
+
'content-type' => 'application/json; charset=utf-8'
|
526
|
+
}
|
527
|
+
|
528
|
+
# Prepare and execute HttpRequest.
|
529
|
+
_request = config.http_client.post(
|
530
|
+
_query_url,
|
531
|
+
headers: _headers,
|
532
|
+
parameters: body.to_json
|
533
|
+
)
|
534
|
+
OAuth2.apply(config, _request)
|
535
|
+
_response = execute_request(_request)
|
536
|
+
|
537
|
+
# Return appropriate response type.
|
538
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
539
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
540
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
541
|
+
end
|
542
|
+
end
|
543
|
+
end
|
@@ -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).
|
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.
|
@@ -149,6 +149,12 @@ module Square
|
|
149
149
|
@transactions ||= TransactionsApi.new config
|
150
150
|
end
|
151
151
|
|
152
|
+
# Access to loyalty controller.
|
153
|
+
# @return [LoyaltyApi] Returns the controller instance.
|
154
|
+
def loyalty
|
155
|
+
@loyalty ||= LoyaltyApi.new config
|
156
|
+
end
|
157
|
+
|
152
158
|
# Access to merchants controller.
|
153
159
|
# @return [MerchantsApi] Returns the controller instance.
|
154
160
|
def merchants
|
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
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- lib/square/api/inventory_api.rb
|
134
134
|
- lib/square/api/labor_api.rb
|
135
135
|
- lib/square/api/locations_api.rb
|
136
|
+
- lib/square/api/loyalty_api.rb
|
136
137
|
- lib/square/api/merchants_api.rb
|
137
138
|
- lib/square/api/mobile_authorization_api.rb
|
138
139
|
- lib/square/api/o_auth_api.rb
|
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
191
|
- !ruby/object:Gem::Version
|
191
192
|
version: '0'
|
192
193
|
requirements: []
|
193
|
-
rubygems_version: 3.0.
|
194
|
+
rubygems_version: 3.0.8
|
194
195
|
signing_key:
|
195
196
|
specification_version: 4
|
196
197
|
summary: square
|