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
|
# EmployeesApi
|
3
3
|
class EmployeesApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# ListEmployees
|
9
5
|
# @param [String] location_id Optional parameter: Example:
|
10
6
|
# @param [EmployeeStatus] status Optional parameter: Specifies the
|
@@ -19,37 +15,21 @@ module Square
|
|
19
15
|
limit: nil,
|
20
16
|
cursor: nil)
|
21
17
|
warn 'Endpoint list_employees in EmployeesApi is deprecated'
|
22
|
-
|
23
|
-
|
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
|
-
)
|
18
|
+
new_api_call_builder
|
19
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
20
|
+
'/v2/employees',
|
21
|
+
'default')
|
22
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
23
|
+
.query_param(new_parameter(status, key: 'status'))
|
24
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
25
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
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
|
# RetrieveEmployee
|
@@ -58,34 +38,19 @@ module Square
|
|
58
38
|
# @return [RetrieveEmployeeResponse Hash] response from the API call
|
59
39
|
def retrieve_employee(id:)
|
60
40
|
warn 'Endpoint retrieve_employee in EmployeesApi is deprecated'
|
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/employees/{id}',
|
44
|
+
'default')
|
45
|
+
.template_param(new_parameter(id, key: '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
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# GiftCardActivitiesApi
|
3
3
|
class GiftCardActivitiesApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Lists gift card activities. By default, you get gift card activities for
|
9
5
|
# all
|
10
6
|
# gift cards in the seller's account. You can optionally specify query
|
@@ -54,41 +50,25 @@ module Square
|
|
54
50
|
limit: nil,
|
55
51
|
cursor: nil,
|
56
52
|
sort_order: nil)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
)
|
53
|
+
new_api_call_builder
|
54
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
55
|
+
'/v2/gift-cards/activities',
|
56
|
+
'default')
|
57
|
+
.query_param(new_parameter(gift_card_id, key: 'gift_card_id'))
|
58
|
+
.query_param(new_parameter(type, key: 'type'))
|
59
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
60
|
+
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
61
|
+
.query_param(new_parameter(end_time, key: 'end_time'))
|
62
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
63
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
64
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
65
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
66
|
+
.auth(Single.new('global')))
|
67
|
+
.response(new_response_handler
|
68
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
69
|
+
.is_api_response(true)
|
70
|
+
.convertor(ApiResponse.method(:create)))
|
71
|
+
.execute
|
92
72
|
end
|
93
73
|
|
94
74
|
# Creates a gift card activity to manage the balance or state of a [gift
|
@@ -101,32 +81,20 @@ module Square
|
|
101
81
|
# object definition for field details.
|
102
82
|
# @return [CreateGiftCardActivityResponse Hash] response from the API call
|
103
83
|
def create_gift_card_activity(body:)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
headers: _headers,
|
119
|
-
parameters: body.to_json
|
120
|
-
)
|
121
|
-
OAuth2.apply(config, _request)
|
122
|
-
_response = execute_request(_request)
|
123
|
-
|
124
|
-
# Return appropriate response type.
|
125
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
126
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
127
|
-
ApiResponse.new(
|
128
|
-
_response, data: decoded, errors: _errors
|
129
|
-
)
|
84
|
+
new_api_call_builder
|
85
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
86
|
+
'/v2/gift-cards/activities',
|
87
|
+
'default')
|
88
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
89
|
+
.body_param(new_parameter(body))
|
90
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
91
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
92
|
+
.auth(Single.new('global')))
|
93
|
+
.response(new_response_handler
|
94
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
95
|
+
.is_api_response(true)
|
96
|
+
.convertor(ApiResponse.method(:create)))
|
97
|
+
.execute
|
130
98
|
end
|
131
99
|
end
|
132
100
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# GiftCardsApi
|
3
3
|
class GiftCardsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Lists all gift cards. You can specify optional filters to retrieve
|
9
5
|
# a subset of the gift cards. Results are sorted by `created_at` in
|
10
6
|
# ascending order.
|
@@ -34,38 +30,22 @@ module Square
|
|
34
30
|
limit: nil,
|
35
31
|
cursor: nil,
|
36
32
|
customer_id: nil)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
54
|
-
|
55
|
-
# Prepare and execute HttpRequest.
|
56
|
-
_request = config.http_client.get(
|
57
|
-
_query_url,
|
58
|
-
headers: _headers
|
59
|
-
)
|
60
|
-
OAuth2.apply(config, _request)
|
61
|
-
_response = execute_request(_request)
|
62
|
-
|
63
|
-
# Return appropriate response type.
|
64
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
65
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
66
|
-
ApiResponse.new(
|
67
|
-
_response, data: decoded, errors: _errors
|
68
|
-
)
|
33
|
+
new_api_call_builder
|
34
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
35
|
+
'/v2/gift-cards',
|
36
|
+
'default')
|
37
|
+
.query_param(new_parameter(type, key: 'type'))
|
38
|
+
.query_param(new_parameter(state, key: 'state'))
|
39
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
40
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
41
|
+
.query_param(new_parameter(customer_id, key: 'customer_id'))
|
42
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
43
|
+
.auth(Single.new('global')))
|
44
|
+
.response(new_response_handler
|
45
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
46
|
+
.is_api_response(true)
|
47
|
+
.convertor(ApiResponse.method(:create)))
|
48
|
+
.execute
|
69
49
|
end
|
70
50
|
|
71
51
|
# Creates a digital gift card or registers a physical (plastic) gift card.
|
@@ -79,32 +59,20 @@ module Square
|
|
79
59
|
# object definition for field details.
|
80
60
|
# @return [CreateGiftCardResponse Hash] response from the API call
|
81
61
|
def create_gift_card(body:)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
headers: _headers,
|
97
|
-
parameters: body.to_json
|
98
|
-
)
|
99
|
-
OAuth2.apply(config, _request)
|
100
|
-
_response = execute_request(_request)
|
101
|
-
|
102
|
-
# Return appropriate response type.
|
103
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
104
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
105
|
-
ApiResponse.new(
|
106
|
-
_response, data: decoded, errors: _errors
|
107
|
-
)
|
62
|
+
new_api_call_builder
|
63
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
64
|
+
'/v2/gift-cards',
|
65
|
+
'default')
|
66
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
67
|
+
.body_param(new_parameter(body))
|
68
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
69
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
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
|
108
76
|
end
|
109
77
|
|
110
78
|
# Retrieves a gift card using the gift card account number (GAN).
|
@@ -113,32 +81,20 @@ module Square
|
|
113
81
|
# object definition for field details.
|
114
82
|
# @return [RetrieveGiftCardFromGANResponse Hash] response from the API call
|
115
83
|
def retrieve_gift_card_from_gan(body:)
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
headers: _headers,
|
131
|
-
parameters: body.to_json
|
132
|
-
)
|
133
|
-
OAuth2.apply(config, _request)
|
134
|
-
_response = execute_request(_request)
|
135
|
-
|
136
|
-
# Return appropriate response type.
|
137
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
138
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
139
|
-
ApiResponse.new(
|
140
|
-
_response, data: decoded, errors: _errors
|
141
|
-
)
|
84
|
+
new_api_call_builder
|
85
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
86
|
+
'/v2/gift-cards/from-gan',
|
87
|
+
'default')
|
88
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
89
|
+
.body_param(new_parameter(body))
|
90
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
91
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
92
|
+
.auth(Single.new('global')))
|
93
|
+
.response(new_response_handler
|
94
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
95
|
+
.is_api_response(true)
|
96
|
+
.convertor(ApiResponse.method(:create)))
|
97
|
+
.execute
|
142
98
|
end
|
143
99
|
|
144
100
|
# Retrieves a gift card using a secure payment token that represents the
|
@@ -148,32 +104,20 @@ module Square
|
|
148
104
|
# corresponding object definition for field details.
|
149
105
|
# @return [RetrieveGiftCardFromNonceResponse Hash] response from the API call
|
150
106
|
def retrieve_gift_card_from_nonce(body:)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
headers: _headers,
|
166
|
-
parameters: body.to_json
|
167
|
-
)
|
168
|
-
OAuth2.apply(config, _request)
|
169
|
-
_response = execute_request(_request)
|
170
|
-
|
171
|
-
# Return appropriate response type.
|
172
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
173
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
174
|
-
ApiResponse.new(
|
175
|
-
_response, data: decoded, errors: _errors
|
176
|
-
)
|
107
|
+
new_api_call_builder
|
108
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
109
|
+
'/v2/gift-cards/from-nonce',
|
110
|
+
'default')
|
111
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
112
|
+
.body_param(new_parameter(body))
|
113
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
114
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
115
|
+
.auth(Single.new('global')))
|
116
|
+
.response(new_response_handler
|
117
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
118
|
+
.is_api_response(true)
|
119
|
+
.convertor(ApiResponse.method(:create)))
|
120
|
+
.execute
|
177
121
|
end
|
178
122
|
|
179
123
|
# Links a customer to a gift card, which is also referred to as adding a
|
@@ -186,36 +130,22 @@ module Square
|
|
186
130
|
# @return [LinkCustomerToGiftCardResponse Hash] response from the API call
|
187
131
|
def link_customer_to_gift_card(gift_card_id:,
|
188
132
|
body:)
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
_request = config.http_client.post(
|
206
|
-
_query_url,
|
207
|
-
headers: _headers,
|
208
|
-
parameters: body.to_json
|
209
|
-
)
|
210
|
-
OAuth2.apply(config, _request)
|
211
|
-
_response = execute_request(_request)
|
212
|
-
|
213
|
-
# Return appropriate response type.
|
214
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
215
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
216
|
-
ApiResponse.new(
|
217
|
-
_response, data: decoded, errors: _errors
|
218
|
-
)
|
133
|
+
new_api_call_builder
|
134
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
135
|
+
'/v2/gift-cards/{gift_card_id}/link-customer',
|
136
|
+
'default')
|
137
|
+
.template_param(new_parameter(gift_card_id, key: 'gift_card_id')
|
138
|
+
.should_encode(true))
|
139
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
140
|
+
.body_param(new_parameter(body))
|
141
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
142
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
143
|
+
.auth(Single.new('global')))
|
144
|
+
.response(new_response_handler
|
145
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
146
|
+
.is_api_response(true)
|
147
|
+
.convertor(ApiResponse.method(:create)))
|
148
|
+
.execute
|
219
149
|
end
|
220
150
|
|
221
151
|
# Unlinks a customer from a gift card, which is also referred to as removing
|
@@ -228,36 +158,22 @@ module Square
|
|
228
158
|
# @return [UnlinkCustomerFromGiftCardResponse Hash] response from the API call
|
229
159
|
def unlink_customer_from_gift_card(gift_card_id:,
|
230
160
|
body:)
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
_request = config.http_client.post(
|
248
|
-
_query_url,
|
249
|
-
headers: _headers,
|
250
|
-
parameters: body.to_json
|
251
|
-
)
|
252
|
-
OAuth2.apply(config, _request)
|
253
|
-
_response = execute_request(_request)
|
254
|
-
|
255
|
-
# Return appropriate response type.
|
256
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
257
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
258
|
-
ApiResponse.new(
|
259
|
-
_response, data: decoded, errors: _errors
|
260
|
-
)
|
161
|
+
new_api_call_builder
|
162
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
163
|
+
'/v2/gift-cards/{gift_card_id}/unlink-customer',
|
164
|
+
'default')
|
165
|
+
.template_param(new_parameter(gift_card_id, key: 'gift_card_id')
|
166
|
+
.should_encode(true))
|
167
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
168
|
+
.body_param(new_parameter(body))
|
169
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
170
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
171
|
+
.auth(Single.new('global')))
|
172
|
+
.response(new_response_handler
|
173
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
174
|
+
.is_api_response(true)
|
175
|
+
.convertor(ApiResponse.method(:create)))
|
176
|
+
.execute
|
261
177
|
end
|
262
178
|
|
263
179
|
# Retrieves a gift card using the gift card ID.
|
@@ -265,34 +181,19 @@ module Square
|
|
265
181
|
# retrieve.
|
266
182
|
# @return [RetrieveGiftCardResponse Hash] response from the API call
|
267
183
|
def retrieve_gift_card(id:)
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
# Prepare and execute HttpRequest.
|
283
|
-
_request = config.http_client.get(
|
284
|
-
_query_url,
|
285
|
-
headers: _headers
|
286
|
-
)
|
287
|
-
OAuth2.apply(config, _request)
|
288
|
-
_response = execute_request(_request)
|
289
|
-
|
290
|
-
# Return appropriate response type.
|
291
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
292
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
293
|
-
ApiResponse.new(
|
294
|
-
_response, data: decoded, errors: _errors
|
295
|
-
)
|
184
|
+
new_api_call_builder
|
185
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
186
|
+
'/v2/gift-cards/{id}',
|
187
|
+
'default')
|
188
|
+
.template_param(new_parameter(id, key: 'id')
|
189
|
+
.should_encode(true))
|
190
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
191
|
+
.auth(Single.new('global')))
|
192
|
+
.response(new_response_handler
|
193
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
194
|
+
.is_api_response(true)
|
195
|
+
.convertor(ApiResponse.method(:create)))
|
196
|
+
.execute
|
296
197
|
end
|
297
198
|
end
|
298
199
|
end
|