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
|
# TransactionsApi
|
3
3
|
class TransactionsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Lists transactions for a particular location.
|
9
5
|
# Transactions include payment information from sales and exchanges and
|
10
6
|
# refund
|
@@ -39,41 +35,23 @@ module Square
|
|
39
35
|
sort_order: nil,
|
40
36
|
cursor: nil)
|
41
37
|
warn 'Endpoint list_transactions in TransactionsApi is deprecated'
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
_headers = {
|
60
|
-
'accept' => 'application/json'
|
61
|
-
}
|
62
|
-
|
63
|
-
# Prepare and execute HttpRequest.
|
64
|
-
_request = config.http_client.get(
|
65
|
-
_query_url,
|
66
|
-
headers: _headers
|
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(
|
75
|
-
_response, data: decoded, errors: _errors
|
76
|
-
)
|
38
|
+
new_api_call_builder
|
39
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
40
|
+
'/v2/locations/{location_id}/transactions',
|
41
|
+
'default')
|
42
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
43
|
+
.should_encode(true))
|
44
|
+
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
45
|
+
.query_param(new_parameter(end_time, key: 'end_time'))
|
46
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
47
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
48
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
49
|
+
.auth(Single.new('global')))
|
50
|
+
.response(new_response_handler
|
51
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
52
|
+
.is_api_response(true)
|
53
|
+
.convertor(ApiResponse.method(:create)))
|
54
|
+
.execute
|
77
55
|
end
|
78
56
|
|
79
57
|
# Retrieves details for a single transaction.
|
@@ -85,35 +63,21 @@ module Square
|
|
85
63
|
def retrieve_transaction(location_id:,
|
86
64
|
transaction_id:)
|
87
65
|
warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated'
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
# Prepare and execute HttpRequest.
|
104
|
-
_request = config.http_client.get(
|
105
|
-
_query_url,
|
106
|
-
headers: _headers
|
107
|
-
)
|
108
|
-
OAuth2.apply(config, _request)
|
109
|
-
_response = execute_request(_request)
|
110
|
-
|
111
|
-
# Return appropriate response type.
|
112
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
113
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
114
|
-
ApiResponse.new(
|
115
|
-
_response, data: decoded, errors: _errors
|
116
|
-
)
|
66
|
+
new_api_call_builder
|
67
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
68
|
+
'/v2/locations/{location_id}/transactions/{transaction_id}',
|
69
|
+
'default')
|
70
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
71
|
+
.should_encode(true))
|
72
|
+
.template_param(new_parameter(transaction_id, key: 'transaction_id')
|
73
|
+
.should_encode(true))
|
74
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
75
|
+
.auth(Single.new('global')))
|
76
|
+
.response(new_response_handler
|
77
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
78
|
+
.is_api_response(true)
|
79
|
+
.convertor(ApiResponse.method(:create)))
|
80
|
+
.execute
|
117
81
|
end
|
118
82
|
|
119
83
|
# Captures a transaction that was created with the
|
@@ -129,35 +93,21 @@ module Square
|
|
129
93
|
def capture_transaction(location_id:,
|
130
94
|
transaction_id:)
|
131
95
|
warn 'Endpoint capture_transaction in TransactionsApi is deprecated'
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
# Prepare and execute HttpRequest.
|
148
|
-
_request = config.http_client.post(
|
149
|
-
_query_url,
|
150
|
-
headers: _headers
|
151
|
-
)
|
152
|
-
OAuth2.apply(config, _request)
|
153
|
-
_response = execute_request(_request)
|
154
|
-
|
155
|
-
# Return appropriate response type.
|
156
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
157
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
158
|
-
ApiResponse.new(
|
159
|
-
_response, data: decoded, errors: _errors
|
160
|
-
)
|
96
|
+
new_api_call_builder
|
97
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
98
|
+
'/v2/locations/{location_id}/transactions/{transaction_id}/capture',
|
99
|
+
'default')
|
100
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
101
|
+
.should_encode(true))
|
102
|
+
.template_param(new_parameter(transaction_id, key: 'transaction_id')
|
103
|
+
.should_encode(true))
|
104
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
105
|
+
.auth(Single.new('global')))
|
106
|
+
.response(new_response_handler
|
107
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
108
|
+
.is_api_response(true)
|
109
|
+
.convertor(ApiResponse.method(:create)))
|
110
|
+
.execute
|
161
111
|
end
|
162
112
|
|
163
113
|
# Cancels a transaction that was created with the
|
@@ -173,35 +123,21 @@ module Square
|
|
173
123
|
def void_transaction(location_id:,
|
174
124
|
transaction_id:)
|
175
125
|
warn 'Endpoint void_transaction in TransactionsApi is deprecated'
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# Prepare and execute HttpRequest.
|
192
|
-
_request = config.http_client.post(
|
193
|
-
_query_url,
|
194
|
-
headers: _headers
|
195
|
-
)
|
196
|
-
OAuth2.apply(config, _request)
|
197
|
-
_response = execute_request(_request)
|
198
|
-
|
199
|
-
# Return appropriate response type.
|
200
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
201
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
202
|
-
ApiResponse.new(
|
203
|
-
_response, data: decoded, errors: _errors
|
204
|
-
)
|
126
|
+
new_api_call_builder
|
127
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
128
|
+
'/v2/locations/{location_id}/transactions/{transaction_id}/void',
|
129
|
+
'default')
|
130
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
131
|
+
.should_encode(true))
|
132
|
+
.template_param(new_parameter(transaction_id, key: 'transaction_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
|
205
141
|
end
|
206
142
|
end
|
207
143
|
end
|