square.rb 3.3.0.20191217

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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +10 -0
  3. data/README.md +285 -0
  4. data/lib/square/api/apple_pay_api.rb +50 -0
  5. data/lib/square/api/base_api.rb +43 -0
  6. data/lib/square/api/cash_drawers_api.rb +150 -0
  7. data/lib/square/api/catalog_api.rb +545 -0
  8. data/lib/square/api/checkout_api.rb +49 -0
  9. data/lib/square/api/customers_api.rb +327 -0
  10. data/lib/square/api/employees_api.rb +86 -0
  11. data/lib/square/api/inventory_api.rb +295 -0
  12. data/lib/square/api/labor_api.rb +553 -0
  13. data/lib/square/api/locations_api.rb +146 -0
  14. data/lib/square/api/merchants_api.rb +82 -0
  15. data/lib/square/api/mobile_authorization_api.rb +52 -0
  16. data/lib/square/api/o_auth_api.rb +163 -0
  17. data/lib/square/api/orders_api.rb +266 -0
  18. data/lib/square/api/payments_api.rb +277 -0
  19. data/lib/square/api/refunds_api.rb +144 -0
  20. data/lib/square/api/reporting_api.rb +138 -0
  21. data/lib/square/api/transactions_api.rb +377 -0
  22. data/lib/square/api/v1_employees_api.rb +715 -0
  23. data/lib/square/api/v1_items_api.rb +2046 -0
  24. data/lib/square/api/v1_locations_api.rb +83 -0
  25. data/lib/square/api/v1_transactions_api.rb +568 -0
  26. data/lib/square/api_helper.rb +276 -0
  27. data/lib/square/client.rb +156 -0
  28. data/lib/square/configuration.rb +93 -0
  29. data/lib/square/exceptions/api_exception.rb +15 -0
  30. data/lib/square/http/api_response.rb +45 -0
  31. data/lib/square/http/auth/o_auth2.rb +12 -0
  32. data/lib/square/http/faraday_client.rb +59 -0
  33. data/lib/square/http/http_call_back.rb +19 -0
  34. data/lib/square/http/http_client.rb +99 -0
  35. data/lib/square/http/http_method_enum.rb +8 -0
  36. data/lib/square/http/http_request.rb +45 -0
  37. data/lib/square/http/http_response.rb +24 -0
  38. data/lib/square.rb +49 -0
  39. data/spec/user_journey_spec.rb +145 -0
  40. data/test/api/api_test_base.rb +24 -0
  41. data/test/api/test_catalog_api.rb +59 -0
  42. data/test/api/test_customers_api.rb +45 -0
  43. data/test/api/test_employees_api.rb +36 -0
  44. data/test/api/test_labor_api.rb +74 -0
  45. data/test/api/test_locations_api.rb +35 -0
  46. data/test/api/test_merchants_api.rb +40 -0
  47. data/test/api/test_payments_api.rb +42 -0
  48. data/test/api/test_refunds_api.rb +41 -0
  49. data/test/http_response_catcher.rb +19 -0
  50. data/test/test_helper.rb +94 -0
  51. metadata +190 -0
@@ -0,0 +1,40 @@
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 MerchantsApiTests < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ @response_catcher = HttpResponseCatcher.new
12
+ @controller = MerchantsApi.new CONFIG, http_call_back: @response_catcher
13
+ end
14
+
15
+ # Returns `Merchant` information for a given access token.
16
+ #
17
+ #If you don't know a `Merchant` ID, you can use this endpoint to retrieve the merchant ID for an access token.
18
+ #You can specify your personal access token to get your own merchant information or specify an OAuth token
19
+ #to get the information for the merchant that granted you access.
20
+ #
21
+ #If you know the merchant ID, you can also use the [RetrieveMerchant](#endpoint-merchants-retrievemerchant)
22
+ #endpoint to get the merchant information.
23
+ def test_list_merchants()
24
+ # Parameters for the API call
25
+ cursor = nil
26
+
27
+ # Perform the API call through the SDK function
28
+ result = @controller.list_merchants(cursor: cursor)
29
+
30
+ # Test response code
31
+ assert_equal(200, @response_catcher.response.status_code)
32
+
33
+ # Test headers
34
+ expected_headers = {}
35
+ expected_headers['content-type'] = 'application/json'
36
+
37
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
38
+ end
39
+
40
+ end
@@ -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
+
@@ -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,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: square.rb
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.3.0.20191217
5
+ platform: ruby
6
+ authors:
7
+ - Square Developer Platform
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-17 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: Use Square APIs to manage and run business including payment, customer,
112
+ product, inventory, and employee management.
113
+ email: developers@squareup.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - LICENSE
119
+ - README.md
120
+ - lib/square.rb
121
+ - lib/square/api/apple_pay_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/customers_api.rb
127
+ - lib/square/api/employees_api.rb
128
+ - lib/square/api/inventory_api.rb
129
+ - lib/square/api/labor_api.rb
130
+ - lib/square/api/locations_api.rb
131
+ - lib/square/api/merchants_api.rb
132
+ - lib/square/api/mobile_authorization_api.rb
133
+ - lib/square/api/o_auth_api.rb
134
+ - lib/square/api/orders_api.rb
135
+ - lib/square/api/payments_api.rb
136
+ - lib/square/api/refunds_api.rb
137
+ - lib/square/api/reporting_api.rb
138
+ - lib/square/api/transactions_api.rb
139
+ - lib/square/api/v1_employees_api.rb
140
+ - lib/square/api/v1_items_api.rb
141
+ - lib/square/api/v1_locations_api.rb
142
+ - lib/square/api/v1_transactions_api.rb
143
+ - lib/square/api_helper.rb
144
+ - lib/square/client.rb
145
+ - lib/square/configuration.rb
146
+ - lib/square/exceptions/api_exception.rb
147
+ - lib/square/http/api_response.rb
148
+ - lib/square/http/auth/o_auth2.rb
149
+ - lib/square/http/faraday_client.rb
150
+ - lib/square/http/http_call_back.rb
151
+ - lib/square/http/http_client.rb
152
+ - lib/square/http/http_method_enum.rb
153
+ - lib/square/http/http_request.rb
154
+ - lib/square/http/http_response.rb
155
+ - spec/user_journey_spec.rb
156
+ - test/api/api_test_base.rb
157
+ - test/api/test_catalog_api.rb
158
+ - test/api/test_customers_api.rb
159
+ - test/api/test_employees_api.rb
160
+ - test/api/test_labor_api.rb
161
+ - test/api/test_locations_api.rb
162
+ - test/api/test_merchants_api.rb
163
+ - test/api/test_payments_api.rb
164
+ - test/api/test_refunds_api.rb
165
+ - test/http_response_catcher.rb
166
+ - test/test_helper.rb
167
+ homepage: https://squareup.com/developers
168
+ licenses:
169
+ - Apache-2.0
170
+ metadata: {}
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '2.0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubygems_version: 3.0.3
187
+ signing_key:
188
+ specification_version: 4
189
+ summary: square
190
+ test_files: []