Class: ConnectWise::PurchaseOrderLineItem

Inherits:
Object
  • Object
show all
Defined in:
lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ PurchaseOrderLineItem

Initializes the object

Parameters:

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

    Model attributes in the form of hash



139
140
141
142
143
144
145
146
147
148
149
150
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
184
185
186
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
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 139

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?(:'backorderedFlag')
    self.backordered_flag = attributes[:'backorderedFlag']
  end

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

end

Instance Attribute Details

#_infoObject

Metadata of the entity



64
65
66
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 64

def _info
  @_info
end

#backordered_flagObject

Returns the value of attribute backordered_flag.



9
10
11
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 9

def backordered_flag
  @backordered_flag
end

#canceled_byObject

Returns the value of attribute canceled_by.



11
12
13
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 11

def canceled_by
  @canceled_by
end

#canceled_flagObject

Returns the value of attribute canceled_flag.



13
14
15
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 13

def canceled_flag
  @canceled_flag
end

#canceled_reasonObject

Returns the value of attribute canceled_reason.



15
16
17
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 15

def canceled_reason
  @canceled_reason
end

#closed_flagObject

Returns the value of attribute closed_flag.



17
18
19
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 17

def closed_flag
  @closed_flag
end

#date_canceledObject

Returns the value of attribute date_canceled.



19
20
21
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 19

def date_canceled
  @date_canceled
end

#date_canceled_utcObject

Returns the value of attribute date_canceled_utc.



21
22
23
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 21

def date_canceled_utc
  @date_canceled_utc
end

#descriptionObject

Returns the value of attribute description.



23
24
25
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 23

def description
  @description
end

#display_internal_notes_flagObject

Returns the value of attribute display_internal_notes_flag.



25
26
27
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 25

def display_internal_notes_flag
  @display_internal_notes_flag
end

#expected_ship_dateObject

Returns the value of attribute expected_ship_date.



27
28
29
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 27

def expected_ship_date
  @expected_ship_date
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 7

def id
  @id
end

#internal_notesObject

Returns the value of attribute internal_notes.



29
30
31
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 29

def internal_notes
  @internal_notes
end

#line_numberObject

Returns the value of attribute line_number.



31
32
33
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 31

def line_number
  @line_number
end

#packing_slipObject

Returns the value of attribute packing_slip.



33
34
35
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 33

def packing_slip
  @packing_slip
end

#productObject

Returns the value of attribute product.



35
36
37
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 35

def product
  @product
end

#purchase_order_idObject

Returns the value of attribute purchase_order_id.



37
38
39
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 37

def purchase_order_id
  @purchase_order_id
end

#quantityObject

Returns the value of attribute quantity.



39
40
41
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 39

def quantity
  @quantity
end

#received_quantityObject

Returns the value of attribute received_quantity.



41
42
43
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 41

def received_quantity
  @received_quantity
end

#serial_numbersObject

Returns the value of attribute serial_numbers.



43
44
45
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 43

def serial_numbers
  @serial_numbers
end

#ship_dateObject

Returns the value of attribute ship_date.



45
46
47
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 45

def ship_date
  @ship_date
end

#shipment_methodObject

Returns the value of attribute shipment_method.



47
48
49
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 47

def shipment_method
  @shipment_method
end

#taxObject

Returns the value of attribute tax.



49
50
51
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 49

def tax
  @tax
end

#tracking_numberObject

Returns the value of attribute tracking_number.



51
52
53
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 51

def tracking_number
  @tracking_number
end

#unit_costObject

Returns the value of attribute unit_cost.



53
54
55
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 53

def unit_cost
  @unit_cost
end

#unit_of_measureObject

Returns the value of attribute unit_of_measure.



55
56
57
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 55

def unit_of_measure
  @unit_of_measure
end

#vendor_order_numberObject

Returns the value of attribute vendor_order_number.



57
58
59
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 57

def vendor_order_number
  @vendor_order_number
end

#warehouseObject

Returns the value of attribute warehouse.



59
60
61
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 59

def warehouse
  @warehouse
end

#warehouse_binObject

Returns the value of attribute warehouse_bin.



61
62
63
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 61

def warehouse_bin
  @warehouse_bin
end

Class Method Details

.attribute_mapObject

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



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 68

def self.attribute_map
  {
    :'id' => :'id',
    :'backordered_flag' => :'backorderedFlag',
    :'canceled_by' => :'canceledBy',
    :'canceled_flag' => :'canceledFlag',
    :'canceled_reason' => :'canceledReason',
    :'closed_flag' => :'closedFlag',
    :'date_canceled' => :'dateCanceled',
    :'date_canceled_utc' => :'dateCanceledUtc',
    :'description' => :'description',
    :'display_internal_notes_flag' => :'displayInternalNotesFlag',
    :'expected_ship_date' => :'expectedShipDate',
    :'internal_notes' => :'internalNotes',
    :'line_number' => :'lineNumber',
    :'packing_slip' => :'packingSlip',
    :'product' => :'product',
    :'purchase_order_id' => :'purchaseOrderId',
    :'quantity' => :'quantity',
    :'received_quantity' => :'receivedQuantity',
    :'serial_numbers' => :'serialNumbers',
    :'ship_date' => :'shipDate',
    :'shipment_method' => :'shipmentMethod',
    :'tax' => :'tax',
    :'tracking_number' => :'trackingNumber',
    :'unit_cost' => :'unitCost',
    :'unit_of_measure' => :'unitOfMeasure',
    :'vendor_order_number' => :'vendorOrderNumber',
    :'warehouse' => :'warehouse',
    :'warehouse_bin' => :'warehouseBin',
    :'_info' => :'_info'
  }
