noths 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/README.md +149 -0
- data/Rakefile +8 -0
- data/bin/generate_gem +18 -0
- data/bin/refresh_schemas +94 -0
- data/docs/AcceptanceBulkModel.md +11 -0
- data/docs/Currency.md +11 -0
- data/docs/DeclineBulkModel.md +9 -0
- data/docs/DeliveryAddress.md +13 -0
- data/docs/DeliveryService.md +9 -0
- data/docs/DeliveryZone.md +9 -0
- data/docs/DispatchBulkModel.md +12 -0
- data/docs/DispatchNotesBulkModel.md +8 -0
- data/docs/Enquiry.md +10 -0
- data/docs/EnquiryMessage.md +8 -0
- data/docs/Error.md +9 -0
- data/docs/Financials.md +25 -0
- data/docs/FinancialsDetails.md +10 -0
- data/docs/ImageUrl.md +13 -0
- data/docs/Item.md +15 -0
- data/docs/ItemFinancials.md +13 -0
- data/docs/Link.md +10 -0
- data/docs/ManualPayment.md +11 -0
- data/docs/Money.md +9 -0
- data/docs/Order.md +53 -0
- data/docs/OrderDetail.md +9 -0
- data/docs/OrderDetailsBulkModel.md +8 -0
- data/docs/OrderIndex.md +10 -0
- data/docs/OrderRefund.md +8 -0
- data/docs/OrdersApi.md +796 -0
- data/docs/Product.md +12 -0
- data/docs/ProductOption.md +9 -0
- data/docs/RefundResponse.md +10 -0
- data/docs/RefundsApi.md +69 -0
- data/docs/SearchResultMeta.md +9 -0
- data/docs/User.md +10 -0
- data/lib/noths.rb +70 -0
- data/lib/noths/api/orders_api.rb +819 -0
- data/lib/noths/api/refunds_api.rb +88 -0
- data/lib/noths/api_client.rb +389 -0
- data/lib/noths/api_error.rb +38 -0
- data/lib/noths/configuration.rb +209 -0
- data/lib/noths/models/acceptance_bulk_model.rb +233 -0
- data/lib/noths/models/currency.rb +235 -0
- data/lib/noths/models/decline_bulk_model.rb +208 -0
- data/lib/noths/models/delivery_address.rb +263 -0
- data/lib/noths/models/delivery_service.rb +207 -0
- data/lib/noths/models/delivery_zone.rb +207 -0
- data/lib/noths/models/dispatch_bulk_model.rb +236 -0
- data/lib/noths/models/dispatch_notes_bulk_model.rb +194 -0
- data/lib/noths/models/enquiry.rb +223 -0
- data/lib/noths/models/enquiry_message.rb +193 -0
- data/lib/noths/models/error.rb +207 -0
- data/lib/noths/models/financials.rb +433 -0
- data/lib/noths/models/financials_details.rb +221 -0
- data/lib/noths/models/image_url.rb +263 -0
- data/lib/noths/models/item.rb +293 -0
- data/lib/noths/models/item_financials.rb +263 -0
- data/lib/noths/models/link.rb +222 -0
- data/lib/noths/models/manual_payment.rb +235 -0
- data/lib/noths/models/money.rb +207 -0
- data/lib/noths/models/order.rb +812 -0
- data/lib/noths/models/order_detail.rb +207 -0
- data/lib/noths/models/order_details_bulk_model.rb +194 -0
- data/lib/noths/models/order_index.rb +225 -0
- data/lib/noths/models/order_refund.rb +193 -0
- data/lib/noths/models/product.rb +249 -0
- data/lib/noths/models/product_option.rb +207 -0
- data/lib/noths/models/refund_response.rb +223 -0
- data/lib/noths/models/search_result_meta.rb +207 -0
- data/lib/noths/models/user.rb +221 -0
- data/lib/noths/version.rb +15 -0
- data/noths.gemspec +45 -0
- data/schemas/api-docs.json +26 -0
- data/schemas/orders.json +2013 -0
- data/schemas/refunds.json +128 -0
- data/spec/api/orders_api_spec.rb +239 -0
- data/spec/api/refunds_api_spec.rb +50 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/acceptance_bulk_model_spec.rb +60 -0
- data/spec/models/currency_spec.rb +60 -0
- data/spec/models/decline_bulk_model_spec.rb +48 -0
- data/spec/models/delivery_address_spec.rb +72 -0
- data/spec/models/delivery_service_spec.rb +48 -0
- data/spec/models/delivery_zone_spec.rb +48 -0
- data/spec/models/dispatch_bulk_model_spec.rb +66 -0
- data/spec/models/dispatch_notes_bulk_model_spec.rb +42 -0
- data/spec/models/enquiry_message_spec.rb +42 -0
- data/spec/models/enquiry_spec.rb +54 -0
- data/spec/models/error_spec.rb +48 -0
- data/spec/models/financials_details_spec.rb +54 -0
- data/spec/models/financials_spec.rb +144 -0
- data/spec/models/image_url_spec.rb +72 -0
- data/spec/models/item_financials_spec.rb +72 -0
- data/spec/models/item_spec.rb +84 -0
- data/spec/models/link_spec.rb +54 -0
- data/spec/models/manual_payment_spec.rb +60 -0
- data/spec/models/money_spec.rb +48 -0
- data/spec/models/order_detail_spec.rb +48 -0
- data/spec/models/order_details_bulk_model_spec.rb +42 -0
- data/spec/models/order_index_spec.rb +54 -0
- data/spec/models/order_refund_spec.rb +42 -0
- data/spec/models/order_spec.rb +312 -0
- data/spec/models/product_option_spec.rb +48 -0
- data/spec/models/product_spec.rb +66 -0
- data/spec/models/refund_response_spec.rb +54 -0
- data/spec/models/search_result_meta_spec.rb +48 -0
- data/spec/models/user_spec.rb +54 -0
- data/spec/spec_helper.rb +111 -0
- data/swagger_config.json +16 -0
- metadata +370 -0
@@ -0,0 +1,193 @@
|
|
1
|
+
=begin
|
2
|
+
#Noths
|
3
|
+
|
4
|
+
#www.notonthehighstreet.com API client
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Noths
|
16
|
+
|
17
|
+
class OrderRefund
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:'id' => :'id'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# Attribute type mapping.
|
29
|
+
def self.swagger_types
|
30
|
+
{
|
31
|
+
:'id' => :'Integer'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Initializes the object
|
36
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
37
|
+
def initialize(attributes = {})
|
38
|
+
return unless attributes.is_a?(Hash)
|
39
|
+
|
40
|
+
# convert string to symbol for hash key
|
41
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
42
|
+
|
43
|
+
if attributes.has_key?(:'id')
|
44
|
+
self.id = attributes[:'id']
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
50
|
+
# @return Array for valid properties with the reasons
|
51
|
+
def list_invalid_properties
|
52
|
+
invalid_properties = Array.new
|
53
|
+
if @id.nil?
|
54
|
+
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
55
|
+
end
|
56
|
+
|
57
|
+
return invalid_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check to see if the all the properties in the model are valid
|
61
|
+
# @return true if the model is valid
|
62
|
+
def valid?
|
63
|
+
return false if @id.nil?
|
64
|
+
return true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checks equality by comparing each attribute.
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def ==(o)
|
70
|
+
return true if self.equal?(o)
|
71
|
+
self.class == o.class &&
|
72
|
+
id == o.id
|
73
|
+
end
|
74
|
+
|
75
|
+
# @see the `==` method
|
76
|
+
# @param [Object] Object to be compared
|
77
|
+
def eql?(o)
|
78
|
+
self == o
|
79
|
+
end
|
80
|
+
|
81
|
+
# Calculates hash code according to all attributes.
|
82
|
+
# @return [Fixnum] Hash code
|
83
|
+
def hash
|
84
|
+
[id].hash
|
85
|
+
end
|
86
|
+
|
87
|
+
# Builds the object from hash
|
88
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
89
|
+
# @return [Object] Returns the model itself
|
90
|
+
def build_from_hash(attributes)
|
91
|
+
return nil unless attributes.is_a?(Hash)
|
92
|
+
self.class.swagger_types.each_pair do |key, type|
|
93
|
+
if type =~ /\AArray<(.*)>/i
|
94
|
+
# check to ensure the input is an array given that the the attribute
|
95
|
+
# is documented as an array but the input is not
|
96
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
97
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
98
|
+
end
|
99
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
100
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
101
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
102
|
+
end
|
103
|
+
|
104
|
+
self
|
105
|
+
end
|
106
|
+
|
107
|
+
# Deserializes the data based on type
|
108
|
+
# @param string type Data type
|
109
|
+
# @param string value Value to be deserialized
|
110
|
+
# @return [Object] Deserialized data
|
111
|
+
def _deserialize(type, value)
|
112
|
+
case type.to_sym
|
113
|
+
when :DateTime
|
114
|
+
DateTime.parse(value)
|
115
|
+
when :Date
|
116
|
+
Date.parse(value)
|
117
|
+
when :String
|
118
|
+
value.to_s
|
119
|
+
when :Integer
|
120
|
+
value.to_i
|
121
|
+
when :Float
|
122
|
+
value.to_f
|
123
|
+
when :BOOLEAN
|
124
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
125
|
+
true
|
126
|
+
else
|
127
|
+
false
|
128
|
+
end
|
129
|
+
when :Object
|
130
|
+
# generic object (usually a Hash), return directly
|
131
|
+
value
|
132
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
133
|
+
inner_type = Regexp.last_match[:inner_type]
|
134
|
+
value.map { |v| _deserialize(inner_type, v) }
|
135
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
136
|
+
k_type = Regexp.last_match[:k_type]
|
137
|
+
v_type = Regexp.last_match[:v_type]
|
138
|
+
{}.tap do |hash|
|
139
|
+
value.each do |k, v|
|
140
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
else # model
|
144
|
+
temp_model = Noths.const_get(type).new
|
145
|
+
temp_model.build_from_hash(value)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Returns the string representation of the object
|
150
|
+
# @return [String] String presentation of the object
|
151
|
+
def to_s
|
152
|
+
to_hash.to_s
|
153
|
+
end
|
154
|
+
|
155
|
+
# to_body is an alias to to_hash (backward compatibility)
|
156
|
+
# @return [Hash] Returns the object in the form of hash
|
157
|
+
def to_body
|
158
|
+
to_hash
|
159
|
+
end
|
160
|
+
|
161
|
+
# Returns the object in the form of hash
|
162
|
+
# @return [Hash] Returns the object in the form of hash
|
163
|
+
def to_hash
|
164
|
+
hash = {}
|
165
|
+
self.class.attribute_map.each_pair do |attr, param|
|
166
|
+
value = self.send(attr)
|
167
|
+
next if value.nil?
|
168
|
+
hash[param] = _to_hash(value)
|
169
|
+
end
|
170
|
+
hash
|
171
|
+
end
|
172
|
+
|
173
|
+
# Outputs non-array value in the form of hash
|
174
|
+
# For object, use to_hash. Otherwise, just return the value
|
175
|
+
# @param [Object] value Any valid value
|
176
|
+
# @return [Hash] Returns the value in the form of hash
|
177
|
+
def _to_hash(value)
|
178
|
+
if value.is_a?(Array)
|
179
|
+
value.compact.map{ |v| _to_hash(v) }
|
180
|
+
elsif value.is_a?(Hash)
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
183
|
+
end
|
184
|
+
elsif value.respond_to? :to_hash
|
185
|
+
value.to_hash
|
186
|
+
else
|
187
|
+
value
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
=begin
|
2
|
+
#Noths
|
3
|
+
|
4
|
+
#www.notonthehighstreet.com API client
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Noths
|
16
|
+
|
17
|
+
class Product
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :sku
|
21
|
+
|
22
|
+
attr_accessor :title
|
23
|
+
|
24
|
+
attr_accessor :personalisable
|
25
|
+
|
26
|
+
attr_accessor :image
|
27
|
+
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'id' => :'id',
|
33
|
+
:'sku' => :'sku',
|
34
|
+
:'title' => :'title',
|
35
|
+
:'personalisable' => :'personalisable',
|
36
|
+
:'image' => :'image'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Attribute type mapping.
|
41
|
+
def self.swagger_types
|
42
|
+
{
|
43
|
+
:'id' => :'Integer',
|
44
|
+
:'sku' => :'String',
|
45
|
+
:'title' => :'String',
|
46
|
+
:'personalisable' => :'BOOLEAN',
|
47
|
+
:'image' => :'ImageUrl'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Initializes the object
|
52
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
53
|
+
def initialize(attributes = {})
|
54
|
+
return unless attributes.is_a?(Hash)
|
55
|
+
|
56
|
+
# convert string to symbol for hash key
|
57
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
58
|
+
|
59
|
+
if attributes.has_key?(:'id')
|
60
|
+
self.id = attributes[:'id']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'sku')
|
64
|
+
self.sku = attributes[:'sku']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.has_key?(:'title')
|
68
|
+
self.title = attributes[:'title']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.has_key?(:'personalisable')
|
72
|
+
self.personalisable = attributes[:'personalisable']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes.has_key?(:'image')
|
76
|
+
self.image = attributes[:'image']
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
82
|
+
# @return Array for valid properties with the reasons
|
83
|
+
def list_invalid_properties
|
84
|
+
invalid_properties = Array.new
|
85
|
+
if @id.nil?
|
86
|
+
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
87
|
+
end
|
88
|
+
|
89
|
+
if @sku.nil?
|
90
|
+
invalid_properties.push("invalid value for 'sku', sku cannot be nil.")
|
91
|
+
end
|
92
|
+
|
93
|
+
if @title.nil?
|
94
|
+
invalid_properties.push("invalid value for 'title', title cannot be nil.")
|
95
|
+
end
|
96
|
+
|
97
|
+
if @personalisable.nil?
|
98
|
+
invalid_properties.push("invalid value for 'personalisable', personalisable cannot be nil.")
|
99
|
+
end
|
100
|
+
|
101
|
+
if @image.nil?
|
102
|
+
invalid_properties.push("invalid value for 'image', image cannot be nil.")
|
103
|
+
end
|
104
|
+
|
105
|
+
return invalid_properties
|
106
|
+
end
|
107
|
+
|
108
|
+
# Check to see if the all the properties in the model are valid
|
109
|
+
# @return true if the model is valid
|
110
|
+
def valid?
|
111
|
+
return false if @id.nil?
|
112
|
+
return false if @sku.nil?
|
113
|
+
return false if @title.nil?
|
114
|
+
return false if @personalisable.nil?
|
115
|
+
return false if @image.nil?
|
116
|
+
return true
|
117
|
+
end
|
118
|
+
|
119
|
+
# Checks equality by comparing each attribute.
|
120
|
+
# @param [Object] Object to be compared
|
121
|
+
def ==(o)
|
122
|
+
return true if self.equal?(o)
|
123
|
+
self.class == o.class &&
|
124
|
+
id == o.id &&
|
125
|
+
sku == o.sku &&
|
126
|
+
title == o.title &&
|
127
|
+
personalisable == o.personalisable &&
|
128
|
+
image == o.image
|
129
|
+
end
|
130
|
+
|
131
|
+
# @see the `==` method
|
132
|
+
# @param [Object] Object to be compared
|
133
|
+
def eql?(o)
|
134
|
+
self == o
|
135
|
+
end
|
136
|
+
|
137
|
+
# Calculates hash code according to all attributes.
|
138
|
+
# @return [Fixnum] Hash code
|
139
|
+
def hash
|
140
|
+
[id, sku, title, personalisable, image].hash
|
141
|
+
end
|
142
|
+
|
143
|
+
# Builds the object from hash
|
144
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
145
|
+
# @return [Object] Returns the model itself
|
146
|
+
def build_from_hash(attributes)
|
147
|
+
return nil unless attributes.is_a?(Hash)
|
148
|
+
self.class.swagger_types.each_pair do |key, type|
|
149
|
+
if type =~ /\AArray<(.*)>/i
|
150
|
+
# check to ensure the input is an array given that the the attribute
|
151
|
+
# is documented as an array but the input is not
|
152
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
153
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
154
|
+
end
|
155
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
156
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
157
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
158
|
+
end
|
159
|
+
|
160
|
+
self
|
161
|
+
end
|
162
|
+
|
163
|
+
# Deserializes the data based on type
|
164
|
+
# @param string type Data type
|
165
|
+
# @param string value Value to be deserialized
|
166
|
+
# @return [Object] Deserialized data
|
167
|
+
def _deserialize(type, value)
|
168
|
+
case type.to_sym
|
169
|
+
when :DateTime
|
170
|
+
DateTime.parse(value)
|
171
|
+
when :Date
|
172
|
+
Date.parse(value)
|
173
|
+
when :String
|
174
|
+
value.to_s
|
175
|
+
when :Integer
|
176
|
+
value.to_i
|
177
|
+
when :Float
|
178
|
+
value.to_f
|
179
|
+
when :BOOLEAN
|
180
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
181
|
+
true
|
182
|
+
else
|
183
|
+
false
|
184
|
+
end
|
185
|
+
when :Object
|
186
|
+
# generic object (usually a Hash), return directly
|
187
|
+
value
|
188
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
189
|
+
inner_type = Regexp.last_match[:inner_type]
|
190
|
+
value.map { |v| _deserialize(inner_type, v) }
|
191
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
192
|
+
k_type = Regexp.last_match[:k_type]
|
193
|
+
v_type = Regexp.last_match[:v_type]
|
194
|
+
{}.tap do |hash|
|
195
|
+
value.each do |k, v|
|
196
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
else # model
|
200
|
+
temp_model = Noths.const_get(type).new
|
201
|
+
temp_model.build_from_hash(value)
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
# Returns the string representation of the object
|
206
|
+
# @return [String] String presentation of the object
|
207
|
+
def to_s
|
208
|
+
to_hash.to_s
|
209
|
+
end
|
210
|
+
|
211
|
+
# to_body is an alias to to_hash (backward compatibility)
|
212
|
+
# @return [Hash] Returns the object in the form of hash
|
213
|
+
def to_body
|
214
|
+
to_hash
|
215
|
+
end
|
216
|
+
|
217
|
+
# Returns the object in the form of hash
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_hash
|
220
|
+
hash = {}
|
221
|
+
self.class.attribute_map.each_pair do |attr, param|
|
222
|
+
value = self.send(attr)
|
223
|
+
next if value.nil?
|
224
|
+
hash[param] = _to_hash(value)
|
225
|
+
end
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Outputs non-array value in the form of hash
|
230
|
+
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
# @param [Object] value Any valid value
|
232
|
+
# @return [Hash] Returns the value in the form of hash
|
233
|
+
def _to_hash(value)
|
234
|
+
if value.is_a?(Array)
|
235
|
+
value.compact.map{ |v| _to_hash(v) }
|
236
|
+
elsif value.is_a?(Hash)
|
237
|
+
{}.tap do |hash|
|
238
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
239
|
+
end
|
240
|
+
elsif value.respond_to? :to_hash
|
241
|
+
value.to_hash
|
242
|
+
else
|
243
|
+
value
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
=begin
|
2
|
+
#Noths
|
3
|
+
|
4
|
+
#www.notonthehighstreet.com API client
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module Noths
|
16
|
+
|
17
|
+
class ProductOption
|
18
|
+
attr_accessor :name
|
19
|
+
|
20
|
+
attr_accessor :value
|
21
|
+
|
22
|
+
|
23
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
24
|
+
def self.attribute_map
|
25
|
+
{
|
26
|
+
:'name' => :'name',
|
27
|
+
:'value' => :'value'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attribute type mapping.
|
32
|
+
def self.swagger_types
|
33
|
+
{
|
34
|
+
:'name' => :'String',
|
35
|
+
:'value' => :'String'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Initializes the object
|
40
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
41
|
+
def initialize(attributes = {})
|
42
|
+
return unless attributes.is_a?(Hash)
|
43
|
+
|
44
|
+
# convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
46
|
+
|
47
|
+
if attributes.has_key?(:'name')
|
48
|
+
self.name = attributes[:'name']
|
49
|
+
end
|
50
|
+
|
51
|
+
if attributes.has_key?(:'value')
|
52
|
+
self.value = attributes[:'value']
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
58
|
+
# @return Array for valid properties with the reasons
|
59
|
+
def list_invalid_properties
|
60
|
+
invalid_properties = Array.new
|
61
|
+
if @name.nil?
|
62
|
+
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
63
|
+
end
|
64
|
+
|
65
|
+
if @value.nil?
|
66
|
+
invalid_properties.push("invalid value for 'value', value cannot be nil.")
|
67
|
+
end
|
68
|
+
|
69
|
+
return invalid_properties
|
70
|
+
end
|
71
|
+
|
72
|
+
# Check to see if the all the properties in the model are valid
|
73
|
+
# @return true if the model is valid
|
74
|
+
def valid?
|
75
|
+
return false if @name.nil?
|
76
|
+
return false if @value.nil?
|
77
|
+
return true
|
78
|
+
end
|
79
|
+
|
80
|
+
# Checks equality by comparing each attribute.
|
81
|
+
# @param [Object] Object to be compared
|
82
|
+
def ==(o)
|
83
|
+
return true if self.equal?(o)
|
84
|
+
self.class == o.class &&
|
85
|
+
name == o.name &&
|
86
|
+
value == o.value
|
87
|
+
end
|
88
|
+
|
89
|
+
# @see the `==` method
|
90
|
+
# @param [Object] Object to be compared
|
91
|
+
def eql?(o)
|
92
|
+
self == o
|
93
|
+
end
|
94
|
+
|
95
|
+
# Calculates hash code according to all attributes.
|
96
|
+
# @return [Fixnum] Hash code
|
97
|
+
def hash
|
98
|
+
[name, value].hash
|
99
|
+
end
|
100
|
+
|
101
|
+
# Builds the object from hash
|
102
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
103
|
+
# @return [Object] Returns the model itself
|
104
|
+
def build_from_hash(attributes)
|
105
|
+
return nil unless attributes.is_a?(Hash)
|
106
|
+
self.class.swagger_types.each_pair do |key, type|
|
107
|
+
if type =~ /\AArray<(.*)>/i
|
108
|
+
# check to ensure the input is an array given that the the attribute
|
109
|
+
# is documented as an array but the input is not
|
110
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
111
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
112
|
+
end
|
113
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
114
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
115
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
116
|
+
end
|
117
|
+
|
118
|
+
self
|
119
|
+
end
|
120
|
+
|
121
|
+
# Deserializes the data based on type
|
122
|
+
# @param string type Data type
|
123
|
+
# @param string value Value to be deserialized
|
124
|
+
# @return [Object] Deserialized data
|
125
|
+
def _deserialize(type, value)
|
126
|
+
case type.to_sym
|
127
|
+
when :DateTime
|
128
|
+
DateTime.parse(value)
|
129
|
+
when :Date
|
130
|
+
Date.parse(value)
|
131
|
+
when :String
|
132
|
+
value.to_s
|
133
|
+
when :Integer
|
134
|
+
value.to_i
|
135
|
+
when :Float
|
136
|
+
value.to_f
|
137
|
+
when :BOOLEAN
|
138
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
139
|
+
true
|
140
|
+
else
|
141
|
+
false
|
142
|
+
end
|
143
|
+
when :Object
|
144
|
+
# generic object (usually a Hash), return directly
|
145
|
+
value
|
146
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
147
|
+
inner_type = Regexp.last_match[:inner_type]
|
148
|
+
value.map { |v| _deserialize(inner_type, v) }
|
149
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
150
|
+
k_type = Regexp.last_match[:k_type]
|
151
|
+
v_type = Regexp.last_match[:v_type]
|
152
|
+
{}.tap do |hash|
|
153
|
+
value.each do |k, v|
|
154
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
else # model
|
158
|
+
temp_model = Noths.const_get(type).new
|
159
|
+
temp_model.build_from_hash(value)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the string representation of the object
|
164
|
+
# @return [String] String presentation of the object
|
165
|
+
def to_s
|
166
|
+
to_hash.to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
# to_body is an alias to to_hash (backward compatibility)
|
170
|
+
# @return [Hash] Returns the object in the form of hash
|
171
|
+
def to_body
|
172
|
+
to_hash
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the object in the form of hash
|
176
|
+
# @return [Hash] Returns the object in the form of hash
|
177
|
+
def to_hash
|
178
|
+
hash = {}
|
179
|
+
self.class.attribute_map.each_pair do |attr, param|
|
180
|
+
value = self.send(attr)
|
181
|
+
next if value.nil?
|
182
|
+
hash[param] = _to_hash(value)
|
183
|
+
end
|
184
|
+
hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Outputs non-array value in the form of hash
|
188
|
+
# For object, use to_hash. Otherwise, just return the value
|
189
|
+
# @param [Object] value Any valid value
|
190
|
+
# @return [Hash] Returns the value in the form of hash
|
191
|
+
def _to_hash(value)
|
192
|
+
if value.is_a?(Array)
|
193
|
+
value.compact.map{ |v| _to_hash(v) }
|
194
|
+
elsif value.is_a?(Hash)
|
195
|
+
{}.tap do |hash|
|
196
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
197
|
+
end
|
198
|
+
elsif value.respond_to? :to_hash
|
199
|
+
value.to_hash
|
200
|
+
else
|
201
|
+
value
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|