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
|
# 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
|
@@ -51,41 +47,25 @@ module Square
|
|
51
47
|
status: nil,
|
52
48
|
source_type: nil,
|
53
49
|
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
|
-
)
|
50
|
+
new_api_call_builder
|
51
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
52
|
+
'/v2/refunds',
|
53
|
+
'default')
|
54
|
+
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
55
|
+
.query_param(new_parameter(end_time, key: 'end_time'))
|
56
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
57
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
58
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
59
|
+
.query_param(new_parameter(status, key: 'status'))
|
60
|
+
.query_param(new_parameter(source_type, key: 'source_type'))
|
61
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
62
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
63
|
+
.auth(Single.new('global')))
|
64
|
+
.response(new_response_handler
|
65
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
66
|
+
.is_api_response(true)
|
67
|
+
.convertor(ApiResponse.method(:create)))
|
68
|
+
.execute
|
89
69
|
end
|
90
70
|
|
91
71
|
# Refunds a payment. You can refund the entire payment amount or a
|
@@ -100,32 +80,20 @@ module Square
|
|
100
80
|
# object definition for field details.
|
101
81
|
# @return [RefundPaymentResponse Hash] response from the API call
|
102
82
|
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
|
-
)
|
83
|
+
new_api_call_builder
|
84
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
85
|
+
'/v2/refunds',
|
86
|
+
'default')
|
87
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
88
|
+
.body_param(new_parameter(body))
|
89
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
90
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
91
|
+
.auth(Single.new('global')))
|
92
|
+
.response(new_response_handler
|
93
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
94
|
+
.is_api_response(true)
|
95
|
+
.convertor(ApiResponse.method(:create)))
|
96
|
+
.execute
|
129
97
|
end
|
130
98
|
|
131
99
|
# Retrieves a specific refund using the `refund_id`.
|
@@ -133,34 +101,19 @@ module Square
|
|
133
101
|
# desired `PaymentRefund`.
|
134
102
|
# @return [GetPaymentRefundResponse Hash] response from the API call
|
135
103
|
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
|
-
)
|
104
|
+
new_api_call_builder
|
105
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
106
|
+
'/v2/refunds/{refund_id}',
|
107
|
+
'default')
|
108
|
+
.template_param(new_parameter(refund_id, key: 'refund_id')
|
109
|
+
.should_encode(true))
|
110
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
111
|
+
.auth(Single.new('global')))
|
112
|
+
.response(new_response_handler
|
113
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
114
|
+
.is_api_response(true)
|
115
|
+
.convertor(ApiResponse.method(:create)))
|
116
|
+
.execute
|
164
117
|
end
|
165
118
|
end
|
166
119
|
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
|