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
@@ -73,6 +73,8 @@ module SquareConnect
73
73
  INVALID_CARD_DATA = "INVALID_CARD_DATA".freeze
74
74
  IDEMPOTENCY_KEY_REUSED = "IDEMPOTENCY_KEY_REUSED".freeze
75
75
  UNEXPECTED_VALUE = "UNEXPECTED_VALUE".freeze
76
+ SANDBOX_NOT_SUPPORTED = "SANDBOX_NOT_SUPPORTED".freeze
77
+ INVALID_EMAIL_ADDRESS = "INVALID_EMAIL_ADDRESS".freeze
76
78
  CARD_DECLINED = "CARD_DECLINED".freeze
77
79
  VERIFY_CVV_FAILURE = "VERIFY_CVV_FAILURE".freeze
78
80
  VERIFY_AVS_FAILURE = "VERIFY_AVS_FAILURE".freeze
@@ -0,0 +1,19 @@
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 InventoryAlertType
14
+
15
+ NONE = "NONE".freeze
16
+ LOW_QUANTITY = "LOW_QUANTITY".freeze
17
+ end
18
+
19
+ end
@@ -0,0 +1,281 @@
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
+ # Price and inventory overrides for a [CatalogItemVariation](#type-catalogitemvariation) at a specific location.
14
+ class ItemVariationLocationOverrides
15
+ # The ID of the location.
16
+ attr_accessor :location_id
17
+
18
+ # The price of the [CatalogItemVariation](#type-catalogitemvariation) at the given location, or blank for variable pricing.
19
+ attr_accessor :price_money
20
+
21
+ # The pricing type (fixed or variable) for the [CatalogItemVariation](#type-catalogitemvariation) at the given location. See [CatalogPricingType](#type-catalogpricingtype) for all possible values.
22
+ attr_accessor :pricing_type
23
+
24
+ # If `true`, inventory tracking is active for the [CatalogItemVariation](#type-catalogitemvariation) at this location.
25
+ attr_accessor :track_inventory
26
+
27
+ # Indicates whether the [CatalogItemVariation](#type-catalogitemvariation) 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.
28
+ attr_accessor :inventory_alert_type
29
+
30
+ # 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.
31
+ attr_accessor :inventory_alert_threshold
32
+
33
+ class EnumAttributeValidator
34
+ attr_reader :datatype
35
+ attr_reader :allowable_values
36
+
37
+ def initialize(datatype, allowable_values)
38
+ @allowable_values = allowable_values.map do |value|
39
+ case datatype.to_s
40
+ when /Integer/i
41
+ value.to_i
42
+ when /Float/i
43
+ value.to_f
44
+ else
45
+ value
46
+ end
47
+ end
48
+ end
49
+
50
+ def valid?(value)
51
+ !value || allowable_values.include?(value)
52
+ end
53
+ end
54
+
55
+ # Attribute mapping from ruby-style variable name to JSON key.
56
+ def self.attribute_map
57
+ {
58
+ :'location_id' => :'location_id',
59
+ :'price_money' => :'price_money',
60
+ :'pricing_type' => :'pricing_type',
61
+ :'track_inventory' => :'track_inventory',
62
+ :'inventory_alert_type' => :'inventory_alert_type',
63
+ :'inventory_alert_threshold' => :'inventory_alert_threshold'
64
+ }
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.swagger_types
69
+ {
70
+ :'location_id' => :'String',
71
+ :'price_money' => :'Money',
72
+ :'pricing_type' => :'String',
73
+ :'track_inventory' => :'BOOLEAN',
74
+ :'inventory_alert_type' => :'String',
75
+ :'inventory_alert_threshold' => :'Integer'
76
+ }
77
+ end
78
+
79
+ # Initializes the object
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ def initialize(attributes = {})
82
+ return unless attributes.is_a?(Hash)
83
+
84
+ # convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
86
+
87
+ if attributes.has_key?(:'location_id')
88
+ self.location_id = attributes[:'location_id']
89
+ end
90
+
91
+ if attributes.has_key?(:'price_money')
92
+ self.price_money = attributes[:'price_money']
93
+ end
94
+
95
+ if attributes.has_key?(:'pricing_type')
96
+ self.pricing_type = attributes[:'pricing_type']
97
+ end
98
+
99
+ if attributes.has_key?(:'track_inventory')
100
+ self.track_inventory = attributes[:'track_inventory']
101
+ end
102
+
103
+ if attributes.has_key?(:'inventory_alert_type')
104
+ self.inventory_alert_type = attributes[:'inventory_alert_type']
105
+ end
106
+
107
+ if attributes.has_key?(:'inventory_alert_threshold')
108
+ self.inventory_alert_threshold = attributes[:'inventory_alert_threshold']
109
+ end
110
+
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properies with the reasons
115
+ def list_invalid_properties
116
+ invalid_properties = Array.new
117
+ return invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ pricing_type_validator = EnumAttributeValidator.new('String', ["FIXED_PRICING", "VARIABLE_PRICING"])
124
+ return false unless pricing_type_validator.valid?(@pricing_type)
125
+ inventory_alert_type_validator = EnumAttributeValidator.new('String', ["NONE", "LOW_QUANTITY"])
126
+ return false unless inventory_alert_type_validator.valid?(@inventory_alert_type)
127
+ return true
128
+ end
129
+
130
+ # Custom attribute writer method checking allowed values (enum).
131
+ # @param [Object] pricing_type Object to be assigned
132
+ def pricing_type=(pricing_type)
133
+ validator = EnumAttributeValidator.new('String', ["FIXED_PRICING", "VARIABLE_PRICING"])
134
+ unless validator.valid?(pricing_type)
135
+ fail ArgumentError, "invalid value for 'pricing_type', must be one of #{validator.allowable_values}."
136
+ end
137
+ @pricing_type = pricing_type
138
+ end
139
+
140
+ # Custom attribute writer method checking allowed values (enum).
141
+ # @param [Object] inventory_alert_type Object to be assigned
142
+ def inventory_alert_type=(inventory_alert_type)
143
+ validator = EnumAttributeValidator.new('String', ["NONE", "LOW_QUANTITY"])
144
+ unless validator.valid?(inventory_alert_type)
145
+ fail ArgumentError, "invalid value for 'inventory_alert_type', must be one of #{validator.allowable_values}."
146
+ end
147
+ @inventory_alert_type = inventory_alert_type
148
+ end
149
+
150
+ # Checks equality by comparing each attribute.
151
+ # @param [Object] Object to be compared
152
+ def ==(o)
153
+ return true if self.equal?(o)
154
+ self.class == o.class &&
155
+ location_id == o.location_id &&
156
+ price_money == o.price_money &&
157
+ pricing_type == o.pricing_type &&
158
+ track_inventory == o.track_inventory &&
159
+ inventory_alert_type == o.inventory_alert_type &&
160
+ inventory_alert_threshold == o.inventory_alert_threshold
161
+ end
162
+
163
+ # @see the `==` method
164
+ # @param [Object] Object to be compared
165
+ def eql?(o)
166
+ self == o
167
+ end
168
+
169
+ # Calculates hash code according to all attributes.
170
+ # @return [Fixnum] Hash code
171
+ def hash
172
+ [location_id, price_money, pricing_type, track_inventory, inventory_alert_type, inventory_alert_threshold].hash
173
+ end
174
+
175
+ # Builds the object from hash
176
+ # @param [Hash] attributes Model attributes in the form of hash
177
+ # @return [Object] Returns the model itself
178
+ def build_from_hash(attributes)
179
+ return nil unless attributes.is_a?(Hash)
180
+ self.class.swagger_types.each_pair do |key, type|
181
+ if type =~ /\AArray<(.*)>/i
182
+ # check to ensure the input is an array given that the the attribute
183
+ # is documented as an array but the input is not
184
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
185
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
186
+ end
187
+ elsif !attributes[self.class.attribute_map[key]].nil?
188
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
189
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
190
+ end
191
+
192
+ self
193
+ end
194
+
195
+ # Deserializes the data based on type
196
+ # @param string type Data type
197
+ # @param string value Value to be deserialized
198
+ # @return [Object] Deserialized data
199
+ def _deserialize(type, value)
200
+ case type.to_sym
201
+ when :DateTime
202
+ DateTime.parse(value)
203
+ when :Date
204
+ Date.parse(value)
205
+ when :String
206
+ value.to_s
207
+ when :Integer
208
+ value.to_i
209
+ when :Float
210
+ value.to_f
211
+ when :BOOLEAN
212
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
213
+ true
214
+ else
215
+ false
216
+ end
217
+ when :Object
218
+ # generic object (usually a Hash), return directly
219
+ value
220
+ when /\AArray<(?<inner_type>.+)>\z/
221
+ inner_type = Regexp.last_match[:inner_type]
222
+ value.map { |v| _deserialize(inner_type, v) }
223
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
224
+ k_type = Regexp.last_match[:k_type]
225
+ v_type = Regexp.last_match[:v_type]
226
+ {}.tap do |hash|
227
+ value.each do |k, v|
228
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
229
+ end
230
+ end
231
+ else # model
232
+ temp_model = SquareConnect.const_get(type).new
233
+ temp_model.build_from_hash(value)
234
+ end
235
+ end
236
+
237
+ # Returns the string representation of the object
238
+ # @return [String] String presentation of the object
239
+ def to_s
240
+ to_hash.to_s
241
+ end
242
+
243
+ # to_body is an alias to to_hash (backward compatibility)
244
+ # @return [Hash] Returns the object in the form of hash
245
+ def to_body
246
+ to_hash
247
+ end
248
+
249
+ # Returns the object in the form of hash
250
+ # @return [Hash] Returns the object in the form of hash
251
+ def to_hash
252
+ hash = {}
253
+ self.class.attribute_map.each_pair do |attr, param|
254
+ value = self.send(attr)
255
+ next if value.nil?
256
+ hash[param] = _to_hash(value)
257
+ end
258
+ hash
259
+ end
260
+
261
+ # Outputs non-array value in the form of hash
262
+ # For object, use to_hash. Otherwise, just return the value
263
+ # @param [Object] value Any valid value
264
+ # @return [Hash] Returns the value in the form of hash
265
+ def _to_hash(value)
266
+ if value.is_a?(Array)
267
+ value.compact.map{ |v| _to_hash(v) }
268
+ elsif value.is_a?(Hash)
269
+ {}.tap do |hash|
270
+ value.each { |k, v| hash[k] = _to_hash(v) }
271
+ end
272
+ elsif value.respond_to? :to_hash
273
+ value.to_hash
274
+ else
275
+ value
276
+ end
277
+ end
278
+
279
+ end
280
+
281
+ end
@@ -0,0 +1,196 @@
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 ListCatalogRequest
15
+ # The pagination cursor returned in the previous response. Leave unset for an initial request. See [Paginating results](#paginatingresults) for more information.
16
+ attr_accessor :cursor
17
+
18
+ # An optional case-insensitive, comma-separated list of object types to retrieve, for example `ITEM,ITEM_VARIATION,CATEGORY`. The legal values are taken from the [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `\"ITEM\"`, `\"ITEM_VARIATION\"`, `\"CATEGORY\"`, `\"DISCOUNT\"`, `\"TAX\"`, `\"MODIFIER\"`, or `\"MODIFIER_LIST\"`.
19
+ attr_accessor :types
20
+
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'cursor' => :'cursor',
26
+ :'types' => :'types'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'cursor' => :'String',
34
+ :'types' => :'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?(:'cursor')
47
+ self.cursor = attributes[:'cursor']
48
+ end
49
+
50
+ if attributes.has_key?(:'types')
51
+ self.types = attributes[:'types']
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
+ return invalid_properties
61
+ end
62
+
63
+ # Check to see if the all the properties in the model are valid
64
+ # @return true if the model is valid
65
+ def valid?
66
+ return true
67
+ end
68
+
69
+ # Checks equality by comparing each attribute.
70
+ # @param [Object] Object to be compared
71
+ def ==(o)
72
+ return true if self.equal?(o)
73
+ self.class == o.class &&
74
+ cursor == o.cursor &&
75
+ types == o.types
76
+ end
77
+
78
+ # @see the `==` method
79
+ # @param [Object] Object to be compared
80
+ def eql?(o)
81
+ self == o
82
+ end
83
+
84
+ # Calculates hash code according to all attributes.
85
+ # @return [Fixnum] Hash code
86
+ def hash
87
+ [cursor, types].hash
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+ self.class.swagger_types.each_pair do |key, type|
96
+ if type =~ /\AArray<(.*)>/i
97
+ # check to ensure the input is an array given that the the attribute
98
+ # is documented as an array but the input is not
99
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
100
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
101
+ end
102
+ elsif !attributes[self.class.attribute_map[key]].nil?
103
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
104
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
105
+ end
106
+
107
+ self
108
+ end
109
+
110
+ # Deserializes the data based on type
111
+ # @param string type Data type
112
+ # @param string value Value to be deserialized
113
+ # @return [Object] Deserialized data
114
+ def _deserialize(type, value)
115
+ case type.to_sym
116
+ when :DateTime
117
+ DateTime.parse(value)
118
+ when :Date
119
+ Date.parse(value)
120
+ when :String
121
+ value.to_s
122
+ when :Integer
123
+ value.to_i
124
+ when :Float
125
+ value.to_f
126
+ when :BOOLEAN
127
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
128
+ true
129
+ else
130
+ false
131
+ end
132
+ when :Object
133
+ # generic object (usually a Hash), return directly
134
+ value
135
+ when /\AArray<(?<inner_type>.+)>\z/
136
+ inner_type = Regexp.last_match[:inner_type]
137
+ value.map { |v| _deserialize(inner_type, v) }
138
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
139
+ k_type = Regexp.last_match[:k_type]
140
+ v_type = Regexp.last_match[:v_type]
141
+ {}.tap do |hash|
142
+ value.each do |k, v|
143
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
144
+ end
145
+ end
146
+ else # model
147
+ temp_model = SquareConnect.const_get(type).new
148
+ temp_model.build_from_hash(value)
149
+ end
150
+ end
151
+
152
+ # Returns the string representation of the object
153
+ # @return [String] String presentation of the object
154
+ def to_s
155
+ to_hash.to_s
156
+ end
157
+
158
+ # to_body is an alias to to_hash (backward compatibility)
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_body
161
+ to_hash
162
+ end
163
+
164
+ # Returns the object in the form of hash
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_hash
167
+ hash = {}
168
+ self.class.attribute_map.each_pair do |attr, param|
169
+ value = self.send(attr)
170
+ next if value.nil?
171
+ hash[param] = _to_hash(value)
172
+ end
173
+ hash
174
+ end
175
+
176
+ # Outputs non-array value in the form of hash
177
+ # For object, use to_hash. Otherwise, just return the value
178
+ # @param [Object] value Any valid value
179
+ # @return [Hash] Returns the value in the form of hash
180
+ def _to_hash(value)
181
+ if value.is_a?(Array)
182
+ value.compact.map{ |v| _to_hash(v) }
183
+ elsif value.is_a?(Hash)
184
+ {}.tap do |hash|
185
+ value.each { |k, v| hash[k] = _to_hash(v) }
186
+ end
187
+ elsif value.respond_to? :to_hash
188
+ value.to_hash
189
+ else
190
+ value
191
+ end
192
+ end
193
+
194
+ end
195
+
196
+ end