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.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +71 -8
  3. data/docs/BatchDeleteCatalogObjectsRequest.md +12 -0
  4. data/docs/BatchDeleteCatalogObjectsResponse.md +14 -0
  5. data/docs/BatchRetrieveCatalogObjectsRequest.md +13 -0
  6. data/docs/BatchRetrieveCatalogObjectsResponse.md +14 -0
  7. data/docs/BatchUpsertCatalogObjectsRequest.md +13 -0
  8. data/docs/BatchUpsertCatalogObjectsResponse.md +15 -0
  9. data/docs/CatalogApi.md +592 -0
  10. data/docs/CatalogCategory.md +12 -0
  11. data/docs/CatalogDiscount.md +17 -0
  12. data/docs/CatalogDiscountType.md +15 -0
  13. data/docs/CatalogIdMapping.md +13 -0
  14. data/docs/CatalogInfoRequest.md +11 -0
  15. data/docs/CatalogInfoResponse.md +13 -0
  16. data/docs/CatalogInfoResponseLimits.md +22 -0
  17. data/docs/CatalogItem.md +25 -0
  18. data/docs/CatalogItemModifierListInfo.md +16 -0
  19. data/docs/CatalogItemProductType.md +16 -0
  20. data/docs/CatalogItemVariation.md +23 -0
  21. data/docs/CatalogModifier.md +13 -0
  22. data/docs/CatalogModifierList.md +14 -0
  23. data/docs/CatalogModifierListSelectionType.md +13 -0
  24. data/docs/CatalogModifierOverride.md +13 -0
  25. data/docs/CatalogObject.md +27 -0
  26. data/docs/CatalogObjectBatch.md +12 -0
  27. data/docs/CatalogObjectType.md +18 -0
  28. data/docs/CatalogPricingType.md +13 -0
  29. data/docs/CatalogQuery.md +18 -0
  30. data/docs/CatalogQueryExact.md +13 -0
  31. data/docs/CatalogQueryItemsForModifierList.md +12 -0
  32. data/docs/CatalogQueryItemsForTax.md +12 -0
  33. data/docs/CatalogQueryPrefix.md +13 -0
  34. data/docs/CatalogQueryRange.md +14 -0
  35. data/docs/CatalogQuerySortedAttribute.md +14 -0
  36. data/docs/CatalogQueryText.md +12 -0
  37. data/docs/CatalogTax.md +17 -0
  38. data/docs/CatalogV1Id.md +13 -0
  39. data/docs/Checkout.md +4 -4
  40. data/docs/CreateCheckoutRequest.md +5 -5
  41. data/docs/DeleteCatalogObjectRequest.md +11 -0
  42. data/docs/DeleteCatalogObjectResponse.md +14 -0
  43. data/docs/ErrorCode.md +2 -0
  44. data/docs/InventoryAlertType.md +13 -0
  45. data/docs/ItemVariationLocationOverrides.md +17 -0
  46. data/docs/ListCatalogRequest.md +13 -0
  47. data/docs/ListCatalogResponse.md +14 -0
  48. data/docs/RetrieveCatalogObjectRequest.md +12 -0
  49. data/docs/RetrieveCatalogObjectResponse.md +14 -0
  50. data/docs/SearchCatalogObjectsRequest.md +18 -0
  51. data/docs/SearchCatalogObjectsResponse.md +15 -0
  52. data/docs/TaxCalculationPhase.md +13 -0
  53. data/docs/TaxInclusionType.md +13 -0
  54. data/docs/UpdateItemModifierListsRequest.md +14 -0
  55. data/docs/UpdateItemModifierListsResponse.md +13 -0
  56. data/docs/UpdateItemTaxesRequest.md +14 -0
  57. data/docs/UpdateItemTaxesResponse.md +13 -0
  58. data/docs/UpsertCatalogObjectRequest.md +13 -0
  59. data/docs/UpsertCatalogObjectResponse.md +14 -0
  60. data/docs/V1Item.md +1 -1
  61. data/docs/V1Variation.md +0 -1
  62. data/lib/square_connect.rb +54 -1
  63. data/lib/square_connect/api/catalog_api.rb +604 -0
  64. data/lib/square_connect/models/batch_delete_catalog_objects_request.rb +188 -0
  65. data/lib/square_connect/models/batch_delete_catalog_objects_response.rb +210 -0
  66. data/lib/square_connect/models/batch_retrieve_catalog_objects_request.rb +203 -0
  67. data/lib/square_connect/models/batch_retrieve_catalog_objects_response.rb +212 -0
  68. data/lib/square_connect/models/batch_upsert_catalog_objects_request.rb +222 -0
  69. data/lib/square_connect/models/batch_upsert_catalog_objects_response.rb +222 -0
  70. data/lib/square_connect/models/catalog_category.rb +210 -0
  71. data/lib/square_connect/models/catalog_discount.rb +293 -0
  72. data/lib/square_connect/models/catalog_discount_type.rb +21 -0
  73. data/lib/square_connect/models/catalog_id_mapping.rb +196 -0
  74. data/lib/square_connect/models/catalog_info_request.rb +176 -0
  75. data/lib/square_connect/models/catalog_info_response.rb +198 -0
  76. data/lib/square_connect/models/catalog_info_response_limits.rb +286 -0
  77. data/lib/square_connect/models/catalog_item.rb +379 -0
  78. data/lib/square_connect/models/catalog_item_modifier_list_info.rb +252 -0
  79. data/lib/square_connect/models/catalog_item_product_type.rb +22 -0
  80. data/lib/square_connect/models/catalog_item_variation.rb +343 -0
  81. data/lib/square_connect/models/catalog_modifier.rb +220 -0
  82. data/lib/square_connect/models/catalog_modifier_list.rb +265 -0
  83. data/lib/square_connect/models/catalog_modifier_list_selection_type.rb +19 -0
  84. data/lib/square_connect/models/catalog_modifier_override.rb +220 -0
  85. data/lib/square_connect/models/catalog_object.rb +404 -0
  86. data/lib/square_connect/models/catalog_object_batch.rb +188 -0
  87. data/lib/square_connect/models/catalog_object_type.rb +24 -0
  88. data/lib/square_connect/models/catalog_pricing_type.rb +19 -0
  89. data/lib/square_connect/models/catalog_query.rb +246 -0
  90. data/lib/square_connect/models/catalog_query_exact.rb +225 -0
  91. data/lib/square_connect/models/catalog_query_items_for_modifier_list.rb +193 -0
  92. data/lib/square_connect/models/catalog_query_items_for_tax.rb +193 -0
  93. data/lib/square_connect/models/catalog_query_prefix.rb +244 -0
  94. data/lib/square_connect/models/catalog_query_range.rb +230 -0
  95. data/lib/square_connect/models/catalog_query_sorted_attribute.rb +263 -0
  96. data/lib/square_connect/models/catalog_query_text.rb +193 -0
  97. data/lib/square_connect/models/catalog_tax.rb +305 -0
  98. data/lib/square_connect/models/catalog_v1_id.rb +196 -0
  99. data/lib/square_connect/models/checkout.rb +4 -4
  100. data/lib/square_connect/models/create_checkout_request.rb +5 -5
  101. data/lib/square_connect/models/delete_catalog_object_request.rb +176 -0
  102. data/lib/square_connect/models/delete_catalog_object_response.rb +210 -0
  103. data/lib/square_connect/models/error.rb +2 -2
  104. data/lib/square_connect/models/error_code.rb +2 -0
  105. data/lib/square_connect/models/inventory_alert_type.rb +19 -0
  106. data/lib/square_connect/models/item_variation_location_overrides.rb +281 -0
  107. data/lib/square_connect/models/list_catalog_request.rb +196 -0
  108. data/lib/square_connect/models/list_catalog_response.rb +210 -0
  109. data/lib/square_connect/models/retrieve_catalog_object_request.rb +186 -0
  110. data/lib/square_connect/models/retrieve_catalog_object_response.rb +210 -0
  111. data/lib/square_connect/models/search_catalog_objects_request.rb +269 -0
  112. data/lib/square_connect/models/search_catalog_objects_response.rb +222 -0
  113. data/lib/square_connect/models/tax_calculation_phase.rb +19 -0
  114. data/lib/square_connect/models/tax_inclusion_type.rb +19 -0
  115. data/lib/square_connect/models/update_item_modifier_lists_request.rb +217 -0
  116. data/lib/square_connect/models/update_item_modifier_lists_response.rb +198 -0
  117. data/lib/square_connect/models/update_item_taxes_request.rb +217 -0
  118. data/lib/square_connect/models/update_item_taxes_response.rb +198 -0
  119. data/lib/square_connect/models/{create_order_request.rb → upsert_catalog_object_request.rb} +14 -23
  120. data/lib/square_connect/models/upsert_catalog_object_response.rb +210 -0
  121. data/lib/square_connect/models/v1_item.rb +1 -1
  122. data/lib/square_connect/models/v1_variation.rb +1 -11
  123. data/lib/square_connect/version.rb +1 -1
  124. data/spec/api/catalog_api_spec.rb +611 -0
  125. data/spec/models/batch_delete_catalog_objects_request_spec.rb +39 -0
  126. data/spec/models/batch_delete_catalog_objects_response_spec.rb +51 -0
  127. data/spec/models/batch_retrieve_catalog_objects_request_spec.rb +45 -0
  128. data/spec/models/batch_retrieve_catalog_objects_response_spec.rb +51 -0
  129. data/spec/models/batch_upsert_catalog_objects_request_spec.rb +45 -0
  130. data/spec/models/batch_upsert_catalog_objects_response_spec.rb +57 -0
  131. data/spec/models/catalog_category_spec.rb +39 -0
  132. data/spec/models/catalog_discount_spec.rb +73 -0
  133. data/spec/models/catalog_discount_type_spec.rb +33 -0
  134. data/spec/models/catalog_id_mapping_spec.rb +45 -0
  135. data/spec/models/catalog_info_request_spec.rb +33 -0
  136. data/spec/models/catalog_info_response_limits_spec.rb +99 -0
  137. data/spec/models/catalog_info_response_spec.rb +45 -0
  138. data/spec/models/catalog_item_modifier_list_info_spec.rb +63 -0
  139. data/spec/models/catalog_item_product_type_spec.rb +33 -0
  140. data/spec/models/catalog_item_spec.rb +121 -0
  141. data/spec/models/catalog_item_variation_spec.rb +113 -0
  142. data/spec/models/catalog_modifier_list_selection_type_spec.rb +33 -0
  143. data/spec/models/catalog_modifier_list_spec.rb +55 -0
  144. data/spec/models/catalog_modifier_override_spec.rb +45 -0
  145. data/spec/models/catalog_modifier_spec.rb +45 -0
  146. data/spec/models/catalog_object_batch_spec.rb +39 -0
  147. data/spec/models/catalog_object_spec.rb +133 -0
  148. data/spec/models/catalog_object_type_spec.rb +33 -0
  149. data/spec/models/catalog_pricing_type_spec.rb +33 -0
  150. data/spec/models/catalog_query_exact_spec.rb +45 -0
  151. data/spec/models/catalog_query_items_for_modifier_list_spec.rb +39 -0
  152. data/spec/models/catalog_query_items_for_tax_spec.rb +39 -0
  153. data/spec/models/catalog_query_prefix_spec.rb +45 -0
  154. data/spec/models/catalog_query_range_spec.rb +51 -0
  155. data/spec/models/catalog_query_sorted_attribute_spec.rb +55 -0
  156. data/spec/models/catalog_query_spec.rb +75 -0
  157. data/spec/models/catalog_query_text_spec.rb +39 -0
  158. data/spec/models/catalog_tax_spec.rb +77 -0
  159. data/spec/models/catalog_v1_id_spec.rb +45 -0
  160. data/spec/models/delete_catalog_object_request_spec.rb +39 -0
  161. data/spec/models/delete_catalog_object_response_spec.rb +51 -0
  162. data/spec/models/inventory_alert_type_spec.rb +33 -0
  163. data/spec/models/item_variation_location_overrides_spec.rb +77 -0
  164. data/spec/models/list_catalog_request_spec.rb +45 -0
  165. data/spec/models/list_catalog_response_spec.rb +51 -0
  166. data/spec/models/retrieve_catalog_object_request_spec.rb +45 -0
  167. data/spec/models/retrieve_catalog_object_response_spec.rb +51 -0
  168. data/spec/models/search_catalog_objects_request_spec.rb +79 -0
  169. data/spec/models/search_catalog_objects_response_spec.rb +57 -0
  170. data/spec/models/tax_calculation_phase_spec.rb +33 -0
  171. data/spec/models/tax_inclusion_type_spec.rb +33 -0
  172. data/spec/models/update_item_modifier_lists_request_spec.rb +51 -0
  173. data/spec/models/update_item_modifier_lists_response_spec.rb +45 -0
  174. data/spec/models/update_item_taxes_request_spec.rb +51 -0
  175. data/spec/models/update_item_taxes_response_spec.rb +45 -0
  176. data/spec/models/{create_order_request_spec.rb → upsert_catalog_object_request_spec.rb} +7 -7
  177. data/spec/models/upsert_catalog_object_response_spec.rb +51 -0
  178. data/square_connect.gemspec +1 -1
  179. data/travis-ci/accounts.enc +0 -0
  180. metadata +222 -17
  181. data/docs/CreateOrderRequest.md +0 -13
  182. data/docs/V1LocationApi.md +0 -102
  183. data/lib/.DS_Store +0 -0
  184. data/lib/square_connect/.DS_Store +0 -0
  185. data/spec/.DS_Store +0 -0
  186. data/square_connect-2.0.2.gem +0 -0
  187. data/square_connect-2.1.0.gem +0 -0
  188. data/square_connect-2.1.0beta.gem +0 -0
