square.rb 26.1.0.20230119 → 26.2.0.20230315
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/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 +166 -331
- 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 +77 -47
- 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 +6 -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 +11 -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
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# MerchantsApi
|
3
3
|
class MerchantsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Provides details about the merchant associated with a given access token.
|
9
5
|
# The access token used to connect your application to a Square seller is
|
10
6
|
# associated
|
@@ -20,34 +16,18 @@ module Square
|
|
20
16
|
# previous response.
|
21
17
|
# @return [ListMerchantsResponse Hash] response from the API call
|
22
18
|
def list_merchants(cursor: nil)
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
36
|
-
|
37
|
-
# Prepare and execute HttpRequest.
|
38
|
-
_request = config.http_client.get(
|
39
|
-
_query_url,
|
40
|
-
headers: _headers
|
41
|
-
)
|
42
|
-
OAuth2.apply(config, _request)
|
43
|
-
_response = execute_request(_request)
|
44
|
-
|
45
|
-
# Return appropriate response type.
|
46
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
47
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
48
|
-
ApiResponse.new(
|
49
|
-
_response, data: decoded, errors: _errors
|
50
|
-
)
|
19
|
+
new_api_call_builder
|
20
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
21
|
+
'/v2/merchants',
|
22
|
+
'default')
|
23
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
24
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
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
|
51
31
|
end
|
52
32
|
|
53
33
|
# Retrieves the `Merchant` object for the given `merchant_id`.
|
@@ -56,34 +36,19 @@ module Square
|
|
56
36
|
# merchant that is currently accessible to this call.
|
57
37
|
# @return [RetrieveMerchantResponse Hash] response from the API call
|
58
38
|
def retrieve_merchant(merchant_id:)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# Prepare and execute HttpRequest.
|
74
|
-
_request = config.http_client.get(
|
75
|
-
_query_url,
|
76
|
-
headers: _headers
|
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(
|
85
|
-
_response, data: decoded, errors: _errors
|
86
|
-
)
|
39
|
+
new_api_call_builder
|
40
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
41
|
+
'/v2/merchants/{merchant_id}',
|
42
|
+
'default')
|
43
|
+
.template_param(new_parameter(merchant_id, key: 'merchant_id')
|
44
|
+
.should_encode(true))
|
45
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
46
|
+
.auth(Single.new('global')))
|
47
|
+
.response(new_response_handler
|
48
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
49
|
+
.is_api_response(true)
|
50
|
+
.convertor(ApiResponse.method(:create)))
|
51
|
+
.execute
|
87
52
|
end
|
88
53
|
end
|
89
54
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# MobileAuthorizationApi
|
3
3
|
class MobileAuthorizationApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Generates code to authorize a mobile application to connect to a Square
|
9
5
|
# card reader.
|
10
6
|
# Authorization codes are one-time-use codes and expire 60 minutes after
|
@@ -23,32 +19,20 @@ module Square
|
|
23
19
|
# corresponding object definition for field details.
|
24
20
|
# @return [CreateMobileAuthorizationCodeResponse Hash] response from the API call
|
25
21
|
def create_mobile_authorization_code(body:)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
headers: _headers,
|
41
|
-
parameters: body.to_json
|
42
|
-
)
|
43
|
-
OAuth2.apply(config, _request)
|
44
|
-
_response = execute_request(_request)
|
45
|
-
|
46
|
-
# Return appropriate response type.
|
47
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
48
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
49
|
-
ApiResponse.new(
|
50
|
-
_response, data: decoded, errors: _errors
|
51
|
-
)
|
22
|
+
new_api_call_builder
|
23
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
24
|
+
'/mobile/authorization-code',
|
25
|
+
'default')
|
26
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
27
|
+
.body_param(new_parameter(body))
|
28
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
29
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
30
|
+
.auth(Single.new('global')))
|
31
|
+
.response(new_response_handler
|
32
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
33
|
+
.is_api_response(true)
|
34
|
+
.convertor(ApiResponse.method(:create)))
|
35
|
+
.execute
|
52
36
|
end
|
53
37
|
end
|
54
38
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# OAuthApi
|
3
3
|
class OAuthApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# `RenewToken` is deprecated. For information about refreshing OAuth access
|
9
5
|
# tokens, see
|
10
6
|
# [Migrate from Renew to Refresh OAuth
|
@@ -39,36 +35,22 @@ module Square
|
|
39
35
|
body:,
|
40
36
|
authorization:)
|
41
37
|
warn 'Endpoint renew_token in OAuthApi is deprecated'
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
# Prepare and execute HttpRequest.
|
59
|
-
_request = config.http_client.post(
|
60
|
-
_query_url,
|
61
|
-
headers: _headers,
|
62
|
-
parameters: body.to_json
|
63
|
-
)
|
64
|
-
_response = execute_request(_request)
|
65
|
-
|
66
|
-
# Return appropriate response type.
|
67
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
68
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
69
|
-
ApiResponse.new(
|
70
|
-
_response, data: decoded, errors: _errors
|
71
|
-
)
|
38
|
+
new_api_call_builder
|
39
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
40
|
+
'/oauth2/clients/{client_id}/access-token/renew',
|
41
|
+
'default')
|
42
|
+
.template_param(new_parameter(client_id, key: 'client_id')
|
43
|
+
.should_encode(true))
|
44
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
45
|
+
.body_param(new_parameter(body))
|
46
|
+
.header_param(new_parameter(authorization, key: 'Authorization'))
|
47
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
48
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end))
|
49
|
+
.response(new_response_handler
|
50
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
51
|
+
.is_api_response(true)
|
52
|
+
.convertor(ApiResponse.method(:create)))
|
53
|
+
.execute
|
72
54
|
end
|
73
55
|
|
74
56
|
# Revokes an access token generated with the OAuth flow.
|
@@ -93,32 +75,20 @@ module Square
|
|
93
75
|
# @return [RevokeTokenResponse Hash] response from the API call
|
94
76
|
def revoke_token(body:,
|
95
77
|
authorization:)
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
_query_url,
|
111
|
-
headers: _headers,
|
112
|
-
parameters: body.to_json
|
113
|
-
)
|
114
|
-
_response = execute_request(_request)
|
115
|
-
|
116
|
-
# Return appropriate response type.
|
117
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
118
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
119
|
-
ApiResponse.new(
|
120
|
-
_response, data: decoded, errors: _errors
|
121
|
-
)
|
78
|
+
new_api_call_builder
|
79
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
80
|
+
'/oauth2/revoke',
|
81
|
+
'default')
|
82
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
83
|
+
.body_param(new_parameter(body))
|
84
|
+
.header_param(new_parameter(authorization, key: 'Authorization'))
|
85
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
86
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end))
|
87
|
+
.response(new_response_handler
|
88
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
89
|
+
.is_api_response(true)
|
90
|
+
.convertor(ApiResponse.method(:create)))
|
91
|
+
.execute
|
122
92
|
end
|
123
93
|
|
124
94
|
# Returns an OAuth access token and a refresh token unless the
|
@@ -142,31 +112,19 @@ module Square
|
|
142
112
|
# definition for field details.
|
143
113
|
# @return [ObtainTokenResponse Hash] response from the API call
|
144
114
|
def obtain_token(body:)
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
_query_url,
|
159
|
-
headers: _headers,
|
160
|
-
parameters: body.to_json
|
161
|
-
)
|
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
|
-
)
|
115
|
+
new_api_call_builder
|
116
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
117
|
+
'/oauth2/token',
|
118
|
+
'default')
|
119
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
120
|
+
.body_param(new_parameter(body))
|
121
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
122
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end))
|
123
|
+
.response(new_response_handler
|
124
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
125
|
+
.is_api_response(true)
|
126
|
+
.convertor(ApiResponse.method(:create)))
|
127
|
+
.execute
|
170
128
|
end
|
171
129
|
|
172
130
|
# Returns information about an [OAuth access
|
@@ -190,30 +148,17 @@ module Square
|
|
190
148
|
# APPLICATION_SECRET
|
191
149
|
# @return [RetrieveTokenStatusResponse Hash] response from the API call
|
192
150
|
def retrieve_token_status(authorization:)
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
# Prepare and execute HttpRequest.
|
205
|
-
_request = config.http_client.post(
|
206
|
-
_query_url,
|
207
|
-
headers: _headers
|
208
|
-
)
|
209
|
-
_response = execute_request(_request)
|
210
|
-
|
211
|
-
# Return appropriate response type.
|
212
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
213
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
214
|
-
ApiResponse.new(
|
215
|
-
_response, data: decoded, errors: _errors
|
216
|
-
)
|
151
|
+
new_api_call_builder
|
152
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
153
|
+
'/oauth2/token/status',
|
154
|
+
'default')
|
155
|
+
.header_param(new_parameter(authorization, key: 'Authorization'))
|
156
|
+
.header_param(new_parameter('application/json', key: 'accept')))
|
157
|
+
.response(new_response_handler
|
158
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
159
|
+
.is_api_response(true)
|
160
|
+
.convertor(ApiResponse.method(:create)))
|
161
|
+
.execute
|
217
162
|
end
|
218
163
|
end
|
219
164
|
end
|