square.rb 3.20190814.0 → 3.20190925.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/square.rb +53 -52
- data/lib/square/api/apple_pay_api.rb +55 -55
- data/lib/square/api/base_api.rb +48 -45
- data/lib/square/api/catalog_api.rb +461 -461
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -335
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -300
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +117 -45
- data/lib/square/api/merchants_api.rb +46 -0
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -168
- data/lib/square/api/orders_api.rb +271 -269
- data/lib/square/api/payments_api.rb +282 -282
- data/lib/square/api/refunds_api.rb +149 -149
- data/lib/square/api/reporting_api.rb +145 -143
- data/lib/square/api/transactions_api.rb +379 -379
- data/lib/square/api/v1_employees_api.rb +720 -720
- data/lib/square/api/v1_items_api.rb +1651 -1651
- data/lib/square/api/v1_locations_api.rb +67 -67
- data/lib/square/api/v1_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -281
- data/lib/square/client.rb +155 -139
- data/lib/square/configuration.rb +98 -88
- data/lib/square/exceptions/api_exception.rb +20 -20
- data/lib/square/http/api_response.rb +50 -50
- data/lib/square/http/auth/o_auth2.rb +17 -17
- data/lib/square/http/faraday_client.rb +64 -64
- data/lib/square/http/http_call_back.rb +24 -24
- data/lib/square/http/http_client.rb +104 -104
- data/lib/square/http/http_method_enum.rb +13 -13
- data/lib/square/http/http_request.rb +50 -50
- data/lib/square/http/http_response.rb +29 -29
- data/test/api/test_labor_api.rb +74 -0
- metadata +4 -3
- data/lib/square/api/v1_locations_api.rbe +0 -67
data/lib/square/client.rb
CHANGED
@@ -1,139 +1,155 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# square client class.
|
8
|
-
class Client
|
9
|
-
attr_reader :config
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# square client class.
|
8
|
+
class Client
|
9
|
+
attr_reader :config
|
10
|
+
|
11
|
+
def sdk_version
|
12
|
+
'3.20190925.0'
|
13
|
+
end
|
14
|
+
|
15
|
+
def square_version
|
16
|
+
'2019-09-25'
|
17
|
+
end
|
18
|
+
|
19
|
+
# Access to mobile_authorization controller.
|
20
|
+
# @return [MobileAuthorizationApi] Returns the controller instance.
|
21
|
+
def mobile_authorization
|
22
|
+
@mobile_authorization ||= MobileAuthorizationApi.new config
|
23
|
+
end
|
24
|
+
|
25
|
+
# Access to o_auth controller.
|
26
|
+
# @return [OAuthApi] Returns the controller instance.
|
27
|
+
def o_auth
|
28
|
+
@o_auth ||= OAuthApi.new config
|
29
|
+
end
|
30
|
+
|
31
|
+
# Access to v1_locations controller.
|
32
|
+
# @return [V1LocationsApi] Returns the controller instance.
|
33
|
+
def v1_locations
|
34
|
+
@v1_locations ||= V1LocationsApi.new config
|
35
|
+
end
|
36
|
+
|
37
|
+
# Access to v1_employees controller.
|
38
|
+
# @return [V1EmployeesApi] Returns the controller instance.
|
39
|
+
def v1_employees
|
40
|
+
@v1_employees ||= V1EmployeesApi.new config
|
41
|
+
end
|
42
|
+
|
43
|
+
# Access to v1_transactions controller.
|
44
|
+
# @return [V1TransactionsApi] Returns the controller instance.
|
45
|
+
def v1_transactions
|
46
|
+
@v1_transactions ||= V1TransactionsApi.new config
|
47
|
+
end
|
48
|
+
|
49
|
+
# Access to v1_items controller.
|
50
|
+
# @return [V1ItemsApi] Returns the controller instance.
|
51
|
+
def v1_items
|
52
|
+
@v1_items ||= V1ItemsApi.new config
|
53
|
+
end
|
54
|
+
|
55
|
+
# Access to apple_pay controller.
|
56
|
+
# @return [ApplePayApi] Returns the controller instance.
|
57
|
+
def apple_pay
|
58
|
+
@apple_pay ||= ApplePayApi.new config
|
59
|
+
end
|
60
|
+
|
61
|
+
# Access to catalog controller.
|
62
|
+
# @return [CatalogApi] Returns the controller instance.
|
63
|
+
def catalog
|
64
|
+
@catalog ||= CatalogApi.new config
|
65
|
+
end
|
66
|
+
|
67
|
+
# Access to customers controller.
|
68
|
+
# @return [CustomersApi] Returns the controller instance.
|
69
|
+
def customers
|
70
|
+
@customers ||= CustomersApi.new config
|
71
|
+
end
|
72
|
+
|
73
|
+
# Access to employees controller.
|
74
|
+
# @return [EmployeesApi] Returns the controller instance.
|
75
|
+
def employees
|
76
|
+
@employees ||= EmployeesApi.new config
|
77
|
+
end
|
78
|
+
|
79
|
+
# Access to inventory controller.
|
80
|
+
# @return [InventoryApi] Returns the controller instance.
|
81
|
+
def inventory
|
82
|
+
@inventory ||= InventoryApi.new config
|
83
|
+
end
|
84
|
+
|
85
|
+
# Access to labor controller.
|
86
|
+
# @return [LaborApi] Returns the controller instance.
|
87
|
+
def labor
|
88
|
+
@labor ||= LaborApi.new config
|
89
|
+
end
|
90
|
+
|
91
|
+
# Access to locations controller.
|
92
|
+
# @return [LocationsApi] Returns the controller instance.
|
93
|
+
def locations
|
94
|
+
@locations ||= LocationsApi.new config
|
95
|
+
end
|
96
|
+
|
97
|
+
# Access to reporting controller.
|
98
|
+
# @return [ReportingApi] Returns the controller instance.
|
99
|
+
def reporting
|
100
|
+
@reporting ||= ReportingApi.new config
|
101
|
+
end
|
102
|
+
|
103
|
+
# Access to checkout controller.
|
104
|
+
# @return [CheckoutApi] Returns the controller instance.
|
105
|
+
def checkout
|
106
|
+
@checkout ||= CheckoutApi.new config
|
107
|
+
end
|
108
|
+
|
109
|
+
# Access to orders controller.
|
110
|
+
# @return [OrdersApi] Returns the controller instance.
|
111
|
+
def orders
|
112
|
+
@orders ||= OrdersApi.new config
|
113
|
+
end
|
114
|
+
|
115
|
+
# Access to transactions controller.
|
116
|
+
# @return [TransactionsApi] Returns the controller instance.
|
117
|
+
def transactions
|
118
|
+
@transactions ||= TransactionsApi.new config
|
119
|
+
end
|
120
|
+
|
121
|
+
# Access to merchants controller.
|
122
|
+
# @return [MerchantsApi] Returns the controller instance.
|
123
|
+
def merchants
|
124
|
+
@merchants ||= MerchantsApi.new config
|
125
|
+
end
|
126
|
+
|
127
|
+
# Access to payments controller.
|
128
|
+
# @return [PaymentsApi] Returns the controller instance.
|
129
|
+
def payments
|
130
|
+
@payments ||= PaymentsApi.new config
|
131
|
+
end
|
132
|
+
|
133
|
+
# Access to refunds controller.
|
134
|
+
# @return [RefundsApi] Returns the controller instance.
|
135
|
+
def refunds
|
136
|
+
@refunds ||= RefundsApi.new config
|
137
|
+
end
|
138
|
+
|
139
|
+
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
140
|
+
backoff_factor: 1, environment: 'production',
|
141
|
+
access_token: 'TODO: Replace', additional_headers: {},
|
142
|
+
config: nil)
|
143
|
+
@config = if config.nil?
|
144
|
+
Configuration.new(timeout: timeout, max_retries: max_retries,
|
145
|
+
retry_interval: retry_interval,
|
146
|
+
backoff_factor: backoff_factor,
|
147
|
+
environment: environment,
|
148
|
+
access_token: access_token,
|
149
|
+
additional_headers: additional_headers)
|
150
|
+
else
|
151
|
+
config
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
data/lib/square/configuration.rb
CHANGED
@@ -1,88 +1,98 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# All configuration including auth info and base URI for the API access
|
8
|
-
# are configured in this class.
|
9
|
-
class Configuration
|
10
|
-
# The attribute readers for properties.
|
11
|
-
attr_reader :http_client
|
12
|
-
attr_reader :timeout
|
13
|
-
attr_reader :max_retries
|
14
|
-
attr_reader :retry_interval
|
15
|
-
attr_reader :backoff_factor
|
16
|
-
attr_reader :environment
|
17
|
-
attr_reader :access_token
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
@
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
#
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# All configuration including auth info and base URI for the API access
|
8
|
+
# are configured in this class.
|
9
|
+
class Configuration
|
10
|
+
# The attribute readers for properties.
|
11
|
+
attr_reader :http_client
|
12
|
+
attr_reader :timeout
|
13
|
+
attr_reader :max_retries
|
14
|
+
attr_reader :retry_interval
|
15
|
+
attr_reader :backoff_factor
|
16
|
+
attr_reader :environment
|
17
|
+
attr_reader :access_token
|
18
|
+
|
19
|
+
def additional_headers
|
20
|
+
@additional_headers.clone
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
attr_reader :environments
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
28
|
+
backoff_factor: 1, environment: 'production',
|
29
|
+
access_token: 'TODO: Replace', additional_headers: {})
|
30
|
+
# The value to use for connection timeout
|
31
|
+
@timeout = timeout
|
32
|
+
|
33
|
+
# The number of times to retry an endpoint call if it fails
|
34
|
+
@max_retries = max_retries
|
35
|
+
|
36
|
+
# Pause in seconds between retries
|
37
|
+
@retry_interval = retry_interval
|
38
|
+
|
39
|
+
# The amount to multiply each successive retry's interval amount
|
40
|
+
# by in order to provide backoff
|
41
|
+
@backoff_factor = backoff_factor
|
42
|
+
|
43
|
+
# Current API environment
|
44
|
+
@environment = environment
|
45
|
+
|
46
|
+
# OAuth 2.0 Access Token
|
47
|
+
@access_token = access_token
|
48
|
+
|
49
|
+
# Additional headers to add to each API request
|
50
|
+
@additional_headers = additional_headers.clone
|
51
|
+
|
52
|
+
# The Http Client to use for making requests.
|
53
|
+
@http_client = create_http_client
|
54
|
+
end
|
55
|
+
|
56
|
+
def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
|
57
|
+
backoff_factor: nil, environment: nil, access_token: nil,
|
58
|
+
additional_headers: nil)
|
59
|
+
timeout ||= self.timeout
|
60
|
+
max_retries ||= self.max_retries
|
61
|
+
retry_interval ||= self.retry_interval
|
62
|
+
backoff_factor ||= self.backoff_factor
|
63
|
+
environment ||= self.environment
|
64
|
+
access_token ||= self.access_token
|
65
|
+
additional_headers ||= self.additional_headers
|
66
|
+
|
67
|
+
Configuration.new(timeout: timeout, max_retries: max_retries,
|
68
|
+
retry_interval: retry_interval,
|
69
|
+
backoff_factor: backoff_factor,
|
70
|
+
environment: environment, access_token: access_token,
|
71
|
+
additional_headers: additional_headers)
|
72
|
+
end
|
73
|
+
|
74
|
+
def create_http_client
|
75
|
+
FaradayClient.new(timeout: timeout, max_retries: max_retries,
|
76
|
+
retry_interval: retry_interval,
|
77
|
+
backoff_factor: backoff_factor)
|
78
|
+
end
|
79
|
+
|
80
|
+
# All the environments the SDK can run in.
|
81
|
+
@environments = {
|
82
|
+
'production' => {
|
83
|
+
'default' => 'https://connect.squareup.com'
|
84
|
+
},
|
85
|
+
'sandbox' => {
|
86
|
+
'default' => 'https://connect.squareupsandbox.com'
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
# Generates the appropriate base URI for the environment and the server.
|
91
|
+
# @param [Configuration::Server] The server enum for which the base URI is
|
92
|
+
# required.
|
93
|
+
# @return [String] The base URI.
|
94
|
+
def get_base_uri(server = 'default')
|
95
|
+
self.class.environments[environment][server].clone
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|