square.rb 3.20190624.0 → 3.20190814.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +10 -28
  3. data/README.md +281 -17235
  4. data/lib/square/api/apple_pay_api.rb +55 -54
  5. data/lib/square/api/base_api.rb +45 -45
  6. data/lib/square/api/catalog_api.rb +461 -460
  7. data/lib/square/api/checkout_api.rb +54 -54
  8. data/lib/square/api/customers_api.rb +335 -334
  9. data/lib/square/api/employees_api.rb +91 -91
  10. data/lib/square/api/inventory_api.rb +300 -298
  11. data/lib/square/api/labor_api.rb +558 -558
  12. data/lib/square/api/locations_api.rb +45 -45
  13. data/lib/square/api/mobile_authorization_api.rb +56 -56
  14. data/lib/square/api/o_auth_api.rb +168 -164
  15. data/lib/square/api/orders_api.rb +269 -151
  16. data/lib/square/api/payments_api.rb +282 -0
  17. data/lib/square/api/refunds_api.rb +149 -0
  18. data/lib/square/api/reporting_api.rb +143 -139
  19. data/lib/square/api/transactions_api.rb +379 -360
  20. data/lib/square/api/v1_employees_api.rb +720 -720
  21. data/lib/square/api/v1_items_api.rb +1651 -1651
  22. data/lib/square/api/v1_locations_api.rb +67 -67
  23. data/lib/square/api/v1_locations_api.rbe +67 -0
  24. data/lib/square/api/v1_transactions_api.rb +574 -574
  25. data/lib/square/api_helper.rb +281 -277
  26. data/lib/square/client.rb +139 -127
  27. data/lib/square/configuration.rb +88 -85
  28. data/lib/square/exceptions/api_exception.rb +20 -20
  29. data/lib/square/http/api_response.rb +50 -50
  30. data/lib/square/http/auth/o_auth2.rb +17 -17
  31. data/lib/square/http/faraday_client.rb +64 -64
  32. data/lib/square/http/http_call_back.rb +24 -24
  33. data/lib/square/http/http_client.rb +104 -104
  34. data/lib/square/http/http_method_enum.rb +13 -13
  35. data/lib/square/http/http_request.rb +50 -50
  36. data/lib/square/http/http_response.rb +29 -29
  37. data/lib/square.rb +52 -50
  38. data/spec/user_journey_spec.rb +4 -1
  39. data/test/api/api_test_base.rb +2 -1
  40. data/test/api/test_catalog_api.rb +59 -0
  41. data/test/api/test_employees_api.rb +36 -0
  42. data/test/api/test_locations_api.rb +35 -0
  43. data/test/api/test_payments_api.rb +42 -0
  44. data/test/api/test_refunds_api.rb +41 -0
  45. metadata +19 -11
