square.rb 26.0.0.20221214 → 26.2.0.20230315
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/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
|
# CustomerGroupsApi
|
3
3
|
class CustomerGroupsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Retrieves the list of customer groups of a business.
|
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,35 +17,19 @@ module Square
|
|
21
17
|
# @return [ListCustomerGroupsResponse Hash] response from the API call
|
22
18
|
def list_customer_groups(cursor: nil,
|
23
19
|
limit: nil)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
# Prepare and execute HttpRequest.
|
40
|
-
_request = config.http_client.get(
|
41
|
-
_query_url,
|
42
|
-
headers: _headers
|
43
|
-
)
|
44
|
-
OAuth2.apply(config, _request)
|
45
|
-
_response = execute_request(_request)
|
46
|
-
|
47
|
-
# Return appropriate response type.
|
48
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
49
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
50
|
-
ApiResponse.new(
|
51
|
-
_response, data: decoded, errors: _errors
|
52
|
-
)
|
20
|
+
new_api_call_builder
|
21
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
22
|
+
'/v2/customers/groups',
|
23
|
+
'default')
|
24
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
25
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
26
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
27
|
+
.auth(Single.new('global')))
|
28
|
+
.response(new_response_handler
|
29
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
30
|
+
.is_api_response(true)
|
31
|
+
.convertor(ApiResponse.method(:create)))
|
32
|
+
.execute
|
53
33
|
end
|
54
34
|
|
55
35
|
# Creates a new customer group for a business.
|
@@ -59,32 +39,20 @@ module Square
|
|
59
39
|
# object definition for field details.
|
60
40
|
# @return [CreateCustomerGroupResponse Hash] response from the API call
|
61
41
|
def create_customer_group(body:)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
headers: _headers,
|
77
|
-
parameters: body.to_json
|
78
|
-
)
|
79
|
-
OAuth2.apply(config, _request)
|
80
|
-
_response = execute_request(_request)
|
81
|
-
|
82
|
-
# Return appropriate response type.
|
83
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
84
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
85
|
-
ApiResponse.new(
|
86
|
-
_response, data: decoded, errors: _errors
|
87
|
-
)
|
42
|
+
new_api_call_builder
|
43
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
44
|
+
'/v2/customers/groups',
|
45
|
+
'default')
|
46
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
47
|
+
.body_param(new_parameter(body))
|
48
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
49
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
50
|
+
.auth(Single.new('global')))
|
51
|
+
.response(new_response_handler
|
52
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
53
|
+
.is_api_response(true)
|
54
|
+
.convertor(ApiResponse.method(:create)))
|
55
|
+
.execute
|
88
56
|
end
|
89
57
|
|
90
58
|
# Deletes a customer group as identified by the `group_id` value.
|
@@ -92,34 +60,19 @@ module Square
|
|
92
60
|
# to delete.
|
93
61
|
# @return [DeleteCustomerGroupResponse Hash] response from the API call
|
94
62
|
def delete_customer_group(group_id:)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
# Prepare and execute HttpRequest.
|
110
|
-
_request = config.http_client.delete(
|
111
|
-
_query_url,
|
112
|
-
headers: _headers
|
113
|
-
)
|
114
|
-
OAuth2.apply(config, _request)
|
115
|
-
_response = execute_request(_request)
|
116
|
-
|
117
|
-
# Return appropriate response type.
|
118
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
119
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
120
|
-
ApiResponse.new(
|
121
|
-
_response, data: decoded, errors: _errors
|
122
|
-
)
|
63
|
+
new_api_call_builder
|
64
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
65
|
+
'/v2/customers/groups/{group_id}',
|
66
|
+
'default')
|
67
|
+
.template_param(new_parameter(group_id, key: 'group_id')
|
68
|
+
.should_encode(true))
|
69
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
70
|
+
.auth(Single.new('global')))
|
71
|
+
.response(new_response_handler
|
72
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
73
|
+
.is_api_response(true)
|
74
|
+
.convertor(ApiResponse.method(:create)))
|
75
|
+
.execute
|
123
76
|
end
|
124
77
|
|
125
78
|
# Retrieves a specific customer group as identified by the `group_id` value.
|
@@ -127,34 +80,19 @@ module Square
|
|
127
80
|
# to retrieve.
|
128
81
|
# @return [RetrieveCustomerGroupResponse Hash] response from the API call
|
129
82
|
def retrieve_customer_group(group_id:)
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
# Prepare and execute HttpRequest.
|
145
|
-
_request = config.http_client.get(
|
146
|
-
_query_url,
|
147
|
-
headers: _headers
|
148
|
-
)
|
149
|
-
OAuth2.apply(config, _request)
|
150
|
-
_response = execute_request(_request)
|
151
|
-
|
152
|
-
# Return appropriate response type.
|
153
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
154
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
155
|
-
ApiResponse.new(
|
156
|
-
_response, data: decoded, errors: _errors
|
157
|
-
)
|
83
|
+
new_api_call_builder
|
84
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
85
|
+
'/v2/customers/groups/{group_id}',
|
86
|
+
'default')
|
87
|
+
.template_param(new_parameter(group_id, key: 'group_id')
|
88
|
+
.should_encode(true))
|
89
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
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
|
158
96
|
end
|
159
97
|
|
160
98
|
# Updates a customer group as identified by the `group_id` value.
|
@@ -166,36 +104,22 @@ module Square
|
|
166
104
|
# @return [UpdateCustomerGroupResponse Hash] response from the API call
|
167
105
|
def update_customer_group(group_id:,
|
168
106
|
body:)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
_request = config.http_client.put(
|
186
|
-
_query_url,
|
187
|
-
headers: _headers,
|
188
|
-
parameters: body.to_json
|
189
|
-
)
|
190
|
-
OAuth2.apply(config, _request)
|
191
|
-
_response = execute_request(_request)
|
192
|
-
|
193
|
-
# Return appropriate response type.
|
194
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
195
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
196
|
-
ApiResponse.new(
|
197
|
-
_response, data: decoded, errors: _errors
|
198
|
-
)
|
107
|
+
new_api_call_builder
|
108
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
109
|
+
'/v2/customers/groups/{group_id}',
|
110
|
+
'default')
|
111
|
+
.template_param(new_parameter(group_id, key: 'group_id')
|
112
|
+
.should_encode(true))
|
113
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
114
|
+
.body_param(new_parameter(body))
|
115
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
116
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
117
|
+
.auth(Single.new('global')))
|
118
|
+
.response(new_response_handler
|
119
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
120
|
+
.is_api_response(true)
|
121
|
+
.convertor(ApiResponse.method(:create)))
|
122
|
+
.execute
|
199
123
|
end
|
200
124
|
end
|
201
125
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# CustomerSegmentsApi
|
3
3
|
class CustomerSegmentsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Retrieves the list of customer segments of a business.
|
9
5
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
6
|
# previous calls to `ListCustomerSegments`. This cursor is used to retrieve
|
@@ -21,35 +17,19 @@ module Square
|
|
21
17
|
# @return [ListCustomerSegmentsResponse Hash] response from the API call
|
22
18
|
def list_customer_segments(cursor: nil,
|
23
19
|
limit: nil)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
# Prepare and execute HttpRequest.
|
40
|
-
_request = config.http_client.get(
|
41
|
-
_query_url,
|
42
|
-
headers: _headers
|
43
|
-
)
|
44
|
-
OAuth2.apply(config, _request)
|
45
|
-
_response = execute_request(_request)
|
46
|
-
|
47
|
-
# Return appropriate response type.
|
48
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
49
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
50
|
-
ApiResponse.new(
|
51
|
-
_response, data: decoded, errors: _errors
|
52
|
-
)
|
20
|
+
new_api_call_builder
|
21
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
22
|
+
'/v2/customers/segments',
|
23
|
+
'default')
|
24
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
25
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
26
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
27
|
+
.auth(Single.new('global')))
|
28
|
+
.response(new_response_handler
|
29
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
30
|
+
.is_api_response(true)
|
31
|
+
.convertor(ApiResponse.method(:create)))
|
32
|
+
.execute
|
53
33
|
end
|
54
34
|
|
55
35
|
# Retrieves a specific customer segment as identified by the `segment_id`
|
@@ -58,34 +38,19 @@ module Square
|
|
58
38
|
# customer segment.
|
59
39
|
# @return [RetrieveCustomerSegmentResponse Hash] response from the API call
|
60
40
|
def retrieve_customer_segment(segment_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/customers/segments/{segment_id}',
|
44
|
+
'default')
|
45
|
+
.template_param(new_parameter(segment_id, key: 'segment_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
|
end
|
91
56
|
end
|