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,210 @@
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
+ # A category to which an [CatalogItem](#type-catalogitem) belongs in the Catalog object model.
14
+ class CatalogCategory
15
+ # The category's name. Searchable.
16
+ attr_accessor :name
17
+
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'name' => :'name'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.swagger_types
28
+ {
29
+ :'name' => :'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?(:'name')
42
+ self.name = attributes[:'name']
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 @name.nil?
52
+ invalid_properties.push("invalid value for 'name', name cannot be nil.")
53
+ end
54
+
55
+ if @name.to_s.length < 1
56
+ invalid_properties.push("invalid value for 'name', the character length must be great than or equal to 1.")
57
+ end
58
+
59
+ return invalid_properties
60
+ end
61
+
62
+ # Check to see if the all the properties in the model are valid
63
+ # @return true if the model is valid
64
+ def valid?
65
+ return false if @name.nil?
66
+ return false if @name.to_s.length < 1
67
+ return true
68
+ end
69
+
70
+ # Custom attribute writer method with validation
71
+ # @param [Object] name Value to be assigned
72
+ def name=(name)
73
+ if name.nil?
74
+ fail ArgumentError, "name cannot be nil"
75
+ end
76
+
77
+ if name.to_s.length < 1
78
+ fail ArgumentError, "invalid value for 'name', the character length must be great than or equal to 1."
79
+ end
80
+
81
+ @name = name
82
+ end
83
+
84
+ # Checks equality by comparing each attribute.
85
+ # @param [Object] Object to be compared
86
+ def ==(o)
87
+ return true if self.equal?(o)
88
+ self.class == o.class &&
89
+ name == o.name
90
+ end
91
+
92
+ # @see the `==` method
93
+ # @param [Object] Object to be compared
94
+ def eql?(o)
95
+ self == o
96
+ end
97
+
98
+ # Calculates hash code according to all attributes.
99
+ # @return [Fixnum] Hash code
100
+ def hash
101
+ [name].hash
102
+ end
103
+
104
+ # Builds the object from hash
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ # @return [Object] Returns the model itself
107
+ def build_from_hash(attributes)
108
+ return nil unless attributes.is_a?(Hash)
109
+ self.class.swagger_types.each_pair do |key, type|
110
+ if type =~ /\AArray<(.*)>/i
111
+ # check to ensure the input is an array given that the the attribute
112
+ # is documented as an array but the input is not
113
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
114
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
115
+ end
116
+ elsif !attributes[self.class.attribute_map[key]].nil?
117
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
118
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
119
+ end
120
+
121
+ self
122
+ end
123
+
124
+ # Deserializes the data based on type
125
+ # @param string type Data type
126
+ # @param string value Value to be deserialized
127
+ # @return [Object] Deserialized data
128
+ def _deserialize(type, value)
129
+ case type.to_sym
130
+ when :DateTime
131
+ DateTime.parse(value)
132
+ when :Date
133
+ Date.parse(value)
134
+ when :String
135
+ value.to_s
136
+ when :Integer
137
+ value.to_i
138
+ when :Float
139
+ value.to_f
140
+ when :BOOLEAN
141
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
142
+ true
143
+ else
144
+ false
145
+ end
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
149
+ when /\AArray<(?<inner_type>.+)>\z/
150
+ inner_type = Regexp.last_match[:inner_type]
151
+ value.map { |v| _deserialize(inner_type, v) }
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
153
+ k_type = Regexp.last_match[:k_type]
154
+ v_type = Regexp.last_match[:v_type]
155
+ {}.tap do |hash|
156
+ value.each do |k, v|
157
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
158
+ end
159
+ end
160
+ else # model
161
+ temp_model = SquareConnect.const_get(type).new
162
+ temp_model.build_from_hash(value)
163
+ end
164
+ end
165
+
166
+ # Returns the string representation of the object
167
+ # @return [String] String presentation of the object
168
+ def to_s
169
+ to_hash.to_s
170
+ end
171
+
172
+ # to_body is an alias to to_hash (backward compatibility)
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_body
175
+ to_hash
176
+ end
177
+
178
+ # Returns the object in the form of hash
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_hash
181
+ hash = {}
182
+ self.class.attribute_map.each_pair do |attr, param|
183
+ value = self.send(attr)
184
+ next if value.nil?
185
+ hash[param] = _to_hash(value)
186
+ end
187
+ hash
188
+ end
189
+
190
+ # Outputs non-array value in the form of hash
191
+ # For object, use to_hash. Otherwise, just return the value
192
+ # @param [Object] value Any valid value
193
+ # @return [Hash] Returns the value in the form of hash
194
+ def _to_hash(value)
195
+ if value.is_a?(Array)
196
+ value.compact.map{ |v| _to_hash(v) }
197
+ elsif value.is_a?(Hash)
198
+ {}.tap do |hash|
199
+ value.each { |k, v| hash[k] = _to_hash(v) }
200
+ end
201
+ elsif value.respond_to? :to_hash
202
+ value.to_hash
203
+ else
204
+ value
205
+ end
206
+ end
207
+
208
+ end
209
+
210
+ end
@@ -0,0 +1,293 @@
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
+ # A discount in the Catalog object model.
14
+ class CatalogDiscount
15
+ # The discount's name. Searchable.
16
+ attr_accessor :name
17
+
18
+ # Indicates whether the discount is a fixed amount or percentage, or entered at the time of sale. See [CatalogDiscountType](#type-catalogdiscounttype) for all possible values.
19
+ attr_accessor :discount_type
20
+
21
+ # The percentage of the discount as a string representation of a decimal number, using a `.` as the decimal separator and without a `%` sign. A value of `7.5` corresponds to `7.5%`. Specify a percentage of `0` if `discount_type` is `VARIABLE_PERCENTAGE`. Do not include this field for amount-based or variable discounts.
22
+ attr_accessor :percentage
23
+
24
+ # The amount of the discount. Specify an amount of `0` if `discount_type` is `VARIABLE_AMOUNT`. Do not include this field for percentage-based or variable discounts.
25
+ attr_accessor :amount_money
26
+
27
+ # Indicates whether a mobile staff member needs to enter their PIN to apply the discount to a payment in the Square Point of Sale app.
28
+ attr_accessor :pin_required
29
+
30
+ # The color of the discount's display label in the Square Point of Sale app.
31
+ attr_accessor :label_color
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
+ :'name' => :'name',
59
+ :'discount_type' => :'discount_type',
60
+ :'percentage' => :'percentage',
61
+ :'amount_money' => :'amount_money',
62
+ :'pin_required' => :'pin_required',
63
+ :'label_color' => :'label_color'
64
+ }
65
+ end
66
+
67
+ # Attribute type mapping.
68
+ def self.swagger_types
69
+ {
70
+ :'name' => :'String',
71
+ :'discount_type' => :'String',
72
+ :'percentage' => :'String',
73
+ :'amount_money' => :'Money',
74
+ :'pin_required' => :'BOOLEAN',
75
+ :'label_color' => :'String'
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?(:'name')
88
+ self.name = attributes[:'name']
89
+ end
90
+
91
+ if attributes.has_key?(:'discount_type')
92
+ self.discount_type = attributes[:'discount_type']
93
+ end
94
+
95
+ if attributes.has_key?(:'percentage')
96
+ self.percentage = attributes[:'percentage']
97
+ end
98
+
99
+ if attributes.has_key?(:'amount_money')
100
+ self.amount_money = attributes[:'amount_money']
101
+ end
102
+
103
+ if attributes.has_key?(:'pin_required')
104
+ self.pin_required = attributes[:'pin_required']
105
+ end
106
+
107
+ if attributes.has_key?(:'label_color')
108
+ self.label_color = attributes[:'label_color']
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
+ if @name.nil?
118
+ invalid_properties.push("invalid value for 'name', name cannot be nil.")
119
+ end
120
+
121
+ if @name.to_s.length < 1
122
+ invalid_properties.push("invalid value for 'name', the character length must be great than or equal to 1.")
123
+ end
124
+
125
+ return invalid_properties
126
+ end
127
+
128
+ # Check to see if the all the properties in the model are valid
129
+ # @return true if the model is valid
130
+ def valid?
131
+ return false if @name.nil?
132
+ return false if @name.to_s.length < 1
133
+ discount_type_validator = EnumAttributeValidator.new('String', ["FIXED_PERCENTAGE", "FIXED_AMOUNT", "VARIABLE_PERCENTAGE", "VARIABLE_AMOUNT"])
134
+ return false unless discount_type_validator.valid?(@discount_type)
135
+ return true
136
+ end
137
+
138
+ # Custom attribute writer method with validation
139
+ # @param [Object] name Value to be assigned
140
+ def name=(name)
141
+ if name.nil?
142
+ fail ArgumentError, "name cannot be nil"
143
+ end
144
+
145
+ if name.to_s.length < 1
146
+ fail ArgumentError, "invalid value for 'name', the character length must be great than or equal to 1."
147
+ end
148
+
149
+ @name = name
150
+ end
151
+
152
+ # Custom attribute writer method checking allowed values (enum).
153
+ # @param [Object] discount_type Object to be assigned
154
+ def discount_type=(discount_type)
155
+ validator = EnumAttributeValidator.new('String', ["FIXED_PERCENTAGE", "FIXED_AMOUNT", "VARIABLE_PERCENTAGE", "VARIABLE_AMOUNT"])
156
+ unless validator.valid?(discount_type)
157
+ fail ArgumentError, "invalid value for 'discount_type', must be one of #{validator.allowable_values}."
158
+ end
159
+ @discount_type = discount_type
160
+ end
161
+
162
+ # Checks equality by comparing each attribute.
163
+ # @param [Object] Object to be compared
164
+ def ==(o)
165
+ return true if self.equal?(o)
166
+ self.class == o.class &&
167
+ name == o.name &&
168
+ discount_type == o.discount_type &&
169
+ percentage == o.percentage &&
170
+ amount_money == o.amount_money &&
171
+ pin_required == o.pin_required &&
172
+ label_color == o.label_color
173
+ end
174
+
175
+ # @see the `==` method
176
+ # @param [Object] Object to be compared
177
+ def eql?(o)
178
+ self == o
179
+ end
180
+
181
+ # Calculates hash code according to all attributes.
182
+ # @return [Fixnum] Hash code
183
+ def hash
184
+ [name, discount_type, percentage, amount_money, pin_required, label_color].hash
185
+ end
186
+
187
+ # Builds the object from hash
188
+ # @param [Hash] attributes Model attributes in the form of hash
189
+ # @return [Object] Returns the model itself
190
+ def build_from_hash(attributes)
191
+ return nil unless attributes.is_a?(Hash)
192
+ self.class.swagger_types.each_pair do |key, type|
193
+ if type =~ /\AArray<(.*)>/i
194
+ # check to ensure the input is an array given that the the attribute
195
+ # is documented as an array but the input is not
196
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
197
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
198
+ end
199
+ elsif !attributes[self.class.attribute_map[key]].nil?
200
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
201
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
202
+ end
203
+
204
+ self
205
+ end
206
+
207
+ # Deserializes the data based on type
208
+ # @param string type Data type
209
+ # @param string value Value to be deserialized
210
+ # @return [Object] Deserialized data
211
+ def _deserialize(type, value)
212
+ case type.to_sym
213
+ when :DateTime
214
+ DateTime.parse(value)
215
+ when :Date
216
+ Date.parse(value)
217
+ when :String
218
+ value.to_s
219
+ when :Integer
220
+ value.to_i
221
+ when :Float
222
+ value.to_f
223
+ when :BOOLEAN
224
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
225
+ true
226
+ else
227
+ false
228
+ end
229
+ when :Object
230
+ # generic object (usually a Hash), return directly
231
+ value
232
+ when /\AArray<(?<inner_type>.+)>\z/
233
+ inner_type = Regexp.last_match[:inner_type]
234
+ value.map { |v| _deserialize(inner_type, v) }
235
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
236
+ k_type = Regexp.last_match[:k_type]
237
+ v_type = Regexp.last_match[:v_type]
238
+ {}.tap do |hash|
239
+ value.each do |k, v|
240
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
241
+ end
242
+ end
243
+ else # model
244
+ temp_model = SquareConnect.const_get(type).new
245
+ temp_model.build_from_hash(value)
246
+ end
247
+ end
248
+
249
+ # Returns the string representation of the object
250
+ # @return [String] String presentation of the object
251
+ def to_s
252
+ to_hash.to_s
253
+ end
254
+
255
+ # to_body is an alias to to_hash (backward compatibility)
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_body
258
+ to_hash
259
+ end
260
+
261
+ # Returns the object in the form of hash
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_hash
264
+ hash = {}
265
+ self.class.attribute_map.each_pair do |attr, param|
266
+ value = self.send(attr)
267
+ next if value.nil?
268
+ hash[param] = _to_hash(value)
269
+ end
270
+ hash
271
+ end
272
+
273
+ # Outputs non-array value in the form of hash
274
+ # For object, use to_hash. Otherwise, just return the value
275
+ # @param [Object] value Any valid value
276
+ # @return [Hash] Returns the value in the form of hash
277
+ def _to_hash(value)
278
+ if value.is_a?(Array)
279
+ value.compact.map{ |v| _to_hash(v) }
280
+ elsif value.is_a?(Hash)
281
+ {}.tap do |hash|
282
+ value.each { |k, v| hash[k] = _to_hash(v) }
283
+ end
284
+ elsif value.respond_to? :to_hash
285
+ value.to_hash
286
+ else
287
+ value
288
+ end
289
+ end
290
+
291
+ end
292
+
293
+ end