@@ -1,64 +1,64 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- require 'faraday/http_cache'
7
- require 'faraday_middleware'
8
-
9
- module Square
10
- # An implementation of HttpClient.
11
- class FaradayClient < HttpClient
12
- # The constructor.
13
- def initialize(timeout:, max_retries:, retry_interval:,
14
- backoff_factor:, cache: false, verify: true)
15
- @connection = Faraday.new do |faraday|
16
- faraday.use Faraday::HttpCache, serializer: Marshal if cache
17
- faraday.use FaradayMiddleware::FollowRedirects
18
- faraday.request :multipart
19
- faraday.request :url_encoded
20
- faraday.ssl[:ca_file] = Certifi.where
21
- faraday.ssl[:verify] = verify
22
- faraday.request :retry, max: max_retries, interval: retry_interval,
23
- backoff_factor: backoff_factor
24
- faraday.adapter Faraday.default_adapter
25
- faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
26
- faraday.options[:timeout] = timeout if timeout > 0
27
- end
28
- end
29
-
30
- # Method overridden from HttpClient.
31
- def execute_as_string(http_request)
32
- response = @connection.send(
33
- http_request.http_method.downcase,
34
- http_request.query_url
35
- ) do |request|
36
- request.headers = http_request.headers
37
- unless http_request.parameters.empty?
38
- request.body = http_request.parameters
39
- end
40
- end
41
- convert_response(response, http_request)
42
- end
43
-
44
- # Method overridden from HttpClient.
45
- def execute_as_binary(http_request)
46
- response = @connection.send(
47
- http_request.http_method.downcase,
48
- http_request.query_url
49
- ) do |request|
50
- request.headers = http_request.headers
51
- unless http_request.parameters.empty?
52
- request.body = http_request.parameters
53
- end
54
- end
55
- convert_response(response, http_request)
56
- end
57
-
58
- # Method overridden from HttpClient.
59
- def convert_response(response, http_request)
60
- HttpResponse.new(response.status, response.reason_phrase,
61
- response.headers, response.body, http_request)
62
- end
63
- end
64
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'faraday/http_cache'
7
+ require 'faraday_middleware'
8
+
9
+ module Square
10
+ # An implementation of HttpClient.
11
+ class FaradayClient < HttpClient
12
+ # The constructor.
13
+ def initialize(timeout:, max_retries:, retry_interval:,
14
+ backoff_factor:, cache: false, verify: true)
15
+ @connection = Faraday.new do |faraday|
16
+ faraday.use Faraday::HttpCache, serializer: Marshal if cache
17
+ faraday.use FaradayMiddleware::FollowRedirects
18
+ faraday.request :multipart
19
+ faraday.request :url_encoded
20
+ faraday.ssl[:ca_file] = Certifi.where
21
+ faraday.ssl[:verify] = verify
22
+ faraday.request :retry, max: max_retries, interval: retry_interval,
23
+ backoff_factor: backoff_factor
24
+ faraday.adapter Faraday.default_adapter
25
+ faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
26
+ faraday.options[:timeout] = timeout if timeout > 0
27
+ end
28
+ end
29
+
30
+ # Method overridden from HttpClient.
31
+ def execute_as_string(http_request)
32
+ response = @connection.send(
33
+ http_request.http_method.downcase,
34
+ http_request.query_url
35
+ ) do |request|
36
+ request.headers = http_request.headers
37
+ unless http_request.parameters.empty?
38
+ request.body = http_request.parameters
39
+ end
40
+ end
41
+ convert_response(response, http_request)
42
+ end
43
+
44
+ # Method overridden from HttpClient.
45
+ def execute_as_binary(http_request)
46
+ response = @connection.send(
47
+ http_request.http_method.downcase,
48
+ http_request.query_url
49
+ ) do |request|
50
+ request.headers = http_request.headers
51
+ unless http_request.parameters.empty?
52
+ request.body = http_request.parameters
53
+ end
54
+ end
55
+ convert_response(response, http_request)
56
+ end
57
+
58
+ # Method overridden from HttpClient.
59
+ def convert_response(response, http_request)
60
+ HttpResponse.new(response.status, response.reason_phrase,
61
+ response.headers, response.body, http_request)
62
+ end
63
+ end
64
+ end
@@ -1,24 +1,24 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # HttpCallBack allows defining callables for pre and post API calls.
8
- class HttpCallBack
9
- # A controller will call this method before making an HTTP Request.
10
- # @param [HttpRequest] The HttpRequest object which the HttpClient
11
- # will execute.
12
- def on_before_request(_http_request)
13
- raise NotImplementedError, 'This method needs
14
- to be implemented in a child class.'
15
- end
16
-
17
- # A controller will call this method after making an HTTP Request.
18
- # @param [HttpResponse] The HttpReponse of the API call.
19
- def on_after_response(_http_response)
20
- raise NotImplementedError, 'This method needs
21
- to be implemented in a child class.'
22
- end
23
- end
24
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # HttpCallBack allows defining callables for pre and post API calls.
8
+ class HttpCallBack
9
+ # A controller will call this method before making an HTTP Request.
10
+ # @param [HttpRequest] The HttpRequest object which the HttpClient
11
+ # will execute.
12
+ def on_before_request(_http_request)
13
+ raise NotImplementedError, 'This method needs
14
+ to be implemented in a child class.'
15
+ end
16
+
17
+ # A controller will call this method after making an HTTP Request.
18
+ # @param [HttpResponse] The HttpReponse of the API call.
19
+ def on_after_response(_http_response)
20
+ raise NotImplementedError, 'This method needs
21
+ to be implemented in a child class.'
22
+ end
23
+ end
24
+ end
@@ -1,104 +1,104 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # An interface for the methods that an HTTP Client must implement.
8
- #
9
- # This class should not be instantiated but should be used as a base class
10
- # for HTTP Client classes.
11
- class HttpClient
12
- # Execute an HttpRequest when the response is expected to be a string.
13
- # @param [HttpRequest] The HttpRequest to be executed.
14
- def execute_as_string(_http_request)
15
- raise NotImplementedError, 'This method needs
16
- to be implemented in a child class.'
17
- end
18
-
19
- # Execute an HttpRequest when the response is expected to be binary.
20
- # @param [HttpRequest] The HttpRequest to be executed.
21
- def execute_as_binary(_http_request)
22
- raise NotImplementedError, 'This method needs
23
- to be implemented in a child class.'
24
- end
25
-
26
- # Converts the HTTP Response from the client to an HttpResponse object.
27
- # @param [Dynamic] The response object received from the client.
28
- def convert_response(_response)
29
- raise NotImplementedError, 'This method needs
30
- to be implemented in a child class.'
31
- end
32
-
33
- # Get a GET HttpRequest object.
34
- # @param [String] The URL to send the request to.
35
- # @param [Hash, Optional] The headers for the HTTP Request.
36
- def get(query_url,
37
- headers: {})
38
- HttpRequest.new(HttpMethodEnum::GET,
39
- query_url,
40
- headers: headers)
41
- end
42
-
43
- # Get a HEAD HttpRequest object.
44
- # @param [String] The URL to send the request to.
45
- # @param [Hash, Optional] The headers for the HTTP Request.
46
- def head(query_url,
47
- headers: {})
48
- HttpRequest.new(HttpMethodEnum::HEAD,
49
- query_url,
50
- headers: headers)
51
- end
52
-
53
- # Get a POST HttpRequest object.
54
- # @param [String] The URL to send the request to.
55
- # @param [Hash, Optional] The headers for the HTTP Request.
56
- # @param [Hash, Optional] The parameters for the HTTP Request.
57
- def post(query_url,
58
- headers: {},
59
- parameters: {})
60
- HttpRequest.new(HttpMethodEnum::POST,
61
- query_url,
62
- headers: headers,
63
- parameters: parameters)
64
- end
65
-
66
- # Get a PUT HttpRequest object.
67
- # @param [String] The URL to send the request to.
68
- # @param [Hash, Optional] The headers for the HTTP Request.
69
- # @param [Hash, Optional] The parameters for the HTTP Request.
70
- def put(query_url,
71
- headers: {},
72
- parameters: {})
73
- HttpRequest.new(HttpMethodEnum::PUT,
74
- query_url,
75
- headers: headers,
76
- parameters: parameters)
77
- end
78
-
79
- # Get a PATCH HttpRequest object.
80
- # @param [String] The URL to send the request to.
81
- # @param [Hash, Optional] The headers for the HTTP Request.
82
- # @param [Hash, Optional] The parameters for the HTTP Request.
83
- def patch(query_url,
84
- headers: {},
85
- parameters: {})
86
- HttpRequest.new(HttpMethodEnum::PATCH,
87
- query_url,
88
- headers: headers,
89
- parameters: parameters)
90
- end
91
-
92
- # Get a DELETE HttpRequest object.
93
- # @param [String] The URL to send the request to.
94
- # @param [Hash, Optional] The headers for the HTTP Request.
95
- def delete(query_url,
96
- headers: {},
97
- parameters: {})
98
- HttpRequest.new(HttpMethodEnum::DELETE,
99
- query_url,
100
- headers: headers,
101
- parameters: parameters)
102
- end
103
- end
104
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # An interface for the methods that an HTTP Client must implement.
8
+ #
9
+ # This class should not be instantiated but should be used as a base class
10
+ # for HTTP Client classes.
11
+ class HttpClient
12
+ # Execute an HttpRequest when the response is expected to be a string.
13
+ # @param [HttpRequest] The HttpRequest to be executed.
14
+ def execute_as_string(_http_request)
15
+ raise NotImplementedError, 'This method needs
16
+ to be implemented in a child class.'
17
+ end
18
+
19
+ # Execute an HttpRequest when the response is expected to be binary.
20
+ # @param [HttpRequest] The HttpRequest to be executed.
21
+ def execute_as_binary(_http_request)
22
+ raise NotImplementedError, 'This method needs
23
+ to be implemented in a child class.'
24
+ end
25
+
26
+ # Converts the HTTP Response from the client to an HttpResponse object.
27
+ # @param [Dynamic] The response object received from the client.
28
+ def convert_response(_response)
29
+ raise NotImplementedError, 'This method needs
30
+ to be implemented in a child class.'
31
+ end
32
+
33
+ # Get a GET HttpRequest object.
34
+ # @param [String] The URL to send the request to.
35
+ # @param [Hash, Optional] The headers for the HTTP Request.
36
+ def get(query_url,
37
+ headers: {})
38
+ HttpRequest.new(HttpMethodEnum::GET,
39
+ query_url,
40
+ headers: headers)
41
+ end
42
+
43
+ # Get a HEAD HttpRequest object.
44
+ # @param [String] The URL to send the request to.
45
+ # @param [Hash, Optional] The headers for the HTTP Request.
46
+ def head(query_url,
47
+ headers: {})
48
+ HttpRequest.new(HttpMethodEnum::HEAD,
49
+ query_url,
50
+ headers: headers)
51
+ end
52
+
53
+ # Get a POST HttpRequest object.
54
+ # @param [String] The URL to send the request to.
55
+ # @param [Hash, Optional] The headers for the HTTP Request.
56
+ # @param [Hash, Optional] The parameters for the HTTP Request.
57
+ def post(query_url,
58
+ headers: {},
59
+ parameters: {})
60
+ HttpRequest.new(HttpMethodEnum::POST,
61
+ query_url,
62
+ headers: headers,
63
+ parameters: parameters)
64
+ end
65
+
66
+ # Get a PUT HttpRequest object.
67
+ # @param [String] The URL to send the request to.
68
+ # @param [Hash, Optional] The headers for the HTTP Request.
69
+ # @param [Hash, Optional] The parameters for the HTTP Request.
70
+ def put(query_url,
71
+ headers: {},
72
+ parameters: {})
73
+ HttpRequest.new(HttpMethodEnum::PUT,
74
+ query_url,
75
+ headers: headers,
76
+ parameters: parameters)
77
+ end
78
+
79
+ # Get a PATCH HttpRequest object.
80
+ # @param [String] The URL to send the request to.
81
+ # @param [Hash, Optional] The headers for the HTTP Request.
82
+ # @param [Hash, Optional] The parameters for the HTTP Request.
83
+ def patch(query_url,
84
+ headers: {},
85
+ parameters: {})
86
+ HttpRequest.new(HttpMethodEnum::PATCH,
87
+ query_url,
88
+ headers: headers,
89
+ parameters: parameters)
90
+ end
91
+
92
+ # Get a DELETE HttpRequest object.
93
+ # @param [String] The URL to send the request to.
94
+ # @param [Hash, Optional] The headers for the HTTP Request.
95
+ def delete(query_url,
96
+ headers: {},
97
+ parameters: {})
98
+ HttpRequest.new(HttpMethodEnum::DELETE,
99
+ query_url,
100
+ headers: headers,
101
+ parameters: parameters)
102
+ end
103
+ end
104
+ end
@@ -1,13 +1,13 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # HTTP Methods Enumeration.
8
- class HttpMethodEnum
9
- HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
10
- PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
11
- DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
12
- end
13
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # HTTP Methods Enumeration.
8
+ class HttpMethodEnum
9
+ HTTPMETHODENUM = [GET = 'GET'.freeze, POST = 'POST'.freeze,
10
+ PUT = 'PUT'.freeze, PATCH = 'PATCH'.freeze,
11
+ DELETE = 'DELETE'.freeze, HEAD = 'HEAD'.freeze].freeze
12
+ end
13
+ end
@@ -1,50 +1,50 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # Represents a single Http Request.
8
- class HttpRequest
9
- attr_accessor :http_method, :query_url, :headers,
10
- :parameters, :username, :password
11
-
12
- # The constructor.
13
- # @param [HttpMethodEnum] The HTTP method.
14
- # @param [String] The URL to send the request to.
15
- # @param [Hash, Optional] The headers for the HTTP Request.
16
- # @param [Hash, Optional] The parameters for the HTTP Request.
17
- def initialize(http_method,
18
- query_url,
19
- headers: {},
20
- parameters: {})
21
- @http_method = http_method
22
- @query_url = query_url
23
- @headers = headers
24
- @parameters = parameters
25
- end
26
-
27
- # Add a header to the HttpRequest.
28
- # @param [String] The name of the header.
29
- # @param [String] The value of the header.
30
- def add_header(name, value)
31
- @headers[name] = value
32
- end
33
-
34
- # Add a parameter to the HttpRequest.
35
- # @param [String] The name of the parameter.
36
- # @param [String] The value of the parameter.
37
- def add_parameter(name, value)
38
- @parameters[name] = value
39
- end
40
-
41
- # Add a query parameter to the HttpRequest.
42
- # @param [String] The name of the query parameter.
43
- # @param [String] The value of the query parameter.
44
- def add_query_parameter(name, value)
45
- @query_url = APIHelper.append_url_with_query_parameters(@query_url,
46
- name => value)
47
- @query_url = APIHelper.clean_url(@query_url)
48
- end
49
- end
50
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # Represents a single Http Request.
8
+ class HttpRequest
9
+ attr_accessor :http_method, :query_url, :headers,
10
+ :parameters, :username, :password
11
+
12
+ # The constructor.
13
+ # @param [HttpMethodEnum] The HTTP method.
14
+ # @param [String] The URL to send the request to.
15
+ # @param [Hash, Optional] The headers for the HTTP Request.
16
+ # @param [Hash, Optional] The parameters for the HTTP Request.
17
+ def initialize(http_method,
18
+ query_url,
19
+ headers: {},
20
+ parameters: {})
21
+ @http_method = http_method
22
+ @query_url = query_url
23
+ @headers = headers
24
+ @parameters = parameters
25
+ end
26
+
27
+ # Add a header to the HttpRequest.
28
+ # @param [String] The name of the header.
29
+ # @param [String] The value of the header.
30
+ def add_header(name, value)
31
+ @headers[name] = value
32
+ end
33
+
34
+ # Add a parameter to the HttpRequest.
35
+ # @param [String] The name of the parameter.
36
+ # @param [String] The value of the parameter.
37
+ def add_parameter(name, value)
38
+ @parameters[name] = value
39
+ end
40
+
41
+ # Add a query parameter to the HttpRequest.
42
+ # @param [String] The name of the query parameter.
43
+ # @param [String] The value of the query parameter.
44
+ def add_query_parameter(name, value)
45
+ @query_url = APIHelper.append_url_with_query_parameters(@query_url,
46
+ name => value)
47
+ @query_url = APIHelper.clean_url(@query_url)
48
+ end
49
+ end
50
+ end
@@ -1,29 +1,29 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # Http response received.
8
- class HttpResponse
9
- attr_reader :status_code, :reason_phrase, :headers, :raw_body, :request
10
-
11
- # The constructor
12
- # @param [Integer] The status code returned by the server.
13
- # @param [String] The reason phrase returned by the server.
14
- # @param [Hash] The headers sent by the server in the response.
15
- # @param [String] The raw body of the response.
16
- # @param [HttpRequest] The request that resulted in this response.
17
- def initialize(status_code,
18
- reason_phrase,
19
- headers,
20
- raw_body,
21
- request)
22
- @status_code = status_code
23
- @reason_phrase = reason_phrase
24
- @headers = headers
25
- @raw_body = raw_body
26
- @request = request
27
- end
28
- end
29
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # Http response received.
8
+ class HttpResponse
9
+ attr_reader :status_code, :reason_phrase, :headers, :raw_body, :request
10
+
11
+ # The constructor
12
+ # @param [Integer] The status code returned by the server.
13
+ # @param [String] The reason phrase returned by the server.
14
+ # @param [Hash] The headers sent by the server in the response.
15
+ # @param [String] The raw body of the response.
16
+ # @param [HttpRequest] The request that resulted in this response.
17
+ def initialize(status_code,
18
+ reason_phrase,
19
+ headers,
20
+ raw_body,
21
+ request)
22
+ @status_code = status_code
23
+ @reason_phrase = reason_phrase
24
+ @headers = headers
25
+ @raw_body = raw_body
26
+ @request = request
27
+ end
28
+ end
29
+ end