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.
@@ -30,7 +30,7 @@ module SquareConnect
30
30
  @config = config
31
31
 
32
32
  # Construct user agent string. Returns slightly different string for JRuby
33
- @user_agent = "Square-Connect-Ruby/2.20180712.1"
33
+ @user_agent = "Square-Connect-Ruby/2.20180712.2"
34
34
 
35
35
  @default_headers = {
36
36
  'Content-Type' => "application/json",
@@ -0,0 +1,216 @@
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 ObtainTokenRequest
15
+ # Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps).
16
+ attr_accessor :client_id
17
+
18
+ # Your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
19
+ attr_accessor :client_secret
20
+
21
+ # The authorization code to exchange.
22
+ attr_accessor :code
23
+
24
+ # The redirect URL assigned in the [application dashboard](https://connect.squareup.com/apps).
25
+ attr_accessor :redirect_uri
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'client_id' => :'client_id',
32
+ :'client_secret' => :'client_secret',
33
+ :'code' => :'code',
34
+ :'redirect_uri' => :'redirect_uri'
35
+ }
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.swagger_types
40
+ {
41
+ :'client_id' => :'String',
42
+ :'client_secret' => :'String',
43
+ :'code' => :'String',
44
+ :'redirect_uri' => :'String'
45
+ }
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ return unless attributes.is_a?(Hash)
52
+
53
+ # convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
55
+
56
+ if attributes.has_key?(:'client_id')
57
+ self.client_id = attributes[:'client_id']
58
+ end
59
+
60
+ if attributes.has_key?(:'client_secret')
61
+ self.client_secret = attributes[:'client_secret']
62
+ end
63
+
64
+ if attributes.has_key?(:'code')
65
+ self.code = attributes[:'code']
66
+ end
67
+
68
+ if attributes.has_key?(:'redirect_uri')
69
+ self.redirect_uri = attributes[:'redirect_uri']
70
+ end
71
+
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properies with the reasons
76
+ def list_invalid_properties
77
+ invalid_properties = Array.new
78
+ return invalid_properties
79
+ end
80
+
81
+ # Check to see if the all the properties in the model are valid
82
+ # @return true if the model is valid
83
+ def valid?
84
+ return true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ client_id == o.client_id &&
93
+ client_secret == o.client_secret &&
94
+ code == o.code &&
95
+ redirect_uri == o.redirect_uri
96
+ end
97
+
98
+ # @see the `==` method
99
+ # @param [Object] Object to be compared
100
+ def eql?(o)
101
+ self == o
102
+ end
103
+
104
+ # Calculates hash code according to all attributes.
105
+ # @return [Fixnum] Hash code
106
+ def hash
107
+ [client_id, client_secret, code, redirect_uri].hash
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.swagger_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :BOOLEAN
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ temp_model = SquareConnect.const_get(type).new
168
+ temp_model.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ next if value.nil?
191
+ hash[param] = _to_hash(value)
192
+ end
193
+ hash
194
+ end
195
+
196
+ # Outputs non-array value in the form of hash
197
+ # For object, use to_hash. Otherwise, just return the value
198
+ # @param [Object] value Any valid value
199
+ # @return [Hash] Returns the value in the form of hash
200
+ def _to_hash(value)
201
+ if value.is_a?(Array)
202
+ value.compact.map{ |v| _to_hash(v) }
203
+ elsif value.is_a?(Hash)
204
+ {}.tap do |hash|
205
+ value.each { |k, v| hash[k] = _to_hash(v) }
206
+ end
207
+ elsif value.respond_to? :to_hash
208
+ value.to_hash
209
+ else
210
+ value
211
+ end
212
+ end
213
+
214
+ end
215
+
216
+ end
@@ -0,0 +1,246 @@
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 ObtainTokenResponse
15
+ # Your application's access token. You provide this token in a header with every request to Connect API endpoints. See [Request and response headers](https://docs.connect.squareup.com/api/connect/v2/#requestandresponseheaders) for the format of this header.
16
+ attr_accessor :access_token
17
+
18
+ # This value is always _bearer_.
19
+ attr_accessor :token_type
20
+
21
+ # The date when access_token expires, in [ISO 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format.
22
+ attr_accessor :expires_at
23
+
24
+ # The ID of the authorizing merchant's business.
25
+ attr_accessor :merchant_id
26
+
27
+ # The ID of the merchant [subscription](https://docs.connect.squareup.com/api/connect/v1/#navsection-subscriptionmanagement) associated with the authorization. Only present if the merchant signed up for a subscription during authorization.
28
+ attr_accessor :subscription_id
29
+
30
+ # The ID of the [subscription](https://docs.connect.squareup.com/api/connect/v1/#navsection-subscriptionmanagement) plan the merchant signed up for. Only present if the merchant signed up for a subscription during authorization.
31
+ attr_accessor :plan_id
32
+
33
+ # Then OpenID token belonging to this this person. Only present if the OPENID scope is included in the authorize request.
34
+ attr_accessor :id_token
35
+
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'access_token' => :'access_token',
41
+ :'token_type' => :'token_type',
42
+ :'expires_at' => :'expires_at',
43
+ :'merchant_id' => :'merchant_id',
44
+ :'subscription_id' => :'subscription_id',
45
+ :'plan_id' => :'plan_id',
46
+ :'id_token' => :'id_token'
47
+ }
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.swagger_types
52
+ {
53
+ :'access_token' => :'String',
54
+ :'token_type' => :'String',
55
+ :'expires_at' => :'String',
56
+ :'merchant_id' => :'String',
57
+ :'subscription_id' => :'String',
58
+ :'plan_id' => :'String',
59
+ :'id_token' => :'String'
60
+ }
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ return unless attributes.is_a?(Hash)
67
+
68
+ # convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
70
+
71
+ if attributes.has_key?(:'access_token')
72
+ self.access_token = attributes[:'access_token']
73
+ end
74
+
75
+ if attributes.has_key?(:'token_type')
76
+ self.token_type = attributes[:'token_type']
77
+ end
78
+
79
+ if attributes.has_key?(:'expires_at')
80
+ self.expires_at = attributes[:'expires_at']
81
+ end
82
+
83
+ if attributes.has_key?(:'merchant_id')
84
+ self.merchant_id = attributes[:'merchant_id']
85
+ end
86
+
87
+ if attributes.has_key?(:'subscription_id')
88
+ self.subscription_id = attributes[:'subscription_id']
89
+ end
90
+
91
+ if attributes.has_key?(:'plan_id')
92
+ self.plan_id = attributes[:'plan_id']
93
+ end
94
+
95
+ if attributes.has_key?(:'id_token')
96
+ self.id_token = attributes[:'id_token']
97
+ end
98
+
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properies with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ return invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ return true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ access_token == o.access_token &&
120
+ token_type == o.token_type &&
121
+ expires_at == o.expires_at &&
122
+ merchant_id == o.merchant_id &&
123
+ subscription_id == o.subscription_id &&
124
+ plan_id == o.plan_id &&
125
+ id_token == o.id_token
126
+ end
127
+
128
+ # @see the `==` method
129
+ # @param [Object] Object to be compared
130
+ def eql?(o)
131
+ self == o
132
+ end
133
+
134
+ # Calculates hash code according to all attributes.
135
+ # @return [Fixnum] Hash code
136
+ def hash
137
+ [access_token, token_type, expires_at, merchant_id, subscription_id, plan_id, id_token].hash
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def build_from_hash(attributes)
144
+ return nil unless attributes.is_a?(Hash)
145
+ self.class.swagger_types.each_pair do |key, type|
146
+ if type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
150
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
151
+ end
152
+ elsif !attributes[self.class.attribute_map[key]].nil?
153
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
154
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
155
+ end
156
+
157
+ self
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def _deserialize(type, value)
165
+ case type.to_sym
166
+ when :DateTime
167
+ DateTime.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :BOOLEAN
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ temp_model = SquareConnect.const_get(type).new
198
+ temp_model.build_from_hash(value)
199
+ end
200
+ end
201
+
202
+ # Returns the string representation of the object
203
+ # @return [String] String presentation of the object
204
+ def to_s
205
+ to_hash.to_s
206
+ end
207
+
208
+ # to_body is an alias to to_hash (backward compatibility)
209
+ # @return [Hash] Returns the object in the form of hash
210
+ def to_body
211
+ to_hash
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = self.send(attr)
220
+ next if value.nil?
221
+ hash[param] = _to_hash(value)
222
+ end
223
+ hash
224
+ end
225
+
226
+ # Outputs non-array value in the form of hash
227
+ # For object, use to_hash. Otherwise, just return the value
228
+ # @param [Object] value Any valid value
229
+ # @return [Hash] Returns the value in the form of hash
230
+ def _to_hash(value)
231
+ if value.is_a?(Array)
232
+ value.compact.map{ |v| _to_hash(v) }
233
+ elsif value.is_a?(Hash)
234
+ {}.tap do |hash|
235
+ value.each { |k, v| hash[k] = _to_hash(v) }
236
+ end
237
+ elsif value.respond_to? :to_hash
238
+ value.to_hash
239
+ else
240
+ value
241
+ end
242
+ end
243
+
244
+ end
245
+
246
+ end