square_connect 2.1.0.beta → 2.1.0.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,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 CatalogModifierListSelectionType
|
|
14
|
+
|
|
15
|
+
SINGLE = "SINGLE".freeze
|
|
16
|
+
MULTIPLE = "MULTIPLE".freeze
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,220 @@
|
|
|
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 CatalogModifierOverride
|
|
15
|
+
# The ID of the [CatalogModifier](#type-catalogmodifier) whose default behavior is being overridden.
|
|
16
|
+
attr_accessor :modifier_id
|
|
17
|
+
|
|
18
|
+
# If `true`, this [CatalogModifier](#type-catalogmodifier) should be selected by default for this [CatalogItem](#type-catalogitem).
|
|
19
|
+
attr_accessor :on_by_default
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
23
|
+
def self.attribute_map
|
|
24
|
+
{
|
|
25
|
+
:'modifier_id' => :'modifier_id',
|
|
26
|
+
:'on_by_default' => :'on_by_default'
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Attribute type mapping.
|
|
31
|
+
def self.swagger_types
|
|
32
|
+
{
|
|
33
|
+
:'modifier_id' => :'String',
|
|
34
|
+
:'on_by_default' => :'BOOLEAN'
|
|
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?(:'modifier_id')
|
|
47
|
+
self.modifier_id = attributes[:'modifier_id']
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if attributes.has_key?(:'on_by_default')
|
|
51
|
+
self.on_by_default = attributes[:'on_by_default']
|
|
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 @modifier_id.nil?
|
|
61
|
+
invalid_properties.push("invalid value for 'modifier_id', modifier_id cannot be nil.")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
if @modifier_id.to_s.length < 1
|
|
65
|
+
invalid_properties.push("invalid value for 'modifier_id', the character length must be great than or equal to 1.")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
return invalid_properties
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Check to see if the all the properties in the model are valid
|
|
72
|
+
# @return true if the model is valid
|
|
73
|
+
def valid?
|
|
74
|
+
return false if @modifier_id.nil?
|
|
75
|
+
return false if @modifier_id.to_s.length < 1
|
|
76
|
+
return true
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Custom attribute writer method with validation
|
|
80
|
+
# @param [Object] modifier_id Value to be assigned
|
|
81
|
+
def modifier_id=(modifier_id)
|
|
82
|
+
if modifier_id.nil?
|
|
83
|
+
fail ArgumentError, "modifier_id cannot be nil"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
if modifier_id.to_s.length < 1
|
|
87
|
+
fail ArgumentError, "invalid value for 'modifier_id', the character length must be great than or equal to 1."
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
@modifier_id = modifier_id
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Checks equality by comparing each attribute.
|
|
94
|
+
# @param [Object] Object to be compared
|
|
95
|
+
def ==(o)
|
|
96
|
+
return true if self.equal?(o)
|
|
97
|
+
self.class == o.class &&
|
|
98
|
+
modifier_id == o.modifier_id &&
|
|
99
|
+
on_by_default == o.on_by_default
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# @see the `==` method
|
|
103
|
+
# @param [Object] Object to be compared
|
|
104
|
+
def eql?(o)
|
|
105
|
+
self == o
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Calculates hash code according to all attributes.
|
|
109
|
+
# @return [Fixnum] Hash code
|
|
110
|
+
def hash
|
|
111
|
+
[modifier_id, on_by_default].hash
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Builds the object from hash
|
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
116
|
+
# @return [Object] Returns the model itself
|
|
117
|
+
def build_from_hash(attributes)
|
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
|
119
|
+
self.class.swagger_types.each_pair do |key, type|
|
|
120
|
+
if type =~ /\AArray<(.*)>/i
|
|
121
|
+
# check to ensure the input is an array given that the the attribute
|
|
122
|
+
# is documented as an array but the input is not
|
|
123
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
124
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
|
125
|
+
end
|
|
126
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
127
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
128
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
self
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Deserializes the data based on type
|
|
135
|
+
# @param string type Data type
|
|
136
|
+
# @param string value Value to be deserialized
|
|
137
|
+
# @return [Object] Deserialized data
|
|
138
|
+
def _deserialize(type, value)
|
|
139
|
+
case type.to_sym
|
|
140
|
+
when :DateTime
|
|
141
|
+
DateTime.parse(value)
|
|
142
|
+
when :Date
|
|
143
|
+
Date.parse(value)
|
|
144
|
+
when :String
|
|
145
|
+
value.to_s
|
|
146
|
+
when :Integer
|
|
147
|
+
value.to_i
|
|
148
|
+
when :Float
|
|
149
|
+
value.to_f
|
|
150
|
+
when :BOOLEAN
|
|
151
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
152
|
+
true
|
|
153
|
+
else
|
|
154
|
+
false
|
|
155
|
+
end
|
|
156
|
+
when :Object
|
|
157
|
+
# generic object (usually a Hash), return directly
|
|
158
|
+
value
|
|
159
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
160
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
161
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
162
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
163
|
+
k_type = Regexp.last_match[:k_type]
|
|
164
|
+
v_type = Regexp.last_match[:v_type]
|
|
165
|
+
{}.tap do |hash|
|
|
166
|
+
value.each do |k, v|
|
|
167
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
else # model
|
|
171
|
+
temp_model = SquareConnect.const_get(type).new
|
|
172
|
+
temp_model.build_from_hash(value)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Returns the string representation of the object
|
|
177
|
+
# @return [String] String presentation of the object
|
|
178
|
+
def to_s
|
|
179
|
+
to_hash.to_s
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
183
|
+
# @return [Hash] Returns the object in the form of hash
|
|
184
|
+
def to_body
|
|
185
|
+
to_hash
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
# Returns the object in the form of hash
|
|
189
|
+
# @return [Hash] Returns the object in the form of hash
|
|
190
|
+
def to_hash
|
|
191
|
+
hash = {}
|
|
192
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
193
|
+
value = self.send(attr)
|
|
194
|
+
next if value.nil?
|
|
195
|
+
hash[param] = _to_hash(value)
|
|
196
|
+
end
|
|
197
|
+
hash
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# Outputs non-array value in the form of hash
|
|
201
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
202
|
+
# @param [Object] value Any valid value
|
|
203
|
+
# @return [Hash] Returns the value in the form of hash
|
|
204
|
+
def _to_hash(value)
|
|
205
|
+
if value.is_a?(Array)
|
|
206
|
+
value.compact.map{ |v| _to_hash(v) }
|
|
207
|
+
elsif value.is_a?(Hash)
|
|
208
|
+
{}.tap do |hash|
|
|
209
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
210
|
+
end
|
|
211
|
+
elsif value.respond_to? :to_hash
|
|
212
|
+
value.to_hash
|
|
213
|
+
else
|
|
214
|
+
value
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
end
|
|
@@ -0,0 +1,404 @@
|
|
|
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
|
+
# The wrapper object for object types in the Catalog data model. The type of a particular `CatalogObject` is determined by the value of `type` and only the corresponding data field may be set. - if type = `ITEM`, only `item_data` will be populated and it will contain a valid [CatalogItem](#type-catalogitem) object. - if type = `ITEM_VARIATION`, only `item_variation_data` will be populated and it will contain a valid [CatalogItemVariation](#type-catalogitemvariation) object. - if type = `MODIFIER`, only `modifier_data` will be populated and it will contain a valid [CatalogModifier](#type-catalogmodifier) object. - if type = `MODIFIER_LIST`, only `modifier_list_data` will be populated and it will contain a valid [CatalogModifierList](#type-catalogmodifierlist) object. - if type = `CATEGORY`, only `category_data` will be populated and it will contain a valid [CatalogCategory](#type-catalogcategory) object. - if type = `DISCOUNT`, only `discount_data` will be populated and it will contain a valid [CatalogDiscount](#type-catalogdiscount) object. - if type = `TAX`, only `tax_data` will be populated and it will contain a valid [CatalogTax](#type-catalogtax) object. For a more detailed discussion of the Catalog data model, please see the [Catalog Overview](https://docs.connect.squareup.com/articles/catalog-overview).
|
|
14
|
+
class CatalogObject
|
|
15
|
+
# The type of this object. Each object type has expected properties expressed in a structured format within its corresponding `*_data` field below. See [CatalogObjectType](#type-catalogobjecttype) for all possible values.
|
|
16
|
+
attr_accessor :type
|
|
17
|
+
|
|
18
|
+
# A unique Square-assigned identifier to reference this object in the catalog.
|
|
19
|
+
attr_accessor :id
|
|
20
|
+
|
|
21
|
+
# Last modification [timestamp](#workingwithdates) in RFC 3339 format, e.g., `\"2016-08-15T23:59:33.123Z\"` would indicate the UTC time (denoted by `Z`) of August 15, 2016 at 23:59:33 and 123 milliseconds.
|
|
22
|
+
attr_accessor :updated_at
|
|
23
|
+
|
|
24
|
+
# The version of the object. When updating an object, the version supplied by the must match the version in the database, otherwise the write will be rejected as conflicting.
|
|
25
|
+
attr_accessor :version
|
|
26
|
+
|
|
27
|
+
# If `true`, the object has been deleted from the database. Must be `false` for new objects being inserted. When deleted, the `updated_at` field will equal the deletion time. being inserted. When deleted, the `updated_at` field will equal the deletion time.
|
|
28
|
+
attr_accessor :is_deleted
|
|
29
|
+
|
|
30
|
+
# The Connect V1 IDs for this object at each location where it is present, where they differ from the object's Connect V2 ID. The field will only be present for objects that have been created or modified by legacy APIs.
|
|
31
|
+
attr_accessor :catalog_v1_ids
|
|
32
|
+
|
|
33
|
+
# If `true`, this object is present at all locations (including future locations), except where specified in the `absent_at_location_ids` field. If `false`, this object is not present at any locations (including future locations), except where specified in the `present_at_location_ids` field.
|
|
34
|
+
attr_accessor :present_at_all_locations
|
|
35
|
+
|
|
36
|
+
# A list of locations where the object is present, even if `present_at_all_locations` is `false`.
|
|
37
|
+
attr_accessor :present_at_location_ids
|
|
38
|
+
|
|
39
|
+
# A list of locations where the object is not present, even if `present_at_all_locations` is `true`.
|
|
40
|
+
attr_accessor :absent_at_location_ids
|
|
41
|
+
|
|
42
|
+
# Structured data for a [CatalogItem](#type-catalogitem), set for CatalogObjects of type `ITEM`.
|
|
43
|
+
attr_accessor :item_data
|
|
44
|
+
|
|
45
|
+
# Structured data for a [CatalogCategory](#type-catalogcategory), set for CatalogObjects of type `CATEGORY`.
|
|
46
|
+
attr_accessor :category_data
|
|
47
|
+
|
|
48
|
+
# Structured data for a [CatalogItemVariation](#type-catalogitemvariation), set for CatalogObjects of type `ITEM_VARIATION`.
|
|
49
|
+
attr_accessor :item_variation_data
|
|
50
|
+
|
|
51
|
+
# Structured data for a [CatalogTax](#type-catalogtax), set for CatalogObjects of type `TAX`.
|
|
52
|
+
attr_accessor :tax_data
|
|
53
|
+
|
|
54
|
+
# Structured data for a [CatalogDiscount](#type-catalogdiscount), set for CatalogObjects of type `DISCOUNT`.
|
|
55
|
+
attr_accessor :discount_data
|
|
56
|
+
|
|
57
|
+
# Structured data for a [CatalogModifierList](#type-catalogmodifierlist), set for CatalogObjects of type `MODIFIER_LIST`.
|
|
58
|
+
attr_accessor :modifier_list_data
|
|
59
|
+
|
|
60
|
+
# Structured data for a [CatalogModifier](#type-catalogmodifier), set for CatalogObjects of type `MODIFIER`.
|
|
61
|
+
attr_accessor :modifier_data
|
|
62
|
+
|
|
63
|
+
class EnumAttributeValidator
|
|
64
|
+
attr_reader :datatype
|
|
65
|
+
attr_reader :allowable_values
|
|
66
|
+
|
|
67
|
+
def initialize(datatype, allowable_values)
|
|
68
|
+
@allowable_values = allowable_values.map do |value|
|
|
69
|
+
case datatype.to_s
|
|
70
|
+
when /Integer/i
|
|
71
|
+
value.to_i
|
|
72
|
+
when /Float/i
|
|
73
|
+
value.to_f
|
|
74
|
+
else
|
|
75
|
+
value
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def valid?(value)
|
|
81
|
+
!value || allowable_values.include?(value)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
86
|
+
def self.attribute_map
|
|
87
|
+
{
|
|
88
|
+
:'type' => :'type',
|
|
89
|
+
:'id' => :'id',
|
|
90
|
+
:'updated_at' => :'updated_at',
|
|
91
|
+
:'version' => :'version',
|
|
92
|
+
:'is_deleted' => :'is_deleted',
|
|
93
|
+
:'catalog_v1_ids' => :'catalog_v1_ids',
|
|
94
|
+
:'present_at_all_locations' => :'present_at_all_locations',
|
|
95
|
+
:'present_at_location_ids' => :'present_at_location_ids',
|
|
96
|
+
:'absent_at_location_ids' => :'absent_at_location_ids',
|
|
97
|
+
:'item_data' => :'item_data',
|
|
98
|
+
:'category_data' => :'category_data',
|
|
99
|
+
:'item_variation_data' => :'item_variation_data',
|
|
100
|
+
:'tax_data' => :'tax_data',
|
|
101
|
+
:'discount_data' => :'discount_data',
|
|
102
|
+
:'modifier_list_data' => :'modifier_list_data',
|
|
103
|
+
:'modifier_data' => :'modifier_data'
|
|
104
|
+
}
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Attribute type mapping.
|
|
108
|
+
def self.swagger_types
|
|
109
|
+
{
|
|
110
|
+
:'type' => :'String',
|
|
111
|
+
:'id' => :'String',
|
|
112
|
+
:'updated_at' => :'String',
|
|
113
|
+
:'version' => :'Integer',
|
|
114
|
+
:'is_deleted' => :'BOOLEAN',
|
|
115
|
+
:'catalog_v1_ids' => :'Array<CatalogV1Id>',
|
|
116
|
+
:'present_at_all_locations' => :'BOOLEAN',
|
|
117
|
+
:'present_at_location_ids' => :'Array<String>',
|
|
118
|
+
:'absent_at_location_ids' => :'Array<String>',
|
|
119
|
+
:'item_data' => :'CatalogItem',
|
|
120
|
+
:'category_data' => :'CatalogCategory',
|
|
121
|
+
:'item_variation_data' => :'CatalogItemVariation',
|
|
122
|
+
:'tax_data' => :'CatalogTax',
|
|
123
|
+
:'discount_data' => :'CatalogDiscount',
|
|
124
|
+
:'modifier_list_data' => :'CatalogModifierList',
|
|
125
|
+
:'modifier_data' => :'CatalogModifier'
|
|
126
|
+
}
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Initializes the object
|
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
131
|
+
def initialize(attributes = {})
|
|
132
|
+
return unless attributes.is_a?(Hash)
|
|
133
|
+
|
|
134
|
+
# convert string to symbol for hash key
|
|
135
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
|
136
|
+
|
|
137
|
+
if attributes.has_key?(:'type')
|
|
138
|
+
self.type = attributes[:'type']
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
if attributes.has_key?(:'id')
|
|
142
|
+
self.id = attributes[:'id']
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
if attributes.has_key?(:'updated_at')
|
|
146
|
+
self.updated_at = attributes[:'updated_at']
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
if attributes.has_key?(:'version')
|
|
150
|
+
self.version = attributes[:'version']
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
if attributes.has_key?(:'is_deleted')
|
|
154
|
+
self.is_deleted = attributes[:'is_deleted']
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
if attributes.has_key?(:'catalog_v1_ids')
|
|
158
|
+
if (value = attributes[:'catalog_v1_ids']).is_a?(Array)
|
|
159
|
+
self.catalog_v1_ids = value
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
if attributes.has_key?(:'present_at_all_locations')
|
|
164
|
+
self.present_at_all_locations = attributes[:'present_at_all_locations']
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
if attributes.has_key?(:'present_at_location_ids')
|
|
168
|
+
if (value = attributes[:'present_at_location_ids']).is_a?(Array)
|
|
169
|
+
self.present_at_location_ids = value
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
if attributes.has_key?(:'absent_at_location_ids')
|
|
174
|
+
if (value = attributes[:'absent_at_location_ids']).is_a?(Array)
|
|
175
|
+
self.absent_at_location_ids = value
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if attributes.has_key?(:'item_data')
|
|
180
|
+
self.item_data = attributes[:'item_data']
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
if attributes.has_key?(:'category_data')
|
|
184
|
+
self.category_data = attributes[:'category_data']
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
if attributes.has_key?(:'item_variation_data')
|
|
188
|
+
self.item_variation_data = attributes[:'item_variation_data']
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
if attributes.has_key?(:'tax_data')
|
|
192
|
+
self.tax_data = attributes[:'tax_data']
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
if attributes.has_key?(:'discount_data')
|
|
196
|
+
self.discount_data = attributes[:'discount_data']
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
if attributes.has_key?(:'modifier_list_data')
|
|
200
|
+
self.modifier_list_data = attributes[:'modifier_list_data']
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
if attributes.has_key?(:'modifier_data')
|
|
204
|
+
self.modifier_data = attributes[:'modifier_data']
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
210
|
+
# @return Array for valid properies with the reasons
|
|
211
|
+
def list_invalid_properties
|
|
212
|
+
invalid_properties = Array.new
|
|
213
|
+
if @type.nil?
|
|
214
|
+
invalid_properties.push("invalid value for 'type', type cannot be nil.")
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
if @id.nil?
|
|
218
|
+
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
if @id.to_s.length < 1
|
|
222
|
+
invalid_properties.push("invalid value for 'id', the character length must be great than or equal to 1.")
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
return invalid_properties
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Check to see if the all the properties in the model are valid
|
|
229
|
+
# @return true if the model is valid
|
|
230
|
+
def valid?
|
|
231
|
+
return false if @type.nil?
|
|
232
|
+
type_validator = EnumAttributeValidator.new('String', ["ITEM", "CATEGORY", "ITEM_VARIATION", "TAX", "DISCOUNT", "MODIFIER_LIST", "MODIFIER"])
|
|
233
|
+
return false unless type_validator.valid?(@type)
|
|
234
|
+
return false if @id.nil?
|
|
235
|
+
return false if @id.to_s.length < 1
|
|
236
|
+
return true
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# Custom attribute writer method checking allowed values (enum).
|
|
240
|
+
# @param [Object] type Object to be assigned
|
|
241
|
+
def type=(type)
|
|
242
|
+
validator = EnumAttributeValidator.new('String', ["ITEM", "CATEGORY", "ITEM_VARIATION", "TAX", "DISCOUNT", "MODIFIER_LIST", "MODIFIER"])
|
|
243
|
+
unless validator.valid?(type)
|
|
244
|
+
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
|
245
|
+
end
|
|
246
|
+
@type = type
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Custom attribute writer method with validation
|
|
250
|
+
# @param [Object] id Value to be assigned
|
|
251
|
+
def id=(id)
|
|
252
|
+
if id.nil?
|
|
253
|
+
fail ArgumentError, "id cannot be nil"
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
if id.to_s.length < 1
|
|
257
|
+
fail ArgumentError, "invalid value for 'id', the character length must be great than or equal to 1."
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
@id = id
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# Checks equality by comparing each attribute.
|
|
264
|
+
# @param [Object] Object to be compared
|
|
265
|
+
def ==(o)
|
|
266
|
+
return true if self.equal?(o)
|
|
267
|
+
self.class == o.class &&
|
|
268
|
+
type == o.type &&
|
|
269
|
+
id == o.id &&
|
|
270
|
+
updated_at == o.updated_at &&
|
|
271
|
+
version == o.version &&
|
|
272
|
+
is_deleted == o.is_deleted &&
|
|
273
|
+
catalog_v1_ids == o.catalog_v1_ids &&
|
|
274
|
+
present_at_all_locations == o.present_at_all_locations &&
|
|
275
|
+
present_at_location_ids == o.present_at_location_ids &&
|
|
276
|
+
absent_at_location_ids == o.absent_at_location_ids &&
|
|
277
|
+
item_data == o.item_data &&
|
|
278
|
+
category_data == o.category_data &&
|
|
279
|
+
item_variation_data == o.item_variation_data &&
|
|
280
|
+
tax_data == o.tax_data &&
|
|
281
|
+
discount_data == o.discount_data &&
|
|
282
|
+
modifier_list_data == o.modifier_list_data &&
|
|
283
|
+
modifier_data == o.modifier_data
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
# @see the `==` method
|
|
287
|
+
# @param [Object] Object to be compared
|
|
288
|
+
def eql?(o)
|
|
289
|
+
self == o
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
# Calculates hash code according to all attributes.
|
|
293
|
+
# @return [Fixnum] Hash code
|
|
294
|
+
def hash
|
|
295
|
+
[type, id, updated_at, version, is_deleted, catalog_v1_ids, present_at_all_locations, present_at_location_ids, absent_at_location_ids, item_data, category_data, item_variation_data, tax_data, discount_data, modifier_list_data, modifier_data].hash
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Builds the object from hash
|
|
299
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
300
|
+
# @return [Object] Returns the model itself
|
|
301
|
+
def build_from_hash(attributes)
|
|
302
|
+
return nil unless attributes.is_a?(Hash)
|
|
303
|
+
self.class.swagger_types.each_pair do |key, type|
|
|
304
|
+
if type =~ /\AArray<(.*)>/i
|
|
305
|
+
# check to ensure the input is an array given that the the attribute
|
|
306
|
+
# is documented as an array but the input is not
|
|
307
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
|
308
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
|
309
|
+
end
|
|
310
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
|
311
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
|
312
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
self
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# Deserializes the data based on type
|
|
319
|
+
# @param string type Data type
|
|
320
|
+
# @param string value Value to be deserialized
|
|
321
|
+
# @return [Object] Deserialized data
|
|
322
|
+
def _deserialize(type, value)
|
|
323
|
+
case type.to_sym
|
|
324
|
+
when :DateTime
|
|
325
|
+
DateTime.parse(value)
|
|
326
|
+
when :Date
|
|
327
|
+
Date.parse(value)
|
|
328
|
+
when :String
|
|
329
|
+
value.to_s
|
|
330
|
+
when :Integer
|
|
331
|
+
value.to_i
|
|
332
|
+
when :Float
|
|
333
|
+
value.to_f
|
|
334
|
+
when :BOOLEAN
|
|
335
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
336
|
+
true
|
|
337
|
+
else
|
|
338
|
+
false
|
|
339
|
+
end
|
|
340
|
+
when :Object
|
|
341
|
+
# generic object (usually a Hash), return directly
|
|
342
|
+
value
|
|
343
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
344
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
345
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
346
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
347
|
+
k_type = Regexp.last_match[:k_type]
|
|
348
|
+
v_type = Regexp.last_match[:v_type]
|
|
349
|
+
{}.tap do |hash|
|
|
350
|
+
value.each do |k, v|
|
|
351
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
else # model
|
|
355
|
+
temp_model = SquareConnect.const_get(type).new
|
|
356
|
+
temp_model.build_from_hash(value)
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Returns the string representation of the object
|
|
361
|
+
# @return [String] String presentation of the object
|
|
362
|
+
def to_s
|
|
363
|
+
to_hash.to_s
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
367
|
+
# @return [Hash] Returns the object in the form of hash
|
|
368
|
+
def to_body
|
|
369
|
+
to_hash
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# Returns the object in the form of hash
|
|
373
|
+
# @return [Hash] Returns the object in the form of hash
|
|
374
|
+
def to_hash
|
|
375
|
+
hash = {}
|
|
376
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
377
|
+
value = self.send(attr)
|
|
378
|
+
next if value.nil?
|
|
379
|
+
hash[param] = _to_hash(value)
|
|
380
|
+
end
|
|
381
|
+
hash
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
# Outputs non-array value in the form of hash
|
|
385
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
386
|
+
# @param [Object] value Any valid value
|
|
387
|
+
# @return [Hash] Returns the value in the form of hash
|
|
388
|
+
def _to_hash(value)
|
|
389
|
+
if value.is_a?(Array)
|
|
390
|
+
value.compact.map{ |v| _to_hash(v) }
|
|
391
|
+
elsif value.is_a?(Hash)
|
|
392
|
+
{}.tap do |hash|
|
|
393
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
394
|
+
end
|
|
395
|
+
elsif value.respond_to? :to_hash
|
|
396
|
+
value.to_hash
|
|
397
|
+
else
|
|
398
|
+
value
|
|
399
|
+
end
|
|
400
|
+
end
|
|
401
|
+
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
end
|