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,45 +1,45 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # LocationsApi
8
- class LocationsApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Provides the details for all of a business's locations.
14
- # Most other Connect API endpoints have a required `location_id` path
15
- # parameter.
16
- # The `id` field of the [`Location`](#type-location) objects returned by
17
- # this
18
- # endpoint correspond to that `location_id` parameter.
19
- # @return [ListLocationsResponse Hash] response from the API call
20
- def list_locations
21
- # Prepare query url.
22
- _query_builder = config.get_base_uri
23
- _query_builder << '/v2/locations'
24
- _query_url = APIHelper.clean_url _query_builder
25
-
26
- # Prepare headers.
27
- _headers = {
28
- 'accept' => 'application/json'
29
- }
30
-
31
- # Prepare and execute HttpRequest.
32
- _request = config.http_client.get(
33
- _query_url,
34
- headers: _headers
35
- )
36
- OAuth2.apply(config, _request)
37
- _response = execute_request(_request)
38
-
39
- # Return appropriate response type.
40
- decoded = APIHelper.json_deserialize(_response.raw_body)
41
- _errors = APIHelper.map_response(decoded, ['errors'])
42
- ApiResponse.new(_response, data: decoded, errors: _errors)
43
- end
44
- end
45
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # LocationsApi
8
+ class LocationsApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Provides the details for all of a business's locations.
14
+ # Most other Connect API endpoints have a required `location_id` path
15
+ # parameter.
16
+ # The `id` field of the [`Location`](#type-location) objects returned by
17
+ # this
18
+ # endpoint correspond to that `location_id` parameter.
19
+ # @return [ListLocationsResponse Hash] response from the API call
20
+ def list_locations
21
+ # Prepare query url.
22
+ _query_builder = config.get_base_uri
23
+ _query_builder << '/v2/locations'
24
+ _query_url = APIHelper.clean_url _query_builder
25
+
26
+ # Prepare headers.
27
+ _headers = {
28
+ 'accept' => 'application/json'
29
+ }
30
+
31
+ # Prepare and execute HttpRequest.
32
+ _request = config.http_client.get(
33
+ _query_url,
34
+ headers: _headers
35
+ )
36
+ OAuth2.apply(config, _request)
37
+ _response = execute_request(_request)
38
+
39
+ # Return appropriate response type.
40
+ decoded = APIHelper.json_deserialize(_response.raw_body)
41
+ _errors = APIHelper.map_response(decoded, ['errors'])
42
+ ApiResponse.new(_response, data: decoded, errors: _errors)
43
+ end
44
+ end
45
+ end
@@ -1,56 +1,56 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # MobileAuthorizationApi
8
- class MobileAuthorizationApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Generates code to authorize a mobile application to connect to a Square
14
- # card reader
15
- # Authorization codes are one-time-use and expire __60 minutes__ after being
16
- # issued.
17
- # __Important:__ The `Authorization` header you provide to this endpoint
18
- # must have the following format:
19
- # ```
20
- # Authorization: Bearer ACCESS_TOKEN
21
- # ```
22
- # Replace `ACCESS_TOKEN` with a [valid production authorization
23
- # credential](https://docs.connect.squareup.com/get-started#step-4-understan
24
- # d-the-different-application-credentials).
25
- # @param [CreateMobileAuthorizationCodeRequest] body Required parameter: An
26
- # object containing the fields to POST for the request. See the
27
- # corresponding object definition for field details.
28
- # @return [CreateMobileAuthorizationCodeResponse Hash] response from the API call
29
- def create_mobile_authorization_code(body:)
30
- # Prepare query url.
31
- _query_builder = config.get_base_uri
32
- _query_builder << '/mobile/authorization-code'
33
- _query_url = APIHelper.clean_url _query_builder
34
-
35
- # Prepare headers.
36
- _headers = {
37
- 'accept' => 'application/json',
38
- 'content-type' => 'application/json; charset=utf-8'
39
- }
40
-
41
- # Prepare and execute HttpRequest.
42
- _request = config.http_client.post(
43
- _query_url,
44
- headers: _headers,
45
- parameters: body.to_json
46
- )
47
- OAuth2.apply(config, _request)
48
- _response = execute_request(_request)
49
-
50
- # Return appropriate response type.
51
- decoded = APIHelper.json_deserialize(_response.raw_body)
52
- _errors = APIHelper.map_response(decoded, ['errors'])
53
- ApiResponse.new(_response, data: decoded, errors: _errors)
54
- end
55
- end
56
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # MobileAuthorizationApi
8
+ class MobileAuthorizationApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Generates code to authorize a mobile application to connect to a Square
14
+ # card reader
15
+ # Authorization codes are one-time-use and expire __60 minutes__ after being
16
+ # issued.
17
+ # __Important:__ The `Authorization` header you provide to this endpoint
18
+ # must have the following format:
19
+ # ```
20
+ # Authorization: Bearer ACCESS_TOKEN
21
+ # ```
22
+ # Replace `ACCESS_TOKEN` with a [valid production authorization
23
+ # credential](https://docs.connect.squareup.com/get-started#step-4-understan
24
+ # d-the-different-application-credentials).
25
+ # @param [CreateMobileAuthorizationCodeRequest] body Required parameter: An
26
+ # object containing the fields to POST for the request. See the
27
+ # corresponding object definition for field details.
28
+ # @return [CreateMobileAuthorizationCodeResponse Hash] response from the API call
29
+ def create_mobile_authorization_code(body:)
30
+ # Prepare query url.
31
+ _query_builder = config.get_base_uri
32
+ _query_builder << '/mobile/authorization-code'
33
+ _query_url = APIHelper.clean_url _query_builder
34
+
35
+ # Prepare headers.
36
+ _headers = {
37
+ 'accept' => 'application/json',
38
+ 'content-type' => 'application/json; charset=utf-8'
39
+ }
40
+
41
+ # Prepare and execute HttpRequest.
42
+ _request = config.http_client.post(
43
+ _query_url,
44
+ headers: _headers,
45
+ parameters: body.to_json
46
+ )
47
+ OAuth2.apply(config, _request)
48
+ _response = execute_request(_request)
49
+
50
+ # Return appropriate response type.
51
+ decoded = APIHelper.json_deserialize(_response.raw_body)
52
+ _errors = APIHelper.map_response(decoded, ['errors'])
53
+ ApiResponse.new(_response, data: decoded, errors: _errors)
54
+ end
55
+ end
56
+ end
@@ -1,164 +1,168 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # OAuthApi
8
- class OAuthApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # `RenewToken` is deprecated. For information about refreshing OAuth access
14
- # tokens, see
15
- # [Renew OAuth Token](/authz/oauth/cookbook/oauth-renew).
16
- # Renews an OAuth access token before it expires.
17
- # OAuth access tokens besides your application's personal access token
18
- # expire after __30 days__.
19
- # You can also renew expired tokens within __15 days__ of their expiration.
20
- # You cannot renew an access token that has been expired for more than 15
21
- # days.
22
- # Instead, the associated user must re-complete the OAuth flow from the
23
- # beginning.
24
- # __Important:__ The `Authorization` header for this endpoint must have the
25
- # following format:
26
- # ```
27
- # Authorization: Client APPLICATION_SECRET
28
- # ```
29
- # Replace `APPLICATION_SECRET` with the application secret on the
30
- # Credentials
31
- # page in the [application dashboard](https://connect.squareup.com/apps).
32
- # @param [String] client_id Required parameter: Your application's ID,
33
- # available from the [application
34
- # dashboard](https://connect.squareup.com/apps).
35
- # @param [RenewTokenRequest] body Required parameter: An object containing
36
- # the fields to POST for the request. See the corresponding object
37
- # definition for field details.
38
- # @param [String] authorization Required parameter: Client
39
- # APPLICATION_SECRET
40
- # @return [RenewTokenResponse Hash] response from the API call
41
- def renew_token(client_id:,
42
- body:,
43
- authorization:)
44
- # Prepare query url.
45
- _query_builder = config.get_base_uri
46
- _query_builder << '/oauth2/clients/{client_id}/access-token/renew'
47
- _query_builder = APIHelper.append_url_with_template_parameters(
48
- _query_builder,
49
- 'client_id' => client_id
50
- )
51
- _query_url = APIHelper.clean_url _query_builder
52
-
53
- # Prepare headers.
54
- _headers = {
55
- 'accept' => 'application/json',
56
- 'content-type' => 'application/json; charset=utf-8',
57
- 'Authorization' => authorization
58
- }
59
-
60
- # Prepare and execute HttpRequest.
61
- _request = config.http_client.post(
62
- _query_url,
63
- headers: _headers,
64
- parameters: body.to_json
65
- )
66
- _response = execute_request(_request)
67
-
68
- # Return appropriate response type.
69
- decoded = APIHelper.json_deserialize(_response.raw_body)
70
- _errors = APIHelper.map_response(decoded, ['errors'])
71
- ApiResponse.new(_response, data: decoded, errors: _errors)
72
- end
73
-
74
- # Revokes an access token generated with the OAuth flow.
75
- # If an account has more than one OAuth access token for your application,
76
- # this
77
- # endpoint revokes all of them, regardless of which token you specify. When
78
- # an
79
- # OAuth access token is revoked, all of the active subscriptions associated
80
- # with that OAuth token are canceled immediately.
81
- # __Important:__ The `Authorization` header for this endpoint must have the
82
- # following format:
83
- # ```
84
- # Authorization: Client APPLICATION_SECRET
85
- # ```
86
- # Replace `APPLICATION_SECRET` with the application secret on the
87
- # Credentials
88
- # page in the [application dashboard](https://connect.squareup.com/apps).
89
- # @param [RevokeTokenRequest] body Required parameter: An object containing
90
- # the fields to POST for the request. See the corresponding object
91
- # definition for field details.
92
- # @param [String] authorization Required parameter: Client
93
- # APPLICATION_SECRET
94
- # @return [RevokeTokenResponse Hash] response from the API call
95
- def revoke_token(body:,
96
- authorization:)
97
- # Prepare query url.
98
- _query_builder = config.get_base_uri
99
- _query_builder << '/oauth2/revoke'
100
- _query_url = APIHelper.clean_url _query_builder
101
-
102
- # Prepare headers.
103
- _headers = {
104
- 'accept' => 'application/json',
105
- 'content-type' => 'application/json; charset=utf-8',
106
- 'Authorization' => authorization
107
- }
108
-
109
- # Prepare and execute HttpRequest.
110
- _request = config.http_client.post(
111
- _query_url,
112
- headers: _headers,
113
- parameters: body.to_json
114
- )
115
- _response = execute_request(_request)
116
-
117
- # Return appropriate response type.
118
- decoded = APIHelper.json_deserialize(_response.raw_body)
119
- _errors = APIHelper.map_response(decoded, ['errors'])
120
- ApiResponse.new(_response, data: decoded, errors: _errors)
121
- end
122
-
123
- # Returns an OAuth access token.
124
- # The endpoint supports distinct methods of obtaining OAuth access tokens.
125
- # Applications specify a method by adding the `grant_type` parameter
126
- # in the request and also provide relevant information.
127
- # For more information, see [OAuth access token
128
- # management](/authz/oauth/how-it-works#oauth-access-token-management).
129
- # __Note:__ Regardless of the method application specified,
130
- # the endpoint always returns two items; an OAuth access token and
131
- # a refresh token in the response.
132
- # __OAuth tokens should only live on secure servers. Application clients
133
- # should never interact directly with OAuth tokens__.
134
- # @param [ObtainTokenRequest] body Required parameter: An object containing
135
- # the fields to POST for the request. See the corresponding object
136
- # definition for field details.
137
- # @return [ObtainTokenResponse Hash] response from the API call
138
- def obtain_token(body:)
139
- # Prepare query url.
140
- _query_builder = config.get_base_uri
141
- _query_builder << '/oauth2/token'
142
- _query_url = APIHelper.clean_url _query_builder
143
-
144
- # Prepare headers.
145
- _headers = {
146
- 'accept' => 'application/json',
147
- 'content-type' => 'application/json; charset=utf-8'
148
- }
149
-
150
- # Prepare and execute HttpRequest.
151
- _request = config.http_client.post(
152
- _query_url,
153
- headers: _headers,
154
- parameters: body.to_json
155
- )
156
- _response = execute_request(_request)
157
-
158
- # Return appropriate response type.
159
- decoded = APIHelper.json_deserialize(_response.raw_body)
160
- _errors = APIHelper.map_response(decoded, ['errors'])
161
- ApiResponse.new(_response, data: decoded, errors: _errors)
162
- end
163
- end
164
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # OAuthApi
8
+ class OAuthApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # `RenewToken` is deprecated. For information about refreshing OAuth access
14
+ # tokens, see
15
+ # [Renew OAuth
16
+ # Token](https://developer.squareup.com/docs/oauth-api/cookbook/renew-oauth-
17
+ # tokens).
18
+ # Renews an OAuth access token before it expires.
19
+ # OAuth access tokens besides your application's personal access token
20
+ # expire after __30 days__.
21
+ # You can also renew expired tokens within __15 days__ of their expiration.
22
+ # You cannot renew an access token that has been expired for more than 15
23
+ # days.
24
+ # Instead, the associated user must re-complete the OAuth flow from the
25
+ # beginning.
26
+ # __Important:__ The `Authorization` header for this endpoint must have the
27
+ # following format:
28
+ # ```
29
+ # Authorization: Client APPLICATION_SECRET
30
+ # ```
31
+ # Replace `APPLICATION_SECRET` with the application secret on the
32
+ # Credentials
33
+ # page in the [application dashboard](https://connect.squareup.com/apps).
34
+ # @param [String] client_id Required parameter: Your application's ID,
35
+ # available from the [application
36
+ # dashboard](https://connect.squareup.com/apps).
37
+ # @param [RenewTokenRequest] body Required parameter: An object containing
38
+ # the fields to POST for the request. See the corresponding object
39
+ # definition for field details.
40
+ # @param [String] authorization Required parameter: Client
41
+ # APPLICATION_SECRET
42
+ # @return [RenewTokenResponse Hash] response from the API call
43
+ def renew_token(client_id:,
44
+ body:,
45
+ authorization:)
46
+ warn 'Endpoint renew_token in OAuthApi is deprecated'
47
+ # Prepare query url.
48
+ _query_builder = config.get_base_uri
49
+ _query_builder << '/oauth2/clients/{client_id}/access-token/renew'
50
+ _query_builder = APIHelper.append_url_with_template_parameters(
51
+ _query_builder,
52
+ 'client_id' => client_id
53
+ )
54
+ _query_url = APIHelper.clean_url _query_builder
55
+
56
+ # Prepare headers.
57
+ _headers = {
58
+ 'accept' => 'application/json',
59
+ 'content-type' => 'application/json; charset=utf-8',
60
+ 'Authorization' => authorization
61
+ }
62
+
63
+ # Prepare and execute HttpRequest.
64
+ _request = config.http_client.post(
65
+ _query_url,
66
+ headers: _headers,
67
+ parameters: body.to_json
68
+ )
69
+ _response = execute_request(_request)
70
+
71
+ # Return appropriate response type.
72
+ decoded = APIHelper.json_deserialize(_response.raw_body)
73
+ _errors = APIHelper.map_response(decoded, ['errors'])
74
+ ApiResponse.new(_response, data: decoded, errors: _errors)
75
+ end
76
+
77
+ # Revokes an access token generated with the OAuth flow.
78
+ # If an account has more than one OAuth access token for your application,
79
+ # this
80
+ # endpoint revokes all of them, regardless of which token you specify. When
81
+ # an
82
+ # OAuth access token is revoked, all of the active subscriptions associated
83
+ # with that OAuth token are canceled immediately.
84
+ # __Important:__ The `Authorization` header for this endpoint must have the
85
+ # following format:
86
+ # ```
87
+ # Authorization: Client APPLICATION_SECRET
88
+ # ```
89
+ # Replace `APPLICATION_SECRET` with the application secret on the
90
+ # Credentials
91
+ # page in the [application dashboard](https://connect.squareup.com/apps).
92
+ # @param [RevokeTokenRequest] body Required parameter: An object containing
93
+ # the fields to POST for the request. See the corresponding object
94
+ # definition for field details.
95
+ # @param [String] authorization Required parameter: Client
96
+ # APPLICATION_SECRET
97
+ # @return [RevokeTokenResponse Hash] response from the API call
98
+ def revoke_token(body:,
99
+ authorization:)
100
+ # Prepare query url.
101
+ _query_builder = config.get_base_uri
102
+ _query_builder << '/oauth2/revoke'
103
+ _query_url = APIHelper.clean_url _query_builder
104
+
105
+ # Prepare headers.
106
+ _headers = {
107
+ 'accept' => 'application/json',
108
+ 'content-type' => 'application/json; charset=utf-8',
109
+ 'Authorization' => authorization
110
+ }
111
+
112
+ # Prepare and execute HttpRequest.
113
+ _request = config.http_client.post(
114
+ _query_url,
115
+ headers: _headers,
116
+ parameters: body.to_json
117
+ )
118
+ _response = execute_request(_request)
119
+
120
+ # Return appropriate response type.
121
+ decoded = APIHelper.json_deserialize(_response.raw_body)
122
+ _errors = APIHelper.map_response(decoded, ['errors'])
123
+ ApiResponse.new(_response, data: decoded, errors: _errors)
124
+ end
125
+
126
+ # Returns an OAuth access token.
127
+ # The endpoint supports distinct methods of obtaining OAuth access tokens.
128
+ # Applications specify a method by adding the `grant_type` parameter
129
+ # in the request and also provide relevant information.
130
+ # For more information, see [OAuth access token
131
+ # management](https://developer.squareup.com/docs/authz/oauth/how-it-works#o
132
+ # auth-access-token-management).
133
+ # __Note:__ Regardless of the method application specified,
134
+ # the endpoint always returns two items; an OAuth access token and
135
+ # a refresh token in the response.
136
+ # __OAuth tokens should only live on secure servers. Application clients
137
+ # should never interact directly with OAuth tokens__.
138
+ # @param [ObtainTokenRequest] body Required parameter: An object containing
139
+ # the fields to POST for the request. See the corresponding object
140
+ # definition for field details.
141
+ # @return [ObtainTokenResponse Hash] response from the API call
142
+ def obtain_token(body:)
143
+ # Prepare query url.
144
+ _query_builder = config.get_base_uri
145
+ _query_builder << '/oauth2/token'
146
+ _query_url = APIHelper.clean_url _query_builder
147
+
148
+ # Prepare headers.
149
+ _headers = {
150
+ 'accept' => 'application/json',
151
+ 'content-type' => 'application/json; charset=utf-8'
152
+ }
153
+
154
+ # Prepare and execute HttpRequest.
155
+ _request = config.http_client.post(
156
+ _query_url,
157
+ headers: _headers,
158
+ parameters: body.to_json
159
+ )
160
+ _response = execute_request(_request)
161
+
162
+ # Return appropriate response type.
163
+ decoded = APIHelper.json_deserialize(_response.raw_body)
164
+ _errors = APIHelper.map_response(decoded, ['errors'])
165
+ ApiResponse.new(_response, data: decoded, errors: _errors)
166
+ end
167
+ end
168
+ end