Class: TripletexRubyClient::PurchaseOrder

Inherits:
Object
  • Object
show all
Defined in:
lib/tripletex_ruby_client/models/purchase_order.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PurchaseOrder

Initializes the object

Parameters:

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

    Model attributes in the form of hash



187
188
189
190
191
192
193
194
195
196
197
198
199
200
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
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 187

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'version')
    self.version = attributes[:'version']
  end

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

  if attributes.has_key?(:'url')
    self.url = attributes[:'url']
  end

  if attributes.has_key?(:'number')
    self.number = attributes[:'number']
  end

  if attributes.has_key?(:'receiverEmail')
    self.receiver_email = attributes[:'receiverEmail']
  end

  if attributes.has_key?(:'discount')
    self.discount = attributes[:'discount']
  end

  if attributes.has_key?(:'packingNoteMessage')
    self.packing_note_message = attributes[:'packingNoteMessage']
  end

  if attributes.has_key?(:'transporterMessage')
    self.transporter_message = attributes[:'transporterMessage']
  end

  if attributes.has_key?(:'comments')
    self.comments = attributes[:'comments']
  end

  if attributes.has_key?(:'supplier')
    self.supplier = attributes[:'supplier']
  end

  if attributes.has_key?(:'deliveryDate')
    self.delivery_date = attributes[:'deliveryDate']
  end

  if attributes.has_key?(:'orderLines')
    if (value = attributes[:'orderLines']).is_a?(Array)
      self.order_lines = value
    end
  end

  if attributes.has_key?(:'project')
    self.project = attributes[:'project']
  end

  if attributes.has_key?(:'department')
    self.department = attributes[:'department']
  end

  if attributes.has_key?(:'deliveryAddress')
    self.delivery_address = attributes[:'deliveryAddress']
  end

  if attributes.has_key?(:'creationDate')
    self.creation_date = attributes[:'creationDate']
  end

  if attributes.has_key?(:'isClosed')
    self.is_closed = attributes[:'isClosed']
  end

  if attributes.has_key?(:'ourContact')
    self.our_contact = attributes[:'ourContact']
  end

  if attributes.has_key?(:'supplierContact')
    self.supplier_contact = attributes[:'supplierContact']
  end

  if attributes.has_key?(:'attention')
    self.attention = attributes[:'attention']
  end

  if attributes.has_key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.has_key?(:'currency')
    self.currency = attributes[:'currency']
  end

  if attributes.has_key?(:'restorder')
    self.restorder = attributes[:'restorder']
  end

  if attributes.has_key?(:'transportType')
    self.transport_type = attributes[:'transportType']
  end

  if attributes.has_key?(:'pickupPoint')
    self.pickup_point = attributes[:'pickupPoint']
  end

  if attributes.has_key?(:'document')
    self.document = attributes[:'document']
  end

  if attributes.has_key?(:'attachment')
    self.attachment = attributes[:'attachment']
  end

  if attributes.has_key?(:'ediDocument')
    self.edi_document = attributes[:'ediDocument']
  end
end

Instance Attribute Details

#attachmentObject

The attachments on this PurchaseOrder (if any)



88
89
90
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 88

def attachment
  @attachment
end

#attentionObject

Attention



69
70
71
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 69

def attention
  @attention
end

#changesObject

Returns the value of attribute changes.



21
22
23
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 21

def changes
  @changes
end

#commentsObject

Delivery information and invoice comments



41
42
43
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 41

def comments
  @comments
end

#creation_dateObject

Returns the value of attribute creation_date.



59
60
61
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 59

def creation_date
  @creation_date
end

#currencyObject

Company currency



74
75
76
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 74

def currency
  @currency
end

#delivery_addressObject

Delivery address



57
58
59
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 57

def delivery_address
  @delivery_address
end

#delivery_dateObject

Returns the value of attribute delivery_date.



45
46
47
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 45

def delivery_date
  @delivery_date
end

#departmentObject

Department/order



54
55
56
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 54

def department
  @department
end

#discountObject

Discount Percentage



32
33
34
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 32

def discount
  @discount
