square.rb 26.1.0.20230119 → 27.0.0.20230419
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/README.md +4 -0
- 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 +171 -336
- data/lib/square/api/bookings_api.rb +140 -263
- data/lib/square/api/cards_api.rb +58 -120
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +200 -426
- data/lib/square/api/checkout_api.rb +86 -176
- data/lib/square/api/customer_custom_attributes_api.rb +157 -310
- 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 +132 -290
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +34 -66
- data/lib/square/api/gift_cards_api.rb +109 -207
- data/lib/square/api/inventory_api.rb +204 -391
- data/lib/square/api/invoices_api.rb +121 -240
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +173 -338
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +283 -535
- 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 +174 -339
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +118 -217
- data/lib/square/api/payouts_api.rb +54 -107
- data/lib/square/api/refunds_api.rb +59 -104
- 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 +64 -128
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +100 -193
- data/lib/square/api/webhook_subscriptions_api.rb +124 -244
- 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,35 +1,33 @@
|
|
1
1
|
module Square
|
2
2
|
# RefundsApi
|
3
3
|
class RefundsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Retrieves a list of refunds for the account making the request.
|
9
5
|
# Results are eventually consistent, and new refunds or changes to refunds
|
10
6
|
# might take several
|
11
7
|
# seconds to appear.
|
12
8
|
# The maximum results per page is 100.
|
13
|
-
# @param [String] begin_time Optional parameter:
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
9
|
+
# @param [String] begin_time Optional parameter: Indicates the start of the
|
10
|
+
# time range to retrieve each PaymentRefund` for, in RFC 3339 format. The
|
11
|
+
# range is determined using the `created_at` field for each `PaymentRefund`.
|
12
|
+
# Default: The current time minus one year.
|
13
|
+
# @param [String] end_time Optional parameter: Indicates the end of the time
|
14
|
+
# range to retrieve each `PaymentRefund` for, in RFC 3339 format. The
|
15
|
+
# range is determined using the `created_at` field for each `PaymentRefund`.
|
16
|
+
# Default: The current time.
|
19
17
|
# @param [String] sort_order Optional parameter: The order in which results
|
20
|
-
# are listed
|
21
|
-
# (default).
|
18
|
+
# are listed by `PaymentRefund.created_at`: - `ASC` - Oldest to newest. -
|
19
|
+
# `DESC` - Newest to oldest (default).
|
22
20
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
23
21
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
24
22
|
# set of results for the original query. For more information, see
|
25
|
-
# [Pagination](https://developer.squareup.com/docs/basics/
|
26
|
-
# .
|
23
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
24
|
+
# atterns/pagination).
|
27
25
|
# @param [String] location_id Optional parameter: Limit results to the
|
28
26
|
# location supplied. By default, results are returned for all locations
|
29
27
|
# associated with the seller.
|
30
28
|
# @param [String] status Optional parameter: If provided, only refunds with
|
31
29
|
# the given status are returned. For a list of refund status values, see
|
32
|
-
# [PaymentRefund](
|
30
|
+
# [PaymentRefund](entity:PaymentRefund). Default: If omitted, refunds are
|
33
31
|
# returned regardless of their status.
|
34
32
|
# @param [String] source_type Optional parameter: If provided, only returns
|
35
33
|
# refunds whose payments have the indicated source type. Current values
|
@@ -51,41 +49,25 @@ module Square
|
|
51
49
|
status: nil,
|
52
50
|
source_type: nil,
|
53
51
|
limit: nil)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
)
|
52
|
+
new_api_call_builder
|
53
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
54
|
+
'/v2/refunds',
|
55
|
+
'default')
|
56
|
+
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
57
|
+
.query_param(new_parameter(end_time, key: 'end_time'))
|
58
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
59
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
60
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
61
|
+
.query_param(new_parameter(status, key: 'status'))
|
62
|
+
.query_param(new_parameter(source_type, key: 'source_type'))
|
63
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
64
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
65
|
+
.auth(Single.new('global')))
|
66
|
+
.response(new_response_handler
|
67
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
68
|
+
.is_api_response(true)
|
69
|
+
.convertor(ApiResponse.method(:create)))
|
70
|
+
.execute
|
89
71
|
end
|
90
72
|
|
91
73
|
# Refunds a payment. You can refund the entire payment amount or a
|
@@ -100,32 +82,20 @@ module Square
|
|
100
82
|
# object definition for field details.
|
101
83
|
# @return [RefundPaymentResponse Hash] response from the API call
|
102
84
|
def refund_payment(body:)
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
headers: _headers,
|
118
|
-
parameters: body.to_json
|
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
|
-
)
|
85
|
+
new_api_call_builder
|
86
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
87
|
+
'/v2/refunds',
|
88
|
+
'default')
|
89
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
90
|
+
.body_param(new_parameter(body))
|
91
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
92
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
93
|
+
.auth(Single.new('global')))
|
94
|
+
.response(new_response_handler
|
95
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
96
|
+
.is_api_response(true)
|
97
|
+
.convertor(ApiResponse.method(:create)))
|
98
|
+
.execute
|
129
99
|
end
|
130
100
|
|
131
101
|
# Retrieves a specific refund using the `refund_id`.
|
@@ -133,34 +103,19 @@ module Square
|
|
133
103
|
# desired `PaymentRefund`.
|
134
104
|
# @return [GetPaymentRefundResponse Hash] response from the API call
|
135
105
|
def get_payment_refund(refund_id:)
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
# Prepare and execute HttpRequest.
|
151
|
-
_request = config.http_client.get(
|
152
|
-
_query_url,
|
153
|
-
headers: _headers
|
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(
|
162
|
-
_response, data: decoded, errors: _errors
|
163
|
-
)
|
106
|
+
new_api_call_builder
|
107
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
108
|
+
'/v2/refunds/{refund_id}',
|
109
|
+
'default')
|
110
|
+
.template_param(new_parameter(refund_id, key: 'refund_id')
|
111
|
+
.should_encode(true))
|
112
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
113
|
+
.auth(Single.new('global')))
|
114
|
+
.response(new_response_handler
|
115
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
116
|
+
.is_api_response(true)
|
117
|
+
.convertor(ApiResponse.method(:create)))
|
118
|
+
.execute
|
164
119
|
end
|
165
120
|
end
|
166
121
|
end
|
data/lib/square/api/sites_api.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# SitesApi
|
3
3
|
class SitesApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Lists the Square Online sites that belong to a seller. Sites are listed in
|
9
5
|
# descending order by the `created_at` date.
|
10
6
|
# __Note:__ Square Online APIs are publicly available as part of an early
|
@@ -14,30 +10,17 @@ module Square
|
|
14
10
|
# for-square-online-apis).
|
15
11
|
# @return [ListSitesResponse Hash] response from the API call
|
16
12
|
def list_sites
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
_request = config.http_client.get(
|
29
|
-
_query_url,
|
30
|
-
headers: _headers
|
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(
|
39
|
-
_response, data: decoded, errors: _errors
|
40
|
-
)
|
13
|
+
new_api_call_builder
|
14
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
15
|
+
'/v2/sites',
|
16
|
+
'default')
|
17
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
18
|
+
.auth(Single.new('global')))
|
19
|
+
.response(new_response_handler
|
20
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
21
|
+
.is_api_response(true)
|
22
|
+
.convertor(ApiResponse.method(:create)))
|
23
|
+
.execute
|
41
24
|
end
|
42
25
|
end
|
43
26
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# SnippetsApi
|
3
3
|
class SnippetsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Removes your snippet from a Square Online site.
|
9
5
|
# You can call [ListSites]($e/Sites/ListSites) to get the IDs of the sites
|
10
6
|
# that belong to a seller.
|
@@ -17,34 +13,19 @@ module Square
|
|
17
13
|
# contains the snippet.
|
18
14
|
# @return [DeleteSnippetResponse Hash] response from the API call
|
19
15
|
def delete_snippet(site_id:)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
# Prepare and execute HttpRequest.
|
35
|
-
_request = config.http_client.delete(
|
36
|
-
_query_url,
|
37
|
-
headers: _headers
|
38
|
-
)
|
39
|
-
OAuth2.apply(config, _request)
|
40
|
-
_response = execute_request(_request)
|
41
|
-
|
42
|
-
# Return appropriate response type.
|
43
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
44
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
45
|
-
ApiResponse.new(
|
46
|
-
_response, data: decoded, errors: _errors
|
47
|
-
)
|
16
|
+
new_api_call_builder
|
17
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
18
|
+
'/v2/sites/{site_id}/snippet',
|
19
|
+
'default')
|
20
|
+
.template_param(new_parameter(site_id, key: 'site_id')
|
21
|
+
.should_encode(true))
|
22
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
23
|
+
.auth(Single.new('global')))
|
24
|
+
.response(new_response_handler
|
25
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
26
|
+
.is_api_response(true)
|
27
|
+
.convertor(ApiResponse.method(:create)))
|
28
|
+
.execute
|
48
29
|
end
|
49
30
|
|
50
31
|
# Retrieves your snippet from a Square Online site. A site can contain
|
@@ -61,34 +42,19 @@ module Square
|
|
61
42
|
# contains the snippet.
|
62
43
|
# @return [RetrieveSnippetResponse Hash] response from the API call
|
63
44
|
def retrieve_snippet(site_id:)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
# Prepare and execute HttpRequest.
|
79
|
-
_request = config.http_client.get(
|
80
|
-
_query_url,
|
81
|
-
headers: _headers
|
82
|
-
)
|
83
|
-
OAuth2.apply(config, _request)
|
84
|
-
_response = execute_request(_request)
|
85
|
-
|
86
|
-
# Return appropriate response type.
|
87
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
88
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
89
|
-
ApiResponse.new(
|
90
|
-
_response, data: decoded, errors: _errors
|
91
|
-
)
|
45
|
+
new_api_call_builder
|
46
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
47
|
+
'/v2/sites/{site_id}/snippet',
|
48
|
+
'default')
|
49
|
+
.template_param(new_parameter(site_id, key: 'site_id')
|
50
|
+
.should_encode(true))
|
51
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
52
|
+
.auth(Single.new('global')))
|
53
|
+
.response(new_response_handler
|
54
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
55
|
+
.is_api_response(true)
|
56
|
+
.convertor(ApiResponse.method(:create)))
|
57
|
+
.execute
|
92
58
|
end
|
93
59
|
|
94
60
|
# Adds a snippet to a Square Online site or updates the existing snippet on
|
@@ -111,36 +77,22 @@ module Square
|
|
111
77
|
# @return [UpsertSnippetResponse Hash] response from the API call
|
112
78
|
def upsert_snippet(site_id:,
|
113
79
|
body:)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
_request = config.http_client.post(
|
131
|
-
_query_url,
|
132
|
-
headers: _headers,
|
133
|
-
parameters: body.to_json
|
134
|
-
)
|
135
|
-
OAuth2.apply(config, _request)
|
136
|
-
_response = execute_request(_request)
|
137
|
-
|
138
|
-
# Return appropriate response type.
|
139
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
140
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
141
|
-
ApiResponse.new(
|
142
|
-
_response, data: decoded, errors: _errors
|
143
|
-
)
|
80
|
+
new_api_call_builder
|
81
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
82
|
+
'/v2/sites/{site_id}/snippet',
|
83
|
+
'default')
|
84
|
+
.template_param(new_parameter(site_id, key: 'site_id')
|
85
|
+
.should_encode(true))
|
86
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
87
|
+
.body_param(new_parameter(body))
|
88
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
89
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
90
|
+
.auth(Single.new('global')))
|
91
|
+
.response(new_response_handler
|
92
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
93
|
+
.is_api_response(true)
|
94
|
+
.convertor(ApiResponse.method(:create)))
|
95
|
+
.execute
|
144
96
|
end
|
145
97
|
end
|
146
98
|
end
|