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,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
|
@@ -18,7 +14,7 @@ module Square
|
|
18
14
|
# card. Otherwise, the endpoint returns all gift card activities for the
|
19
15
|
# seller.
|
20
16
|
# @param [String] type Optional parameter: If a
|
21
|
-
# [type](
|
17
|
+
# [type](entity:GiftCardActivityType) is provided, the endpoint returns gift
|
22
18
|
# card activities of the specified type. Otherwise, the endpoint returns
|
23
19
|
# all types of gift card activities.
|
24
20
|
# @param [String] location_id Optional parameter: If a location ID is
|
@@ -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,19 +1,16 @@
|
|
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.
|
11
|
-
# @param [String] type Optional parameter: If a [type](
|
12
|
-
# provided, the endpoint returns gift cards of the specified type.
|
7
|
+
# @param [String] type Optional parameter: If a [type](entity:GiftCardType)
|
8
|
+
# is provided, the endpoint returns gift cards of the specified type.
|
13
9
|
# Otherwise, the endpoint returns gift cards of all types.
|
14
|
-
# @param [String] state Optional parameter: If a
|
15
|
-
# is provided, the endpoint returns the gift
|
16
|
-
# Otherwise, the endpoint returns the gift
|
10
|
+
# @param [String] state Optional parameter: If a
|
11
|
+
# [state](entity:GiftCardStatus) is provided, the endpoint returns the gift
|
12
|
+
# cards in the specified state. Otherwise, the endpoint returns the gift
|
13
|
+
# cards of all states.
|
17
14
|
# @param [Integer] limit Optional parameter: If a limit is provided, the
|
18
15
|
# endpoint returns only the specified number of results per page. The
|
19
16
|
# maximum value is 50. The default value is 30. For more information, see
|
@@ -34,38 +31,22 @@ module Square
|
|
34
31
|
limit: nil,
|
35
32
|
cursor: nil,
|
36
33
|
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
|
-
)
|
34
|
+
new_api_call_builder
|
35
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
36
|
+
'/v2/gift-cards',
|
37
|
+
'default')
|
38
|
+
.query_param(new_parameter(type, key: 'type'))
|
39
|
+
.query_param(new_parameter(state, key: 'state'))
|
40
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
41
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
42
|
+
.query_param(new_parameter(customer_id, key: 'customer_id'))
|
43
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
44
|
+
.auth(Single.new('global')))
|
45
|
+
.response(new_response_handler
|
46
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
47
|
+
.is_api_response(true)
|
48
|
+
.convertor(ApiResponse.method(:create)))
|
49
|
+
.execute
|
69
50
|
end
|
70
51
|
|
71
52
|
# Creates a digital gift card or registers a physical (plastic) gift card.
|
@@ -79,32 +60,20 @@ module Square
|
|
79
60
|
# object definition for field details.
|
80
61
|
# @return [CreateGiftCardResponse Hash] response from the API call
|
81
62
|
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
|
-
)
|
63
|
+
new_api_call_builder
|
64
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
65
|
+
'/v2/gift-cards',
|
66
|
+
'default')
|
67
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
68
|
+
.body_param(new_parameter(body))
|
69
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
70
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
71
|
+
.auth(Single.new('global')))
|
72
|
+
.response(new_response_handler
|
73
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
74
|
+
.is_api_response(true)
|
75
|
+
.convertor(ApiResponse.method(:create)))
|
76
|
+
.execute
|
108
77
|
end
|
109
78
|
|
110
79
|
# Retrieves a gift card using the gift card account number (GAN).
|
@@ -113,32 +82,20 @@ module Square
|
|
113
82
|
# object definition for field details.
|
114
83
|
# @return [RetrieveGiftCardFromGANResponse Hash] response from the API call
|
115
84
|
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
|
-
)
|
85
|
+
new_api_call_builder
|
86
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
87
|
+
'/v2/gift-cards/from-gan',
|
88
|
+
'default')
|
89
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
90
|
+
.body_param(new_parameter(body))
|
91
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
92
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
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
|
142
99
|
end
|
143
100
|
|
144
101
|
# Retrieves a gift card using a secure payment token that represents the
|
@@ -148,32 +105,20 @@ module Square
|
|
148
105
|
# corresponding object definition for field details.
|
149
106
|
# @return [RetrieveGiftCardFromNonceResponse Hash] response from the API call
|
150
107
|
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
|
-
)
|
108
|
+
new_api_call_builder
|
109
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
110
|
+
'/v2/gift-cards/from-nonce',
|
111
|
+
'default')
|
112
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
113
|
+
.body_param(new_parameter(body))
|
114
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
115
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
116
|
+
.auth(Single.new('global')))
|
117
|
+
.response(new_response_handler
|
118
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
119
|
+
.is_api_response(true)
|
120
|
+
.convertor(ApiResponse.method(:create)))
|
121
|
+
.execute
|
177
122
|
end
|
178
123
|
|
179
124
|
# Links a customer to a gift card, which is also referred to as adding a
|
@@ -186,36 +131,22 @@ module Square
|
|
186
131
|
# @return [LinkCustomerToGiftCardResponse Hash] response from the API call
|
187
132
|
def link_customer_to_gift_card(gift_card_id:,
|
188
133
|
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
|
-
)
|
134
|
+
new_api_call_builder
|
135
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
136
|
+
'/v2/gift-cards/{gift_card_id}/link-customer',
|
137
|
+
'default')
|
138
|
+
.template_param(new_parameter(gift_card_id, key: 'gift_card_id')
|
139
|
+
.should_encode(true))
|
140
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
141
|
+
.body_param(new_parameter(body))
|
142
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
143
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
144
|
+
.auth(Single.new('global')))
|
145
|
+
.response(new_response_handler
|
146
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
147
|
+
.is_api_response(true)
|
148
|
+
.convertor(ApiResponse.method(:create)))
|
149
|
+
.execute
|
219
150
|
end
|
220
151
|
|
221
152
|
# Unlinks a customer from a gift card, which is also referred to as removing
|
@@ -228,36 +159,22 @@ module Square
|
|
228
159
|
# @return [UnlinkCustomerFromGiftCardResponse Hash] response from the API call
|
229
160
|
def unlink_customer_from_gift_card(gift_card_id:,
|
230
161
|
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
|
-
)
|
162
|
+
new_api_call_builder
|
163
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
164
|
+
'/v2/gift-cards/{gift_card_id}/unlink-customer',
|
165
|
+
'default')
|
166
|
+
.template_param(new_parameter(gift_card_id, key: 'gift_card_id')
|
167
|
+
.should_encode(true))
|
168
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
169
|
+
.body_param(new_parameter(body))
|
170
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
171
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
172
|
+
.auth(Single.new('global')))
|
173
|
+
.response(new_response_handler
|
174
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
175
|
+
.is_api_response(true)
|
176
|
+
.convertor(ApiResponse.method(:create)))
|
177
|
+
.execute
|
261
178
|
end
|
262
179
|
|
263
180
|
# Retrieves a gift card using the gift card ID.
|
@@ -265,34 +182,19 @@ module Square
|
|
265
182
|
# retrieve.
|
266
183
|
# @return [RetrieveGiftCardResponse Hash] response from the API call
|
267
184
|
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
|
-
)
|
185
|
+
new_api_call_builder
|
186
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
187
|
+
'/v2/gift-cards/{id}',
|
188
|
+
'default')
|
189
|
+
.template_param(new_parameter(id, key: 'id')
|
190
|
+
.should_encode(true))
|
191
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
192
|
+
.auth(Single.new('global')))
|
193
|
+
.response(new_response_handler
|
194
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
195
|
+
.is_api_response(true)
|
196
|
+
.convertor(ApiResponse.method(:create)))
|
197
|
+
.execute
|
296
198
|
end
|
297
199
|
end
|
298
200
|
end
|