Class: Zippendo::CreateShippingRuleRequest

Inherits:
ApiModelBase show all
Defined in:
lib/zippendo/models/create_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 = {}) ⇒ CreateShippingRuleRequest

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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/zippendo/models/create_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::CreateShippingRuleRequest` 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::CreateShippingRuleRequest`. 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']
  else
    self.name = nil
  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']
  else
    self.carrier_id = nil
  end

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

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

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

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

  if attributes.key?(:'receiving_countries')
    if (value = attributes[:'receiving_countries']).is_a?(Array)
      self.receiving_countries = value
    end
  else
    self.receiving_countries = nil
  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
  else
    self.conditions = nil
  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/create_shipping_rule_request.rb', line 36

def additional_parameters
  @additional_parameters
end

#address_idObject

Sender address ID



39
40
41
# File 'lib/zippendo/models/create_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/create_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/create_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/create_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/create_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/create_shipping_rule_request.rb', line 63

def conditions
  @conditions
end

#descriptionObject

Optional description



22
23
24
# File 'lib/zippendo/models/create_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/create_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/create_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/create_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/create_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/create_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/create_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/create_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/create_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/create_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/create_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/create_shipping_rule_request.rb', line 51

def min_weight
  @min_weight
end

#nameObject

Shipping rule name



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

def name
  @name
end

#phone_notificationObject

Send SMS notification to recipient



48
49
50
# File 'lib/zippendo/models/create_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/create_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/create_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/create_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/create_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/create_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/create_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/create_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



602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/zippendo/models/create_shipping_rule_request.rb', line 602

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/create_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/create_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



557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
# File 'lib/zippendo/models/create_shipping_rule_request.rb', line 557

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


589
590
591
# File 'lib/zippendo/models/create_shipping_rule_request.rb', line 589

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



595
596
597
# File 'lib/zippendo/models/create_shipping_rule_request.rb', line 595

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



356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/zippendo/models/create_shipping_rule_request.rb', line 356

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @name.nil?
    invalid_properties.push('invalid value for "name", name cannot be nil.')
  end

  if @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 @carrier_id.nil?
    invalid_properties.push('invalid value for "carrier_id", carrier_id cannot be nil.')
  end

  if @product_id.nil?
    invalid_properties.push('invalid value for "product_id", product_id cannot be nil.')
  end

  if @services.nil?
    invalid_properties.push('invalid value for "services", services cannot be nil.')
  end

  if @address_id.nil?
    invalid_properties.push('invalid value for "address_id", address_id cannot be nil.')
  end

  if @receiving_countries.nil?
    invalid_properties.push('invalid value for "receiving_countries", receiving_countries cannot be nil.')
  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

  if @conditions.nil?
    invalid_properties.push('invalid value for "conditions", conditions cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



624
625
626
627
628
629
630
631
632
633
634
635
636
# File 'lib/zippendo/models/create_shipping_rule_request.rb', line 624

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



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# File 'lib/zippendo/models/create_shipping_rule_request.rb', line 412

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @name.nil?
  return false if @name.to_s.length < 1
  direction_validator = EnumAttributeValidator.new('String', ["outbound", "inbound"])
  return false unless direction_validator.valid?(@direction)
  return false if @carrier_id.nil?
  return false if @product_id.nil?
  return false if @services.nil?
  return false if @address_id.nil?
  return false if @receiving_countries.nil?
  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
  return false if @conditions.nil?
  true
end