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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fe50fe3512834461866b9d1ebbd83bee0ca14f16313e4928f7ae114105ffc22
|
4
|
+
data.tar.gz: e168aac2b86e67820df82977d1cd628f83566abbc77e821f029f509fadb19b5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4960b642816caa0d3aa71aceed7b834ca127c188b4e91098e56beacabb501531e67cf2747bdd3045e3dceedc565d9db9ec99f2fdfd369bdbec2c2bb110ca4d
|
7
|
+
data.tar.gz: 745fb7ff183d3445c7edcbe352dbb701597acf2a551971d9cfdd0cfa57e3002a085c3497404b52b49a39d89b7221991f092c14b7fec09352d6fe2b203def7940
|
data/LICENSE
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# ApplePayApi
|
3
3
|
class ApplePayApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Activates a domain for use with Apple Pay on the Web and Square. A
|
9
5
|
# validation
|
10
6
|
# is performed on this domain by Apple to ensure that it is properly set up
|
@@ -28,32 +24,20 @@ module Square
|
|
28
24
|
# object definition for field details.
|
29
25
|
# @return [RegisterDomainResponse Hash] response from the API call
|
30
26
|
def register_domain(body:)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
headers: _headers,
|
46
|
-
parameters: body.to_json
|
47
|
-
)
|
48
|
-
OAuth2.apply(config, _request)
|
49
|
-
_response = execute_request(_request)
|
50
|
-
|
51
|
-
# Return appropriate response type.
|
52
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
53
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
54
|
-
ApiResponse.new(
|
55
|
-
_response, data: decoded, errors: _errors
|
56
|
-
)
|
27
|
+
new_api_call_builder
|
28
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
29
|
+
'/v2/apple-pay/domains',
|
30
|
+
'default')
|
31
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
32
|
+
.body_param(new_parameter(body))
|
33
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
34
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
35
|
+
.auth(Single.new('global')))
|
36
|
+
.response(new_response_handler
|
37
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
38
|
+
.is_api_response(true)
|
39
|
+
.convertor(ApiResponse.method(:create)))
|
40
|
+
.execute
|
57
41
|
end
|
58
42
|
end
|
59
43
|
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# BankAccountsApi
|
3
3
|
class BankAccountsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Returns a list of [BankAccount]($m/BankAccount) objects linked to a Square
|
9
5
|
# account.
|
10
6
|
# @param [String] cursor Optional parameter: The pagination cursor returned
|
@@ -23,36 +19,20 @@ module Square
|
|
23
19
|
def list_bank_accounts(cursor: nil,
|
24
20
|
limit: nil,
|
25
21
|
location_id: nil)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
41
|
-
|
42
|
-
# Prepare and execute HttpRequest.
|
43
|
-
_request = config.http_client.get(
|
44
|
-
_query_url,
|
45
|
-
headers: _headers
|
46
|
-
)
|
47
|
-
OAuth2.apply(config, _request)
|
48
|
-
_response = execute_request(_request)
|
49
|
-
|
50
|
-
# Return appropriate response type.
|
51
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
52
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
53
|
-
ApiResponse.new(
|
54
|
-
_response, data: decoded, errors: _errors
|
55
|
-
)
|
22
|
+
new_api_call_builder
|
23
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
24
|
+
'/v2/bank-accounts',
|
25
|
+
'default')
|
26
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
27
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
28
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
29
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
30
|
+
.auth(Single.new('global')))
|
31
|
+
.response(new_response_handler
|
32
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
33
|
+
.is_api_response(true)
|
34
|
+
.convertor(ApiResponse.method(:create)))
|
35
|
+
.execute
|
56
36
|
end
|
57
37
|
|
58
38
|
# Returns details of a [BankAccount]($m/BankAccount) identified by V1 bank
|
@@ -64,34 +44,19 @@ module Square
|
|
64
44
|
# -account-by-using-an-id-issued-by-v1-bank-accounts-api).
|
65
45
|
# @return [GetBankAccountByV1IdResponse Hash] response from the API call
|
66
46
|
def get_bank_account_by_v1_id(v1_bank_account_id:)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
# Prepare and execute HttpRequest.
|
82
|
-
_request = config.http_client.get(
|
83
|
-
_query_url,
|
84
|
-
headers: _headers
|
85
|
-
)
|
86
|
-
OAuth2.apply(config, _request)
|
87
|
-
_response = execute_request(_request)
|
88
|
-
|
89
|
-
# Return appropriate response type.
|
90
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
91
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
92
|
-
ApiResponse.new(
|
93
|
-
_response, data: decoded, errors: _errors
|
94
|
-
)
|
47
|
+
new_api_call_builder
|
48
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
49
|
+
'/v2/bank-accounts/by-v1-id/{v1_bank_account_id}',
|
50
|
+
'default')
|
51
|
+
.template_param(new_parameter(v1_bank_account_id, key: 'v1_bank_account_id')
|
52
|
+
.should_encode(true))
|
53
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
54
|
+
.auth(Single.new('global')))
|
55
|
+
.response(new_response_handler
|
56
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
57
|
+
.is_api_response(true)
|
58
|
+
.convertor(ApiResponse.method(:create)))
|
59
|
+
.execute
|
95
60
|
end
|
96
61
|
|
97
62
|
# Returns details of a [BankAccount]($m/BankAccount)
|
@@ -100,34 +65,19 @@ module Square
|
|
100
65
|
# the desired `BankAccount`.
|
101
66
|
# @return [GetBankAccountResponse Hash] response from the API call
|
102
67
|
def get_bank_account(bank_account_id:)
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
# Prepare and execute HttpRequest.
|
118
|
-
_request = config.http_client.get(
|
119
|
-
_query_url,
|
120
|
-
headers: _headers
|
121
|
-
)
|
122
|
-
OAuth2.apply(config, _request)
|
123
|
-
_response = execute_request(_request)
|
124
|
-
|
125
|
-
# Return appropriate response type.
|
126
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
127
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
128
|
-
ApiResponse.new(
|
129
|
-
_response, data: decoded, errors: _errors
|
130
|
-
)
|
68
|
+
new_api_call_builder
|
69
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
70
|
+
'/v2/bank-accounts/{bank_account_id}',
|
71
|
+
'default')
|
72
|
+
.template_param(new_parameter(bank_account_id, key: 'bank_account_id')
|
73
|
+
.should_encode(true))
|
74
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
75
|
+
.auth(Single.new('global')))
|
76
|
+
.response(new_response_handler
|
77
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
78
|
+
.is_api_response(true)
|
79
|
+
.convertor(ApiResponse.method(:create)))
|
80
|
+
.execute
|
131
81
|
end
|
132
82
|
end
|
133
83
|
end
|
data/lib/square/api/base_api.rb
CHANGED
@@ -1,61 +1,61 @@
|
|
1
|
-
require 'erb'
|
2
1
|
module Square
|
3
2
|
# BaseApi.
|
4
3
|
class BaseApi
|
5
4
|
attr_accessor :config, :http_call_back
|
6
5
|
|
7
|
-
def
|
8
|
-
|
9
|
-
|
6
|
+
def self.user_agent
|
7
|
+
'Square-Ruby-SDK/26.2.0.20230315 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
8
|
+
end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
'
|
10
|
+
def self.user_agent_parameters
|
11
|
+
{
|
12
|
+
'{engine}' => { 'value' => RUBY_ENGINE, 'encode' => false },
|
13
|
+
'{engine-version}' => { 'value' => RUBY_ENGINE_VERSION, 'encode' => false },
|
14
|
+
'{os-info}' => { 'value' => RUBY_PLATFORM, 'encode' => false }
|
14
15
|
}
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
# Initialization constructor.
|
19
|
+
# @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
|
20
|
+
def initialize(global_configuration)
|
21
|
+
@global_configuration = global_configuration
|
22
|
+
@config = @global_configuration.client_configuration
|
23
|
+
@http_call_back = @config.http_callback
|
24
|
+
@api_call = ApiCall.new(@global_configuration)
|
21
25
|
end
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
27
|
+
# Creates a new builder for the Api Call instance.
|
28
|
+
# @return [ApiCall] The instance of ApiCall.
|
29
|
+
def new_api_call_builder
|
30
|
+
@api_call.new_builder
|
28
31
|
end
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
42
|
-
@http_call_back&.on_after_response(response)
|
33
|
+
# Creates a new instance of the request builder.
|
34
|
+
# @param [HttpMethodEnum] http_method The HTTP method to use in the request.
|
35
|
+
# @param [String] path The endpoint path to use in the request.
|
36
|
+
# @param [String] server The server to extract the base uri for the request.
|
37
|
+
# @return [RequestBuilder] The instance of RequestBuilder.
|
38
|
+
def new_request_builder(http_method, path, server)
|
39
|
+
RequestBuilder.new
|
40
|
+
.http_method(http_method)
|
41
|
+
.path(path)
|
42
|
+
.server(server)
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
+
# Creates a new instance of the response handler.
|
46
|
+
# @return [ResponseHandler] The instance of ResponseHandler.
|
47
|
+
def new_response_handler
|
48
|
+
ResponseHandler.new
|
45
49
|
end
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
else
|
56
|
-
user_agent['{detail}'] = ERB::Util.url_encode(config.user_agent_detail.to_s)
|
57
|
-
end
|
58
|
-
user_agent
|
51
|
+
# Creates a new instance of the parameter.
|
52
|
+
# @param [String|optional] key The key of the parameter.
|
53
|
+
# @param [Object] value The value of the parameter.
|
54
|
+
# @return [Parameter] The instance of Parameter.
|
55
|
+
def new_parameter(value, key: nil)
|
56
|
+
Parameter.new
|
57
|
+
.key(key)
|
58
|
+
.value(value)
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|