Class: Zippendo::UpdateShippingRuleRequest

Inherits:
ApiModelBase show all
Defined in:
lib/zippendo/models/update_shipping_rule_request.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ UpdateShippingRuleRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 201

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Zippendo::UpdateShippingRuleRequest` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Zippendo::UpdateShippingRuleRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.key?(:'direction')
    self.direction = attributes[:'direction']
  else
    self.direction = 'outbound'
  end

  if attributes.key?(:'carrier_id')
    self.carrier_id = attributes[:'carrier_id']
  end

  if attributes.key?(:'product_id')
    self.product_id = attributes[:'product_id']
  end

  if attributes.key?(:'services')
    if (value = attributes[:'services']).is_a?(Array)
      self.services = value
    end
  end

  if attributes.key?(:'additional_parameters')
    self.additional_parameters = attributes[:'additional_parameters']
  end

  if attributes.key?(:'address_id')
    self.address_id = attributes[:'address_id']
  end

  if attributes.key?(:'receiving_countries')
    if (value = attributes[:'receiving_countries']).is_a?(Array)
      self.receiving_countries = value
    end
  end

  if attributes.key?(:'email_notification')
    self.email_notification = attributes[:'email_notification']
  else
    self.email_notification = false
  end

  if attributes.key?(:'phone_notification')
    self.phone_notification = attributes[:'phone_notification']
  else
    self.phone_notification = false
  end

  if attributes.key?(:'min_weight')
    self.min_weight = attributes[:'min_weight']
  end

  if attributes.key?(:'max_weight')
    self.max_weight = attributes[:'max_weight']
  end

  if attributes.key?(:'min_order_value')
    self.min_order_value = attributes[:'min_order_value']
  end

  if attributes.key?(:'max_order_value')
    self.max_order_value = attributes[:'max_order_value']
  end

  if attributes.key?(:'conditions')
    if (value = attributes[:'conditions']).is_a?(Array)
      self.conditions = value
    end
  end

  if attributes.key?(:'generate_proforma_invoice')
    self.generate_proforma_invoice = attributes[:'generate_proforma_invoice']
  else
    self.generate_proforma_invoice = false
  end

  if attributes.key?(:'generate_commercial_invoice')
    self.generate_commercial_invoice = attributes[:'generate_commercial_invoice']
  else
    self.generate_commercial_invoice = false
  end

  if attributes.key?(:'generate_packing_list')
    self.generate_packing_list = attributes[:'generate_packing_list']
  else
    self.generate_packing_list = false
  end

  if attributes.key?(:'auto_print_labels')
    self.auto_print_labels = attributes[:'auto_print_labels']
  else
    self.auto_print_labels = false
  end

  if attributes.key?(:'auto_print_documents')
    self.auto_print_documents = attributes[:'auto_print_documents']
  else
    self.auto_print_documents = false
  end

  if attributes.key?(:'label_printer_id')
    self.label_printer_id = attributes[:'label_printer_id']
  end

  if attributes.key?(:'document_printer_id')
    self.document_printer_id = attributes[:'document_printer_id']
  end

  if attributes.key?(:'return_shipping_rule_id')
    self.return_shipping_rule_id = attributes[:'return_shipping_rule_id']
  end

  if attributes.key?(:'auto_create_return_shipment')
    self.auto_create_return_shipment = attributes[:'auto_create_return_shipment']
  else
    self.auto_create_return_shipment = false
  end
end

Instance Attribute Details

#additional_parametersObject

Returns the value of attribute additional_parameters.



36
37
38
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 36

def additional_parameters
  @additional_parameters
end

#address_idObject

Sender address ID



39
40
41
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 39

def address_id
  @address_id
end

#auto_create_return_shipmentObject

Automatically create and send a return shipment on dispatch



90
91
92
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 90

def auto_create_return_shipment
  @auto_create_return_shipment
end

#auto_print_documentsObject

Automatically print documents when shipment is sent



78
79
80
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 78

def auto_print_documents
  @auto_print_documents
end

#auto_print_labelsObject

Automatically print labels when shipment is sent



75
76
77
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 75

def auto_print_labels
  @auto_print_labels
end

#carrier_idObject

Carrier ID



28
29
30
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 28

def carrier_id
  @carrier_id
end

#conditionsObject

Rule conditions (weight/price/quantity)



63
64
65
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 63

def conditions
  @conditions
end

#descriptionObject

Optional description



22
23
24
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 22

def description
  @description
end

#directionObject

Whether this rule is for outbound or inbound (return) shipments



25
26
27
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 25

def direction
  @direction
end

#document_printer_idObject

ID of the document printer



84
85
86
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 84

def document_printer_id
  @document_printer_id
end

#email_notificationObject

Send email notification to recipient



45
46
47
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 45

def email_notification
  @email_notification
end

#generate_commercial_invoiceObject

Generate commercial invoice for international shipments



69
70
71
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 69

def generate_commercial_invoice
  @generate_commercial_invoice
end

#generate_packing_listObject

Generate packing slip with package and item details



72
73
74
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 72

def generate_packing_list
  @generate_packing_list
end

#generate_proforma_invoiceObject

Generate proforma invoice for shipments



66
67
68
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 66

def generate_proforma_invoice
  @generate_proforma_invoice
end

#label_printer_idObject

ID of the label printer



81
82
83
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 81

def label_printer_id
  @label_printer_id
end

#max_order_valueObject

Maximum allowed order value in currency units



60
61
62
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 60

def max_order_value
  @max_order_value
end

#max_weightObject

Maximum allowed weight in kg



54
55
56
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 54

def max_weight
  @max_weight
end

#min_order_valueObject

Minimum required order value in currency units



57
58
59
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 57

def min_order_value
  @min_order_value
end

#min_weightObject

Minimum required weight in kg



51
52
53
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 51

def min_weight
  @min_weight
end

#nameObject

Shipping rule name



19
20
21
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 19

def name
  @name
end

#phone_notificationObject

Send SMS notification to recipient



48
49
50
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 48

def phone_notification
  @phone_notification
end

#product_idObject

Product ID from carrier



31
32
33
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 31

def product_id
  @product_id
end

#receiving_countriesObject

List of supported country codes



42
43
44
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 42

def receiving_countries
  @receiving_countries
end

#return_shipping_rule_idObject

ID of the return shipping rule



87
88
89
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 87

def return_shipping_rule_id
  @return_shipping_rule_id
end

#servicesObject

List of selected services



34
35
36
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 34

def services
  @services
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



146
147
148
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 146

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



151
152
153
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 151

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 115

def self.attribute_map
  {
    :'name' => :'name',
    :'description' => :'description',
    :'direction' => :'direction',
    :'carrier_id' => :'carrierId',
    :'product_id' => :'productId',
    :'services' => :'services',
    :'additional_parameters' => :'additionalParameters',
    :'address_id' => :'addressId',
    :'receiving_countries' => :'receivingCountries',
    :'email_notification' => :'emailNotification',
    :'phone_notification' => :'phoneNotification',
    :'min_weight' => :'minWeight',
    :'max_weight' => :'maxWeight',
    :'min_order_value' => :'minOrderValue',
    :'max_order_value' => :'maxOrderValue',
    :'conditions' => :'conditions',
    :'generate_proforma_invoice' => :'generateProformaInvoice',
    :'generate_commercial_invoice' => :'generateCommercialInvoice',
    :'generate_packing_list' => :'generatePackingList',
    :'auto_print_labels' => :'autoPrintLabels',
    :'auto_print_documents' => :'autoPrintDocuments',
    :'label_printer_id' => :'labelPrinterId',
    :'document_printer_id' => :'documentPrinterId',
    :'return_shipping_rule_id' => :'returnShippingRuleId',
    :'auto_create_return_shipment' => :'autoCreateReturnShipment'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 493

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



187
188
189
190
191
192
193
194
195
196
197
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 187

def self.openapi_nullable
  Set.new([
    :'min_weight',
    :'max_weight',
    :'min_order_value',
    :'max_order_value',
    :'label_printer_id',
    :'document_printer_id',
    :'return_shipping_rule_id',
  ])
end

.openapi_typesObject

Attribute type mapping.



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 156

def self.openapi_types
  {
    :'name' => :'String',
    :'description' => :'String',
    :'direction' => :'String',
    :'carrier_id' => :'String',
    :'product_id' => :'String',
    :'services' => :'Array<String>',
    :'additional_parameters' => :'CreateShippingRuleRequestAdditionalParameters',
    :'address_id' => :'String',
    :'receiving_countries' => :'Array<String>',
    :'email_notification' => :'Boolean',
    :'phone_notification' => :'Boolean',
    :'min_weight' => :'Float',
    :'max_weight' => :'Float',
    :'min_order_value' => :'Float',
    :'max_order_value' => :'Float',
    :'conditions' => :'Array<CreateShippingRuleRequestConditionsInner>',
    :'generate_proforma_invoice' => :'Boolean',
    :'generate_commercial_invoice' => :'Boolean',
    :'generate_packing_list' => :'Boolean',
    :'auto_print_labels' => :'Boolean',
    :'auto_print_documents' => :'Boolean',
    :'label_printer_id' => :'String',
    :'document_printer_id' => :'String',
    :'return_shipping_rule_id' => :'String',
    :'auto_create_return_shipment' => :'Boolean'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 448

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      name == o.name &&
      description == o.description &&
      direction == o.direction &&
      carrier_id == o.carrier_id &&
      product_id == o.product_id &&
      services == o.services &&
      additional_parameters == o.additional_parameters &&
      address_id == o.address_id &&
      receiving_countries == o.receiving_countries &&
      email_notification == o.email_notification &&
      phone_notification == o.phone_notification &&
      min_weight == o.min_weight &&
      max_weight == o.max_weight &&
      min_order_value == o.min_order_value &&
      max_order_value == o.max_order_value &&
      conditions == o.conditions &&
      generate_proforma_invoice == o.generate_proforma_invoice &&
      generate_commercial_invoice == o.generate_commercial_invoice &&
      generate_packing_list == o.generate_packing_list &&
      auto_print_labels == o.auto_print_labels &&
      auto_print_documents == o.auto_print_documents &&
      label_printer_id == o.label_printer_id &&
      document_printer_id == o.document_printer_id &&
      return_shipping_rule_id == o.return_shipping_rule_id &&
      auto_create_return_shipment == o.auto_create_return_shipment
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


480
481
482
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 480

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



486
487
488
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 486

def hash
  [name, description, direction, carrier_id, product_id, services, additional_parameters, address_id, receiving_countries, email_notification, phone_notification, min_weight, max_weight, min_order_value, max_order_value, conditions, generate_proforma_invoice, generate_commercial_invoice, generate_packing_list, auto_print_labels, auto_print_documents, label_printer_id, document_printer_id, return_shipping_rule_id, auto_create_return_shipment].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 342

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if !@name.nil? && @name.to_s.length < 1
    invalid_properties.push('invalid value for "name", the character length must be greater than or equal to 1.')
  end

  if !@min_weight.nil? && @min_weight < 0
    invalid_properties.push('invalid value for "min_weight", must be greater than or equal to 0.')
  end

  if !@max_weight.nil? && @max_weight < 0
    invalid_properties.push('invalid value for "max_weight", must be greater than or equal to 0.')
  end

  if !@min_order_value.nil? && @min_order_value < 0
    invalid_properties.push('invalid value for "min_order_value", must be greater than or equal to 0.')
  end

  if !@max_order_value.nil? && @max_order_value < 0
    invalid_properties.push('invalid value for "max_order_value", must be greater than or equal to 0.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



515
516
517
518
519
520
521
522
523
524
525
526
527
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 515

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



370
371
372
373
374
375
376
377
378
379
380
# File 'lib/zippendo/models/update_shipping_rule_request.rb', line 370

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if !@name.nil? && @name.to_s.length < 1
  direction_validator = EnumAttributeValidator.new('String', ["outbound", "inbound"])
  return false unless direction_validator.valid?(@direction)
  return false if !@min_weight.nil? && @min_weight < 0
  return false if !@max_weight.nil? && @max_weight < 0
  return false if !@min_order_value.nil? && @min_order_value < 0
  return false if !@max_order_value.nil? && @max_order_value < 0
  true
end