end

#documentObject

The PDF representing this PurchaseOrder



85
86
87
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 85

def document
  @document
end

#edi_documentObject

The machine readable document (such as EHF or EFO/NELFO) this PurchaseOrder is based on (if any)



91
92
93
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 91

def edi_document
  @edi_document
end

#idObject

Returns the value of attribute id.



17
18
19
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 17

def id
  @id
end

#is_closedObject

Returns the value of attribute is_closed.



61
62
63
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 61

def is_closed
  @is_closed
end

#numberObject

Purchase order number



26
27
28
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 26

def number
  @number
end

#order_linesObject

Order lines tied to the purchase order



48
49
50
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 48

def order_lines
  @order_lines
end

#our_contactObject

Returns the value of attribute our_contact.



63
64
65
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 63

def our_contact
  @our_contact
end

#packing_note_messageObject

Message on packing note.Wholesaler specific.



35
36
37
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 35

def packing_note_message
  @packing_note_message
end

#pickup_pointObject

Pickup point, wholesaler specific



82
83
84
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 82

def pickup_point
  @pickup_point
end

#projectObject

Project/order



51
52
53
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 51

def project
  @project
end

#receiver_emailObject

Email when purchase order is send by email.



29
30
31
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 29

def receiver_email
  @receiver_email
end

#restorderObject

Returns the value of attribute restorder.



76
77
78
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 76

def restorder
  @restorder
end

#statusObject

Returns the value of attribute status.



71
72
73
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 71

def status
  @status
end

#supplierObject

Returns the value of attribute supplier.



43
44
45
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 43

def supplier
  @supplier
end

#supplier_contactObject

Recipient when purchase order is send by email.



66
67
68
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 66

def supplier_contact
  @supplier_contact
end

#transport_typeObject

Transport type



79
80
81
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 79

def transport_type
  @transport_type
end

#transporter_messageObject

Message to transporter.Wholesaler specific.



38
39
40
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 38

def transporter_message
  @transporter_message
end

#urlObject

Returns the value of attribute url.



23
24
25
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 23

def url
  @url
end

#versionObject

Returns the value of attribute version.



19
20
21
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 19

def version
  @version
end

Class Method Details

.attribute_mapObject

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



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
144
145
146
147
148
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 116

def self.attribute_map
  {
    :'id' => :'id',
    :'version' => :'version',
    :'changes' => :'changes',
    :'url' => :'url',
    :'number' => :'number',
    :'receiver_email' => :'receiverEmail',
    :'discount' => :'discount',
    :'packing_note_message' => :'packingNoteMessage',
    :'transporter_message' => :'transporterMessage',
    :'comments' => :'comments',
    :'supplier' => :'supplier',
    :'delivery_date' => :'deliveryDate',
    :'order_lines' => :'orderLines',
    :'project' => :'project',
    :'department' => :'department',
    :'delivery_address' => :'deliveryAddress',
    :'creation_date' => :'creationDate',
    :'is_closed' => :'isClosed',
    :'our_contact' => :'ourContact',
    :'supplier_contact' => :'supplierContact',
    :'attention' => :'attention',
    :'status' => :'status',
    :'currency' => :'currency',
    :'restorder' => :'restorder',
    :'transport_type' => :'transportType',
    :'pickup_point' => :'pickupPoint',
    :'document' => :'document',
    :'attachment' => :'attachment',
    :'edi_document' => :'ediDocument'
  }
end

.swagger_typesObject

Attribute type mapping.



151
152
153
154
155
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
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 151

