square_connect 2.20180712.1.234 → 2.20180712.2.237
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +11 -0
- data/README.md +10 -1
- data/docs/OAuthApi.md +169 -0
- data/docs/ObtainTokenRequest.md +15 -0
- data/docs/ObtainTokenResponse.md +18 -0
- data/docs/RenewTokenRequest.md +12 -0
- data/docs/RenewTokenResponse.md +17 -0
- data/docs/RevokeTokenRequest.md +14 -0
- data/docs/RevokeTokenResponse.md +12 -0
- data/lib/square_connect/api/o_auth_api.rb +189 -0
- data/lib/square_connect/api_client.rb +1 -1
- data/lib/square_connect/models/obtain_token_request.rb +216 -0
- data/lib/square_connect/models/obtain_token_response.rb +246 -0
- data/lib/square_connect/models/renew_token_request.rb +186 -0
- data/lib/square_connect/models/renew_token_response.rb +236 -0
- data/lib/square_connect/models/revoke_token_request.rb +206 -0
- data/lib/square_connect/models/revoke_token_response.rb +186 -0
- data/lib/square_connect/version.rb +1 -1
- data/lib/square_connect.rb +7 -0
- data/spec/api/o_auth_api_spec.rb +69 -0
- data/spec/models/obtain_token_request_spec.rb +57 -0
- data/spec/models/obtain_token_response_spec.rb +75 -0
- data/spec/models/renew_token_request_spec.rb +39 -0
- data/spec/models/renew_token_response_spec.rb +69 -0
- data/spec/models/revoke_token_request_spec.rb +51 -0
- data/spec/models/revoke_token_response_spec.rb +39 -0
- metadata +31 -3
@@ -0,0 +1,186 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'date'
|
11
|
+
|
12
|
+
module SquareConnect
|
13
|
+
#
|
14
|
+
class RevokeTokenResponse
|
15
|
+
# If the request is successful, this is true.
|
16
|
+
attr_accessor :success
|
17
|
+
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'success' => :'success'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.swagger_types
|
28
|
+
{
|
29
|
+
:'success' => :'BOOLEAN'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Initializes the object
|
34
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
35
|
+
def initialize(attributes = {})
|
36
|
+
return unless attributes.is_a?(Hash)
|
37
|
+
|
38
|
+
# convert string to symbol for hash key
|
39
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
40
|
+
|
41
|
+
if attributes.has_key?(:'success')
|
42
|
+
self.success = attributes[:'success']
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
48
|
+
# @return Array for valid properies with the reasons
|
49
|
+
def list_invalid_properties
|
50
|
+
invalid_properties = Array.new
|
51
|
+
return invalid_properties
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check to see if the all the properties in the model are valid
|
55
|
+
# @return true if the model is valid
|
56
|
+
def valid?
|
57
|
+
return true
|
58
|
+
end
|
59
|
+
|
60
|
+
# Checks equality by comparing each attribute.
|
61
|
+
# @param [Object] Object to be compared
|
62
|
+
def ==(o)
|
63
|
+
return true if self.equal?(o)
|
64
|
+
self.class == o.class &&
|
65
|
+
success == o.success
|
66
|
+
end
|
67
|
+
|
68
|
+
# @see the `==` method
|
69
|
+
# @param [Object] Object to be compared
|
70
|
+
def eql?(o)
|
71
|
+
self == o
|
72
|
+
end
|
73
|
+
|
74
|
+
# Calculates hash code according to all attributes.
|
75
|
+
# @return [Fixnum] Hash code
|
76
|
+
def hash
|
77
|
+
[success].hash
|
78
|
+
end
|
79
|
+
|
80
|
+
# Builds the object from hash
|
81
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
82
|
+
# @return [Object] Returns the model itself
|
83
|
+
def build_from_hash(attributes)
|
84
|
+
return nil unless attributes.is_a?(Hash)
|
85
|
+
self.class.swagger_types.each_pair do |key, type|
|
86
|
+
if type =~ /\AArray<(.*)>/i
|
87
|
+
# check to ensure the input is an array given that the the attribute
|
88
|
+
# is documented as an array but the input is not
|
89
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
90
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
91
|
+
end
|
92
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
93
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
94
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
95
|
+
end
|
96
|
+
|
97
|
+
self
|
98
|
+
end
|
99
|
+
|
100
|
+
# Deserializes the data based on type
|
101
|
+
# @param string type Data type
|
102
|
+
# @param string value Value to be deserialized
|
103
|
+
# @return [Object] Deserialized data
|
104
|
+
def _deserialize(type, value)
|
105
|
+
case type.to_sym
|
106
|
+
when :DateTime
|
107
|
+
DateTime.parse(value)
|
108
|
+
when :Date
|
109
|
+
Date.parse(value)
|
110
|
+
when :String
|
111
|
+
value.to_s
|
112
|
+
when :Integer
|
113
|
+
value.to_i
|
114
|
+
when :Float
|
115
|
+
value.to_f
|
116
|
+
when :BOOLEAN
|
117
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
118
|
+
true
|
119
|
+
else
|
120
|
+
false
|
121
|
+
end
|
122
|
+
when :Object
|
123
|
+
# generic object (usually a Hash), return directly
|
124
|
+
value
|
125
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
126
|
+
inner_type = Regexp.last_match[:inner_type]
|
127
|
+
value.map { |v| _deserialize(inner_type, v) }
|
128
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
129
|
+
k_type = Regexp.last_match[:k_type]
|
130
|
+
v_type = Regexp.last_match[:v_type]
|
131
|
+
{}.tap do |hash|
|
132
|
+
value.each do |k, v|
|
133
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
else # model
|
137
|
+
temp_model = SquareConnect.const_get(type).new
|
138
|
+
temp_model.build_from_hash(value)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
# Returns the string representation of the object
|
143
|
+
# @return [String] String presentation of the object
|
144
|
+
def to_s
|
145
|
+
to_hash.to_s
|
146
|
+
end
|
147
|
+
|
148
|
+
# to_body is an alias to to_hash (backward compatibility)
|
149
|
+
# @return [Hash] Returns the object in the form of hash
|
150
|
+
def to_body
|
151
|
+
to_hash
|
152
|
+
end
|
153
|
+
|
154
|
+
# Returns the object in the form of hash
|
155
|
+
# @return [Hash] Returns the object in the form of hash
|
156
|
+
def to_hash
|
157
|
+
hash = {}
|
158
|
+
self.class.attribute_map.each_pair do |attr, param|
|
159
|
+
value = self.send(attr)
|
160
|
+
next if value.nil?
|
161
|
+
hash[param] = _to_hash(value)
|
162
|
+
end
|
163
|
+
hash
|
164
|
+
end
|
165
|
+
|
166
|
+
# Outputs non-array value in the form of hash
|
167
|
+
# For object, use to_hash. Otherwise, just return the value
|
168
|
+
# @param [Object] value Any valid value
|
169
|
+
# @return [Hash] Returns the value in the form of hash
|
170
|
+
def _to_hash(value)
|
171
|
+
if value.is_a?(Array)
|
172
|
+
value.compact.map{ |v| _to_hash(v) }
|
173
|
+
elsif value.is_a?(Hash)
|
174
|
+
{}.tap do |hash|
|
175
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
176
|
+
end
|
177
|
+
elsif value.respond_to? :to_hash
|
178
|
+
value.to_hash
|
179
|
+
else
|
180
|
+
value
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
185
|
+
|
186
|
+
end
|
data/lib/square_connect.rb
CHANGED
@@ -122,6 +122,8 @@ require 'square_connect/models/location_capability'
|
|
122
122
|
require 'square_connect/models/location_status'
|
123
123
|
require 'square_connect/models/location_type'
|
124
124
|
require 'square_connect/models/money'
|
125
|
+
require 'square_connect/models/obtain_token_request'
|
126
|
+
require 'square_connect/models/obtain_token_response'
|
125
127
|
require 'square_connect/models/order'
|
126
128
|
require 'square_connect/models/order_line_item'
|
127
129
|
require 'square_connect/models/order_line_item_discount'
|
@@ -135,12 +137,16 @@ require 'square_connect/models/refund_status'
|
|
135
137
|
require 'square_connect/models/register_domain_request'
|
136
138
|
require 'square_connect/models/register_domain_response'
|
137
139
|
require 'square_connect/models/register_domain_response_status'
|
140
|
+
require 'square_connect/models/renew_token_request'
|
141
|
+
require 'square_connect/models/renew_token_response'
|
138
142
|
require 'square_connect/models/retrieve_catalog_object_request'
|
139
143
|
require 'square_connect/models/retrieve_catalog_object_response'
|
140
144
|
require 'square_connect/models/retrieve_customer_request'
|
141
145
|
require 'square_connect/models/retrieve_customer_response'
|
142
146
|
require 'square_connect/models/retrieve_transaction_request'
|
143
147
|
require 'square_connect/models/retrieve_transaction_response'
|
148
|
+
require 'square_connect/models/revoke_token_request'
|
149
|
+
require 'square_connect/models/revoke_token_response'
|
144
150
|
require 'square_connect/models/search_catalog_objects_request'
|
145
151
|
require 'square_connect/models/search_catalog_objects_response'
|
146
152
|
require 'square_connect/models/search_customers_request'
|
@@ -214,6 +220,7 @@ require 'square_connect/api/checkout_api'
|
|
214
220
|
require 'square_connect/api/customers_api'
|
215
221
|
require 'square_connect/api/locations_api'
|
216
222
|
require 'square_connect/api/mobile_authorization_api'
|
223
|
+
require 'square_connect/api/o_auth_api'
|
217
224
|
require 'square_connect/api/orders_api'
|
218
225
|
require 'square_connect/api/reporting_api'
|
219
226
|
require 'square_connect/api/transactions_api'
|
@@ -0,0 +1,69 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'spec_helper'
|
11
|
+
require 'json'
|
12
|
+
|
13
|
+
# Unit tests for SquareConnect::OAuthApi
|
14
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
15
|
+
# Please update as you see appropriate
|
16
|
+
describe 'OAuthApi' do
|
17
|
+
before do
|
18
|
+
# run before each test
|
19
|
+
@instance = SquareConnect::OAuthApi.new
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
# run after each test
|
24
|
+
end
|
25
|
+
|
26
|
+
describe 'test an instance of OAuthApi' do
|
27
|
+
it 'should create an instact of OAuthApi' do
|
28
|
+
expect(@instance).to be_instance_of(SquareConnect::OAuthApi)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# unit tests for obtain_token
|
33
|
+
# ObtainToken
|
34
|
+
# Exchanges the authorization code for an access token. After a merchant authorizes your application with the permissions form, an authorization code is sent to the application's redirect URL (See [Implementing OAuth](https://docs.connect.squareup.com/api/oauth#implementingoauth) for information about how to set up the redirect URL).
|
35
|
+
# @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
|
36
|
+
# @param [Hash] opts the optional parameters
|
37
|
+
# @return [ObtainTokenResponse]
|
38
|
+
describe 'obtain_token test' do
|
39
|
+
it "should work" do
|
40
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# unit tests for renew_token
|
45
|
+
# RenewToken
|
46
|
+
# Renews an OAuth access token before it expires. OAuth access tokens besides your application's personal access token expire after __30 days__. You can also renew expired tokens within __15 days__ of their expiration. You cannot renew an access token that has been expired for more than 15 days. Instead, the associated merchant must complete the [OAuth flow](https://docs.connect.squareup.com/api/oauth#implementingoauth) from the beginning. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
|
47
|
+
# @param client_id Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps).
|
48
|
+
# @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
|
49
|
+
# @param [Hash] opts the optional parameters
|
50
|
+
# @return [RenewTokenResponse]
|
51
|
+
describe 'renew_token test' do
|
52
|
+
it "should work" do
|
53
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# unit tests for revoke_token
|
58
|
+
# RevokeToken
|
59
|
+
# Revokes an access token generated with the OAuth flow. If a merchant has more than one access token for your application, this endpoint revokes all of them, regardless of which token you specify. If you revoke a merchant's access token, all of the merchant's active subscriptions associated with your application are canceled immediately. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
|
60
|
+
# @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
|
61
|
+
# @param [Hash] opts the optional parameters
|
62
|
+
# @return [RevokeTokenResponse]
|
63
|
+
describe 'revoke_token test' do
|
64
|
+
it "should work" do
|
65
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'spec_helper'
|
11
|
+
require 'json'
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
# Unit tests for SquareConnect::ObtainTokenRequest
|
15
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
16
|
+
# Please update as you see appropriate
|
17
|
+
describe 'ObtainTokenRequest' do
|
18
|
+
before do
|
19
|
+
# run before each test
|
20
|
+
@instance = SquareConnect::ObtainTokenRequest.new
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
# run after each test
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'test an instance of ObtainTokenRequest' do
|
28
|
+
it 'should create an instact of ObtainTokenRequest' do
|
29
|
+
expect(@instance).to be_instance_of(SquareConnect::ObtainTokenRequest)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe 'test attribute "client_id"' do
|
33
|
+
it 'should work' do
|
34
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'test attribute "client_secret"' do
|
39
|
+
it 'should work' do
|
40
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'test attribute "code"' do
|
45
|
+
it 'should work' do
|
46
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'test attribute "redirect_uri"' do
|
51
|
+
it 'should work' do
|
52
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'spec_helper'
|
11
|
+
require 'json'
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
# Unit tests for SquareConnect::ObtainTokenResponse
|
15
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
16
|
+
# Please update as you see appropriate
|
17
|
+
describe 'ObtainTokenResponse' do
|
18
|
+
before do
|
19
|
+
# run before each test
|
20
|
+
@instance = SquareConnect::ObtainTokenResponse.new
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
# run after each test
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'test an instance of ObtainTokenResponse' do
|
28
|
+
it 'should create an instact of ObtainTokenResponse' do
|
29
|
+
expect(@instance).to be_instance_of(SquareConnect::ObtainTokenResponse)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe 'test attribute "access_token"' do
|
33
|
+
it 'should work' do
|
34
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'test attribute "token_type"' do
|
39
|
+
it 'should work' do
|
40
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'test attribute "expires_at"' do
|
45
|
+
it 'should work' do
|
46
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'test attribute "merchant_id"' do
|
51
|
+
it 'should work' do
|
52
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'test attribute "subscription_id"' do
|
57
|
+
it 'should work' do
|
58
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'test attribute "plan_id"' do
|
63
|
+
it 'should work' do
|
64
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'test attribute "id_token"' do
|
69
|
+
it 'should work' do
|
70
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'spec_helper'
|
11
|
+
require 'json'
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
# Unit tests for SquareConnect::RenewTokenRequest
|
15
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
16
|
+
# Please update as you see appropriate
|
17
|
+
describe 'RenewTokenRequest' do
|
18
|
+
before do
|
19
|
+
# run before each test
|
20
|
+
@instance = SquareConnect::RenewTokenRequest.new
|
21
|
+
end
|
22
|
+
|
23
|
+
after do
|
24
|
+
# run after each test
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'test an instance of RenewTokenRequest' do
|
28
|
+
it 'should create an instact of RenewTokenRequest' do
|
29
|
+
expect(@instance).to be_instance_of(SquareConnect::RenewTokenRequest)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe 'test attribute "access_token"' do
|
33
|
+
it 'should work' do
|
34
|
+
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|