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,39 +1,22 @@
|
|
1
1
|
module Square
|
2
2
|
# LocationsApi
|
3
3
|
class LocationsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Provides details about all of the seller's
|
9
5
|
# [locations](https://developer.squareup.com/docs/locations-api),
|
10
6
|
# including those with an inactive status.
|
11
7
|
# @return [ListLocationsResponse Hash] response from the API call
|
12
8
|
def list_locations
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
_request = config.http_client.get(
|
25
|
-
_query_url,
|
26
|
-
headers: _headers
|
27
|
-
)
|
28
|
-
OAuth2.apply(config, _request)
|
29
|
-
_response = execute_request(_request)
|
30
|
-
|
31
|
-
# Return appropriate response type.
|
32
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
33
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
34
|
-
ApiResponse.new(
|
35
|
-
_response, data: decoded, errors: _errors
|
36
|
-
)
|
9
|
+
new_api_call_builder
|
10
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
11
|
+
'/v2/locations',
|
12
|
+
'default')
|
13
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
14
|
+
.auth(Single.new('global')))
|
15
|
+
.response(new_response_handler
|
16
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
17
|
+
.is_api_response(true)
|
18
|
+
.convertor(ApiResponse.method(:create)))
|
19
|
+
.execute
|
37
20
|
end
|
38
21
|
|
39
22
|
# Creates a [location](https://developer.squareup.com/docs/locations-api).
|
@@ -51,32 +34,20 @@ module Square
|
|
51
34
|
# object definition for field details.
|
52
35
|
# @return [CreateLocationResponse Hash] response from the API call
|
53
36
|
def create_location(body:)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
headers: _headers,
|
69
|
-
parameters: body.to_json
|
70
|
-
)
|
71
|
-
OAuth2.apply(config, _request)
|
72
|
-
_response = execute_request(_request)
|
73
|
-
|
74
|
-
# Return appropriate response type.
|
75
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
76
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
77
|
-
ApiResponse.new(
|
78
|
-
_response, data: decoded, errors: _errors
|
79
|
-
)
|
37
|
+
new_api_call_builder
|
38
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
39
|
+
'/v2/locations',
|
40
|
+
'default')
|
41
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
42
|
+
.body_param(new_parameter(body))
|
43
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
44
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
45
|
+
.auth(Single.new('global')))
|
46
|
+
.response(new_response_handler
|
47
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
48
|
+
.is_api_response(true)
|
49
|
+
.convertor(ApiResponse.method(:create)))
|
50
|
+
.execute
|
80
51
|
end
|
81
52
|
|
82
53
|
# Retrieves details of a single location. Specify "main"
|
@@ -87,34 +58,19 @@ module Square
|
|
87
58
|
# retrieve. Specify the string "main" to return the main location.
|
88
59
|
# @return [RetrieveLocationResponse Hash] response from the API call
|
89
60
|
def retrieve_location(location_id:)
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
# Prepare and execute HttpRequest.
|
105
|
-
_request = config.http_client.get(
|
106
|
-
_query_url,
|
107
|
-
headers: _headers
|
108
|
-
)
|
109
|
-
OAuth2.apply(config, _request)
|
110
|
-
_response = execute_request(_request)
|
111
|
-
|
112
|
-
# Return appropriate response type.
|
113
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
114
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
115
|
-
ApiResponse.new(
|
116
|
-
_response, data: decoded, errors: _errors
|
117
|
-
)
|
61
|
+
new_api_call_builder
|
62
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
63
|
+
'/v2/locations/{location_id}',
|
64
|
+
'default')
|
65
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
66
|
+
.should_encode(true))
|
67
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
68
|
+
.auth(Single.new('global')))
|
69
|
+
.response(new_response_handler
|
70
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
71
|
+
.is_api_response(true)
|
72
|
+
.convertor(ApiResponse.method(:create)))
|
73
|
+
.execute
|
118
74
|
end
|
119
75
|
|
120
76
|
# Updates a [location](https://developer.squareup.com/docs/locations-api).
|
@@ -126,36 +82,22 @@ module Square
|
|
126
82
|
# @return [UpdateLocationResponse Hash] response from the API call
|
127
83
|
def update_location(location_id:,
|
128
84
|
body:)
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
_request = config.http_client.put(
|
146
|
-
_query_url,
|
147
|
-
headers: _headers,
|
148
|
-
parameters: body.to_json
|
149
|
-
)
|
150
|
-
OAuth2.apply(config, _request)
|
151
|
-
_response = execute_request(_request)
|
152
|
-
|
153
|
-
# Return appropriate response type.
|
154
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
155
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
156
|
-
ApiResponse.new(
|
157
|
-
_response, data: decoded, errors: _errors
|
158
|
-
)
|
85
|
+
new_api_call_builder
|
86
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
87
|
+
'/v2/locations/{location_id}',
|
88
|
+
'default')
|
89
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
90
|
+
.should_encode(true))
|
91
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
92
|
+
.body_param(new_parameter(body))
|
93
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
94
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
95
|
+
.auth(Single.new('global')))
|
96
|
+
.response(new_response_handler
|
97
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
98
|
+
.is_api_response(true)
|
99
|
+
.convertor(ApiResponse.method(:create)))
|
100
|
+
.execute
|
159
101
|
end
|
160
102
|
end
|
161
103
|
end
|