def self.swagger_types
  {
    :'id' => :'Integer',
    :'version' => :'Integer',
    :'changes' => :'Array<Change>',
    :'url' => :'String',
    :'number' => :'String',
    :'receiver_email' => :'String',
    :'discount' => :'Float',
    :'packing_note_message' => :'String',
    :'transporter_message' => :'String',
    :'comments' => :'String',
    :'supplier' => :'Supplier',
    :'delivery_date' => :'String',
    :'order_lines' => :'Array<PurchaseOrderline>',
    :'project' => :'Project',
    :'department' => :'Department',
    :'delivery_address' => :'Address',
    :'creation_date' => :'String',
    :'is_closed' => :'BOOLEAN',
    :'our_contact' => :'Employee',
    :'supplier_contact' => :'Employee',
    :'attention' => :'Employee',
    :'status' => :'String',
    :'currency' => :'Currency',
    :'restorder' => :'PurchaseOrder',
    :'transport_type' => :'TransportType',
    :'pickup_point' => :'PickupPoint',
    :'document' => :'Document',
    :'attachment' => :'Document',
    :'edi_document' => :'Document'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 416

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      version == o.version &&
      changes == o.changes &&
      url == o.url &&
      number == o.number &&
      receiver_email == o.receiver_email &&
      discount == o.discount &&
      packing_note_message == o.packing_note_message &&
      transporter_message == o.transporter_message &&
      comments == o.comments &&
      supplier == o.supplier &&
      delivery_date == o.delivery_date &&
      order_lines == o.order_lines &&
      project == o.project &&
      department == o.department &&
      delivery_address == o.delivery_address &&
      creation_date == o.creation_date &&
      is_closed == o.is_closed &&
      our_contact == o.our_contact &&
      supplier_contact == o.supplier_contact &&
      attention == o.attention &&
      status == o.status &&
      currency == o.currency &&
      restorder == o.restorder &&
      transport_type == o.transport_type &&
      pickup_point == o.pickup_point &&
      document == o.document &&
      attachment == o.attachment &&
      edi_document == o.edi_document
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 486

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = TripletexRubyClient.const_get(type).new
    temp_model.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



552
553
554
555
556
557
558
559
560
561
562
563
564
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 552

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
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



465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 465

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if 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[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


452
453
454
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 452

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



458
459
460
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 458

def hash
  [id, version, changes, url, number, receiver_email, discount, packing_note_message, transporter_message, comments, supplier, delivery_date, order_lines, project, department, delivery_address, creation_date, is_closed, our_contact, supplier_contact, attention, status, currency, restorder, transport_type, pickup_point, document, attachment, edi_document].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 316

def list_invalid_properties
  invalid_properties = Array.new
  if !@number.nil? && @number.to_s.length > 100
    invalid_properties.push('invalid value for "number", the character length must be smaller than or equal to 100.')
  end

  if !@receiver_email.nil? && @receiver_email.to_s.length > 100
    invalid_properties.push('invalid value for "receiver_email", the character length must be smaller than or equal to 100.')
  end

  if !@packing_note_message.nil? && @packing_note_message.to_s.length > 50
    invalid_properties.push('invalid value for "packing_note_message", the character length must be smaller than or equal to 50.')
  end

  if !@transporter_message.nil? && @transporter_message.to_s.length > 255
    invalid_properties.push('invalid value for "transporter_message", the character length must be smaller than or equal to 255.')
  end

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

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

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

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



532
533
534
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 532

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



538
539
540
541
542
543
544
545
546
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 538

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



526
527
528
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 526

def to_s
  to_hash.to_s
end

#valid?Boolean

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

Returns:

  • (Boolean)

    true if the model is valid



351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/tripletex_ruby_client/models/purchase_order.rb', line 351

def valid?
  return false if !@number.nil? && @number.to_s.length > 100
  return false if !@receiver_email.nil? && @receiver_email.to_s.length > 100
  return false if !@packing_note_message.nil? && @packing_note_message.to_s.length > 50
  return false if !@transporter_message.nil? && @transporter_message.to_s.length > 255
  return false if @supplier.nil?
  return false if @delivery_date.nil?
  return false if @our_contact.nil?
  status_validator = EnumAttributeValidator.new('String', ['STATUS_OPEN', 'STATUS_SENT', 'STATUS_RECEIVING', 'STATUS_CONFIRMED_DEVIATION_DETECTED', 'STATUS_DEVIATION_OPEN', 'STATUS_DEVIATION_CONFIRMED', 'STATUS_CONFIRMED', 'STATUS_CANCELLED'])
  return false unless status_validator.valid?(@status)
  true
end