square.rb 6.0.0.20200625 → 6.5.0.20201028
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 +37 -30
- data/lib/square.rb +61 -60
- data/lib/square/api/apple_pay_api.rb +3 -1
- data/lib/square/api/bank_accounts_api.rb +12 -15
- data/lib/square/api/base_api.rb +2 -2
- data/lib/square/api/cash_drawers_api.rb +11 -5
- data/lib/square/api/catalog_api.rb +119 -49
- data/lib/square/api/checkout_api.rb +4 -2
- data/lib/square/api/customer_groups_api.rb +18 -8
- data/lib/square/api/customer_segments_api.rb +7 -3
- data/lib/square/api/customers_api.rb +47 -27
- data/lib/square/api/devices_api.rb +17 -6
- data/lib/square/api/disputes_api.rb +39 -34
- data/lib/square/api/employees_api.rb +10 -5
- data/lib/square/api/inventory_api.rb +30 -15
- data/lib/square/api/invoices_api.rb +359 -0
- data/lib/square/api/labor_api.rb +131 -22
- data/lib/square/api/locations_api.rb +20 -12
- data/lib/square/api/loyalty_api.rb +59 -65
- data/lib/square/api/merchants_api.rb +9 -4
- data/lib/square/api/mobile_authorization_api.rb +3 -1
- data/lib/square/api/o_auth_api.rb +10 -4
- data/lib/square/api/orders_api.rb +111 -90
- data/lib/square/api/payments_api.rb +75 -65
- data/lib/square/api/refunds_api.rb +21 -11
- data/lib/square/api/subscriptions_api.rb +263 -0
- data/lib/square/api/team_api.rb +32 -16
- data/lib/square/api/terminal_api.rb +156 -7
- data/lib/square/api/transactions_api.rb +32 -18
- data/lib/square/api/v1_employees_api.rb +59 -27
- data/lib/square/api/v1_items_api.rb +195 -115
- data/lib/square/api/v1_locations_api.rb +6 -2
- data/lib/square/api/v1_transactions_api.rb +49 -27
- data/lib/square/api_helper.rb +14 -9
- data/lib/square/client.rb +23 -16
- data/lib/square/configuration.rb +12 -4
- data/lib/square/http/api_response.rb +2 -0
- data/lib/square/http/faraday_client.rb +1 -0
- data/spec/user_journey_spec.rb +2 -5
- data/test/api/api_test_base.rb +1 -6
- data/test/api/test_catalog_api.rb +1 -4
- data/test/api/test_customers_api.rb +1 -4
- data/test/api/test_employees_api.rb +1 -4
- data/test/api/test_labor_api.rb +2 -6
- data/test/api/test_locations_api.rb +22 -33
- data/test/api/test_merchants_api.rb +1 -4
- data/test/api/test_payments_api.rb +3 -6
- data/test/api/test_refunds_api.rb +3 -6
- data/test/http_response_catcher.rb +0 -5
- data/test/test_helper.rb +0 -5
- metadata +33 -14
- data/lib/square/api/reporting_api.rb +0 -138
data/test/api/api_test_base.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
1
|
require 'json'
|
7
2
|
require 'minitest/autorun'
|
8
3
|
require 'minitest/hell'
|
@@ -19,6 +14,6 @@ class ApiTestBase < Minitest::Test
|
|
19
14
|
# Create configuration and set any test parameters
|
20
15
|
CONFIG = Configuration.new(
|
21
16
|
access_token: ENV.fetch('SQUARE_SANDBOX_TOKEN', 'AccessToken'),
|
22
|
-
environment:
|
17
|
+
environment: 'sandbox'
|
23
18
|
)
|
24
19
|
end
|
data/test/api/test_labor_api.rb
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
1
|
+
|
5
2
|
|
6
3
|
require_relative 'api_test_base'
|
7
4
|
|
@@ -35,12 +32,11 @@ class LaborApiTests < ApiTestBase
|
|
35
32
|
# Returns a paginated list of `EmployeeWage` instances for a business.
|
36
33
|
def test_list_employee_wages()
|
37
34
|
# Parameters for the API call
|
38
|
-
employee_id = nil
|
39
35
|
limit = nil
|
40
36
|
cursor = nil
|
41
37
|
|
42
38
|
# Perform the API call through the SDK function
|
43
|
-
result = @controller.list_employee_wages(
|
39
|
+
result = @controller.list_employee_wages(limit: limit, cursor: cursor)
|
44
40
|
|
45
41
|
# Test response code
|
46
42
|
assert_equal(200, @response_catcher.response.status_code)
|
@@ -1,35 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
@response_catcher = HttpResponseCatcher.new
|
12
|
-
@controller = LocationsApi.new CONFIG, http_call_back: @response_catcher
|
13
|
-
end
|
14
|
-
|
15
|
-
# Provides the details for all of a business's locations.
|
1
|
+
require_relative 'api_test_base'
|
2
|
+
|
3
|
+
class LocationsApiTests < ApiTestBase
|
4
|
+
# Called only once for the class before any test has executed
|
5
|
+
def setup
|
6
|
+
@response_catcher = HttpResponseCatcher.new
|
7
|
+
@controller = LocationsApi.new CONFIG, http_call_back: @response_catcher
|
8
|
+
end
|
9
|
+
|
10
|
+
# Provides information of all locations of a business.
|
16
11
|
#
|
17
|
-
#
|
12
|
+
#Many Square API endpoints require a `location_id` parameter.
|
18
13
|
#The `id` field of the [`Location`](#type-location) objects returned by this
|
19
|
-
#endpoint correspond to that `location_id` parameter.
|
20
|
-
def
|
21
|
-
|
22
|
-
# Perform the API call through the SDK function
|
23
|
-
result = @controller.list_locations()
|
24
|
-
|
25
|
-
# Test response code
|
26
|
-
assert_equal(200, @response_catcher.response.status_code)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
expected_headers['content-type'] = 'application/json'
|
31
|
-
|
32
|
-
assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
14
|
+
#endpoint correspond to that `location_id` parameter.
|
15
|
+
def test_list_locations()
|
16
|
+
|
17
|
+
# Perform the API call through the SDK function
|
18
|
+
result = @controller.list_locations()
|
19
|
+
|
20
|
+
# Test response code
|
21
|
+
assert_equal(200, @response_catcher.response.status_code)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
1
|
+
|
5
2
|
|
6
3
|
require_relative 'api_test_base'
|
7
4
|
|
@@ -12,8 +9,8 @@ class PaymentsApiTests < ApiTestBase
|
|
12
9
|
@controller = PaymentsApi.new CONFIG, http_call_back: @response_catcher
|
13
10
|
end
|
14
11
|
|
15
|
-
# Retrieves a list of payments taken by the account making the request.
|
16
|
-
#
|
12
|
+
# Retrieves a list of payments taken by the account making the request.
|
13
|
+
#
|
17
14
|
#Max results per page: 100
|
18
15
|
def test_test_list_payments()
|
19
16
|
# Parameters for the API call
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
1
|
+
|
5
2
|
|
6
3
|
require_relative 'api_test_base'
|
7
4
|
|
@@ -12,8 +9,8 @@ class RefundsApiTests < ApiTestBase
|
|
12
9
|
@controller = RefundsApi.new CONFIG, http_call_back: @response_catcher
|
13
10
|
end
|
14
11
|
|
15
|
-
# Retrieves a list of refunds for the account making the request.
|
16
|
-
#
|
12
|
+
# Retrieves a list of refunds for the account making the request.
|
13
|
+
#
|
17
14
|
#Max results per page: 100
|
18
15
|
def test_test_list_payment_refunds()
|
19
16
|
# Parameters for the API call
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: square.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.5.0.20201028
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Square Developer Platform
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -16,42 +16,48 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '2.
|
19
|
+
version: '2.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '2.
|
26
|
+
version: '2.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
33
|
+
version: '1.0'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.0.1
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
41
|
- - "~>"
|
39
42
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
43
|
+
version: '1.0'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.0.1
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: faraday_middleware
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
53
|
+
version: '1.0'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
58
|
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
60
|
+
version: '1.0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: certifi
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,6 +65,9 @@ dependencies:
|
|
59
65
|
- - "~>"
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '2018.1'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2018.01.18
|
62
71
|
type: :runtime
|
63
72
|
prerelease: false
|
64
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,34 +75,43 @@ dependencies:
|
|
66
75
|
- - "~>"
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '2018.1'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2018.01.18
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: faraday-http-cache
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
73
85
|
- - "~>"
|
74
86
|
- !ruby/object:Gem::Version
|
75
|
-
version: '2.
|
87
|
+
version: '2.2'
|
76
88
|
type: :runtime
|
77
89
|
prerelease: false
|
78
90
|
version_requirements: !ruby/object:Gem::Requirement
|
79
91
|
requirements:
|
80
92
|
- - "~>"
|
81
93
|
- !ruby/object:Gem::Version
|
82
|
-
version: '2.
|
94
|
+
version: '2.2'
|
83
95
|
- !ruby/object:Gem::Dependency
|
84
96
|
name: minitest
|
85
97
|
requirement: !ruby/object:Gem::Requirement
|
86
98
|
requirements:
|
87
99
|
- - "~>"
|
88
100
|
- !ruby/object:Gem::Version
|
89
|
-
version: '5.
|
101
|
+
version: '5.14'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 5.14.1
|
90
105
|
type: :development
|
91
106
|
prerelease: false
|
92
107
|
version_requirements: !ruby/object:Gem::Requirement
|
93
108
|
requirements:
|
94
109
|
- - "~>"
|
95
110
|
- !ruby/object:Gem::Version
|
96
|
-
version: '5.
|
111
|
+
version: '5.14'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 5.14.1
|
97
115
|
- !ruby/object:Gem::Dependency
|
98
116
|
name: minitest-proveit
|
99
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,6 +149,7 @@ files:
|
|
131
149
|
- lib/square/api/disputes_api.rb
|
132
150
|
- lib/square/api/employees_api.rb
|
133
151
|
- lib/square/api/inventory_api.rb
|
152
|
+
- lib/square/api/invoices_api.rb
|
134
153
|
- lib/square/api/labor_api.rb
|
135
154
|
- lib/square/api/locations_api.rb
|
136
155
|
- lib/square/api/loyalty_api.rb
|
@@ -140,7 +159,7 @@ files:
|
|
140
159
|
- lib/square/api/orders_api.rb
|
141
160
|
- lib/square/api/payments_api.rb
|
142
161
|
- lib/square/api/refunds_api.rb
|
143
|
-
- lib/square/api/
|
162
|
+
- lib/square/api/subscriptions_api.rb
|
144
163
|
- lib/square/api/team_api.rb
|
145
164
|
- lib/square/api/terminal_api.rb
|
146
165
|
- lib/square/api/transactions_api.rb
|
@@ -192,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
211
|
- !ruby/object:Gem::Version
|
193
212
|
version: '0'
|
194
213
|
requirements: []
|
195
|
-
rubygems_version: 3.
|
214
|
+
rubygems_version: 3.1.4
|
196
215
|
signing_key:
|
197
216
|
specification_version: 4
|
198
217
|
summary: square
|
@@ -1,138 +0,0 @@
|
|
1
|
-
module Square
|
2
|
-
# ReportingApi
|
3
|
-
class ReportingApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
|
-
# Returns a list of refunded transactions (across all possible originating
|
9
|
-
# locations) relating to monies
|
10
|
-
# credited to the provided location ID by another Square account using the
|
11
|
-
# `additional_recipients` field in a transaction.
|
12
|
-
# Max results per [page](#paginatingresults): 50
|
13
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
14
|
-
# list AdditionalRecipientReceivableRefunds for.
|
15
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
16
|
-
# requested reporting period, in RFC 3339 format. See [Date
|
17
|
-
# ranges](#dateranges) for details on date inclusivity/exclusivity. Default
|
18
|
-
# value: The current time minus one year.
|
19
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
20
|
-
# reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
|
21
|
-
# details on date inclusivity/exclusivity. Default value: The current
|
22
|
-
# time.
|
23
|
-
# @param [SortOrder] sort_order Optional parameter: The order in which
|
24
|
-
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
25
|
-
# newest first). Default value: `DESC`
|
26
|
-
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
27
|
-
# a previous call to this endpoint. Provide this to retrieve the next set of
|
28
|
-
# results for your original query. See [Paginating
|
29
|
-
# results](#paginatingresults) for more information.
|
30
|
-
# @return [ListAdditionalRecipientReceivableRefundsResponse Hash] response from the API call
|
31
|
-
def list_additional_recipient_receivable_refunds(location_id:,
|
32
|
-
begin_time: nil,
|
33
|
-
end_time: nil,
|
34
|
-
sort_order: nil,
|
35
|
-
cursor: nil)
|
36
|
-
warn 'Endpoint list_additional_recipient_receivable_refunds in Reporting'\
|
37
|
-
'Api is deprecated'
|
38
|
-
# Prepare query url.
|
39
|
-
_query_builder = config.get_base_uri
|
40
|
-
_query_builder << '/v2/locations/{location_id}/additional-recipient-receivable-refunds'
|
41
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
42
|
-
_query_builder,
|
43
|
-
'location_id' => location_id
|
44
|
-
)
|
45
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
46
|
-
_query_builder,
|
47
|
-
'begin_time' => begin_time,
|
48
|
-
'end_time' => end_time,
|
49
|
-
'sort_order' => sort_order,
|
50
|
-
'cursor' => cursor
|
51
|
-
)
|
52
|
-
_query_url = APIHelper.clean_url _query_builder
|
53
|
-
|
54
|
-
# Prepare headers.
|
55
|
-
_headers = {
|
56
|
-
'accept' => 'application/json'
|
57
|
-
}
|
58
|
-
|
59
|
-
# Prepare and execute HttpRequest.
|
60
|
-
_request = config.http_client.get(
|
61
|
-
_query_url,
|
62
|
-
headers: _headers
|
63
|
-
)
|
64
|
-
OAuth2.apply(config, _request)
|
65
|
-
_response = execute_request(_request)
|
66
|
-
|
67
|
-
# Return appropriate response type.
|
68
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
69
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
70
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
71
|
-
end
|
72
|
-
|
73
|
-
# Returns a list of receivables (across all possible sending locations)
|
74
|
-
# representing monies credited
|
75
|
-
# to the provided location ID by another Square account using the
|
76
|
-
# `additional_recipients` field in a transaction.
|
77
|
-
# Max results per [page](#paginatingresults): 50
|
78
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
79
|
-
# list AdditionalRecipientReceivables for.
|
80
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
81
|
-
# requested reporting period, in RFC 3339 format. See [Date
|
82
|
-
# ranges](#dateranges) for details on date inclusivity/exclusivity. Default
|
83
|
-
# value: The current time minus one year.
|
84
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
85
|
-
# reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
|
86
|
-
# details on date inclusivity/exclusivity. Default value: The current
|
87
|
-
# time.
|
88
|
-
# @param [SortOrder] sort_order Optional parameter: The order in which
|
89
|
-
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
90
|
-
# newest first). Default value: `DESC`
|
91
|
-
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
92
|
-
# a previous call to this endpoint. Provide this to retrieve the next set of
|
93
|
-
# results for your original query. See [Paginating
|
94
|
-
# results](#paginatingresults) for more information.
|
95
|
-
# @return [ListAdditionalRecipientReceivablesResponse Hash] response from the API call
|
96
|
-
def list_additional_recipient_receivables(location_id:,
|
97
|
-
begin_time: nil,
|
98
|
-
end_time: nil,
|
99
|
-
sort_order: nil,
|
100
|
-
cursor: nil)
|
101
|
-
warn 'Endpoint list_additional_recipient_receivables in ReportingApi is '\
|
102
|
-
'deprecated'
|
103
|
-
# Prepare query url.
|
104
|
-
_query_builder = config.get_base_uri
|
105
|
-
_query_builder << '/v2/locations/{location_id}/additional-recipient-receivables'
|
106
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
107
|
-
_query_builder,
|
108
|
-
'location_id' => location_id
|
109
|
-
)
|
110
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
111
|
-
_query_builder,
|
112
|
-
'begin_time' => begin_time,
|
113
|
-
'end_time' => end_time,
|
114
|
-
'sort_order' => sort_order,
|
115
|
-
'cursor' => cursor
|
116
|
-
)
|
117
|
-
_query_url = APIHelper.clean_url _query_builder
|
118
|
-
|
119
|
-
# Prepare headers.
|
120
|
-
_headers = {
|
121
|
-
'accept' => 'application/json'
|
122
|
-
}
|
123
|
-
|
124
|
-
# Prepare and execute HttpRequest.
|
125
|
-
_request = config.http_client.get(
|
126
|
-
_query_url,
|
127
|
-
headers: _headers
|
128
|
-
)
|
129
|
-
OAuth2.apply(config, _request)
|
130
|
-
_response = execute_request(_request)
|
131
|
-
|
132
|
-
# Return appropriate response type.
|
133
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
134
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
135
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|