square.rb 26.0.0.20221214 → 26.2.0.20230315
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- 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 +419 -0
- 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 +82 -46
- 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 +7 -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 +12 -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
|
# DevicesApi
|
3
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
4
|
# Lists all DeviceCodes associated with the merchant.
|
9
5
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
6
|
# a previous call to this endpoint. Provide this to retrieve the next set of
|
@@ -25,37 +21,21 @@ module Square
|
|
25
21
|
location_id: nil,
|
26
22
|
product_type: nil,
|
27
23
|
status: nil)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
44
|
-
|
45
|
-
# Prepare and execute HttpRequest.
|
46
|
-
_request = config.http_client.get(
|
47
|
-
_query_url,
|
48
|
-
headers: _headers
|
49
|
-
)
|
50
|
-
OAuth2.apply(config, _request)
|
51
|
-
_response = execute_request(_request)
|
52
|
-
|
53
|
-
# Return appropriate response type.
|
54
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
55
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
56
|
-
ApiResponse.new(
|
57
|
-
_response, data: decoded, errors: _errors
|
58
|
-
)
|
24
|
+
new_api_call_builder
|
25
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
26
|
+
'/v2/devices/codes',
|
27
|
+
'default')
|
28
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
29
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
30
|
+
.query_param(new_parameter(product_type, key: 'product_type'))
|
31
|
+
.query_param(new_parameter(status, key: 'status'))
|
32
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
33
|
+
.auth(Single.new('global')))
|
34
|
+
.response(new_response_handler
|
35
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
36
|
+
.is_api_response(true)
|
37
|
+
.convertor(ApiResponse.method(:create)))
|
38
|
+
.execute
|
59
39
|
end
|
60
40
|
|
61
41
|
# Creates a DeviceCode that can be used to login to a Square Terminal device
|
@@ -66,32 +46,20 @@ module Square
|
|
66
46
|
# object definition for field details.
|
67
47
|
# @return [CreateDeviceCodeResponse Hash] response from the API call
|
68
48
|
def create_device_code(body:)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
headers: _headers,
|
84
|
-
parameters: body.to_json
|
85
|
-
)
|
86
|
-
OAuth2.apply(config, _request)
|
87
|
-
_response = execute_request(_request)
|
88
|
-
|
89
|
-
# Return appropriate response type.
|
90
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
91
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
92
|
-
ApiResponse.new(
|
93
|
-
_response, data: decoded, errors: _errors
|
94
|
-
)
|
49
|
+
new_api_call_builder
|
50
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
51
|
+
'/v2/devices/codes',
|
52
|
+
'default')
|
53
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
54
|
+
.body_param(new_parameter(body))
|
55
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
56
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
57
|
+
.auth(Single.new('global')))
|
58
|
+
.response(new_response_handler
|
59
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
60
|
+
.is_api_response(true)
|
61
|
+
.convertor(ApiResponse.method(:create)))
|
62
|
+
.execute
|
95
63
|
end
|
96
64
|
|
97
65
|
# Retrieves DeviceCode with the associated ID.
|
@@ -99,34 +67,19 @@ module Square
|
|
99
67
|
# device code.
|
100
68
|
# @return [GetDeviceCodeResponse Hash] response from the API call
|
101
69
|
def get_device_code(id:)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
# Prepare and execute HttpRequest.
|
117
|
-
_request = config.http_client.get(
|
118
|
-
_query_url,
|
119
|
-
headers: _headers
|
120
|
-
)
|
121
|
-
OAuth2.apply(config, _request)
|
122
|
-
_response = execute_request(_request)
|
123
|
-
|
124
|
-
# Return appropriate response type.
|
125
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
126
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
127
|
-
ApiResponse.new(
|
128
|
-
_response, data: decoded, errors: _errors
|
129
|
-
)
|
70
|
+
new_api_call_builder
|
71
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
72
|
+
'/v2/devices/codes/{id}',
|
73
|
+
'default')
|
74
|
+
.template_param(new_parameter(id, key: 'id')
|
75
|
+
.should_encode(true))
|
76
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
77
|
+
.auth(Single.new('global')))
|
78
|
+
.response(new_response_handler
|
79
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
80
|
+
.is_api_response(true)
|
81
|
+
.convertor(ApiResponse.method(:create)))
|
82
|
+
.execute
|
130
83
|
end
|
131
84
|
end
|
132
85
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# DisputesApi
|
3
3
|
class DisputesApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Returns a list of disputes associated with a particular account.
|
9
5
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
6
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
@@ -21,36 +17,20 @@ module Square
|
|
21
17
|
def list_disputes(cursor: nil,
|
22
18
|
states: nil,
|
23
19
|
location_id: nil)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
# Prepare and execute HttpRequest.
|
41
|
-
_request = config.http_client.get(
|
42
|
-
_query_url,
|
43
|
-
headers: _headers
|
44
|
-
)
|
45
|
-
OAuth2.apply(config, _request)
|
46
|
-
_response = execute_request(_request)
|
47
|
-
|
48
|
-
# Return appropriate response type.
|
49
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
50
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
51
|
-
ApiResponse.new(
|
52
|
-
_response, data: decoded, errors: _errors
|
53
|
-
)
|
20
|
+
new_api_call_builder
|
21
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
22
|
+
'/v2/disputes',
|
23
|
+
'default')
|
24
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
25
|
+
.query_param(new_parameter(states, key: 'states'))
|
26
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
27
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
28
|
+
.auth(Single.new('global')))
|
29
|
+
.response(new_response_handler
|
30
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
31
|
+
.is_api_response(true)
|
32
|
+
.convertor(ApiResponse.method(:create)))
|
33
|
+
.execute
|
54
34
|
end
|
55
35
|
|
56
36
|
# Returns details about a specific dispute.
|
@@ -58,34 +38,19 @@ module Square
|
|
58
38
|
# want more details about.
|
59
39
|
# @return [RetrieveDisputeResponse Hash] response from the API call
|
60
40
|
def retrieve_dispute(dispute_id:)
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
# Prepare and execute HttpRequest.
|
76
|
-
_request = config.http_client.get(
|
77
|
-
_query_url,
|
78
|
-
headers: _headers
|
79
|
-
)
|
80
|
-
OAuth2.apply(config, _request)
|
81
|
-
_response = execute_request(_request)
|
82
|
-
|
83
|
-
# Return appropriate response type.
|
84
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
85
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
86
|
-
ApiResponse.new(
|
87
|
-
_response, data: decoded, errors: _errors
|
88
|
-
)
|
41
|
+
new_api_call_builder
|
42
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
43
|
+
'/v2/disputes/{dispute_id}',
|
44
|
+
'default')
|
45
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
46
|
+
.should_encode(true))
|
47
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
48
|
+
.auth(Single.new('global')))
|
49
|
+
.response(new_response_handler
|
50
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
51
|
+
.is_api_response(true)
|
52
|
+
.convertor(ApiResponse.method(:create)))
|
53
|
+
.execute
|
89
54
|
end
|
90
55
|
|
91
56
|
# Accepts the loss on a dispute. Square returns the disputed amount to the
|
@@ -98,34 +63,19 @@ module Square
|
|
98
63
|
# want to accept.
|
99
64
|
# @return [AcceptDisputeResponse Hash] response from the API call
|
100
65
|
def accept_dispute(dispute_id:)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
# Prepare and execute HttpRequest.
|
116
|
-
_request = config.http_client.post(
|
117
|
-
_query_url,
|
118
|
-
headers: _headers
|
119
|
-
)
|
120
|
-
OAuth2.apply(config, _request)
|
121
|
-
_response = execute_request(_request)
|
122
|
-
|
123
|
-
# Return appropriate response type.
|
124
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
125
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
126
|
-
ApiResponse.new(
|
127
|
-
_response, data: decoded, errors: _errors
|
128
|
-
)
|
66
|
+
new_api_call_builder
|
67
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
68
|
+
'/v2/disputes/{dispute_id}/accept',
|
69
|
+
'default')
|
70
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
71
|
+
.should_encode(true))
|
72
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
73
|
+
.auth(Single.new('global')))
|
74
|
+
.response(new_response_handler
|
75
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
76
|
+
.is_api_response(true)
|
77
|
+
.convertor(ApiResponse.method(:create)))
|
78
|
+
.execute
|
129
79
|
end
|
130
80
|
|
131
81
|
# Returns a list of evidence associated with a dispute.
|
@@ -138,38 +88,20 @@ module Square
|
|
138
88
|
# @return [ListDisputeEvidenceResponse Hash] response from the API call
|
139
89
|
def list_dispute_evidence(dispute_id:,
|
140
90
|
cursor: nil)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
_headers = {
|
156
|
-
'accept' => 'application/json'
|
157
|
-
}
|
158
|
-
|
159
|
-
# Prepare and execute HttpRequest.
|
160
|
-
_request = config.http_client.get(
|
161
|
-
_query_url,
|
162
|
-
headers: _headers
|
163
|
-
)
|
164
|
-
OAuth2.apply(config, _request)
|
165
|
-
_response = execute_request(_request)
|
166
|
-
|
167
|
-
# Return appropriate response type.
|
168
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
169
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
170
|
-
ApiResponse.new(
|
171
|
-
_response, data: decoded, errors: _errors
|
172
|
-
)
|
91
|
+
new_api_call_builder
|
92
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
93
|
+
'/v2/disputes/{dispute_id}/evidence',
|
94
|
+
'default')
|
95
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
96
|
+
.should_encode(true))
|
97
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
98
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
99
|
+
.auth(Single.new('global')))
|
100
|
+
.response(new_response_handler
|
101
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
102
|
+
.is_api_response(true)
|
103
|
+
.convertor(ApiResponse.method(:create)))
|
104
|
+
.execute
|
173
105
|
end
|
174
106
|
|
175
107
|
# Uploads a file to use as evidence in a dispute challenge. The endpoint
|
@@ -185,56 +117,23 @@ module Square
|
|
185
117
|
def create_dispute_evidence_file(dispute_id:,
|
186
118
|
request: nil,
|
187
119
|
image_file: nil)
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
# Prepare headers.
|
206
|
-
_headers = {
|
207
|
-
'accept' => 'application/json'
|
208
|
-
}
|
209
|
-
|
210
|
-
# Prepare form parameters.
|
211
|
-
_parameters = {
|
212
|
-
'request' => Faraday::UploadIO.new(
|
213
|
-
StringIO.new(request.to_json),
|
214
|
-
'application/json'
|
215
|
-
),
|
216
|
-
'image_file' => Faraday::UploadIO.new(
|
217
|
-
image_file_wrapper,
|
218
|
-
image_file_content_type
|
219
|
-
)
|
220
|
-
}
|
221
|
-
_parameters = APIHelper.form_encode_parameters(_parameters)
|
222
|
-
|
223
|
-
# Prepare and execute HttpRequest.
|
224
|
-
_request = config.http_client.post(
|
225
|
-
_query_url,
|
226
|
-
headers: _headers,
|
227
|
-
parameters: _parameters
|
228
|
-
)
|
229
|
-
OAuth2.apply(config, _request)
|
230
|
-
_response = execute_request(_request)
|
231
|
-
|
232
|
-
# Return appropriate response type.
|
233
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
234
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
235
|
-
ApiResponse.new(
|
236
|
-
_response, data: decoded, errors: _errors
|
237
|
-
)
|
120
|
+
new_api_call_builder
|
121
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
122
|
+
'/v2/disputes/{dispute_id}/evidence-files',
|
123
|
+
'default')
|
124
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
125
|
+
.should_encode(true))
|
126
|
+
.multipart_param(new_parameter(StringIO.new(request.to_json), key: 'request')
|
127
|
+
.default_content_type('application/json; charset=utf-8'))
|
128
|
+
.multipart_param(new_parameter(image_file, key: 'image_file')
|
129
|
+
.default_content_type('image/jpeg'))
|
130
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
131
|
+
.auth(Single.new('global')))
|
132
|
+
.response(new_response_handler
|
133
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
134
|
+
.is_api_response(true)
|
135
|
+
.convertor(ApiResponse.method(:create)))
|
136
|
+
.execute
|
238
137
|
end
|
239
138
|
|
240
139
|
# Uploads text to use as evidence for a dispute challenge.
|
@@ -246,36 +145,22 @@ module Square
|
|
246
145
|
# @return [CreateDisputeEvidenceTextResponse Hash] response from the API call
|
247
146
|
def create_dispute_evidence_text(dispute_id:,
|
248
147
|
body:)
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
_request = config.http_client.post(
|
266
|
-
_query_url,
|
267
|
-
headers: _headers,
|
268
|
-
parameters: body.to_json
|
269
|
-
)
|
270
|
-
OAuth2.apply(config, _request)
|
271
|
-
_response = execute_request(_request)
|
272
|
-
|
273
|
-
# Return appropriate response type.
|
274
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
275
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
276
|
-
ApiResponse.new(
|
277
|
-
_response, data: decoded, errors: _errors
|
278
|
-
)
|
148
|
+
new_api_call_builder
|
149
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
150
|
+
'/v2/disputes/{dispute_id}/evidence-text',
|
151
|
+
'default')
|
152
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
153
|
+
.should_encode(true))
|
154
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
155
|
+
.body_param(new_parameter(body))
|
156
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
157
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
158
|
+
.auth(Single.new('global')))
|
159
|
+
.response(new_response_handler
|
160
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
161
|
+
.is_api_response(true)
|
162
|
+
.convertor(ApiResponse.method(:create)))
|
163
|
+
.execute
|
279
164
|
end
|
280
165
|
|
281
166
|
# Removes specified evidence from a dispute.
|
@@ -287,35 +172,21 @@ module Square
|
|
287
172
|
# @return [DeleteDisputeEvidenceResponse Hash] response from the API call
|
288
173
|
def delete_dispute_evidence(dispute_id:,
|
289
174
|
evidence_id:)
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
# Prepare and execute HttpRequest.
|
306
|
-
_request = config.http_client.delete(
|
307
|
-
_query_url,
|
308
|
-
headers: _headers
|
309
|
-
)
|
310
|
-
OAuth2.apply(config, _request)
|
311
|
-
_response = execute_request(_request)
|
312
|
-
|
313
|
-
# Return appropriate response type.
|
314
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
315
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
316
|
-
ApiResponse.new(
|
317
|
-
_response, data: decoded, errors: _errors
|
318
|
-
)
|
175
|
+
new_api_call_builder
|
176
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
177
|
+
'/v2/disputes/{dispute_id}/evidence/{evidence_id}',
|
178
|
+
'default')
|
179
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
180
|
+
.should_encode(true))
|
181
|
+
.template_param(new_parameter(evidence_id, key: 'evidence_id')
|
182
|
+
.should_encode(true))
|
183
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
184
|
+
.auth(Single.new('global')))
|
185
|
+
.response(new_response_handler
|
186
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
187
|
+
.is_api_response(true)
|
188
|
+
.convertor(ApiResponse.method(:create)))
|
189
|
+
.execute
|
319
190
|
end
|
320
191
|
|
321
192
|
# Returns the metadata for the evidence specified in the request URL path.
|
@@ -328,35 +199,21 @@ module Square
|
|
328
199
|
# @return [RetrieveDisputeEvidenceResponse Hash] response from the API call
|
329
200
|
def retrieve_dispute_evidence(dispute_id:,
|
330
201
|
evidence_id:)
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
# Prepare and execute HttpRequest.
|
347
|
-
_request = config.http_client.get(
|
348
|
-
_query_url,
|
349
|
-
headers: _headers
|
350
|
-
)
|
351
|
-
OAuth2.apply(config, _request)
|
352
|
-
_response = execute_request(_request)
|
353
|
-
|
354
|
-
# Return appropriate response type.
|
355
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
356
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
357
|
-
ApiResponse.new(
|
358
|
-
_response, data: decoded, errors: _errors
|
359
|
-
)
|
202
|
+
new_api_call_builder
|
203
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
204
|
+
'/v2/disputes/{dispute_id}/evidence/{evidence_id}',
|
205
|
+
'default')
|
206
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
207
|
+
.should_encode(true))
|
208
|
+
.template_param(new_parameter(evidence_id, key: 'evidence_id')
|
209
|
+
.should_encode(true))
|
210
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
211
|
+
.auth(Single.new('global')))
|
212
|
+
.response(new_response_handler
|
213
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
214
|
+
.is_api_response(true)
|
215
|
+
.convertor(ApiResponse.method(:create)))
|
216
|
+
.execute
|
360
217
|
end
|
361
218
|
|
362
219
|
# Submits evidence to the cardholder's bank.
|
@@ -372,34 +229,19 @@ module Square
|
|
372
229
|
# which you want to submit evidence.
|
373
230
|
# @return [SubmitEvidenceResponse Hash] response from the API call
|
374
231
|
def submit_evidence(dispute_id:)
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
# Prepare and execute HttpRequest.
|
390
|
-
_request = config.http_client.post(
|
391
|
-
_query_url,
|
392
|
-
headers: _headers
|
393
|
-
)
|
394
|
-
OAuth2.apply(config, _request)
|
395
|
-
_response = execute_request(_request)
|
396
|
-
|
397
|
-
# Return appropriate response type.
|
398
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
399
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
400
|
-
ApiResponse.new(
|
401
|
-
_response, data: decoded, errors: _errors
|
402
|
-
)
|
232
|
+
new_api_call_builder
|
233
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
234
|
+
'/v2/disputes/{dispute_id}/submit-evidence',
|
235
|
+
'default')
|
236
|
+
.template_param(new_parameter(dispute_id, key: 'dispute_id')
|
237
|
+
.should_encode(true))
|
238
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
239
|
+
.auth(Single.new('global')))
|
240
|
+
.response(new_response_handler
|
241
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
242
|
+
.is_api_response(true)
|
243
|
+
.convertor(ApiResponse.method(:create)))
|
244
|
+
.execute
|
403
245
|
end
|
404
246
|
end
|
405
247
|
end
|