square_connect 2.2.1.145 → 2.3.0.153
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/docs/BatchRetrieveOrdersRequest.md +12 -0
- data/docs/BatchRetrieveOrdersResponse.md +13 -0
- data/docs/CatalogItemVariation.md +1 -1
- data/docs/CatalogObject.md +1 -1
- data/docs/CatalogV1Id.md +2 -2
- data/docs/CreateOrderRequest.md +5 -4
- data/docs/CreateOrderRequestDiscount.md +5 -4
- data/docs/CreateOrderRequestLineItem.md +10 -6
- data/docs/CreateOrderRequestModifier.md +12 -0
- data/docs/CreateOrderRequestTax.md +5 -4
- data/docs/CreateOrderResponse.md +13 -0
- data/docs/Currency.md +1 -0
- data/docs/CustomersApi.md +1 -1
- data/docs/ErrorCode.md +2 -0
- data/docs/ItemVariationLocationOverrides.md +5 -5
- data/docs/Location.md +9 -1
- data/docs/LocationStatus.md +13 -0
- data/docs/Order.md +1 -0
- data/docs/OrderLineItem.md +6 -1
- data/docs/OrderLineItemDiscount.md +1 -0
- data/docs/OrderLineItemDiscountScope.md +1 -0
- data/docs/OrderLineItemDiscountType.md +1 -1
- data/docs/OrderLineItemModifier.md +15 -0
- data/docs/OrderLineItemTax.md +1 -0
- data/docs/OrderLineItemTaxType.md +1 -1
- data/docs/OrdersApi.md +120 -0
- data/docs/SearchCatalogObjectsRequest.md +1 -1
- data/docs/Transaction.md +1 -1
- data/docs/TransactionsApi.md +1 -1
- data/docs/V1Payment.md +3 -3
- data/docs/V1Refund.md +0 -5
- data/lib/square_connect/api/customers_api.rb +2 -2
- data/lib/square_connect/api/orders_api.rb +134 -0
- data/lib/square_connect/api/transactions_api.rb +2 -2
- data/lib/square_connect/api_client.rb +1 -1
- data/lib/square_connect/models/batch_retrieve_orders_request.rb +193 -0
- data/lib/square_connect/models/batch_retrieve_orders_response.rb +200 -0
- data/lib/square_connect/models/catalog_item_variation.rb +1 -1
- data/lib/square_connect/models/catalog_object.rb +1 -1
- data/lib/square_connect/models/catalog_v1_id.rb +2 -2
- data/lib/square_connect/models/charge_request.rb +108 -0
- data/lib/square_connect/models/create_checkout_request.rb +16 -0
- data/lib/square_connect/models/create_order_request.rb +31 -5
- data/lib/square_connect/models/create_order_request_discount.rb +47 -5
- data/lib/square_connect/models/create_order_request_line_item.rb +106 -7
- data/lib/square_connect/models/create_order_request_modifier.rb +219 -0
- data/lib/square_connect/models/create_order_request_tax.rb +49 -7
- data/lib/square_connect/models/create_order_response.rb +198 -0
- data/lib/square_connect/models/create_refund_request.rb +72 -0
- data/lib/square_connect/models/currency.rb +1 -0
- data/lib/square_connect/models/error.rb +2 -2
- data/lib/square_connect/models/error_code.rb +2 -0
- data/lib/square_connect/models/item_variation_location_overrides.rb +5 -5
- data/lib/square_connect/models/location.rb +121 -5
- data/lib/square_connect/models/location_status.rb +19 -0
- data/lib/square_connect/models/money.rb +27 -2
- data/lib/square_connect/models/order.rb +11 -1
- data/lib/square_connect/models/order_line_item.rb +54 -2
- data/lib/square_connect/models/order_line_item_discount.rb +15 -5
- data/lib/square_connect/models/order_line_item_discount_scope.rb +1 -0
- data/lib/square_connect/models/order_line_item_discount_type.rb +1 -1
- data/lib/square_connect/models/order_line_item_modifier.rb +216 -0
- data/lib/square_connect/models/order_line_item_tax.rb +13 -3
- data/lib/square_connect/models/order_line_item_tax_type.rb +1 -1
- data/lib/square_connect/models/search_catalog_objects_request.rb +1 -1
- data/lib/square_connect/models/transaction.rb +14 -14
- data/lib/square_connect/models/v1_payment.rb +3 -0
- data/lib/square_connect/models/v1_refund.rb +1 -51
- data/lib/square_connect/version.rb +1 -1
- data/lib/square_connect.rb +7 -0
- metadata +17 -3
@@ -0,0 +1,219 @@
|
|
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
|
+
# Represents a modifier applied to a single line item.
|
14
|
+
class CreateOrderRequestModifier
|
15
|
+
# The catalog object ID of a [CatalogModifier](#type-catalogmodifier).
|
16
|
+
attr_accessor :catalog_object_id
|
17
|
+
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'catalog_object_id' => :'catalog_object_id'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.swagger_types
|
28
|
+
{
|
29
|
+
:'catalog_object_id' => :'String'
|
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?(:'catalog_object_id')
|
42
|
+
self.catalog_object_id = attributes[:'catalog_object_id']
|
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
|
+
if @catalog_object_id.nil?
|
52
|
+
invalid_properties.push("invalid value for 'catalog_object_id', catalog_object_id cannot be nil.")
|
53
|
+
end
|
54
|
+
|
55
|
+
if @catalog_object_id.to_s.length > 192
|
56
|
+
invalid_properties.push("invalid value for 'catalog_object_id', the character length must be smaller than or equal to 192.")
|
57
|
+
end
|
58
|
+
|
59
|
+
if @catalog_object_id.to_s.length < 1
|
60
|
+
invalid_properties.push("invalid value for 'catalog_object_id', the character length must be great than or equal to 1.")
|
61
|
+
end
|
62
|
+
|
63
|
+
return invalid_properties
|
64
|
+
end
|
65
|
+
|
66
|
+
# Check to see if the all the properties in the model are valid
|
67
|
+
# @return true if the model is valid
|
68
|
+
def valid?
|
69
|
+
return false if @catalog_object_id.nil?
|
70
|
+
return false if @catalog_object_id.to_s.length > 192
|
71
|
+
return false if @catalog_object_id.to_s.length < 1
|
72
|
+
return true
|
73
|
+
end
|
74
|
+
|
75
|
+
# Custom attribute writer method with validation
|
76
|
+
# @param [Object] catalog_object_id Value to be assigned
|
77
|
+
def catalog_object_id=(catalog_object_id)
|
78
|
+
if catalog_object_id.nil?
|
79
|
+
fail ArgumentError, "catalog_object_id cannot be nil"
|
80
|
+
end
|
81
|
+
|
82
|
+
if catalog_object_id.to_s.length > 192
|
83
|
+
fail ArgumentError, "invalid value for 'catalog_object_id', the character length must be smaller than or equal to 192."
|
84
|
+
end
|
85
|
+
|
86
|
+
if catalog_object_id.to_s.length < 1
|
87
|
+
fail ArgumentError, "invalid value for 'catalog_object_id', the character length must be great than or equal to 1."
|
88
|
+
end
|
89
|
+
|
90
|
+
@catalog_object_id = catalog_object_id
|
91
|
+
end
|
92
|
+
|
93
|
+
# Checks equality by comparing each attribute.
|
94
|
+
# @param [Object] Object to be compared
|
95
|
+
def ==(o)
|
96
|
+
return true if self.equal?(o)
|
97
|
+
self.class == o.class &&
|
98
|
+
catalog_object_id == o.catalog_object_id
|
99
|
+
end
|
100
|
+
|
101
|
+
# @see the `==` method
|
102
|
+
# @param [Object] Object to be compared
|
103
|
+
def eql?(o)
|
104
|
+
self == o
|
105
|
+
end
|
106
|
+
|
107
|
+
# Calculates hash code according to all attributes.
|
108
|
+
# @return [Fixnum] Hash code
|
109
|
+
def hash
|
110
|
+
[catalog_object_id].hash
|
111
|
+
end
|
112
|
+
|
113
|
+
# Builds the object from hash
|
114
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
115
|
+
# @return [Object] Returns the model itself
|
116
|
+
def build_from_hash(attributes)
|
117
|
+
return nil unless attributes.is_a?(Hash)
|
118
|
+
self.class.swagger_types.each_pair do |key, type|
|
119
|
+
if type =~ /\AArray<(.*)>/i
|
120
|
+
# check to ensure the input is an array given that the the attribute
|
121
|
+
# is documented as an array but the input is not
|
122
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
123
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
124
|
+
end
|
125
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
126
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
127
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
128
|
+
end
|
129
|
+
|
130
|
+
self
|
131
|
+
end
|
132
|
+
|
133
|
+
# Deserializes the data based on type
|
134
|
+
# @param string type Data type
|
135
|
+
# @param string value Value to be deserialized
|
136
|
+
# @return [Object] Deserialized data
|
137
|
+
def _deserialize(type, value)
|
138
|
+
case type.to_sym
|
139
|
+
when :DateTime
|
140
|
+
DateTime.parse(value)
|
141
|
+
when :Date
|
142
|
+
Date.parse(value)
|
143
|
+
when :String
|
144
|
+
value.to_s
|
145
|
+
when :Integer
|
146
|
+
value.to_i
|
147
|
+
when :Float
|
148
|
+
value.to_f
|
149
|
+
when :BOOLEAN
|
150
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
151
|
+
true
|
152
|
+
else
|
153
|
+
false
|
154
|
+
end
|
155
|
+
when :Object
|
156
|
+
# generic object (usually a Hash), return directly
|
157
|
+
value
|
158
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
159
|
+
inner_type = Regexp.last_match[:inner_type]
|
160
|
+
value.map { |v| _deserialize(inner_type, v) }
|
161
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
162
|
+
k_type = Regexp.last_match[:k_type]
|
163
|
+
v_type = Regexp.last_match[:v_type]
|
164
|
+
{}.tap do |hash|
|
165
|
+
value.each do |k, v|
|
166
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
else # model
|
170
|
+
temp_model = SquareConnect.const_get(type).new
|
171
|
+
temp_model.build_from_hash(value)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the string representation of the object
|
176
|
+
# @return [String] String presentation of the object
|
177
|
+
def to_s
|
178
|
+
to_hash.to_s
|
179
|
+
end
|
180
|
+
|
181
|
+
# to_body is an alias to to_hash (backward compatibility)
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_body
|
184
|
+
to_hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the object in the form of hash
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
189
|
+
def to_hash
|
190
|
+
hash = {}
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
192
|
+
value = self.send(attr)
|
193
|
+
next if value.nil?
|
194
|
+
hash[param] = _to_hash(value)
|
195
|
+
end
|
196
|
+
hash
|
197
|
+
end
|
198
|
+
|
199
|
+
# Outputs non-array value in the form of hash
|
200
|
+
# For object, use to_hash. Otherwise, just return the value
|
201
|
+
# @param [Object] value Any valid value
|
202
|
+
# @return [Hash] Returns the value in the form of hash
|
203
|
+
def _to_hash(value)
|
204
|
+
if value.is_a?(Array)
|
205
|
+
value.compact.map{ |v| _to_hash(v) }
|
206
|
+
elsif value.is_a?(Hash)
|
207
|
+
{}.tap do |hash|
|
208
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
209
|
+
end
|
210
|
+
elsif value.respond_to? :to_hash
|
211
|
+
value.to_hash
|
212
|
+
else
|
213
|
+
value
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
|
219
|
+
end
|
@@ -10,15 +10,18 @@ Generated by: https://github.com/swagger-api/swagger-codegen.git
|
|
10
10
|
require 'date'
|
11
11
|
|
12
12
|
module SquareConnect
|
13
|
-
# Represents a tax that
|
13
|
+
# Represents a tax that can apply to either a single line item or an entire order.
|
14
14
|
class CreateOrderRequestTax
|
15
|
-
# The
|
15
|
+
# Only used for catalog taxes. The catalog object ID of an existing [CatalogTax](#type-catalogtax). Do not provide a value for this field if you provide values in other fields for an ad hoc tax.
|
16
|
+
attr_accessor :catalog_object_id
|
17
|
+
|
18
|
+
# Only used for ad hoc taxes. The tax's name. Do not provide a value for this field if you set catalog_object_id.
|
16
19
|
attr_accessor :name
|
17
20
|
|
18
|
-
# Indicates the calculation method used to apply the line item tax. Default: `ADDITIVE`; See [OrderLineItemTaxType](#type-orderlineitemtaxtype) for possible values.
|
21
|
+
# Only used for ad hoc taxes. Indicates the calculation method used to apply the line item tax. Default: `ADDITIVE`; See [OrderLineItemTaxType](#type-orderlineitemtaxtype) for possible values.
|
19
22
|
attr_accessor :type
|
20
23
|
|
21
|
-
# The percentage of the tax, as a string representation of a decimal number. A value of `7.25` corresponds to a percentage of 7.25%. This value range between 0.0 up to 100.0
|
24
|
+
# Only used for ad hoc taxes. The percentage of the tax, as a string representation of a decimal number. A value of `7.25` corresponds to a percentage of 7.25%. This value range between 0.0 up to 100.0
|
22
25
|
attr_accessor :percentage
|
23
26
|
|
24
27
|
class EnumAttributeValidator
|
@@ -46,6 +49,7 @@ module SquareConnect
|
|
46
49
|
# Attribute mapping from ruby-style variable name to JSON key.
|
47
50
|
def self.attribute_map
|
48
51
|
{
|
52
|
+
:'catalog_object_id' => :'catalog_object_id',
|
49
53
|
:'name' => :'name',
|
50
54
|
:'type' => :'type',
|
51
55
|
:'percentage' => :'percentage'
|
@@ -55,6 +59,7 @@ module SquareConnect
|
|
55
59
|
# Attribute type mapping.
|
56
60
|
def self.swagger_types
|
57
61
|
{
|
62
|
+
:'catalog_object_id' => :'String',
|
58
63
|
:'name' => :'String',
|
59
64
|
:'type' => :'String',
|
60
65
|
:'percentage' => :'String'
|
@@ -69,6 +74,10 @@ module SquareConnect
|
|
69
74
|
# convert string to symbol for hash key
|
70
75
|
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
71
76
|
|
77
|
+
if attributes.has_key?(:'catalog_object_id')
|
78
|
+
self.catalog_object_id = attributes[:'catalog_object_id']
|
79
|
+
end
|
80
|
+
|
72
81
|
if attributes.has_key?(:'name')
|
73
82
|
self.name = attributes[:'name']
|
74
83
|
end
|
@@ -87,22 +96,43 @@ module SquareConnect
|
|
87
96
|
# @return Array for valid properies with the reasons
|
88
97
|
def list_invalid_properties
|
89
98
|
invalid_properties = Array.new
|
99
|
+
if !@catalog_object_id.nil? && @catalog_object_id.to_s.length > 192
|
100
|
+
invalid_properties.push("invalid value for 'catalog_object_id', the character length must be smaller than or equal to 192.")
|
101
|
+
end
|
102
|
+
|
90
103
|
if !@name.nil? && @name.to_s.length > 255
|
91
104
|
invalid_properties.push("invalid value for 'name', the character length must be smaller than or equal to 255.")
|
92
105
|
end
|
93
106
|
|
107
|
+
if !@percentage.nil? && @percentage.to_s.length > 10
|
108
|
+
invalid_properties.push("invalid value for 'percentage', the character length must be smaller than or equal to 10.")
|
109
|
+
end
|
110
|
+
|
94
111
|
return invalid_properties
|
95
112
|
end
|
96
113
|
|
97
114
|
# Check to see if the all the properties in the model are valid
|
98
115
|
# @return true if the model is valid
|
99
116
|
def valid?
|
117
|
+
return false if !@catalog_object_id.nil? && @catalog_object_id.to_s.length > 192
|
100
118
|
return false if !@name.nil? && @name.to_s.length > 255
|
101
|
-
type_validator = EnumAttributeValidator.new('String', ["
|
119
|
+
type_validator = EnumAttributeValidator.new('String', ["UNKNOWN_TAX", "ADDITIVE", "INCLUSIVE"])
|
102
120
|
return false unless type_validator.valid?(@type)
|
121
|
+
return false if !@percentage.nil? && @percentage.to_s.length > 10
|
103
122
|
return true
|
104
123
|
end
|
105
124
|
|
125
|
+
# Custom attribute writer method with validation
|
126
|
+
# @param [Object] catalog_object_id Value to be assigned
|
127
|
+
def catalog_object_id=(catalog_object_id)
|
128
|
+
|
129
|
+
if !catalog_object_id.nil? && catalog_object_id.to_s.length > 192
|
130
|
+
fail ArgumentError, "invalid value for 'catalog_object_id', the character length must be smaller than or equal to 192."
|
131
|
+
end
|
132
|
+
|
133
|
+
@catalog_object_id = catalog_object_id
|
134
|
+
end
|
135
|
+
|
106
136
|
# Custom attribute writer method with validation
|
107
137
|
# @param [Object] name Value to be assigned
|
108
138
|
def name=(name)
|
@@ -117,18 +147,30 @@ module SquareConnect
|
|
117
147
|
# Custom attribute writer method checking allowed values (enum).
|
118
148
|
# @param [Object] type Object to be assigned
|
119
149
|
def type=(type)
|
120
|
-
validator = EnumAttributeValidator.new('String', ["
|
150
|
+
validator = EnumAttributeValidator.new('String', ["UNKNOWN_TAX", "ADDITIVE", "INCLUSIVE"])
|
121
151
|
unless validator.valid?(type)
|
122
152
|
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
123
153
|
end
|
124
154
|
@type = type
|
125
155
|
end
|
126
156
|
|
157
|
+
# Custom attribute writer method with validation
|
158
|
+
# @param [Object] percentage Value to be assigned
|
159
|
+
def percentage=(percentage)
|
160
|
+
|
161
|
+
if !percentage.nil? && percentage.to_s.length > 10
|
162
|
+
fail ArgumentError, "invalid value for 'percentage', the character length must be smaller than or equal to 10."
|
163
|
+
end
|
164
|
+
|
165
|
+
@percentage = percentage
|
166
|
+
end
|
167
|
+
|
127
168
|
# Checks equality by comparing each attribute.
|
128
169
|
# @param [Object] Object to be compared
|
129
170
|
def ==(o)
|
130
171
|
return true if self.equal?(o)
|
131
172
|
self.class == o.class &&
|
173
|
+
catalog_object_id == o.catalog_object_id &&
|
132
174
|
name == o.name &&
|
133
175
|
type == o.type &&
|
134
176
|
percentage == o.percentage
|
@@ -143,7 +185,7 @@ module SquareConnect
|
|
143
185
|
# Calculates hash code according to all attributes.
|
144
186
|
# @return [Fixnum] Hash code
|
145
187
|
def hash
|
146
|
-
[name, type, percentage].hash
|
188
|
+
[catalog_object_id, name, type, percentage].hash
|
147
189
|
end
|
148
190
|
|
149
191
|
# Builds the object from hash
|
@@ -0,0 +1,198 @@
|
|
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
|
+
# Defines the fields that are included in the response body of a request to the [CreateOrder](#endpoint-createorder) endpoint. One of `errors` or `order` is present in a given response (never both).
|
14
|
+
class CreateOrderResponse
|
15
|
+
# The newly created order.
|
16
|
+
attr_accessor :order
|
17
|
+
|
18
|
+
# Any errors that occurred during the request.
|
19
|
+
attr_accessor :errors
|
20
|
+
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'order' => :'order',
|
26
|
+
:'errors' => :'errors'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.swagger_types
|
32
|
+
{
|
33
|
+
:'order' => :'Order',
|
34
|
+
:'errors' => :'Array<Error>'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Initializes the object
|
39
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
40
|
+
def initialize(attributes = {})
|
41
|
+
return unless attributes.is_a?(Hash)
|
42
|
+
|
43
|
+
# convert string to symbol for hash key
|
44
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
45
|
+
|
46
|
+
if attributes.has_key?(:'order')
|
47
|
+
self.order = attributes[:'order']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes.has_key?(:'errors')
|
51
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
52
|
+
self.errors = value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
59
|
+
# @return Array for valid properies with the reasons
|
60
|
+
def list_invalid_properties
|
61
|
+
invalid_properties = Array.new
|
62
|
+
return invalid_properties
|
63
|
+
end
|
64
|
+
|
65
|
+
# Check to see if the all the properties in the model are valid
|
66
|
+
# @return true if the model is valid
|
67
|
+
def valid?
|
68
|
+
return true
|
69
|
+
end
|
70
|
+
|
71
|
+
# Checks equality by comparing each attribute.
|
72
|
+
# @param [Object] Object to be compared
|
73
|
+
def ==(o)
|
74
|
+
return true if self.equal?(o)
|
75
|
+
self.class == o.class &&
|
76
|
+
order == o.order &&
|
77
|
+
errors == o.errors
|
78
|
+
end
|
79
|
+
|
80
|
+
# @see the `==` method
|
81
|
+
# @param [Object] Object to be compared
|
82
|
+
def eql?(o)
|
83
|
+
self == o
|
84
|
+
end
|
85
|
+
|
86
|
+
# Calculates hash code according to all attributes.
|
87
|
+
# @return [Fixnum] Hash code
|
88
|
+
def hash
|
89
|
+
[order, errors].hash
|
90
|
+
end
|
91
|
+
|
92
|
+
# Builds the object from hash
|
93
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
94
|
+
# @return [Object] Returns the model itself
|
95
|
+
def build_from_hash(attributes)
|
96
|
+
return nil unless attributes.is_a?(Hash)
|
97
|
+
self.class.swagger_types.each_pair do |key, type|
|
98
|
+
if type =~ /\AArray<(.*)>/i
|
99
|
+
# check to ensure the input is an array given that the the attribute
|
100
|
+
# is documented as an array but the input is not
|
101
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
102
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
103
|
+
end
|
104
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
105
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
106
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
107
|
+
end
|
108
|
+
|
109
|
+
self
|
110
|
+
end
|
111
|
+
|
112
|
+
# Deserializes the data based on type
|
113
|
+
# @param string type Data type
|
114
|
+
# @param string value Value to be deserialized
|
115
|
+
# @return [Object] Deserialized data
|
116
|
+
def _deserialize(type, value)
|
117
|
+
case type.to_sym
|
118
|
+
when :DateTime
|
119
|
+
DateTime.parse(value)
|
120
|
+
when :Date
|
121
|
+
Date.parse(value)
|
122
|
+
when :String
|
123
|
+
value.to_s
|
124
|
+
when :Integer
|
125
|
+
value.to_i
|
126
|
+
when :Float
|
127
|
+
value.to_f
|
128
|
+
when :BOOLEAN
|
129
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
130
|
+
true
|
131
|
+
else
|
132
|
+
false
|
133
|
+
end
|
134
|
+
when :Object
|
135
|
+
# generic object (usually a Hash), return directly
|
136
|
+
value
|
137
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
138
|
+
inner_type = Regexp.last_match[:inner_type]
|
139
|
+
value.map { |v| _deserialize(inner_type, v) }
|
140
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
141
|
+
k_type = Regexp.last_match[:k_type]
|
142
|
+
v_type = Regexp.last_match[:v_type]
|
143
|
+
{}.tap do |hash|
|
144
|
+
value.each do |k, v|
|
145
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
else # model
|
149
|
+
temp_model = SquareConnect.const_get(type).new
|
150
|
+
temp_model.build_from_hash(value)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Returns the string representation of the object
|
155
|
+
# @return [String] String presentation of the object
|
156
|
+
def to_s
|
157
|
+
to_hash.to_s
|
158
|
+
end
|
159
|
+
|
160
|
+
# to_body is an alias to to_hash (backward compatibility)
|
161
|
+
# @return [Hash] Returns the object in the form of hash
|
162
|
+
def to_body
|
163
|
+
to_hash
|
164
|
+
end
|
165
|
+
|
166
|
+
# Returns the object in the form of hash
|
167
|
+
# @return [Hash] Returns the object in the form of hash
|
168
|
+
def to_hash
|
169
|
+
hash = {}
|
170
|
+
self.class.attribute_map.each_pair do |attr, param|
|
171
|
+
value = self.send(attr)
|
172
|
+
next if value.nil?
|
173
|
+
hash[param] = _to_hash(value)
|
174
|
+
end
|
175
|
+
hash
|
176
|
+
end
|
177
|
+
|
178
|
+
# Outputs non-array value in the form of hash
|
179
|
+
# For object, use to_hash. Otherwise, just return the value
|
180
|
+
# @param [Object] value Any valid value
|
181
|
+
# @return [Hash] Returns the value in the form of hash
|
182
|
+
def _to_hash(value)
|
183
|
+
if value.is_a?(Array)
|
184
|
+
value.compact.map{ |v| _to_hash(v) }
|
185
|
+
elsif value.is_a?(Hash)
|
186
|
+
{}.tap do |hash|
|
187
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
188
|
+
end
|
189
|
+
elsif value.respond_to? :to_hash
|
190
|
+
value.to_hash
|
191
|
+
else
|
192
|
+
value
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
197
|
+
|
198
|
+
end
|
@@ -79,10 +79,30 @@ module SquareConnect
|
|
79
79
|
invalid_properties.push("invalid value for 'idempotency_key', idempotency_key cannot be nil.")
|
80
80
|
end
|
81
81
|
|
82
|
+
if @idempotency_key.to_s.length > 192
|
83
|
+
invalid_properties.push("invalid value for 'idempotency_key', the character length must be smaller than or equal to 192.")
|
84
|
+
end
|
85
|
+
|
86
|
+
if @idempotency_key.to_s.length < 1
|
87
|
+
invalid_properties.push("invalid value for 'idempotency_key', the character length must be great than or equal to 1.")
|
88
|
+
end
|
89
|
+
|
82
90
|
if @tender_id.nil?
|
83
91
|
invalid_properties.push("invalid value for 'tender_id', tender_id cannot be nil.")
|
84
92
|
end
|
85
93
|
|
94
|
+
if @tender_id.to_s.length > 192
|
95
|
+
invalid_properties.push("invalid value for 'tender_id', the character length must be smaller than or equal to 192.")
|
96
|
+
end
|
97
|
+
|
98
|
+
if @tender_id.to_s.length < 1
|
99
|
+
invalid_properties.push("invalid value for 'tender_id', the character length must be great than or equal to 1.")
|
100
|
+
end
|
101
|
+
|
102
|
+
if !@reason.nil? && @reason.to_s.length > 192
|
103
|
+
invalid_properties.push("invalid value for 'reason', the character length must be smaller than or equal to 192.")
|
104
|
+
end
|
105
|
+
|
86
106
|
if @amount_money.nil?
|
87
107
|
invalid_properties.push("invalid value for 'amount_money', amount_money cannot be nil.")
|
88
108
|
end
|
@@ -94,11 +114,63 @@ module SquareConnect
|
|
94
114
|
# @return true if the model is valid
|
95
115
|
def valid?
|
96
116
|
return false if @idempotency_key.nil?
|
117
|
+
return false if @idempotency_key.to_s.length > 192
|
118
|
+
return false if @idempotency_key.to_s.length < 1
|
97
119
|
return false if @tender_id.nil?
|
120
|
+
return false if @tender_id.to_s.length > 192
|
121
|
+
return false if @tender_id.to_s.length < 1
|
122
|
+
return false if !@reason.nil? && @reason.to_s.length > 192
|
98
123
|
return false if @amount_money.nil?
|
99
124
|
return true
|
100
125
|
end
|
101
126
|
|
127
|
+
# Custom attribute writer method with validation
|
128
|
+
# @param [Object] idempotency_key Value to be assigned
|
129
|
+
def idempotency_key=(idempotency_key)
|
130
|
+
if idempotency_key.nil?
|
131
|
+
fail ArgumentError, "idempotency_key cannot be nil"
|
132
|
+
end
|
133
|
+
|
134
|
+
if idempotency_key.to_s.length > 192
|
135
|
+
fail ArgumentError, "invalid value for 'idempotency_key', the character length must be smaller than or equal to 192."
|
136
|
+
end
|
137
|
+
|
138
|
+
if idempotency_key.to_s.length < 1
|
139
|
+
fail ArgumentError, "invalid value for 'idempotency_key', the character length must be great than or equal to 1."
|
140
|
+
end
|
141
|
+
|
142
|
+
@idempotency_key = idempotency_key
|
143
|
+
end
|
144
|
+
|
145
|
+
# Custom attribute writer method with validation
|
146
|
+
# @param [Object] tender_id Value to be assigned
|
147
|
+
def tender_id=(tender_id)
|
148
|
+
if tender_id.nil?
|
149
|
+
fail ArgumentError, "tender_id cannot be nil"
|
150
|
+
end
|
151
|
+
|
152
|
+
if tender_id.to_s.length > 192
|
153
|
+
fail ArgumentError, "invalid value for 'tender_id', the character length must be smaller than or equal to 192."
|
154
|
+
end
|
155
|
+
|
156
|
+
if tender_id.to_s.length < 1
|
157
|
+
fail ArgumentError, "invalid value for 'tender_id', the character length must be great than or equal to 1."
|
158
|
+
end
|
159
|
+
|
160
|
+
@tender_id = tender_id
|
161
|
+
end
|
162
|
+
|
163
|
+
# Custom attribute writer method with validation
|
164
|
+
# @param [Object] reason Value to be assigned
|
165
|
+
def reason=(reason)
|
166
|
+
|
167
|
+
if !reason.nil? && reason.to_s.length > 192
|
168
|
+
fail ArgumentError, "invalid value for 'reason', the character length must be smaller than or equal to 192."
|
169
|
+
end
|
170
|
+
|
171
|
+
@reason = reason
|
172
|
+
end
|
173
|
+
|
102
174
|
# Checks equality by comparing each attribute.
|
103
175
|
# @param [Object] Object to be compared
|
104
176
|
def ==(o)
|
@@ -114,7 +114,7 @@ module SquareConnect
|
|
114
114
|
category_validator = EnumAttributeValidator.new('String', ["API_ERROR", "AUTHENTICATION_ERROR", "INVALID_REQUEST_ERROR", "RATE_LIMIT_ERROR", "PAYMENT_METHOD_ERROR", "REFUND_ERROR"])
|
115
115
|
return false unless category_validator.valid?(@category)
|
116
116
|
return false if @code.nil?
|
117
|
-
code_validator = EnumAttributeValidator.new('String', ["INTERNAL_SERVER_ERROR", "UNAUTHORIZED", "ACCESS_TOKEN_EXPIRED", "ACCESS_TOKEN_REVOKED", "FORBIDDEN", "INSUFFICIENT_SCOPES", "APPLICATION_DISABLED", "V1_APPLICATION", "V1_ACCESS_TOKEN", "CARD_PROCESSING_NOT_ENABLED", "BAD_REQUEST", "MISSING_REQUIRED_PARAMETER", "INCORRECT_TYPE", "INVALID_TIME", "INVALID_TIME_RANGE", "INVALID_VALUE", "INVALID_CURSOR", "UNKNOWN_QUERY_PARAMETER", "CONFLICTING_PARAMETERS", "EXPECTED_JSON_BODY", "INVALID_SORT_ORDER", "VALUE_REGEX_MISMATCH", "VALUE_TOO_SHORT", "VALUE_TOO_LONG", "VALUE_TOO_LOW", "VALUE_TOO_HIGH", "VALUE_EMPTY", "ARRAY_EMPTY", "EXPECTED_BOOLEAN", "EXPECTED_INTEGER", "EXPECTED_FLOAT", "EXPECTED_STRING", "EXPECTED_OBJECT", "EXPECTED_ARRAY", "EXPECTED_BASE64_ENCODED_BYTE_ARRAY", "INVALID_ARRAY_VALUE", "INVALID_ENUM_VALUE", "INVALID_CONTENT_TYPE", "INVALID_FORM_VALUE", "ONE_INSTRUMENT_EXPECTED", "NO_FIELDS_SET", "CARD_EXPIRED", "INVALID_EXPIRATION", "INVALID_EXPIRATION_YEAR", "INVALID_EXPIRATION_DATE", "UNSUPPORTED_CARD_BRAND", "INVALID_CARD", "DELAYED_TRANSACTION_EXPIRED", "DELAYED_TRANSACTION_CANCELED", "DELAYED_TRANSACTION_CAPTURED", "DELAYED_TRANSACTION_FAILED", "CARD_TOKEN_EXPIRED", "CARD_TOKEN_USED", "AMOUNT_TOO_HIGH", "UNSUPPORTED_INSTRUMENT_TYPE", "REFUND_AMOUNT_INVALID", "REFUND_ALREADY_PENDING", "PAYMENT_NOT_REFUNDABLE", "INVALID_CARD_DATA", "IDEMPOTENCY_KEY_REUSED", "UNEXPECTED_VALUE", "SANDBOX_NOT_SUPPORTED", "INVALID_EMAIL_ADDRESS", "CHECKOUT_EXPIRED", "CARD_DECLINED", "VERIFY_CVV_FAILURE", "VERIFY_AVS_FAILURE", "CARD_DECLINED_CALL_ISSUER", "NOT_FOUND", "REQUEST_TIMEOUT", "CONFLICT", "REQUEST_ENTITY_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "RATE_LIMITED", "NOT_IMPLEMENTED", "SERVICE_UNAVAILABLE"])
|
117
|
+
code_validator = EnumAttributeValidator.new('String', ["INTERNAL_SERVER_ERROR", "UNAUTHORIZED", "ACCESS_TOKEN_EXPIRED", "ACCESS_TOKEN_REVOKED", "FORBIDDEN", "INSUFFICIENT_SCOPES", "APPLICATION_DISABLED", "V1_APPLICATION", "V1_ACCESS_TOKEN", "CARD_PROCESSING_NOT_ENABLED", "BAD_REQUEST", "MISSING_REQUIRED_PARAMETER", "INCORRECT_TYPE", "INVALID_TIME", "INVALID_TIME_RANGE", "INVALID_VALUE", "INVALID_CURSOR", "UNKNOWN_QUERY_PARAMETER", "CONFLICTING_PARAMETERS", "EXPECTED_JSON_BODY", "INVALID_SORT_ORDER", "VALUE_REGEX_MISMATCH", "VALUE_TOO_SHORT", "VALUE_TOO_LONG", "VALUE_TOO_LOW", "VALUE_TOO_HIGH", "VALUE_EMPTY", "ARRAY_LENGTH_TOO_LONG", "ARRAY_LENGTH_TOO_SHORT", "ARRAY_EMPTY", "EXPECTED_BOOLEAN", "EXPECTED_INTEGER", "EXPECTED_FLOAT", "EXPECTED_STRING", "EXPECTED_OBJECT", "EXPECTED_ARRAY", "EXPECTED_BASE64_ENCODED_BYTE_ARRAY", "INVALID_ARRAY_VALUE", "INVALID_ENUM_VALUE", "INVALID_CONTENT_TYPE", "INVALID_FORM_VALUE", "ONE_INSTRUMENT_EXPECTED", "NO_FIELDS_SET", "CARD_EXPIRED", "INVALID_EXPIRATION", "INVALID_EXPIRATION_YEAR", "INVALID_EXPIRATION_DATE", "UNSUPPORTED_CARD_BRAND", "INVALID_CARD", "DELAYED_TRANSACTION_EXPIRED", "DELAYED_TRANSACTION_CANCELED", "DELAYED_TRANSACTION_CAPTURED", "DELAYED_TRANSACTION_FAILED", "CARD_TOKEN_EXPIRED", "CARD_TOKEN_USED", "AMOUNT_TOO_HIGH", "UNSUPPORTED_INSTRUMENT_TYPE", "REFUND_AMOUNT_INVALID", "REFUND_ALREADY_PENDING", "PAYMENT_NOT_REFUNDABLE", "INVALID_CARD_DATA", "IDEMPOTENCY_KEY_REUSED", "UNEXPECTED_VALUE", "SANDBOX_NOT_SUPPORTED", "INVALID_EMAIL_ADDRESS", "CHECKOUT_EXPIRED", "CARD_DECLINED", "VERIFY_CVV_FAILURE", "VERIFY_AVS_FAILURE", "CARD_DECLINED_CALL_ISSUER", "NOT_FOUND", "REQUEST_TIMEOUT", "CONFLICT", "REQUEST_ENTITY_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "RATE_LIMITED", "NOT_IMPLEMENTED", "SERVICE_UNAVAILABLE"])
|
118
118
|
return false unless code_validator.valid?(@code)
|
119
119
|
return true
|
120
120
|
end
|
@@ -132,7 +132,7 @@ module SquareConnect
|
|
132
132
|
# Custom attribute writer method checking allowed values (enum).
|
133
133
|
# @param [Object] code Object to be assigned
|
134
134
|
def code=(code)
|
135
|
-
validator = EnumAttributeValidator.new('String', ["INTERNAL_SERVER_ERROR", "UNAUTHORIZED", "ACCESS_TOKEN_EXPIRED", "ACCESS_TOKEN_REVOKED", "FORBIDDEN", "INSUFFICIENT_SCOPES", "APPLICATION_DISABLED", "V1_APPLICATION", "V1_ACCESS_TOKEN", "CARD_PROCESSING_NOT_ENABLED", "BAD_REQUEST", "MISSING_REQUIRED_PARAMETER", "INCORRECT_TYPE", "INVALID_TIME", "INVALID_TIME_RANGE", "INVALID_VALUE", "INVALID_CURSOR", "UNKNOWN_QUERY_PARAMETER", "CONFLICTING_PARAMETERS", "EXPECTED_JSON_BODY", "INVALID_SORT_ORDER", "VALUE_REGEX_MISMATCH", "VALUE_TOO_SHORT", "VALUE_TOO_LONG", "VALUE_TOO_LOW", "VALUE_TOO_HIGH", "VALUE_EMPTY", "ARRAY_EMPTY", "EXPECTED_BOOLEAN", "EXPECTED_INTEGER", "EXPECTED_FLOAT", "EXPECTED_STRING", "EXPECTED_OBJECT", "EXPECTED_ARRAY", "EXPECTED_BASE64_ENCODED_BYTE_ARRAY", "INVALID_ARRAY_VALUE", "INVALID_ENUM_VALUE", "INVALID_CONTENT_TYPE", "INVALID_FORM_VALUE", "ONE_INSTRUMENT_EXPECTED", "NO_FIELDS_SET", "CARD_EXPIRED", "INVALID_EXPIRATION", "INVALID_EXPIRATION_YEAR", "INVALID_EXPIRATION_DATE", "UNSUPPORTED_CARD_BRAND", "INVALID_CARD", "DELAYED_TRANSACTION_EXPIRED", "DELAYED_TRANSACTION_CANCELED", "DELAYED_TRANSACTION_CAPTURED", "DELAYED_TRANSACTION_FAILED", "CARD_TOKEN_EXPIRED", "CARD_TOKEN_USED", "AMOUNT_TOO_HIGH", "UNSUPPORTED_INSTRUMENT_TYPE", "REFUND_AMOUNT_INVALID", "REFUND_ALREADY_PENDING", "PAYMENT_NOT_REFUNDABLE", "INVALID_CARD_DATA", "IDEMPOTENCY_KEY_REUSED", "UNEXPECTED_VALUE", "SANDBOX_NOT_SUPPORTED", "INVALID_EMAIL_ADDRESS", "CHECKOUT_EXPIRED", "CARD_DECLINED", "VERIFY_CVV_FAILURE", "VERIFY_AVS_FAILURE", "CARD_DECLINED_CALL_ISSUER", "NOT_FOUND", "REQUEST_TIMEOUT", "CONFLICT", "REQUEST_ENTITY_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "RATE_LIMITED", "NOT_IMPLEMENTED", "SERVICE_UNAVAILABLE"])
|
135
|
+
validator = EnumAttributeValidator.new('String', ["INTERNAL_SERVER_ERROR", "UNAUTHORIZED", "ACCESS_TOKEN_EXPIRED", "ACCESS_TOKEN_REVOKED", "FORBIDDEN", "INSUFFICIENT_SCOPES", "APPLICATION_DISABLED", "V1_APPLICATION", "V1_ACCESS_TOKEN", "CARD_PROCESSING_NOT_ENABLED", "BAD_REQUEST", "MISSING_REQUIRED_PARAMETER", "INCORRECT_TYPE", "INVALID_TIME", "INVALID_TIME_RANGE", "INVALID_VALUE", "INVALID_CURSOR", "UNKNOWN_QUERY_PARAMETER", "CONFLICTING_PARAMETERS", "EXPECTED_JSON_BODY", "INVALID_SORT_ORDER", "VALUE_REGEX_MISMATCH", "VALUE_TOO_SHORT", "VALUE_TOO_LONG", "VALUE_TOO_LOW", "VALUE_TOO_HIGH", "VALUE_EMPTY", "ARRAY_LENGTH_TOO_LONG", "ARRAY_LENGTH_TOO_SHORT", "ARRAY_EMPTY", "EXPECTED_BOOLEAN", "EXPECTED_INTEGER", "EXPECTED_FLOAT", "EXPECTED_STRING", "EXPECTED_OBJECT", "EXPECTED_ARRAY", "EXPECTED_BASE64_ENCODED_BYTE_ARRAY", "INVALID_ARRAY_VALUE", "INVALID_ENUM_VALUE", "INVALID_CONTENT_TYPE", "INVALID_FORM_VALUE", "ONE_INSTRUMENT_EXPECTED", "NO_FIELDS_SET", "CARD_EXPIRED", "INVALID_EXPIRATION", "INVALID_EXPIRATION_YEAR", "INVALID_EXPIRATION_DATE", "UNSUPPORTED_CARD_BRAND", "INVALID_CARD", "DELAYED_TRANSACTION_EXPIRED", "DELAYED_TRANSACTION_CANCELED", "DELAYED_TRANSACTION_CAPTURED", "DELAYED_TRANSACTION_FAILED", "CARD_TOKEN_EXPIRED", "CARD_TOKEN_USED", "AMOUNT_TOO_HIGH", "UNSUPPORTED_INSTRUMENT_TYPE", "REFUND_AMOUNT_INVALID", "REFUND_ALREADY_PENDING", "PAYMENT_NOT_REFUNDABLE", "INVALID_CARD_DATA", "IDEMPOTENCY_KEY_REUSED", "UNEXPECTED_VALUE", "SANDBOX_NOT_SUPPORTED", "INVALID_EMAIL_ADDRESS", "CHECKOUT_EXPIRED", "CARD_DECLINED", "VERIFY_CVV_FAILURE", "VERIFY_AVS_FAILURE", "CARD_DECLINED_CALL_ISSUER", "NOT_FOUND", "REQUEST_TIMEOUT", "CONFLICT", "REQUEST_ENTITY_TOO_LARGE", "UNSUPPORTED_MEDIA_TYPE", "RATE_LIMITED", "NOT_IMPLEMENTED", "SERVICE_UNAVAILABLE"])
|
136
136
|
unless validator.valid?(code)
|
137
137
|
fail ArgumentError, "invalid value for 'code', must be one of #{validator.allowable_values}."
|
138
138
|
end
|