@@ -0,0 +1,252 @@
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
+ # Controls the properties of a [CatalogModifierList](#type-catalogmodifierlist) as it applies to this [CatalogItem](#type-catalogitem).
14
+ class CatalogItemModifierListInfo
15
+ # The ID of the [CatalogModifierList](#type-catalogmodifierlist) controlled by this [CatalogModifierListInfo](#type-catalogmodifierlistinfo).
16
+ attr_accessor :modifier_list_id
17
+
18
+ # A set of [CatalogModifierOverride](#type-catalogmodifieroverride) objects that override whether a given [CatalogModifier](#type-catalogmodifier) is enabled by default.
19
+ attr_accessor :modifier_overrides
20
+
21
+ # If zero or larger, the smallest number of [CatalogModifier](#type-catalogmodifier)s that must be selected from this [CatalogModifierList](#type-catalogmodifierlist).
22
+ attr_accessor :min_selected_modifiers
23
+
24
+ # If zero or larger, the largest number of [CatalogModifier](#type-catalogmodifier)s that can be selected from this [CatalogModifierList](#type-catalogmodifierlist).
25
+ attr_accessor :max_selected_modifiers
26
+
27
+ # If `true`, enable this [CatalogModifierList](#type-catalogmodifierlist).
28
+ attr_accessor :enabled
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'modifier_list_id' => :'modifier_list_id',
35
+ :'modifier_overrides' => :'modifier_overrides',
36
+ :'min_selected_modifiers' => :'min_selected_modifiers',
37
+ :'max_selected_modifiers' => :'max_selected_modifiers',
38
+ :'enabled' => :'enabled'
39
+ }
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.swagger_types
44
+ {
45
+ :'modifier_list_id' => :'String',
46
+ :'modifier_overrides' => :'Array<CatalogModifierOverride>',
47
+ :'min_selected_modifiers' => :'Integer',
48
+ :'max_selected_modifiers' => :'Integer',
49
+ :'enabled' => :'BOOLEAN'
50
+ }
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ return unless attributes.is_a?(Hash)
57
+
58
+ # convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
60
+
61
+ if attributes.has_key?(:'modifier_list_id')
62
+ self.modifier_list_id = attributes[:'modifier_list_id']
63
+ end
64
+
65
+ if attributes.has_key?(:'modifier_overrides')
66
+ if (value = attributes[:'modifier_overrides']).is_a?(Array)
67
+ self.modifier_overrides = value
68
+ end
69
+ end
70
+
71
+ if attributes.has_key?(:'min_selected_modifiers')
72
+ self.min_selected_modifiers = attributes[:'min_selected_modifiers']
73
+ end
74
+
75
+ if attributes.has_key?(:'max_selected_modifiers')
76
+ self.max_selected_modifiers = attributes[:'max_selected_modifiers']
77
+ end
78
+
79
+ if attributes.has_key?(:'enabled')
80
+ self.enabled = attributes[:'enabled']
81
+ end
82
+
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properies with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ if @modifier_list_id.nil?
90
+ invalid_properties.push("invalid value for 'modifier_list_id', modifier_list_id cannot be nil.")
91
+ end
92
+
93
+ if @modifier_list_id.to_s.length < 1
94
+ invalid_properties.push("invalid value for 'modifier_list_id', the character length must be great than or equal to 1.")
95
+ end
96
+
97
+ return invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ return false if @modifier_list_id.nil?
104
+ return false if @modifier_list_id.to_s.length < 1
105
+ return true
106
+ end
107
+
108
+ # Custom attribute writer method with validation
109
+ # @param [Object] modifier_list_id Value to be assigned
110
+ def modifier_list_id=(modifier_list_id)
111
+ if modifier_list_id.nil?
112
+ fail ArgumentError, "modifier_list_id cannot be nil"
113
+ end
114
+
115
+ if modifier_list_id.to_s.length < 1
116
+ fail ArgumentError, "invalid value for 'modifier_list_id', the character length must be great than or equal to 1."
117
+ end
118
+
119
+ @modifier_list_id = modifier_list_id
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ modifier_list_id == o.modifier_list_id &&
128
+ modifier_overrides == o.modifier_overrides &&
129
+ min_selected_modifiers == o.min_selected_modifiers &&
130
+ max_selected_modifiers == o.max_selected_modifiers &&
131
+ enabled == o.enabled
132
+ end
133
+
134
+ # @see the `==` method
135
+ # @param [Object] Object to be compared
136
+ def eql?(o)
137
+ self == o
138
+ end
139
+
140
+ # Calculates hash code according to all attributes.
141
+ # @return [Fixnum] Hash code
142
+ def hash
143
+ [modifier_list_id, modifier_overrides, min_selected_modifiers, max_selected_modifiers, enabled].hash
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ self.class.swagger_types.each_pair do |key, type|
152
+ if type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
156
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
157
+ end
158
+ elsif !attributes[self.class.attribute_map[key]].nil?
159
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
161
+ end
162
+
163
+ self
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def _deserialize(type, value)
171
+ case type.to_sym
172
+ when :DateTime
173
+ DateTime.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :BOOLEAN
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ temp_model = SquareConnect.const_get(type).new
204
+ temp_model.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ next if value.nil?
227
+ hash[param] = _to_hash(value)
228
+ end
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map{ |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to? :to_hash
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+
252
+ end
@@ -0,0 +1,22 @@
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
+ class CatalogItemProductType
14
+
15
+ REGULAR = "REGULAR".freeze
16
+ GIFT_CARD = "GIFT_CARD".freeze
17
+ APPOINTMENTS_SERVICE = "APPOINTMENTS_SERVICE".freeze
18
+ RETAIL_ITEM = "RETAIL_ITEM".freeze
19
+ RESTAURANT_ITEM = "RESTAURANT_ITEM".freeze
20
+ end
21
+
22
+ end
@@ -0,0 +1,343 @@
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
+ # An item variation (i.e., product) in the Catalog object model.
14
+ class CatalogItemVariation
15
+ # The ID of the [CatalogItem](#type-catalogitem) associated with this item variation. Searchable.
16
+ attr_accessor :item_id
17
+
18
+ # The item variation's name. Searchable.
19
+ attr_accessor :name
20
+
21
+ # The item variation's SKU, if any. Searchable.
22
+ attr_accessor :sku
23
+
24
+ # The item variation's UPC, if any. Searchable.
25
+ attr_accessor :upc
26
+
27
+ # Indicates whether the item variation's price is fixed or determined at the time of sale. See [CatalogPricingType](#type-catalogpricingtype) for all possible values.
28
+ attr_accessor :pricing_type
29
+
30
+ # The item variation's price, if fixed pricing is used.
31
+ attr_accessor :price_money
32
+
33
+ # Per-location price and inventory overrides.
34
+ attr_accessor :location_overrides
35
+
36
+ # If `true`, inventory tracking is active for the variation.
37
+ attr_accessor :track_inventory
38
+
39
+ # Indicates whether the item variation displays an alert when its inventory quantity is less than or equal to its `inventory_alert_threshold`. See [InventoryAlertType](#type-inventoryalerttype) for all possible values.
40
+ attr_accessor :inventory_alert_type
41
+
42
+ # If the inventory quantity for the variation is less than or equal to this value and `inventory_alert_type` is `LOW_QUANTITY`, the variation displays an alert in the merchant dashboard. This value is always an integer.
43
+ attr_accessor :inventory_alert_threshold
44
+
45
+ # Arbitrary user metadata to associate with the item variation. Cannot exceed 255 characters. Searchable.
46
+ attr_accessor :user_data
47
+
48
+ # If the [CatalogItem](#type-catalogitem) that owns this item variation is of type `APPOINTMENTS_SERVICE`, then this is the duration of the service in milliseconds. For example, a 30 minute appointment would have the value `1800000`, which is equal to 30 (minutes) * 60 (seconds per minute) * 1000 (milliseconds per second).
49
+ attr_accessor :service_duration
50
+
51
+ class EnumAttributeValidator
52
+ attr_reader :datatype
53
+ attr_reader :allowable_values
54
+
55
+ def initialize(datatype, allowable_values)
56
+ @allowable_values = allowable_values.map do |value|
57
+ case datatype.to_s
58
+ when /Integer/i
59
+ value.to_i
60
+ when /Float/i
61
+ value.to_f
62
+ else
63
+ value
64
+ end
65
+ end
66
+ end
67
+
68
+ def valid?(value)
69
+ !value || allowable_values.include?(value)
70
+ end
71
+ end
72
+
73
+ # Attribute mapping from ruby-style variable name to JSON key.
74
+ def self.attribute_map
75
+ {
76
+ :'item_id' => :'item_id',
77
+ :'name' => :'name',
78
+ :'sku' => :'sku',
79
+ :'upc' => :'upc',
80
+ :'pricing_type' => :'pricing_type',
81
+ :'price_money' => :'price_money',
82
+ :'location_overrides' => :'location_overrides',
83
+ :'track_inventory' => :'track_inventory',
84
+ :'inventory_alert_type' => :'inventory_alert_type',
85
+ :'inventory_alert_threshold' => :'inventory_alert_threshold',
86
+ :'user_data' => :'user_data',
87
+ :'service_duration' => :'service_duration'
88
+ }
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.swagger_types
93
+ {
94
+ :'item_id' => :'String',
95
+ :'name' => :'String',
96
+ :'sku' => :'String',
97
+ :'upc' => :'String',
98
+ :'pricing_type' => :'String',
99
+ :'price_money' => :'Money',
100
+ :'location_overrides' => :'Array<ItemVariationLocationOverrides>',
101
+ :'track_inventory' => :'BOOLEAN',
102
+ :'inventory_alert_type' => :'String',
103
+ :'inventory_alert_threshold' => :'Integer',
104
+ :'user_data' => :'String',
105
+ :'service_duration' => :'Integer'
106
+ }
107
+ end
108
+
109
+ # Initializes the object
110
+ # @param [Hash] attributes Model attributes in the form of hash
111
+ def initialize(attributes = {})
112
+ return unless attributes.is_a?(Hash)
113
+
114
+ # convert string to symbol for hash key
115
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
116
+
117
+ if attributes.has_key?(:'item_id')
118
+ self.item_id = attributes[:'item_id']
119
+ end
120
+
121
+ if attributes.has_key?(:'name')
122
+ self.name = attributes[:'name']
123
+ end
124
+
125
+ if attributes.has_key?(:'sku')
126
+ self.sku = attributes[:'sku']
127
+ end
128
+
129
+ if attributes.has_key?(:'upc')
130
+ self.upc = attributes[:'upc']
131
+ end
132
+
133
+ if attributes.has_key?(:'pricing_type')
134
+ self.pricing_type = attributes[:'pricing_type']
135
+ end
136
+
137
+ if attributes.has_key?(:'price_money')
138
+ self.price_money = attributes[:'price_money']
139
+ end
140
+
141
+ if attributes.has_key?(:'location_overrides')
142
+ if (value = attributes[:'location_overrides']).is_a?(Array)
143
+ self.location_overrides = value
144
+ end
145
+ end
146
+
147
+ if attributes.has_key?(:'track_inventory')
148
+ self.track_inventory = attributes[:'track_inventory']
149
+ end
150
+
151
+ if attributes.has_key?(:'inventory_alert_type')
152
+ self.inventory_alert_type = attributes[:'inventory_alert_type']
153
+ end
154
+
155
+ if attributes.has_key?(:'inventory_alert_threshold')
156
+ self.inventory_alert_threshold = attributes[:'inventory_alert_threshold']
157
+ end
158
+
159
+ if attributes.has_key?(:'user_data')
160
+ self.user_data = attributes[:'user_data']
161
+ end
162
+
163
+ if attributes.has_key?(:'service_duration')
164
+ self.service_duration = attributes[:'service_duration']
165
+ end
166
+
167
+ end
168
+
169
+ # Show invalid properties with the reasons. Usually used together with valid?
170
+ # @return Array for valid properies with the reasons
171
+ def list_invalid_properties
172
+ invalid_properties = Array.new
173
+ return invalid_properties
174
+ end
175
+
176
+ # Check to see if the all the properties in the model are valid
177
+ # @return true if the model is valid
178
+ def valid?
179
+ pricing_type_validator = EnumAttributeValidator.new('String', ["FIXED_PRICING", "VARIABLE_PRICING"])
180
+ return false unless pricing_type_validator.valid?(@pricing_type)
181
+ inventory_alert_type_validator = EnumAttributeValidator.new('String', ["NONE", "LOW_QUANTITY"])
182
+ return false unless inventory_alert_type_validator.valid?(@inventory_alert_type)
183
+ return true
184
+ end
185
+
186
+ # Custom attribute writer method checking allowed values (enum).
187
+ # @param [Object] pricing_type Object to be assigned
188
+ def pricing_type=(pricing_type)
189
+ validator = EnumAttributeValidator.new('String', ["FIXED_PRICING", "VARIABLE_PRICING"])
190
+ unless validator.valid?(pricing_type)
191
+ fail ArgumentError, "invalid value for 'pricing_type', must be one of #{validator.allowable_values}."
192
+ end
193
+ @pricing_type = pricing_type
194
+ end
195
+
196
+ # Custom attribute writer method checking allowed values (enum).
197
+ # @param [Object] inventory_alert_type Object to be assigned
198
+ def inventory_alert_type=(inventory_alert_type)
199
+ validator = EnumAttributeValidator.new('String', ["NONE", "LOW_QUANTITY"])
200
+ unless validator.valid?(inventory_alert_type)
201
+ fail ArgumentError, "invalid value for 'inventory_alert_type', must be one of #{validator.allowable_values}."
202
+ end
203
+ @inventory_alert_type = inventory_alert_type
204
+ end
205
+
206
+ # Checks equality by comparing each attribute.
207
+ # @param [Object] Object to be compared
208
+ def ==(o)
209
+ return true if self.equal?(o)
210
+ self.class == o.class &&
211
+ item_id == o.item_id &&
212
+ name == o.name &&
213
+ sku == o.sku &&
214
+ upc == o.upc &&
215
+ pricing_type == o.pricing_type &&
216
+ price_money == o.price_money &&
217
+ location_overrides == o.location_overrides &&
218
+ track_inventory == o.track_inventory &&
219
+ inventory_alert_type == o.inventory_alert_type &&
220
+ inventory_alert_threshold == o.inventory_alert_threshold &&
221
+ user_data == o.user_data &&
222
+ service_duration == o.service_duration
223
+ end
224
+
225
+ # @see the `==` method
226
+ # @param [Object] Object to be compared
227
+ def eql?(o)
228
+ self == o
229
+ end
230
+
231
+ # Calculates hash code according to all attributes.
232
+ # @return [Fixnum] Hash code
233
+ def hash
234
+ [item_id, name, sku, upc, pricing_type, price_money, location_overrides, track_inventory, inventory_alert_type, inventory_alert_threshold, user_data, service_duration].hash
235
+ end
236
+
237
+ # Builds the object from hash
238
+ # @param [Hash] attributes Model attributes in the form of hash
239
+ # @return [Object] Returns the model itself
240
+ def build_from_hash(attributes)
241
+ return nil unless attributes.is_a?(Hash)
242
+ self.class.swagger_types.each_pair do |key, type|
243
+ if type =~ /\AArray<(.*)>/i
244
+ # check to ensure the input is an array given that the the attribute
245
+ # is documented as an array but the input is not
246
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
247
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
248
+ end
249
+ elsif !attributes[self.class.attribute_map[key]].nil?
250
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
251
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
252
+ end
253
+
254
+ self
255
+ end
256
+
257
+ # Deserializes the data based on type
258
+ # @param string type Data type
259
+ # @param string value Value to be deserialized
260
+ # @return [Object] Deserialized data
261
+ def _deserialize(type, value)
262
+ case type.to_sym
263
+ when :DateTime
264
+ DateTime.parse(value)
265
+ when :Date
266
+ Date.parse(value)
267
+ when :String
268
+ value.to_s
269
+ when :Integer
270
+ value.to_i
271
+ when :Float
272
+ value.to_f
273
+ when :BOOLEAN
274
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
275
+ true
276
+ else
277
+ false
278
+ end
279
+ when :Object
280
+ # generic object (usually a Hash), return directly
281
+ value
282
+ when /\AArray<(?<inner_type>.+)>\z/
283
+ inner_type = Regexp.last_match[:inner_type]
284
+ value.map { |v| _deserialize(inner_type, v) }
285
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
286
+ k_type = Regexp.last_match[:k_type]
287
+ v_type = Regexp.last_match[:v_type]
288
+ {}.tap do |hash|
289
+ value.each do |k, v|
290
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
291
+ end
292
+ end
293
+ else # model
294
+ temp_model = SquareConnect.const_get(type).new
295
+ temp_model.build_from_hash(value)
296
+ end
297
+ end
298
+
299
+ # Returns the string representation of the object
300
+ # @return [String] String presentation of the object
301
+ def to_s
302
+ to_hash.to_s
303
+ end
304
+
305
+ # to_body is an alias to to_hash (backward compatibility)
306
+ # @return [Hash] Returns the object in the form of hash
307
+ def to_body
308
+ to_hash
309
+ end
310
+
311
+ # Returns the object in the form of hash
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_hash
314
+ hash = {}
315
+ self.class.attribute_map.each_pair do |attr, param|
316
+ value = self.send(attr)
317
+ next if value.nil?
318
+ hash[param] = _to_hash(value)
319
+ end
320
+ hash
321
+ end
322
+
323
+ # Outputs non-array value in the form of hash
324
+ # For object, use to_hash. Otherwise, just return the value
325
+ # @param [Object] value Any valid value
326
+ # @return [Hash] Returns the value in the form of hash
327
+ def _to_hash(value)
328
+ if value.is_a?(Array)
329
+ value.compact.map{ |v| _to_hash(v) }
330
+ elsif value.is_a?(Hash)
331
+ {}.tap do |hash|
332
+ value.each { |k, v| hash[k] = _to_hash(v) }
333
+ end
334
+ elsif value.respond_to? :to_hash
335
+ value.to_hash
336
+ else
337
+ value
338
+ end
339
+ end
340
+
341
+ end
342
+
343
+ end