square_connect 2.1.0.beta → 2.1.0.78
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +71 -8
- data/docs/BatchDeleteCatalogObjectsRequest.md +12 -0
- data/docs/BatchDeleteCatalogObjectsResponse.md +14 -0
- data/docs/BatchRetrieveCatalogObjectsRequest.md +13 -0
- data/docs/BatchRetrieveCatalogObjectsResponse.md +14 -0
- data/docs/BatchUpsertCatalogObjectsRequest.md +13 -0
- data/docs/BatchUpsertCatalogObjectsResponse.md +15 -0
- data/docs/CatalogApi.md +592 -0
- data/docs/CatalogCategory.md +12 -0
- data/docs/CatalogDiscount.md +17 -0
- data/docs/CatalogDiscountType.md +15 -0
- data/docs/CatalogIdMapping.md +13 -0
- data/docs/CatalogInfoRequest.md +11 -0
- data/docs/CatalogInfoResponse.md +13 -0
- data/docs/CatalogInfoResponseLimits.md +22 -0
- data/docs/CatalogItem.md +25 -0
- data/docs/CatalogItemModifierListInfo.md +16 -0
- data/docs/CatalogItemProductType.md +16 -0
- data/docs/CatalogItemVariation.md +23 -0
- data/docs/CatalogModifier.md +13 -0
- data/docs/CatalogModifierList.md +14 -0
- data/docs/CatalogModifierListSelectionType.md +13 -0
- data/docs/CatalogModifierOverride.md +13 -0
- data/docs/CatalogObject.md +27 -0
- data/docs/CatalogObjectBatch.md +12 -0
- data/docs/CatalogObjectType.md +18 -0
- data/docs/CatalogPricingType.md +13 -0
- data/docs/CatalogQuery.md +18 -0
- data/docs/CatalogQueryExact.md +13 -0
- data/docs/CatalogQueryItemsForModifierList.md +12 -0
- data/docs/CatalogQueryItemsForTax.md +12 -0
- data/docs/CatalogQueryPrefix.md +13 -0
- data/docs/CatalogQueryRange.md +14 -0
- data/docs/CatalogQuerySortedAttribute.md +14 -0
- data/docs/CatalogQueryText.md +12 -0
- data/docs/CatalogTax.md +17 -0
- data/docs/CatalogV1Id.md +13 -0
- data/docs/Checkout.md +4 -4
- data/docs/CreateCheckoutRequest.md +5 -5
- data/docs/DeleteCatalogObjectRequest.md +11 -0
- data/docs/DeleteCatalogObjectResponse.md +14 -0
- data/docs/ErrorCode.md +2 -0
- data/docs/InventoryAlertType.md +13 -0
- data/docs/ItemVariationLocationOverrides.md +17 -0
- data/docs/ListCatalogRequest.md +13 -0
- data/docs/ListCatalogResponse.md +14 -0
- data/docs/RetrieveCatalogObjectRequest.md +12 -0
- data/docs/RetrieveCatalogObjectResponse.md +14 -0
- data/docs/SearchCatalogObjectsRequest.md +18 -0
- data/docs/SearchCatalogObjectsResponse.md +15 -0
- data/docs/TaxCalculationPhase.md +13 -0
- data/docs/TaxInclusionType.md +13 -0
- data/docs/UpdateItemModifierListsRequest.md +14 -0
- data/docs/UpdateItemModifierListsResponse.md +13 -0
- data/docs/UpdateItemTaxesRequest.md +14 -0
- data/docs/UpdateItemTaxesResponse.md +13 -0
- data/docs/UpsertCatalogObjectRequest.md +13 -0
- data/docs/UpsertCatalogObjectResponse.md +14 -0
- data/docs/V1Item.md +1 -1
- data/docs/V1Variation.md +0 -1
- data/lib/square_connect.rb +54 -1
- data/lib/square_connect/api/catalog_api.rb +604 -0
- data/lib/square_connect/models/batch_delete_catalog_objects_request.rb +188 -0
- data/lib/square_connect/models/batch_delete_catalog_objects_response.rb +210 -0
- data/lib/square_connect/models/batch_retrieve_catalog_objects_request.rb +203 -0
- data/lib/square_connect/models/batch_retrieve_catalog_objects_response.rb +212 -0
- data/lib/square_connect/models/batch_upsert_catalog_objects_request.rb +222 -0
- data/lib/square_connect/models/batch_upsert_catalog_objects_response.rb +222 -0
- data/lib/square_connect/models/catalog_category.rb +210 -0
- data/lib/square_connect/models/catalog_discount.rb +293 -0
- data/lib/square_connect/models/catalog_discount_type.rb +21 -0
- data/lib/square_connect/models/catalog_id_mapping.rb +196 -0
- data/lib/square_connect/models/catalog_info_request.rb +176 -0
- data/lib/square_connect/models/catalog_info_response.rb +198 -0
- data/lib/square_connect/models/catalog_info_response_limits.rb +286 -0
- data/lib/square_connect/models/catalog_item.rb +379 -0
- data/lib/square_connect/models/catalog_item_modifier_list_info.rb +252 -0
- data/lib/square_connect/models/catalog_item_product_type.rb +22 -0
- data/lib/square_connect/models/catalog_item_variation.rb +343 -0
- data/lib/square_connect/models/catalog_modifier.rb +220 -0
- data/lib/square_connect/models/catalog_modifier_list.rb +265 -0
- data/lib/square_connect/models/catalog_modifier_list_selection_type.rb +19 -0
- data/lib/square_connect/models/catalog_modifier_override.rb +220 -0
- data/lib/square_connect/models/catalog_object.rb +404 -0
- data/lib/square_connect/models/catalog_object_batch.rb +188 -0
- data/lib/square_connect/models/catalog_object_type.rb +24 -0
- data/lib/square_connect/models/catalog_pricing_type.rb +19 -0
- data/lib/square_connect/models/catalog_query.rb +246 -0
- data/lib/square_connect/models/catalog_query_exact.rb +225 -0
- data/lib/square_connect/models/catalog_query_items_for_modifier_list.rb +193 -0
- data/lib/square_connect/models/catalog_query_items_for_tax.rb +193 -0
- data/lib/square_connect/models/catalog_query_prefix.rb +244 -0
- data/lib/square_connect/models/catalog_query_range.rb +230 -0
- data/lib/square_connect/models/catalog_query_sorted_attribute.rb +263 -0
- data/lib/square_connect/models/catalog_query_text.rb +193 -0
- data/lib/square_connect/models/catalog_tax.rb +305 -0
- data/lib/square_connect/models/catalog_v1_id.rb +196 -0
- data/lib/square_connect/models/checkout.rb +4 -4
- data/lib/square_connect/models/create_checkout_request.rb +5 -5
- data/lib/square_connect/models/delete_catalog_object_request.rb +176 -0
- data/lib/square_connect/models/delete_catalog_object_response.rb +210 -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/inventory_alert_type.rb +19 -0
- data/lib/square_connect/models/item_variation_location_overrides.rb +281 -0
- data/lib/square_connect/models/list_catalog_request.rb +196 -0
- data/lib/square_connect/models/list_catalog_response.rb +210 -0
- data/lib/square_connect/models/retrieve_catalog_object_request.rb +186 -0
- data/lib/square_connect/models/retrieve_catalog_object_response.rb +210 -0
- data/lib/square_connect/models/search_catalog_objects_request.rb +269 -0
- data/lib/square_connect/models/search_catalog_objects_response.rb +222 -0
- data/lib/square_connect/models/tax_calculation_phase.rb +19 -0
- data/lib/square_connect/models/tax_inclusion_type.rb +19 -0
- data/lib/square_connect/models/update_item_modifier_lists_request.rb +217 -0
- data/lib/square_connect/models/update_item_modifier_lists_response.rb +198 -0
- data/lib/square_connect/models/update_item_taxes_request.rb +217 -0
- data/lib/square_connect/models/update_item_taxes_response.rb +198 -0
- data/lib/square_connect/models/{create_order_request.rb → upsert_catalog_object_request.rb} +14 -23
- data/lib/square_connect/models/upsert_catalog_object_response.rb +210 -0
- data/lib/square_connect/models/v1_item.rb +1 -1
- data/lib/square_connect/models/v1_variation.rb +1 -11
- data/lib/square_connect/version.rb +1 -1
- data/spec/api/catalog_api_spec.rb +611 -0
- data/spec/models/batch_delete_catalog_objects_request_spec.rb +39 -0
- data/spec/models/batch_delete_catalog_objects_response_spec.rb +51 -0
- data/spec/models/batch_retrieve_catalog_objects_request_spec.rb +45 -0
- data/spec/models/batch_retrieve_catalog_objects_response_spec.rb +51 -0
- data/spec/models/batch_upsert_catalog_objects_request_spec.rb +45 -0
- data/spec/models/batch_upsert_catalog_objects_response_spec.rb +57 -0
- data/spec/models/catalog_category_spec.rb +39 -0
- data/spec/models/catalog_discount_spec.rb +73 -0
- data/spec/models/catalog_discount_type_spec.rb +33 -0
- data/spec/models/catalog_id_mapping_spec.rb +45 -0
- data/spec/models/catalog_info_request_spec.rb +33 -0
- data/spec/models/catalog_info_response_limits_spec.rb +99 -0
- data/spec/models/catalog_info_response_spec.rb +45 -0
- data/spec/models/catalog_item_modifier_list_info_spec.rb +63 -0
- data/spec/models/catalog_item_product_type_spec.rb +33 -0
- data/spec/models/catalog_item_spec.rb +121 -0
- data/spec/models/catalog_item_variation_spec.rb +113 -0
- data/spec/models/catalog_modifier_list_selection_type_spec.rb +33 -0
- data/spec/models/catalog_modifier_list_spec.rb +55 -0
- data/spec/models/catalog_modifier_override_spec.rb +45 -0
- data/spec/models/catalog_modifier_spec.rb +45 -0
- data/spec/models/catalog_object_batch_spec.rb +39 -0
- data/spec/models/catalog_object_spec.rb +133 -0
- data/spec/models/catalog_object_type_spec.rb +33 -0
- data/spec/models/catalog_pricing_type_spec.rb +33 -0
- data/spec/models/catalog_query_exact_spec.rb +45 -0
- data/spec/models/catalog_query_items_for_modifier_list_spec.rb +39 -0
- data/spec/models/catalog_query_items_for_tax_spec.rb +39 -0
- data/spec/models/catalog_query_prefix_spec.rb +45 -0
- data/spec/models/catalog_query_range_spec.rb +51 -0
- data/spec/models/catalog_query_sorted_attribute_spec.rb +55 -0
- data/spec/models/catalog_query_spec.rb +75 -0
- data/spec/models/catalog_query_text_spec.rb +39 -0
- data/spec/models/catalog_tax_spec.rb +77 -0
- data/spec/models/catalog_v1_id_spec.rb +45 -0
- data/spec/models/delete_catalog_object_request_spec.rb +39 -0
- data/spec/models/delete_catalog_object_response_spec.rb +51 -0
- data/spec/models/inventory_alert_type_spec.rb +33 -0
- data/spec/models/item_variation_location_overrides_spec.rb +77 -0
- data/spec/models/list_catalog_request_spec.rb +45 -0
- data/spec/models/list_catalog_response_spec.rb +51 -0
- data/spec/models/retrieve_catalog_object_request_spec.rb +45 -0
- data/spec/models/retrieve_catalog_object_response_spec.rb +51 -0
- data/spec/models/search_catalog_objects_request_spec.rb +79 -0
- data/spec/models/search_catalog_objects_response_spec.rb +57 -0
- data/spec/models/tax_calculation_phase_spec.rb +33 -0
- data/spec/models/tax_inclusion_type_spec.rb +33 -0
- data/spec/models/update_item_modifier_lists_request_spec.rb +51 -0
- data/spec/models/update_item_modifier_lists_response_spec.rb +45 -0
- data/spec/models/update_item_taxes_request_spec.rb +51 -0
- data/spec/models/update_item_taxes_response_spec.rb +45 -0
- data/spec/models/{create_order_request_spec.rb → upsert_catalog_object_request_spec.rb} +7 -7
- data/spec/models/upsert_catalog_object_response_spec.rb +51 -0
- data/square_connect.gemspec +1 -1
- data/travis-ci/accounts.enc +0 -0
- metadata +222 -17
- data/docs/CreateOrderRequest.md +0 -13
- data/docs/V1LocationApi.md +0 -102
- data/lib/.DS_Store +0 -0
- data/lib/square_connect/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
- data/square_connect-2.0.2.gem +0 -0
- data/square_connect-2.1.0.gem +0 -0
- data/square_connect-2.1.0beta.gem +0 -0
@@ -0,0 +1,244 @@
|
|
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 CatalogQueryPrefix
|
15
|
+
# The name of the attribute to be searched.
|
16
|
+
attr_accessor :attribute_name
|
17
|
+
|
18
|
+
# The desired prefix of the search attribute value.
|
19
|
+
attr_accessor :attribute_prefix
|
20
|
+
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'attribute_name' => :'attribute_name',
|
26
|
+
:'attribute_prefix' => :'attribute_prefix'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.swagger_types
|
32
|
+
{
|
33
|
+
:'attribute_name' => :'String',
|
34
|
+
:'attribute_prefix' => :'String'
|
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?(:'attribute_name')
|
47
|
+
self.attribute_name = attributes[:'attribute_name']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes.has_key?(:'attribute_prefix')
|
51
|
+
self.attribute_prefix = attributes[:'attribute_prefix']
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
57
|
+
# @return Array for valid properies with the reasons
|
58
|
+
def list_invalid_properties
|
59
|
+
invalid_properties = Array.new
|
60
|
+
if @attribute_name.nil?
|
61
|
+
invalid_properties.push("invalid value for 'attribute_name', attribute_name cannot be nil.")
|
62
|
+
end
|
63
|
+
|
64
|
+
if @attribute_name.to_s.length < 1
|
65
|
+
invalid_properties.push("invalid value for 'attribute_name', the character length must be great than or equal to 1.")
|
66
|
+
end
|
67
|
+
|
68
|
+
if @attribute_prefix.nil?
|
69
|
+
invalid_properties.push("invalid value for 'attribute_prefix', attribute_prefix cannot be nil.")
|
70
|
+
end
|
71
|
+
|
72
|
+
if @attribute_prefix.to_s.length < 1
|
73
|
+
invalid_properties.push("invalid value for 'attribute_prefix', the character length must be great than or equal to 1.")
|
74
|
+
end
|
75
|
+
|
76
|
+
return invalid_properties
|
77
|
+
end
|
78
|
+
|
79
|
+
# Check to see if the all the properties in the model are valid
|
80
|
+
# @return true if the model is valid
|
81
|
+
def valid?
|
82
|
+
return false if @attribute_name.nil?
|
83
|
+
return false if @attribute_name.to_s.length < 1
|
84
|
+
return false if @attribute_prefix.nil?
|
85
|
+
return false if @attribute_prefix.to_s.length < 1
|
86
|
+
return true
|
87
|
+
end
|
88
|
+
|
89
|
+
# Custom attribute writer method with validation
|
90
|
+
# @param [Object] attribute_name Value to be assigned
|
91
|
+
def attribute_name=(attribute_name)
|
92
|
+
if attribute_name.nil?
|
93
|
+
fail ArgumentError, "attribute_name cannot be nil"
|
94
|
+
end
|
95
|
+
|
96
|
+
if attribute_name.to_s.length < 1
|
97
|
+
fail ArgumentError, "invalid value for 'attribute_name', the character length must be great than or equal to 1."
|
98
|
+
end
|
99
|
+
|
100
|
+
@attribute_name = attribute_name
|
101
|
+
end
|
102
|
+
|
103
|
+
# Custom attribute writer method with validation
|
104
|
+
# @param [Object] attribute_prefix Value to be assigned
|
105
|
+
def attribute_prefix=(attribute_prefix)
|
106
|
+
if attribute_prefix.nil?
|
107
|
+
fail ArgumentError, "attribute_prefix cannot be nil"
|
108
|
+
end
|
109
|
+
|
110
|
+
if attribute_prefix.to_s.length < 1
|
111
|
+
fail ArgumentError, "invalid value for 'attribute_prefix', the character length must be great than or equal to 1."
|
112
|
+
end
|
113
|
+
|
114
|
+
@attribute_prefix = attribute_prefix
|
115
|
+
end
|
116
|
+
|
117
|
+
# Checks equality by comparing each attribute.
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def ==(o)
|
120
|
+
return true if self.equal?(o)
|
121
|
+
self.class == o.class &&
|
122
|
+
attribute_name == o.attribute_name &&
|
123
|
+
attribute_prefix == o.attribute_prefix
|
124
|
+
end
|
125
|
+
|
126
|
+
# @see the `==` method
|
127
|
+
# @param [Object] Object to be compared
|
128
|
+
def eql?(o)
|
129
|
+
self == o
|
130
|
+
end
|
131
|
+
|
132
|
+
# Calculates hash code according to all attributes.
|
133
|
+
# @return [Fixnum] Hash code
|
134
|
+
def hash
|
135
|
+
[attribute_name, attribute_prefix].hash
|
136
|
+
end
|
137
|
+
|
138
|
+
# Builds the object from hash
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
140
|
+
# @return [Object] Returns the model itself
|
141
|
+
def build_from_hash(attributes)
|
142
|
+
return nil unless attributes.is_a?(Hash)
|
143
|
+
self.class.swagger_types.each_pair do |key, type|
|
144
|
+
if type =~ /\AArray<(.*)>/i
|
145
|
+
# check to ensure the input is an array given that the the attribute
|
146
|
+
# is documented as an array but the input is not
|
147
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
148
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
149
|
+
end
|
150
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
151
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
152
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
153
|
+
end
|
154
|
+
|
155
|
+
self
|
156
|
+
end
|
157
|
+
|
158
|
+
# Deserializes the data based on type
|
159
|
+
# @param string type Data type
|
160
|
+
# @param string value Value to be deserialized
|
161
|
+
# @return [Object] Deserialized data
|
162
|
+
def _deserialize(type, value)
|
163
|
+
case type.to_sym
|
164
|
+
when :DateTime
|
165
|
+
DateTime.parse(value)
|
166
|
+
when :Date
|
167
|
+
Date.parse(value)
|
168
|
+
when :String
|
169
|
+
value.to_s
|
170
|
+
when :Integer
|
171
|
+
value.to_i
|
172
|
+
when :Float
|
173
|
+
value.to_f
|
174
|
+
when :BOOLEAN
|
175
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
176
|
+
true
|
177
|
+
else
|
178
|
+
false
|
179
|
+
end
|
180
|
+
when :Object
|
181
|
+
# generic object (usually a Hash), return directly
|
182
|
+
value
|
183
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
184
|
+
inner_type = Regexp.last_match[:inner_type]
|
185
|
+
value.map { |v| _deserialize(inner_type, v) }
|
186
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
187
|
+
k_type = Regexp.last_match[:k_type]
|
188
|
+
v_type = Regexp.last_match[:v_type]
|
189
|
+
{}.tap do |hash|
|
190
|
+
value.each do |k, v|
|
191
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
else # model
|
195
|
+
temp_model = SquareConnect.const_get(type).new
|
196
|
+
temp_model.build_from_hash(value)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns the string representation of the object
|
201
|
+
# @return [String] String presentation of the object
|
202
|
+
def to_s
|
203
|
+
to_hash.to_s
|
204
|
+
end
|
205
|
+
|
206
|
+
# to_body is an alias to to_hash (backward compatibility)
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_body
|
209
|
+
to_hash
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the object in the form of hash
|
213
|
+
# @return [Hash] Returns the object in the form of hash
|
214
|
+
def to_hash
|
215
|
+
hash = {}
|
216
|
+
self.class.attribute_map.each_pair do |attr, param|
|
217
|
+
value = self.send(attr)
|
218
|
+
next if value.nil?
|
219
|
+
hash[param] = _to_hash(value)
|
220
|
+
end
|
221
|
+
hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Outputs non-array value in the form of hash
|
225
|
+
# For object, use to_hash. Otherwise, just return the value
|
226
|
+
# @param [Object] value Any valid value
|
227
|
+
# @return [Hash] Returns the value in the form of hash
|
228
|
+
def _to_hash(value)
|
229
|
+
if value.is_a?(Array)
|
230
|
+
value.compact.map{ |v| _to_hash(v) }
|
231
|
+
elsif value.is_a?(Hash)
|
232
|
+
{}.tap do |hash|
|
233
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
234
|
+
end
|
235
|
+
elsif value.respond_to? :to_hash
|
236
|
+
value.to_hash
|
237
|
+
else
|
238
|
+
value
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
244
|
+
end
|
@@ -0,0 +1,230 @@
|
|
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 CatalogQueryRange
|
15
|
+
# The name of the attribute to be searched.
|
16
|
+
attr_accessor :attribute_name
|
17
|
+
|
18
|
+
# The desired minimum value for the search attribute (inclusive).
|
19
|
+
attr_accessor :attribute_min_value
|
20
|
+
|
21
|
+
# The desired maximum value for the search attribute (inclusive).
|
22
|
+
attr_accessor :attribute_max_value
|
23
|
+
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'attribute_name' => :'attribute_name',
|
29
|
+
:'attribute_min_value' => :'attribute_min_value',
|
30
|
+
:'attribute_max_value' => :'attribute_max_value'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Attribute type mapping.
|
35
|
+
def self.swagger_types
|
36
|
+
{
|
37
|
+
:'attribute_name' => :'String',
|
38
|
+
:'attribute_min_value' => :'Integer',
|
39
|
+
:'attribute_max_value' => :'Integer'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Initializes the object
|
44
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
45
|
+
def initialize(attributes = {})
|
46
|
+
return unless attributes.is_a?(Hash)
|
47
|
+
|
48
|
+
# convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
50
|
+
|
51
|
+
if attributes.has_key?(:'attribute_name')
|
52
|
+
self.attribute_name = attributes[:'attribute_name']
|
53
|
+
end
|
54
|
+
|
55
|
+
if attributes.has_key?(:'attribute_min_value')
|
56
|
+
self.attribute_min_value = attributes[:'attribute_min_value']
|
57
|
+
end
|
58
|
+
|
59
|
+
if attributes.has_key?(:'attribute_max_value')
|
60
|
+
self.attribute_max_value = attributes[:'attribute_max_value']
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
66
|
+
# @return Array for valid properies with the reasons
|
67
|
+
def list_invalid_properties
|
68
|
+
invalid_properties = Array.new
|
69
|
+
if @attribute_name.nil?
|
70
|
+
invalid_properties.push("invalid value for 'attribute_name', attribute_name cannot be nil.")
|
71
|
+
end
|
72
|
+
|
73
|
+
if @attribute_name.to_s.length < 1
|
74
|
+
invalid_properties.push("invalid value for 'attribute_name', the character length must be great than or equal to 1.")
|
75
|
+
end
|
76
|
+
|
77
|
+
return invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
return false if @attribute_name.nil?
|
84
|
+
return false if @attribute_name.to_s.length < 1
|
85
|
+
return true
|
86
|
+
end
|
87
|
+
|
88
|
+
# Custom attribute writer method with validation
|
89
|
+
# @param [Object] attribute_name Value to be assigned
|
90
|
+
def attribute_name=(attribute_name)
|
91
|
+
if attribute_name.nil?
|
92
|
+
fail ArgumentError, "attribute_name cannot be nil"
|
93
|
+
end
|
94
|
+
|
95
|
+
if attribute_name.to_s.length < 1
|
96
|
+
fail ArgumentError, "invalid value for 'attribute_name', the character length must be great than or equal to 1."
|
97
|
+
end
|
98
|
+
|
99
|
+
@attribute_name = attribute_name
|
100
|
+
end
|
101
|
+
|
102
|
+
# Checks equality by comparing each attribute.
|
103
|
+
# @param [Object] Object to be compared
|
104
|
+
def ==(o)
|
105
|
+
return true if self.equal?(o)
|
106
|
+
self.class == o.class &&
|
107
|
+
attribute_name == o.attribute_name &&
|
108
|
+
attribute_min_value == o.attribute_min_value &&
|
109
|
+
attribute_max_value == o.attribute_max_value
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see the `==` method
|
113
|
+
# @param [Object] Object to be compared
|
114
|
+
def eql?(o)
|
115
|
+
self == o
|
116
|
+
end
|
117
|
+
|
118
|
+
# Calculates hash code according to all attributes.
|
119
|
+
# @return [Fixnum] Hash code
|
120
|
+
def hash
|
121
|
+
[attribute_name, attribute_min_value, attribute_max_value].hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def build_from_hash(attributes)
|
128
|
+
return nil unless attributes.is_a?(Hash)
|
129
|
+
self.class.swagger_types.each_pair do |key, type|
|
130
|
+
if type =~ /\AArray<(.*)>/i
|
131
|
+
# check to ensure the input is an array given that the the attribute
|
132
|
+
# is documented as an array but the input is not
|
133
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
134
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
135
|
+
end
|
136
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
137
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
138
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
139
|
+
end
|
140
|
+
|
141
|
+
self
|
142
|
+
end
|
143
|
+
|
144
|
+
# Deserializes the data based on type
|
145
|
+
# @param string type Data type
|
146
|
+
# @param string value Value to be deserialized
|
147
|
+
# @return [Object] Deserialized data
|
148
|
+
def _deserialize(type, value)
|
149
|
+
case type.to_sym
|
150
|
+
when :DateTime
|
151
|
+
DateTime.parse(value)
|
152
|
+
when :Date
|
153
|
+
Date.parse(value)
|
154
|
+
when :String
|
155
|
+
value.to_s
|
156
|
+
when :Integer
|
157
|
+
value.to_i
|
158
|
+
when :Float
|
159
|
+
value.to_f
|
160
|
+
when :BOOLEAN
|
161
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
162
|
+
true
|
163
|
+
else
|
164
|
+
false
|
165
|
+
end
|
166
|
+
when :Object
|
167
|
+
# generic object (usually a Hash), return directly
|
168
|
+
value
|
169
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
170
|
+
inner_type = Regexp.last_match[:inner_type]
|
171
|
+
value.map { |v| _deserialize(inner_type, v) }
|
172
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
173
|
+
k_type = Regexp.last_match[:k_type]
|
174
|
+
v_type = Regexp.last_match[:v_type]
|
175
|
+
{}.tap do |hash|
|
176
|
+
value.each do |k, v|
|
177
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
else # model
|
181
|
+
temp_model = SquareConnect.const_get(type).new
|
182
|
+
temp_model.build_from_hash(value)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# Returns the string representation of the object
|
187
|
+
# @return [String] String presentation of the object
|
188
|
+
def to_s
|
189
|
+
to_hash.to_s
|
190
|
+
end
|
191
|
+
|
192
|
+
# to_body is an alias to to_hash (backward compatibility)
|
193
|
+
# @return [Hash] Returns the object in the form of hash
|
194
|
+
def to_body
|
195
|
+
to_hash
|
196
|
+
end
|
197
|
+
|
198
|
+
# Returns the object in the form of hash
|
199
|
+
# @return [Hash] Returns the object in the form of hash
|
200
|
+
def to_hash
|
201
|
+
hash = {}
|
202
|
+
self.class.attribute_map.each_pair do |attr, param|
|
203
|
+
value = self.send(attr)
|
204
|
+
next if value.nil?
|
205
|
+
hash[param] = _to_hash(value)
|
206
|
+
end
|
207
|
+
hash
|
208
|
+
end
|
209
|
+
|
210
|
+
# Outputs non-array value in the form of hash
|
211
|
+
# For object, use to_hash. Otherwise, just return the value
|
212
|
+
# @param [Object] value Any valid value
|
213
|
+
# @return [Hash] Returns the value in the form of hash
|
214
|
+
def _to_hash(value)
|
215
|
+
if value.is_a?(Array)
|
216
|
+
value.compact.map{ |v| _to_hash(v) }
|
217
|
+
elsif value.is_a?(Hash)
|
218
|
+
{}.tap do |hash|
|
219
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
220
|
+
end
|
221
|
+
elsif value.respond_to? :to_hash
|
222
|
+
value.to_hash
|
223
|
+
else
|
224
|
+
value
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
|
230
|
+
end
|