end

.swagger_typesObject

Attribute type mapping.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 103

def self.swagger_types
  {
    :'id' => :'Integer',
    :'backordered_flag' => :'BOOLEAN',
    :'canceled_by' => :'String',
    :'canceled_flag' => :'BOOLEAN',
    :'canceled_reason' => :'String',
    :'closed_flag' => :'BOOLEAN',
    :'date_canceled' => :'DateTime',
    :'date_canceled_utc' => :'DateTime',
    :'description' => :'String',
    :'display_internal_notes_flag' => :'BOOLEAN',
    :'expected_ship_date' => :'DateTime',
    :'internal_notes' => :'String',
    :'line_number' => :'Integer',
    :'packing_slip' => :'String',
    :'product' => :'IvItemReference',
    :'purchase_order_id' => :'Integer',
    :'quantity' => :'Float',
    :'received_quantity' => :'Integer',
    :'serial_numbers' => :'String',
    :'ship_date' => :'DateTime',
    :'shipment_method' => :'ShipmentMethodReference',
    :'tax' => :'Float',
    :'tracking_number' => :'String',
    :'unit_cost' => :'Float',
    :'unit_of_measure' => :'UnitOfMeasureReference',
    :'vendor_order_number' => :'String',
    :'warehouse' => :'WarehouseReference',
    :'warehouse_bin' => :'WarehouseBinReference',
    :'_info' => :'Metadata'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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
449
450
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 418

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      backordered_flag == o.backordered_flag &&
      canceled_by == o.canceled_by &&
      canceled_flag == o.canceled_flag &&
      canceled_reason == o.canceled_reason &&
      closed_flag == o.closed_flag &&
      date_canceled == o.date_canceled &&
      date_canceled_utc == o.date_canceled_utc &&
      description == o.description &&
      display_internal_notes_flag == o.display_internal_notes_flag &&
      expected_ship_date == o.expected_ship_date &&
      internal_notes == o.internal_notes &&
      line_number == o.line_number &&
      packing_slip == o.packing_slip &&
      product == o.product &&
      purchase_order_id == o.purchase_order_id &&
      quantity == o.quantity &&
      received_quantity == o.received_quantity &&
      serial_numbers == o.serial_numbers &&
      ship_date == o.ship_date &&
      shipment_method == o.shipment_method &&
      tax == o.tax &&
      tracking_number == o.tracking_number &&
      unit_cost == o.unit_cost &&
      unit_of_measure == o.unit_of_measure &&
      vendor_order_number == o.vendor_order_number &&
      warehouse == o.warehouse &&
      warehouse_bin == o.warehouse_bin &&
      _info == o._info
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



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
523
524
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 488

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 = ConnectWise.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



554
555
556
557
558
559
560
561
562
563
564
565
566
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 554

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



467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 467

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


454
455
456
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 454

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



460
461
462
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 460

def hash
  [id, backordered_flag, canceled_by, canceled_flag, canceled_reason, closed_flag, date_canceled, date_canceled_utc, description, display_internal_notes_flag, expected_ship_date, internal_notes, line_number, packing_slip, product, purchase_order_id, quantity, received_quantity, serial_numbers, ship_date, shipment_method, tax, tracking_number, unit_cost, unit_of_measure, vendor_order_number, warehouse, warehouse_bin, _info].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properies with the reasons



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
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 265

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

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

  if @description.to_s.length > 6000
    invalid_properties.push("invalid value for 'description', the character length must be smaller than or equal to 6000.")
  end

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

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

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

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

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

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

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

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

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

  return 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



534
535
536
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 534

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



540
541
542
543
544
545
546
547
548
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 540

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



528
529
530
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 528

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



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/connectwise-ruby-sdk/models/purchase_order_line_item.rb', line 320

def valid?
  return false if !@canceled_reason.nil? && @canceled_reason.to_s.length > 100
  return false if @description.nil?
  return false if @description.to_s.length > 6000
  return false if !@internal_notes.nil? && @internal_notes.to_s.length > 1000
  return false if @line_number.nil?
  return false if !@packing_slip.nil? && @packing_slip.to_s.length > 30
  return false if @product.nil?
  return false if @quantity.nil?
  return false if !@serial_numbers.nil? && @serial_numbers.to_s.length > 100
  return false if !@tracking_number.nil? && @tracking_number.to_s.length > 50
  return false if @unit_of_measure.nil?
  return false if !@vendor_order_number.nil? && @vendor_order_number.to_s.length > 50
  return true
end