fangkuai.rb 0.0.1
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 +7 -0
- data/LICENSE +10 -0
- data/README.md +1 -0
- data/lib/square.rb +61 -0
- data/lib/square/api/apple_pay_api.rb +50 -0
- data/lib/square/api/bank_accounts_api.rb +136 -0
- data/lib/square/api/base_api.rb +43 -0
- data/lib/square/api/cash_drawers_api.rb +150 -0
- data/lib/square/api/catalog_api.rb +572 -0
- data/lib/square/api/checkout_api.rb +49 -0
- data/lib/square/api/customer_groups_api.rb +182 -0
- data/lib/square/api/customer_segments_api.rb +78 -0
- data/lib/square/api/customers_api.rb +418 -0
- data/lib/square/api/devices_api.rb +120 -0
- data/lib/square/api/disputes_api.rb +398 -0
- data/lib/square/api/employees_api.rb +87 -0
- data/lib/square/api/inventory_api.rb +296 -0
- data/lib/square/api/invoices_api.rb +358 -0
- data/lib/square/api/labor_api.rb +630 -0
- data/lib/square/api/locations_api.rb +151 -0
- data/lib/square/api/loyalty_api.rb +543 -0
- data/lib/square/api/merchants_api.rb +83 -0
- data/lib/square/api/mobile_authorization_api.rb +52 -0
- data/lib/square/api/o_auth_api.rb +163 -0
- data/lib/square/api/orders_api.rb +280 -0
- data/lib/square/api/payments_api.rb +279 -0
- data/lib/square/api/refunds_api.rb +145 -0
- data/lib/square/api/subscriptions_api.rb +251 -0
- data/lib/square/api/team_api.rb +326 -0
- data/lib/square/api/terminal_api.rb +141 -0
- data/lib/square/api/transactions_api.rb +369 -0
- data/lib/square/api/v1_employees_api.rb +723 -0
- data/lib/square/api/v1_items_api.rb +1686 -0
- data/lib/square/api/v1_locations_api.rb +65 -0
- data/lib/square/api/v1_transactions_api.rb +572 -0
- data/lib/square/api_helper.rb +276 -0
- data/lib/square/client.rb +211 -0
- data/lib/square/configuration.rb +101 -0
- data/lib/square/exceptions/api_exception.rb +15 -0
- data/lib/square/http/api_response.rb +45 -0
- data/lib/square/http/auth/o_auth2.rb +12 -0
- data/lib/square/http/faraday_client.rb +55 -0
- data/lib/square/http/http_call_back.rb +19 -0
- data/lib/square/http/http_client.rb +99 -0
- data/lib/square/http/http_method_enum.rb +8 -0
- data/lib/square/http/http_request.rb +45 -0
- data/lib/square/http/http_response.rb +24 -0
- data/lib/square/utilities/file_wrapper.rb +12 -0
- data/spec/user_journey_spec.rb +148 -0
- data/test/api/api_test_base.rb +24 -0
- data/test/api/test_catalog_api.rb +59 -0
- data/test/api/test_customers_api.rb +45 -0
- data/test/api/test_employees_api.rb +36 -0
- data/test/api/test_labor_api.rb +74 -0
- data/test/api/test_locations_api.rb +35 -0
- data/test/api/test_merchants_api.rb +40 -0
- data/test/api/test_payments_api.rb +42 -0
- data/test/api/test_refunds_api.rb +41 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/test_helper.rb +94 -0
- metadata +199 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require_relative 'api_test_base'
|
7
|
+
|
8
|
+
class PaymentsApiTests < ApiTestBase
|
9
|
+
# Called only once for the class before any test has executed
|
10
|
+
def setup
|
11
|
+
@response_catcher = HttpResponseCatcher.new
|
12
|
+
@controller = PaymentsApi.new CONFIG, http_call_back: @response_catcher
|
13
|
+
end
|
14
|
+
|
15
|
+
# Retrieves a list of payments taken by the account making the request.
|
16
|
+
#
|
17
|
+
#Max results per page: 100
|
18
|
+
def test_test_list_payments()
|
19
|
+
# Parameters for the API call
|
20
|
+
begin_time = nil
|
21
|
+
end_time = nil
|
22
|
+
sort_order = nil
|
23
|
+
cursor = nil
|
24
|
+
location_id = nil
|
25
|
+
total = nil
|
26
|
+
last_4 = nil
|
27
|
+
card_brand = nil
|
28
|
+
|
29
|
+
# Perform the API call through the SDK function
|
30
|
+
result = @controller.list_payments(begin_time: begin_time, end_time: end_time, sort_order: sort_order, cursor: cursor, location_id: location_id, total: total, last_4: last_4, card_brand: card_brand)
|
31
|
+
|
32
|
+
# Test response code
|
33
|
+
assert_equal(200, @response_catcher.response.status_code)
|
34
|
+
|
35
|
+
# Test headers
|
36
|
+
expected_headers = {}
|
37
|
+
expected_headers['content-type'] = 'application/json'
|
38
|
+
|
39
|
+
assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require_relative 'api_test_base'
|
7
|
+
|
8
|
+
class RefundsApiTests < ApiTestBase
|
9
|
+
# Called only once for the class before any test has executed
|
10
|
+
def setup
|
11
|
+
@response_catcher = HttpResponseCatcher.new
|
12
|
+
@controller = RefundsApi.new CONFIG, http_call_back: @response_catcher
|
13
|
+
end
|
14
|
+
|
15
|
+
# Retrieves a list of refunds for the account making the request.
|
16
|
+
#
|
17
|
+
#Max results per page: 100
|
18
|
+
def test_test_list_payment_refunds()
|
19
|
+
# Parameters for the API call
|
20
|
+
begin_time = nil
|
21
|
+
end_time = nil
|
22
|
+
sort_order = nil
|
23
|
+
cursor = nil
|
24
|
+
location_id = nil
|
25
|
+
status = nil
|
26
|
+
source_type = nil
|
27
|
+
|
28
|
+
# Perform the API call through the SDK function
|
29
|
+
result = @controller.list_payment_refunds(begin_time: begin_time, end_time: end_time, sort_order: sort_order, cursor: cursor, location_id: location_id, status: status, source_type: source_type)
|
30
|
+
|
31
|
+
# Test response code
|
32
|
+
assert_equal(200, @response_catcher.response.status_code)
|
33
|
+
|
34
|
+
# Test headers
|
35
|
+
expected_headers = {}
|
36
|
+
expected_headers['content-type'] = 'application/json'
|
37
|
+
|
38
|
+
assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
class HttpResponseCatcher < Square::HttpCallBack
|
7
|
+
attr_accessor :response
|
8
|
+
|
9
|
+
def on_before_request(request)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Catching the response
|
13
|
+
def on_after_response(response)
|
14
|
+
@response = response
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
require 'tempfile'
|
7
|
+
require 'open-uri'
|
8
|
+
|
9
|
+
class TestHelper
|
10
|
+
|
11
|
+
@cache = Hash.new
|
12
|
+
|
13
|
+
# Class method to compare the received headers with the expected headers.
|
14
|
+
# @param [Hash] A hash of expected headers (keys in lower case).
|
15
|
+
# @param [Hash] A hash of received headers.
|
16
|
+
# @param [Boolean, optional] A flag which determines if we allow extra headers.
|
17
|
+
def self.match_headers(expected_headers,
|
18
|
+
received_headers,
|
19
|
+
allow_extra: true)
|
20
|
+
return false if ((received_headers.length < expected_headers.length) ||
|
21
|
+
((allow_extra == false) && (received_headers.length > expected_headers.length)))
|
22
|
+
|
23
|
+
received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
|
24
|
+
expected_headers.each do |e_key, e_value|
|
25
|
+
return false unless received_headers.key?(e_key)
|
26
|
+
return false if ((e_value != nil) &&
|
27
|
+
(e_value != received_headers[e_key]))
|
28
|
+
end
|
29
|
+
|
30
|
+
return true
|
31
|
+
end
|
32
|
+
|
33
|
+
# Class method to compare the received body with the expected body.
|
34
|
+
# @param [Dynamic] The expected body.
|
35
|
+
# @param [Dynamic] The received body.
|
36
|
+
# @param [Boolean, optional] A flag which determines if we check values in dictionaries.
|
37
|
+
# @param [Boolean, optional] A flag which determines if we check the order of array elements.
|
38
|
+
# @param [Boolean, optional] A flag which determines if we check the count of array elements.
|
39
|
+
def self.match_body(expected_body,
|
40
|
+
received_body,
|
41
|
+
check_values: false,
|
42
|
+
check_order: false,
|
43
|
+
check_count: false)
|
44
|
+
if expected_body.instance_of? Hash
|
45
|
+
return false unless received_body.instance_of? Hash
|
46
|
+
for key in expected_body.keys
|
47
|
+
return false unless received_body.keys.include? key
|
48
|
+
if check_values or expected_body[key].instance_of? Hash
|
49
|
+
return false unless TestHelper.match_body(expected_body[key],
|
50
|
+
received_body[key],
|
51
|
+
check_values: check_values,
|
52
|
+
check_order: check_order,
|
53
|
+
check_count: check_count)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
elsif expected_body.instance_of? Array
|
57
|
+
return False unless received_body.instance_of? Array
|
58
|
+
if check_count == true && (expected_body.length != received_body.length)
|
59
|
+
return false
|
60
|
+
else
|
61
|
+
previous_matches = Array.new
|
62
|
+
expected_body.each.with_index do |expected_element, i|
|
63
|
+
matches = (received_body.map.with_index do |received_element, j|
|
64
|
+
j if TestHelper.match_body(expected_element,
|
65
|
+
received_element,
|
66
|
+
check_values: check_values,
|
67
|
+
check_order: check_order,
|
68
|
+
check_count: check_count)
|
69
|
+
end).compact
|
70
|
+
return false if matches.length == 0
|
71
|
+
if check_order == true
|
72
|
+
return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
|
73
|
+
previous_matches = matches
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
elsif expected_body != received_body
|
78
|
+
return false
|
79
|
+
end
|
80
|
+
return true
|
81
|
+
end
|
82
|
+
|
83
|
+
# Class method which takes a URL, downloads the file (if not already downloaded
|
84
|
+
# for this test session) and returns the path of the file.
|
85
|
+
# @param [String] The URL of the required file.
|
86
|
+
def self.get_file(url)
|
87
|
+
unless @cache.keys.include? url
|
88
|
+
@cache[url] = Tempfile.new('APIMatic')
|
89
|
+
@cache[url].binmode
|
90
|
+
@cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
|
91
|
+
end
|
92
|
+
return @cache[url].path
|
93
|
+
end
|
94
|
+
end
|
metadata
ADDED
@@ -0,0 +1,199 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fangkuai.rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- okenshields
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logging
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.15'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday_middleware
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.13'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.13'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: certifi
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2018.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2018.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: faraday-http-cache
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '5.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: minitest-proveit
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
description: ''
|
112
|
+
email: okenshields@example.com
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- LICENSE
|
118
|
+
- README.md
|
119
|
+
- lib/square.rb
|
120
|
+
- lib/square/api/apple_pay_api.rb
|
121
|
+
- lib/square/api/bank_accounts_api.rb
|
122
|
+
- lib/square/api/base_api.rb
|
123
|
+
- lib/square/api/cash_drawers_api.rb
|
124
|
+
- lib/square/api/catalog_api.rb
|
125
|
+
- lib/square/api/checkout_api.rb
|
126
|
+
- lib/square/api/customer_groups_api.rb
|
127
|
+
- lib/square/api/customer_segments_api.rb
|
128
|
+
- lib/square/api/customers_api.rb
|
129
|
+
- lib/square/api/devices_api.rb
|
130
|
+
- lib/square/api/disputes_api.rb
|
131
|
+
- lib/square/api/employees_api.rb
|
132
|
+
- lib/square/api/inventory_api.rb
|
133
|
+
- lib/square/api/invoices_api.rb
|
134
|
+
- lib/square/api/labor_api.rb
|
135
|
+
- lib/square/api/locations_api.rb
|
136
|
+
- lib/square/api/loyalty_api.rb
|
137
|
+
- lib/square/api/merchants_api.rb
|
138
|
+
- lib/square/api/mobile_authorization_api.rb
|
139
|
+
- lib/square/api/o_auth_api.rb
|
140
|
+
- lib/square/api/orders_api.rb
|
141
|
+
- lib/square/api/payments_api.rb
|
142
|
+
- lib/square/api/refunds_api.rb
|
143
|
+
- lib/square/api/subscriptions_api.rb
|
144
|
+
- lib/square/api/team_api.rb
|
145
|
+
- lib/square/api/terminal_api.rb
|
146
|
+
- lib/square/api/transactions_api.rb
|
147
|
+
- lib/square/api/v1_employees_api.rb
|
148
|
+
- lib/square/api/v1_items_api.rb
|
149
|
+
- lib/square/api/v1_locations_api.rb
|
150
|
+
- lib/square/api/v1_transactions_api.rb
|
151
|
+
- lib/square/api_helper.rb
|
152
|
+
- lib/square/client.rb
|
153
|
+
- lib/square/configuration.rb
|
154
|
+
- lib/square/exceptions/api_exception.rb
|
155
|
+
- lib/square/http/api_response.rb
|
156
|
+
- lib/square/http/auth/o_auth2.rb
|
157
|
+
- lib/square/http/faraday_client.rb
|
158
|
+
- lib/square/http/http_call_back.rb
|
159
|
+
- lib/square/http/http_client.rb
|
160
|
+
- lib/square/http/http_method_enum.rb
|
161
|
+
- lib/square/http/http_request.rb
|
162
|
+
- lib/square/http/http_response.rb
|
163
|
+
- lib/square/utilities/file_wrapper.rb
|
164
|
+
- spec/user_journey_spec.rb
|
165
|
+
- test/api/api_test_base.rb
|
166
|
+
- test/api/test_catalog_api.rb
|
167
|
+
- test/api/test_customers_api.rb
|
168
|
+
- test/api/test_employees_api.rb
|
169
|
+
- test/api/test_labor_api.rb
|
170
|
+
- test/api/test_locations_api.rb
|
171
|
+
- test/api/test_merchants_api.rb
|
172
|
+
- test/api/test_payments_api.rb
|
173
|
+
- test/api/test_refunds_api.rb
|
174
|
+
- test/http_response_catcher.rb
|
175
|
+
- test/test_helper.rb
|
176
|
+
homepage: https://github.com/okenshields
|
177
|
+
licenses:
|
178
|
+
- Apache-2.0
|
179
|
+
metadata: {}
|
180
|
+
post_install_message:
|
181
|
+
rdoc_options: []
|
182
|
+
require_paths:
|
183
|
+
- lib
|
184
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
|
+
requirements:
|
186
|
+
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '2.0'
|
189
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - ">="
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '0'
|
194
|
+
requirements: []
|
195
|
+
rubygems_version: 3.1.4
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: fangkuai
|
199
|
+
test_files: []
|