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
data/lib/square/api/cards_api.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# CardsApi
|
3
3
|
class CardsApi < 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 cards owned by the account making the request.
|
9
5
|
# A max of 25 cards will be returned.
|
10
6
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
@@ -29,38 +25,22 @@ module Square
|
|
29
25
|
include_disabled: false,
|
30
26
|
reference_id: nil,
|
31
27
|
sort_order: nil)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
}
|
49
|
-
|
50
|
-
# Prepare and execute HttpRequest.
|
51
|
-
_request = config.http_client.get(
|
52
|
-
_query_url,
|
53
|
-
headers: _headers
|
54
|
-
)
|
55
|
-
OAuth2.apply(config, _request)
|
56
|
-
_response = execute_request(_request)
|
57
|
-
|
58
|
-
# Return appropriate response type.
|
59
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
60
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
61
|
-
ApiResponse.new(
|
62
|
-
_response, data: decoded, errors: _errors
|
63
|
-
)
|
28
|
+
new_api_call_builder
|
29
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
30
|
+
'/v2/cards',
|
31
|
+
'default')
|
32
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
33
|
+
.query_param(new_parameter(customer_id, key: 'customer_id'))
|
34
|
+
.query_param(new_parameter(include_disabled, key: 'include_disabled'))
|
35
|
+
.query_param(new_parameter(reference_id, key: 'reference_id'))
|
36
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
37
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
38
|
+
.auth(Single.new('global')))
|
39
|
+
.response(new_response_handler
|
40
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
41
|
+
.is_api_response(true)
|
42
|
+
.convertor(ApiResponse.method(:create)))
|
43
|
+
.execute
|
64
44
|
end
|
65
45
|
|
66
46
|
# Adds a card on file to an existing merchant.
|
@@ -69,32 +49,20 @@ module Square
|
|
69
49
|
# definition for field details.
|
70
50
|
# @return [CreateCardResponse Hash] response from the API call
|
71
51
|
def create_card(body:)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
headers: _headers,
|
87
|
-
parameters: body.to_json
|
88
|
-
)
|
89
|
-
OAuth2.apply(config, _request)
|
90
|
-
_response = execute_request(_request)
|
91
|
-
|
92
|
-
# Return appropriate response type.
|
93
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
94
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
95
|
-
ApiResponse.new(
|
96
|
-
_response, data: decoded, errors: _errors
|
97
|
-
)
|
52
|
+
new_api_call_builder
|
53
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
54
|
+
'/v2/cards',
|
55
|
+
'default')
|
56
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
57
|
+
.body_param(new_parameter(body))
|
58
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
59
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
60
|
+
.auth(Single.new('global')))
|
61
|
+
.response(new_response_handler
|
62
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
63
|
+
.is_api_response(true)
|
64
|
+
.convertor(ApiResponse.method(:create)))
|
65
|
+
.execute
|
98
66
|
end
|
99
67
|
|
100
68
|
# Retrieves details for a specific Card.
|
@@ -102,34 +70,19 @@ module Square
|
|
102
70
|
# Card.
|
103
71
|
# @return [RetrieveCardResponse Hash] response from the API call
|
104
72
|
def retrieve_card(card_id:)
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
# Prepare and execute HttpRequest.
|
120
|
-
_request = config.http_client.get(
|
121
|
-
_query_url,
|
122
|
-
headers: _headers
|
123
|
-
)
|
124
|
-
OAuth2.apply(config, _request)
|
125
|
-
_response = execute_request(_request)
|
126
|
-
|
127
|
-
# Return appropriate response type.
|
128
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
129
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
130
|
-
ApiResponse.new(
|
131
|
-
_response, data: decoded, errors: _errors
|
132
|
-
)
|
73
|
+
new_api_call_builder
|
74
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
75
|
+
'/v2/cards/{card_id}',
|
76
|
+
'default')
|
77
|
+
.template_param(new_parameter(card_id, key: 'card_id')
|
78
|
+
.should_encode(true))
|
79
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
80
|
+
.auth(Single.new('global')))
|
81
|
+
.response(new_response_handler
|
82
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
83
|
+
.is_api_response(true)
|
84
|
+
.convertor(ApiResponse.method(:create)))
|
85
|
+
.execute
|
133
86
|
end
|
134
87
|
|
135
88
|
# Disables the card, preventing any further updates or charges.
|
@@ -138,34 +91,19 @@ module Square
|
|
138
91
|
# Card.
|
139
92
|
# @return [DisableCardResponse Hash] response from the API call
|
140
93
|
def disable_card(card_id:)
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
# Prepare and execute HttpRequest.
|
156
|
-
_request = config.http_client.post(
|
157
|
-
_query_url,
|
158
|
-
headers: _headers
|
159
|
-
)
|
160
|
-
OAuth2.apply(config, _request)
|
161
|
-
_response = execute_request(_request)
|
162
|
-
|
163
|
-
# Return appropriate response type.
|
164
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
165
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
166
|
-
ApiResponse.new(
|
167
|
-
_response, data: decoded, errors: _errors
|
168
|
-
)
|
94
|
+
new_api_call_builder
|
95
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
96
|
+
'/v2/cards/{card_id}/disable',
|
97
|
+
'default')
|
98
|
+
.template_param(new_parameter(card_id, key: 'card_id')
|
99
|
+
.should_encode(true))
|
100
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
101
|
+
.auth(Single.new('global')))
|
102
|
+
.response(new_response_handler
|
103
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
104
|
+
.is_api_response(true)
|
105
|
+
.convertor(ApiResponse.method(:create)))
|
106
|
+
.execute
|
169
107
|
end
|
170
108
|
end
|
171
109
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# CashDrawersApi
|
3
3
|
class CashDrawersApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Provides the details for all of the cash drawer shifts for a location
|
9
5
|
# in a date range.
|
10
6
|
# @param [String] location_id Required parameter: The ID of the location to
|
@@ -27,39 +23,23 @@ module Square
|
|
27
23
|
end_time: nil,
|
28
24
|
limit: nil,
|
29
25
|
cursor: nil)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
48
|
-
|
49
|
-
# Prepare and execute HttpRequest.
|
50
|
-
_request = config.http_client.get(
|
51
|
-
_query_url,
|
52
|
-
headers: _headers
|
53
|
-
)
|
54
|
-
OAuth2.apply(config, _request)
|
55
|
-
_response = execute_request(_request)
|
56
|
-
|
57
|
-
# Return appropriate response type.
|
58
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
59
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
60
|
-
ApiResponse.new(
|
61
|
-
_response, data: decoded, errors: _errors
|
62
|
-
)
|
26
|
+
new_api_call_builder
|
27
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
28
|
+
'/v2/cash-drawers/shifts',
|
29
|
+
'default')
|
30
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
31
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
32
|
+
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
33
|
+
.query_param(new_parameter(end_time, key: 'end_time'))
|
34
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
35
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
36
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
37
|
+
.auth(Single.new('global')))
|
38
|
+
.response(new_response_handler
|
39
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
40
|
+
.is_api_response(true)
|
41
|
+
.convertor(ApiResponse.method(:create)))
|
42
|
+
.execute
|
63
43
|
end
|
64
44
|
|
65
45
|
# Provides the summary details for a single cash drawer shift. See
|
@@ -71,38 +51,20 @@ module Square
|
|
71
51
|
# @return [RetrieveCashDrawerShiftResponse Hash] response from the API call
|
72
52
|
def retrieve_cash_drawer_shift(location_id:,
|
73
53
|
shift_id:)
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
_headers = {
|
89
|
-
'accept' => 'application/json'
|
90
|
-
}
|
91
|
-
|
92
|
-
# Prepare and execute HttpRequest.
|
93
|
-
_request = config.http_client.get(
|
94
|
-
_query_url,
|
95
|
-
headers: _headers
|
96
|
-
)
|
97
|
-
OAuth2.apply(config, _request)
|
98
|
-
_response = execute_request(_request)
|
99
|
-
|
100
|
-
# Return appropriate response type.
|
101
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
102
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
103
|
-
ApiResponse.new(
|
104
|
-
_response, data: decoded, errors: _errors
|
105
|
-
)
|
54
|
+
new_api_call_builder
|
55
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
56
|
+
'/v2/cash-drawers/shifts/{shift_id}',
|
57
|
+
'default')
|
58
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
59
|
+
.template_param(new_parameter(shift_id, key: 'shift_id')
|
60
|
+
.should_encode(true))
|
61
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
62
|
+
.auth(Single.new('global')))
|
63
|
+
.response(new_response_handler
|
64
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
65
|
+
.is_api_response(true)
|
66
|
+
.convertor(ApiResponse.method(:create)))
|
67
|
+
.execute
|
106
68
|
end
|
107
69
|
|
108
70
|
# Provides a paginated list of events for a single cash drawer shift.
|
@@ -118,40 +80,22 @@ module Square
|
|
118
80
|
shift_id:,
|
119
81
|
limit: nil,
|
120
82
|
cursor: nil)
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
_headers = {
|
138
|
-
'accept' => 'application/json'
|
139
|
-
}
|
140
|
-
|
141
|
-
# Prepare and execute HttpRequest.
|
142
|
-
_request = config.http_client.get(
|
143
|
-
_query_url,
|
144
|
-
headers: _headers
|
145
|
-
)
|
146
|
-
OAuth2.apply(config, _request)
|
147
|
-
_response = execute_request(_request)
|
148
|
-
|
149
|
-
# Return appropriate response type.
|
150
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
151
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
152
|
-
ApiResponse.new(
|
153
|
-
_response, data: decoded, errors: _errors
|
154
|
-
)
|
83
|
+
new_api_call_builder
|
84
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
85
|
+
'/v2/cash-drawers/shifts/{shift_id}/events',
|
86
|
+
'default')
|
87
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
88
|
+
.template_param(new_parameter(shift_id, key: 'shift_id')
|
89
|
+
.should_encode(true))
|
90
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
91
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
92
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
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
|
155
99
|
end
|
156
100
|
end
|
157
101
|
end
|