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,99 @@
1
+ module Square
2
+ # An interface for the methods that an HTTP Client must implement.
3
+ #
4
+ # This class should not be instantiated but should be used as a base class
5
+ # for HTTP Client classes.
6
+ class HttpClient
7
+ # Execute an HttpRequest when the response is expected to be a string.
8
+ # @param [HttpRequest] The HttpRequest to be executed.
9
+ def execute_as_string(_http_request)
10
+ raise NotImplementedError, 'This method needs
11
+ to be implemented in a child class.'
12
+ end
13
+
14
+ # Execute an HttpRequest when the response is expected to be binary.
15
+ # @param [HttpRequest] The HttpRequest to be executed.
16
+ def execute_as_binary(_http_request)
17
+ raise NotImplementedError, 'This method needs
18
+ to be implemented in a child class.'
19
+ end
20
+
21
+ # Converts the HTTP Response from the client to an HttpResponse object.
22
+ # @param [Dynamic] The response object received from the client.
23
+ def convert_response(_response)
24
+ raise NotImplementedError, 'This method needs
25
+ to be implemented in a child class.'
26
+ end
27
+
28
+ # Get a GET HttpRequest object.
29
+ # @param [String] The URL to send the request to.
30
+ # @param [Hash, Optional] The headers for the HTTP Request.
31
+ def get(query_url,
32
+ headers: {})
33
+ HttpRequest.new(HttpMethodEnum::GET,
34
+ query_url,
35
+ headers: headers)
36
+ end
37
+
38
+ # Get a HEAD HttpRequest object.
39
+ # @param [String] The URL to send the request to.
40
+ # @param [Hash, Optional] The headers for the HTTP Request.
41
+ def head(query_url,
42
+ headers: {})
43
+ HttpRequest.new(HttpMethodEnum::HEAD,
44
+ query_url,
45
+ headers: headers)
46
+ end
47
+
48
+ # Get a POST HttpRequest object.
49
+ # @param [String] The URL to send the request to.
50
+ # @param [Hash, Optional] The headers for the HTTP Request.
51
+ # @param [Hash, Optional] The parameters for the HTTP Request.
52
+ def post(query_url,
53
+ headers: {},
54
+ parameters: {})
55
+ HttpRequest.new(HttpMethodEnum::POST,
56
+ query_url,
57
+ headers: headers,
58
+ parameters: parameters)
59
+ end
60
+
61
+ # Get a PUT HttpRequest object.
62
+ # @param [String] The URL to send the request to.
63
+ # @param [Hash, Optional] The headers for the HTTP Request.
64
+ # @param [Hash, Optional] The parameters for the HTTP Request.
65
+ def put(query_url,
66
+ headers: {},
67
+ parameters: {})
68
+ HttpRequest.new(HttpMethodEnum::PUT,
69
+ query_url,
70
+ headers: headers,
71
+ parameters: parameters)
72
+ end
73
+
74
+ # Get a PATCH HttpRequest object.
75
+ # @param [String] The URL to send the request to.
76
+ # @param [Hash, Optional] The headers for the HTTP Request.
77
+ # @param [Hash, Optional] The parameters for the HTTP Request.
78
+ def patch(query_url,
79
+ headers: {},
80
+ parameters: {})
81
+ HttpRequest.new(HttpMethodEnum::PATCH,
82
+ query_url,
83
+ headers: headers,
84
+ parameters: parameters)
85
+ end
86
+
87
+ # Get a DELETE HttpRequest object.
88
+ # @param [String] The URL to send the request to.
89
+ # @param [Hash, Optional] The headers for the HTTP Request.
90
+ def delete(query_url,
91
+ headers: {},
92
+ parameters: {})
93
+ HttpRequest.new(HttpMethodEnum::DELETE,
94
+ query_url,
95
+ headers: headers,
96
+ parameters: parameters)
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,8 @@
1
+ module Square
2
+ # HTTP Methods Enumeration.
3
+ class HttpMethodEnum
4
+ HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
5
+ PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
6
+ DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
7
+ end
8
+ end
@@ -0,0 +1,45 @@
1
+ module Square
2
+ # Represents a single Http Request.
3
+ class HttpRequest
4
+ attr_accessor :http_method, :query_url, :headers,
5
+ :parameters, :username, :password
6
+
7
+ # The constructor.
8
+ # @param [HttpMethodEnum] The HTTP method.
9
+ # @param [String] The URL to send the request to.
10
+ # @param [Hash, Optional] The headers for the HTTP Request.
11
+ # @param [Hash, Optional] The parameters for the HTTP Request.
12
+ def initialize(http_method,
13
+ query_url,
14
+ headers: {},
15
+ parameters: {})
16
+ @http_method = http_method
17
+ @query_url = query_url
18
+ @headers = headers
19
+ @parameters = parameters
20
+ end
21
+
22
+ # Add a header to the HttpRequest.
23
+ # @param [String] The name of the header.
24
+ # @param [String] The value of the header.
25
+ def add_header(name, value)
26
+ @headers[name] = value
27
+ end
28
+
29
+ # Add a parameter to the HttpRequest.
30
+ # @param [String] The name of the parameter.
31
+ # @param [String] The value of the parameter.
32
+ def add_parameter(name, value)
33
+ @parameters[name] = value
34
+ end
35
+
36
+ # Add a query parameter to the HttpRequest.
37
+ # @param [String] The name of the query parameter.
38
+ # @param [String] The value of the query parameter.
39
+ def add_query_parameter(name, value)
40
+ @query_url = APIHelper.append_url_with_query_parameters(@query_url,
41
+ name => value)
42
+ @query_url = APIHelper.clean_url(@query_url)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,24 @@
1
+ module Square
2
+ # Http response received.
3
+ class HttpResponse
4
+ attr_reader :status_code, :reason_phrase, :headers, :raw_body, :request
5
+
6
+ # The constructor
7
+ # @param [Integer] The status code returned by the server.
8
+ # @param [String] The reason phrase returned by the server.
9
+ # @param [Hash] The headers sent by the server in the response.
10
+ # @param [String] The raw body of the response.
11
+ # @param [HttpRequest] The request that resulted in this response.
12
+ def initialize(status_code,
13
+ reason_phrase,
14
+ headers,
15
+ raw_body,
16
+ request)
17
+ @status_code = status_code
18
+ @reason_phrase = reason_phrase
19
+ @headers = headers
20
+ @raw_body = raw_body
21
+ @request = request
22
+ end
23
+ end
24
+ end
data/lib/square.rb ADDED
@@ -0,0 +1,49 @@
1
+ require 'date'
2
+ require 'json'
3
+ require 'faraday'
4
+ require 'certifi'
5
+ require 'logging'
6
+
7
+ require_relative 'square/api_helper.rb'
8
+ require_relative 'square/client.rb'
9
+
10
+ # Http
11
+ require_relative 'square/http/api_response.rb'
12
+ require_relative 'square/http/http_call_back.rb'
13
+ require_relative 'square/http/http_client.rb'
14
+ require_relative 'square/http/faraday_client.rb'
15
+ require_relative 'square/http/http_method_enum.rb'
16
+ require_relative 'square/http/http_request.rb'
17
+ require_relative 'square/http/http_response.rb'
18
+ require_relative 'square/http/auth/o_auth2.rb'
19
+
20
+ # Models
21
+
22
+ # Exceptions
23
+ require_relative 'square/exceptions/api_exception.rb'
24
+
25
+ require_relative 'square/configuration.rb'
26
+
27
+ # Controllers
28
+ require_relative 'square/api/base_api.rb'
29
+ require_relative 'square/api/mobile_authorization_api.rb'
30
+ require_relative 'square/api/o_auth_api.rb'
31
+ require_relative 'square/api/v1_locations_api.rb'
32
+ require_relative 'square/api/v1_employees_api.rb'
33
+ require_relative 'square/api/v1_transactions_api.rb'
34
+ require_relative 'square/api/v1_items_api.rb'
35
+ require_relative 'square/api/apple_pay_api.rb'
36
+ require_relative 'square/api/cash_drawers_api.rb'
37
+ require_relative 'square/api/catalog_api.rb'
38
+ require_relative 'square/api/customers_api.rb'
39
+ require_relative 'square/api/employees_api.rb'
40
+ require_relative 'square/api/inventory_api.rb'
41
+ require_relative 'square/api/labor_api.rb'
42
+ require_relative 'square/api/locations_api.rb'
43
+ require_relative 'square/api/reporting_api.rb'
44
+ require_relative 'square/api/checkout_api.rb'
45
+ require_relative 'square/api/orders_api.rb'
46
+ require_relative 'square/api/transactions_api.rb'
47
+ require_relative 'square/api/merchants_api.rb'
48
+ require_relative 'square/api/payments_api.rb'
49
+ require_relative 'square/api/refunds_api.rb'
@@ -0,0 +1,145 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../test/api/api_test_base'
4
+ require 'json'
5
+
6
+ describe "UserJourney" do
7
+ let(:access_token) { ApiTestBase::CONFIG.access_token }
8
+ let(:environment) { ApiTestBase::CONFIG.environment }
9
+
10
+ let(:phone_number) { "1-212-555-4240" }
11
+ let(:phone_number2) { "1-917-500-1000" }
12
+ let(:postal_code) { "10003" }
13
+ let(:postal_code2) { "98100" }
14
+
15
+ let :customer do
16
+ {
17
+ "given_name": "Amelia",
18
+ "family_name": "Earhart",
19
+ "phone_number": phone_number,
20
+ "note": "a customer",
21
+ "address": {
22
+ "address_line_1": "500 Electric Ave",
23
+ "address_line_2": "Suite 600",
24
+ "locality": "New York",
25
+ "administrative_district_level_1": "NY",
26
+ "postal_code": postal_code,
27
+ "country": "US"
28
+ }
29
+ }
30
+ end
31
+
32
+ let :sq do
33
+ Square::Client.new(access_token: access_token, environment: environment)
34
+ end
35
+
36
+ let :unauthoerized_sq do
37
+ Square::Client.new(access_token: "bad_token")
38
+ end
39
+
40
+ let :customer2 do
41
+ tmp_customer = customer.clone
42
+ tmp_customer[:phone_number] = phone_number2
43
+ tmp_customer[:address][:postal_code] = postal_code2
44
+ tmp_customer
45
+ end
46
+
47
+ describe 'Response Object Verification' do
48
+ it "should contain following fields" do
49
+ response = sq.locations.list_locations
50
+ assert_equal response.status_code, 200
51
+ assert_includes response.body.to_h.keys, :locations
52
+ assert_equal response.data.to_h.keys, %i[locations]
53
+ assert_nil response.errors
54
+ assert_nil response.cursor
55
+ end
56
+ end
57
+
58
+ describe 'ListLocations' do
59
+ it 'should return success 200' do
60
+ assert_equal sq.locations.list_locations.status_code, 200
61
+ end
62
+ end
63
+
64
+ describe 'API Call Error' do
65
+ it 'should return error' do
66
+ response = unauthoerized_sq.locations.list_locations
67
+ assert_equal response.status_code, 401
68
+ assert_instance_of Array, response.errors
69
+ refute_nil response.errors
70
+ end
71
+ end
72
+
73
+ # There is no sandbox support for V1 endpoints as production token is required for the following tests
74
+ # describe 'V1 Category' do
75
+ # it 'should succeed for each endpoint call' do
76
+ # location_id = "your_location_id"
77
+ # access_token = "your_production_access_token"
78
+ # name1 = "fruit"
79
+ # name2 = "drink"
80
+ # api = Square::Client.new(access_token: access_token).v1_items
81
+ #
82
+ # # create
83
+ # response = api.create_category(location_id: location_id, body: {name: name1})
84
+ # assert_equal response.data.name, name1
85
+ # assert_nil response.errors
86
+ # assert_equal response.status_code, 200
87
+ #
88
+ # created_id = response.data.id
89
+ #
90
+ # # list
91
+ # response = api.list_categories(location_id: location_id)
92
+ # assert_instance_of Array, response.data
93
+ # assert_equal response.status_code, 200
94
+ #
95
+ # # update
96
+ # response = api.update_category(location_id: location_id, category_id: created_id, body: {name: name2})
97
+ # assert_equal response.data.name, name2
98
+ # assert_equal response.status_code, 200
99
+ #
100
+ # # delete
101
+ # response = api.delete_category(location_id: location_id, category_id: created_id)
102
+ # assert_nil response.data
103
+ # assert_equal response.status_code, 200
104
+ # end
105
+ # end
106
+
107
+ describe 'V2 Customers' do
108
+ it 'should succeed for each endpoint call' do
109
+ # create
110
+ response = sq.customers.create_customer(body: customer)
111
+ assert_equal response.data.customer[:phone_number], phone_number
112
+
113
+ assert_equal response.status_code, 200
114
+ created_customer = response.data.customer
115
+
116
+ # retrieve
117
+ response = sq.customers.retrieve_customer(customer_id: created_customer[:id])
118
+ assert_equal response.data.customer[:phone_number], phone_number
119
+ assert_equal response.data.customer[:address][:postal_code], postal_code
120
+ assert_equal response.status_code, 200
121
+
122
+ # list
123
+ response = sq.customers.list_customers
124
+ assert_equal response.data.to_h.keys, %i[customers]
125
+ assert_equal response.status_code, 200
126
+
127
+ # update
128
+ response = sq.customers.update_customer(customer_id: created_customer[:id], body: customer2)
129
+ assert_equal response.data.customer[:phone_number], phone_number2
130
+ assert_equal response.data.customer[:address][:postal_code], postal_code2
131
+ assert_equal response.status_code, 200
132
+
133
+ # retrieve
134
+ response = sq.customers.retrieve_customer(customer_id: created_customer[:id])
135
+ assert_equal response.data.customer[:phone_number], phone_number2
136
+ assert_equal response.data.customer[:address][:postal_code], postal_code2
137
+ assert_equal response.status_code, 200
138
+
139
+ # delete
140
+ response = sq.customers.delete_customer(customer_id: created_customer[:id])
141
+ assert_equal response.data.to_h, {}
142
+ assert_equal response.status_code, 200
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,24 @@
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'json'
7
+ require 'minitest/autorun'
8
+ require 'minitest/hell'
9
+ require 'minitest/pride'
10
+ require 'minitest/proveit'
11
+ require 'square'
12
+ require_relative '../test_helper'
13
+ require_relative '../http_response_catcher'
14
+
15
+ class ApiTestBase < Minitest::Test
16
+ parallelize_me!
17
+ include Square
18
+
19
+ # Create configuration and set any test parameters
20
+ CONFIG = Configuration.new(
21
+ access_token: ENV.fetch('SQUARE_SANDBOX_TOKEN', 'AccessToken'),
22
+ environment: "sandbox"
23
+ )
24
+ end
@@ -0,0 +1,59 @@
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 CatalogApiTests < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ @response_catcher = HttpResponseCatcher.new
12
+ @controller = CatalogApi.new CONFIG, http_call_back: @response_catcher
13
+ end
14
+
15
+ # Returns information about the Square Catalog API, such as batch size
16
+ #limits for `BatchUpsertCatalogObjects`.
17
+ def test_test_catalog_info()
18
+
19
+ # Perform the API call through the SDK function
20
+ result = @controller.catalog_info()
21
+
22
+ # Test response code
23
+ assert_equal(200, @response_catcher.response.status_code)
24
+
25
+ # Test headers
26
+ expected_headers = {}
27
+ expected_headers['content-type'] = 'application/json'
28
+
29
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
30
+ end
31
+
32
+ # Returns a list of [CatalogObject](#type-catalogobject)s that includes
33
+ #all objects of a set of desired types (for example, all [CatalogItem](#type-catalogitem)
34
+ #and [CatalogTax](#type-catalogtax) objects) in the catalog. The `types` parameter
35
+ #is specified as a comma-separated list of valid [CatalogObject](#type-catalogobject) types:
36
+ #`ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`, `DISCOUNT`, `TAX`.
37
+ #
38
+ #__Important:__ ListCatalog does not return deleted catalog items. To retrieve
39
+ #deleted catalog items, use SearchCatalogObjects and set `include_deleted_objects`
40
+ #to `true`.
41
+ def test_test_list_catalog()
42
+ # Parameters for the API call
43
+ cursor = nil
44
+ types = nil
45
+
46
+ # Perform the API call through the SDK function
47
+ result = @controller.list_catalog(cursor: cursor, types: types)
48
+
49
+ # Test response code
50
+ assert_equal(200, @response_catcher.response.status_code)
51
+
52
+ # Test headers
53
+ expected_headers = {}
54
+ expected_headers['content-type'] = 'application/json'
55
+
56
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
57
+ end
58
+
59
+ end
@@ -0,0 +1,45 @@
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 CustomersApiTests < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ @response_catcher = HttpResponseCatcher.new
12
+ @controller = CustomersApi.new CONFIG, http_call_back: @response_catcher
13
+ end
14
+
15
+ # Creates a new customer for a business, which can have associated cards on file.
16
+ #
17
+ #You must provide __at least one__ of the following values in your request to this
18
+ #endpoint:
19
+ #
20
+ #- `given_name`
21
+ #- `family_name`
22
+ #- `company_name`
23
+ #- `email_address`
24
+ #- `phone_number`
25
+ #
26
+ #This endpoint does not accept an idempotency key. If you accidentally create
27
+ #a duplicate customer, you can delete it with the
28
+ #[DeleteCustomer](#endpoint-deletecustomer) endpoint.
29
+ def test_create_customer()
30
+ # Parameters for the API call
31
+ body = APIHelper.json_deserialize(
32
+ '{"given_name":"Amelia","family_name":"Earhart","email_address":"Amelia.Ear'\
33
+ 'hart@example.com","address":{"address_line_1":"500 Electric Ave","address_l'\
34
+ 'ine_2":"Suite 600","locality":"New York"},"phone_number":"1-212-555-4240","'\
35
+ 'reference_id":"YOUR_REFERENCE_ID","note":"a customer"}'
36
+ )
37
+
38
+ # Perform the API call through the SDK function
39
+ result = @controller.create_customer(body: body)
40
+
41
+ # Test response code
42
+ assert_equal(200, @response_catcher.response.status_code)
43
+ end
44
+
45
+ end
@@ -0,0 +1,36 @@
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 EmployeesApiTests < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ @response_catcher = HttpResponseCatcher.new
12
+ @controller = EmployeesApi.new CONFIG, http_call_back: @response_catcher
13
+ end
14
+
15
+ # Gets a list of `Employee` objects for a business.
16
+ def test_test_list_employees()
17
+ # Parameters for the API call
18
+ location_id = nil
19
+ status = nil
20
+ limit = nil
21
+ cursor = nil
22
+
23
+ # Perform the API call through the SDK function
24
+ result = @controller.list_employees(location_id: location_id, status: status, limit: limit, cursor: cursor)
25
+
26
+ # Test response code
27
+ assert_equal(200, @response_catcher.response.status_code)
28
+
29
+ # Test headers
30
+ expected_headers = {}
31
+ expected_headers['content-type'] = 'application/json'
32
+
33
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
34
+ end
35
+
36
+ end
@@ -0,0 +1,74 @@
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 LaborApiTests < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ @response_catcher = HttpResponseCatcher.new
12
+ @controller = LaborApi.new CONFIG, http_call_back: @response_catcher
13
+ end
14
+
15
+ # Returns a paginated list of `BreakType` instances for a business.
16
+ def test_list_break_types()
17
+ # Parameters for the API call
18
+ location_id = nil
19
+ limit = nil
20
+ cursor = nil
21
+
22
+ # Perform the API call through the SDK function
23
+ result = @controller.list_break_types(location_id: location_id, limit: limit, cursor: cursor)
24
+
25
+ # Test response code
26
+ assert_equal(200, @response_catcher.response.status_code)
27
+
28
+ # Test headers
29
+ expected_headers = {}
30
+ expected_headers['content-type'] = 'application/json'
31
+
32
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
33
+ end
34
+
35
+ # Returns a paginated list of `EmployeeWage` instances for a business.
36
+ def test_list_employee_wages()
37
+ # Parameters for the API call
38
+ employee_id = nil
39
+ limit = nil
40
+ cursor = nil
41
+
42
+ # Perform the API call through the SDK function
43
+ result = @controller.list_employee_wages(employee_id: employee_id, limit: limit, cursor: cursor)
44
+
45
+ # Test response code
46
+ assert_equal(200, @response_catcher.response.status_code)
47
+
48
+ # Test headers
49
+ expected_headers = {}
50
+ expected_headers['content-type'] = 'application/json'
51
+
52
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
53
+ end
54
+
55
+ # Returns a list of `WorkweekConfig` instances for a business.
56
+ def test_list_workweek_configs()
57
+ # Parameters for the API call
58
+ limit = nil
59
+ cursor = nil
60
+
61
+ # Perform the API call through the SDK function
62
+ result = @controller.list_workweek_configs(limit: limit, cursor: cursor)
63
+
64
+ # Test response code
65
+ assert_equal(200, @response_catcher.response.status_code)
66
+
67
+ # Test headers
68
+ expected_headers = {}
69
+ expected_headers['content-type'] = 'application/json'
70
+
71
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
72
+ end
73
+
74
+ end
@@ -0,0 +1,35 @@
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 LocationsApiTests < ApiTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
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.
16
+ #
17
+ #Most other Connect API endpoints have a required `location_id` path parameter.
18
+ #The `id` field of the [`Location`](#type-location) objects returned by this
19
+ #endpoint correspond to that `location_id` parameter.
20
+ def test_test_list_locations()
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
+ # Test headers
29
+ expected_headers = {}
30
+ expected_headers['content-type'] = 'application/json'
31
+
32
+ assert(TestHelper.match_headers(expected_headers, @response_catcher.response.headers))
33
+ end
34
+
35
+ end