Class: ConnectWise::PurchaseOrderLineItem

Inherits:
Object
  • Object
show all
Defined in:
lib/connect_wise/models/purchase_order_line_item.rb

Defined Under Namespace

Classes: EnumAttributeValidator

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

Raises:

  • (ArgumentError)


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
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 167

def initialize(attributes = {})
  raise ArgumentError, 'The input argument (attributes) must be a hash in `ConnectWise::PurchaseOrderLineItem` initialize method' unless attributes.is_a?(Hash)

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) do |(k, v), h|
    raise ArgumentError, "`#{k}` is not a valid attribute in `ConnectWise::PurchaseOrderLineItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect unless self.class.attribute_map.key?(k.to_sym)

    h[k.to_sym] = v
  end

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

  self.line_number = attributes[:line_number] if attributes.key?(:line_number)

  self.quantity = attributes[:quantity] if attributes.key?(:quantity)

  self.id = attributes[:id] if attributes.key?(:id)

  self.backordered_flag = attributes[:backordered_flag] if attributes.key?(:backordered_flag)

  self.canceled_by = attributes[:canceled_by] if attributes.key?(:canceled_by)

  self.canceled_flag = attributes[:canceled_flag] if attributes.key?(:canceled_flag)

  self.canceled_reason = attributes[:canceled_reason] if attributes.key?(:canceled_reason)

  self.closed_flag = attributes[:closed_flag] if attributes.key?(:closed_flag)

  self.date_canceled = attributes[:date_canceled] if attributes.key?(:date_canceled)

  self.date_canceled_utc = attributes[:date_canceled_utc] if attributes.key?(:date_canceled_utc)

  self.display_internal_notes_flag = attributes[:display_internal_notes_flag] if attributes.key?(:display_internal_notes_flag)

  self.expected_ship_date = attributes[:expected_ship_date] if attributes.key?(:expected_ship_date)

  self.internal_notes = attributes[:internal_notes] if attributes.key?(:internal_notes)

  self.packing_slip = attributes[:packing_slip] if attributes.key?(:packing_slip)

  self.product = attributes[:product] if attributes.key?(:product)

  self.purchase_order_id = attributes[:purchase_order_id] if attributes.key?(:purchase_order_id)

  self.received_quantity = attributes[:received_quantity] if attributes.key?(:received_quantity)

  self.serial_numbers = attributes[:serial_numbers] if attributes.key?(:serial_numbers)

  self.ship_date = attributes[:ship_date] if attributes.key?(:ship_date)

  self.shipment_method = attributes[:shipment_method] if attributes.key?(:shipment_method)

  self.tax = attributes[:tax] if attributes.key?(:tax)

  self.tracking_number = attributes[:tracking_number] if attributes.key?(:tracking_number)

  self.unit_cost = attributes[:unit_cost] if attributes.key?(:unit_cost)

  self.unit_of_measure = attributes[:unit_of_measure] if attributes.key?(:unit_of_measure)

  self.vendor_order_number = attributes[:vendor_order_number] if attributes.key?(:vendor_order_number)

  self.vendor_sku = attributes[:vendor_sku] if attributes.key?(:vendor_sku)

  self.warehouse = attributes[:warehouse] if attributes.key?(:warehouse)

  self.warehouse_bin = attributes[:warehouse_bin] if attributes.key?(:warehouse_bin)

  self.ship_set = attributes[:ship_set] if attributes.key?(:ship_set)

  self.date_received = attributes[:date_received] if attributes.key?(:date_received)

  self.received_status = attributes[:received_status] if attributes.key?(:received_status)

  if attributes.key?(:_info) && (value = attributes[:_info]).is_a?(Hash)
    self._info = value
  end

  return unless attributes.key?(:custom_fields)
  return unless (value = attributes[:custom_fields]).is_a?(Array)

  self.custom_fields = value
end

Instance Attribute Details

#_infoObject

Returns the value of attribute _info.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def _info
  @_info
end

#backordered_flagObject

Returns the value of attribute backordered_flag.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def backordered_flag
  @backordered_flag
end

#canceled_byObject

Returns the value of attribute canceled_by.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def canceled_by
  @canceled_by
end

#canceled_flagObject

Returns the value of attribute canceled_flag.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def canceled_flag
  @canceled_flag
end

#canceled_reasonObject

Max length: 100;



22
23
24
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 22

def canceled_reason
  @canceled_reason
end

#closed_flagObject

Returns the value of attribute closed_flag.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def closed_flag
  @closed_flag
end

#custom_fieldsObject

Returns the value of attribute custom_fields.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def custom_fields
  @custom_fields
end

#date_canceledObject

Returns the value of attribute date_canceled.



19
20
21
# File 'lib/connect_wise/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.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def date_canceled_utc
  @date_canceled_utc
end

#date_receivedObject

Returns the value of attribute date_received.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def date_received
  @date_received
end

#descriptionObject

Max length: 6000;



17
18
19
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 17

def description
  @description
end

#display_internal_notes_flagObject

Returns the value of attribute display_internal_notes_flag.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def display_internal_notes_flag
  @display_internal_notes_flag
end

#expected_ship_dateObject

Returns the value of attribute expected_ship_date.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def expected_ship_date
  @expected_ship_date
end

#idObject

Returns the value of attribute id.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def id
  @id
end

#internal_notesObject

Max length: 1000;



25
26
27
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 25

def internal_notes
  @internal_notes
end

#line_numberObject

Returns the value of attribute line_number.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def line_number
  @line_number
end

#packing_slipObject

Max length: 50;



28
29
30
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 28

def packing_slip
  @packing_slip
end

#productObject

Returns the value of attribute product.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def product
  @product
end

#purchase_order_idObject

Returns the value of attribute purchase_order_id.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def purchase_order_id
  @purchase_order_id
end

#quantityObject

Returns the value of attribute quantity.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def quantity
  @quantity
end

#received_quantityObject

Returns the value of attribute received_quantity.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def received_quantity
  @received_quantity
end

#received_statusObject

Returns the value of attribute received_status.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def received_status
  @received_status
end

#serial_numbersObject

Returns the value of attribute serial_numbers.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def serial_numbers
  @serial_numbers
end

#ship_dateObject

Returns the value of attribute ship_date.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def ship_date
  @ship_date
end

#ship_setObject

Max length: 10;



40
41
42
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 40

def ship_set
  @ship_set
end

#shipment_methodObject

Returns the value of attribute shipment_method.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def shipment_method
  @shipment_method
end

#taxObject

Returns the value of attribute tax.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def tax
  @tax
end

#tracking_numberObject

Max length: 50;



31
32
33
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 31

def tracking_number
  @tracking_number
end

#unit_costObject

Returns the value of attribute unit_cost.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def unit_cost
  @unit_cost
end

#unit_of_measureObject

Returns the value of attribute unit_of_measure.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def unit_of_measure
  @unit_of_measure
end

#vendor_order_numberObject

Max length: 50;



34
35
36
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 34

def vendor_order_number
  @vendor_order_number
end

#vendor_skuObject

Max length: 50;



37
38
39
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 37

def vendor_sku
  @vendor_sku
end

#warehouseObject

Returns the value of attribute warehouse.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def warehouse
  @warehouse
end

#warehouse_binObject

Returns the value of attribute warehouse_bin.



19
20
21
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 19

def warehouse_bin
  @warehouse_bin
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



104
105
106
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 104

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



64
65
66
67
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
101
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 64

def self.attribute_map
  {
    description: :description,
    line_number: :lineNumber,
    quantity: :quantity,
    id: :id,
    backordered_flag: :backorderedFlag,
    canceled_by: :canceledBy,
    canceled_flag: :canceledFlag,
    canceled_reason: :canceledReason,
    closed_flag: :closedFlag,
    date_canceled: :dateCanceled,
    date_canceled_utc: :dateCanceledUtc,
    display_internal_notes_flag: :displayInternalNotesFlag,
    expected_ship_date: :expectedShipDate,
    internal_notes: :internalNotes,
    packing_slip: :packingSlip,
    product: :product,
    purchase_order_id: :purchaseOrderId,
    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,
    vendor_sku: :vendorSku,
    warehouse: :warehouse,
    warehouse_bin: :warehouseBin,
    ship_set: :shipSet,
    date_received: :dateReceived,
    received_status: :receivedStatus,
    _info: :_info,
    custom_fields: :customFields
  }
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



337
338
339
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 337

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 149

def self.openapi_nullable
  Set.new(i[
            line_number
            quantity
            backordered_flag
            canceled_flag
            closed_flag
            display_internal_notes_flag
            purchase_order_id
            received_quantity
            tax
            unit_cost
            received_status
          ])
end

.openapi_typesObject

Attribute type mapping.



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
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 109

def self.openapi_types
  {
    description: :String,
    line_number: :Integer,
    quantity: :Float,
    id: :Integer,
    backordered_flag: :Boolean,
    canceled_by: :String,
    canceled_flag: :Boolean,
    canceled_reason: :String,
    closed_flag: :Boolean,
    date_canceled: :Time,
    date_canceled_utc: :Time,
    display_internal_notes_flag: :Boolean,
    expected_ship_date: :Time,
    internal_notes: :String,
    packing_slip: :String,
    product: :IvItemReference,
    purchase_order_id: :Integer,
    received_quantity: :Integer,
    serial_numbers: :String,
    ship_date: :Time,
    shipment_method: :ShipmentMethodReference,
    tax: :Float,
    tracking_number: :String,
    unit_cost: :Float,
    unit_of_measure: :UnitOfMeasureReference,
    vendor_order_number: :String,
    vendor_sku: :String,
    warehouse: :WarehouseReference,
    warehouse_bin: :WarehouseBinReference,
    ship_set: :String,
    date_received: :Time,
    received_status: :String,
    _info: :'Hash<String, String>',
    custom_fields: :'Array<CustomFieldValue>'
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 282

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    description == other.description &&
    line_number == other.line_number &&
    quantity == other.quantity &&
    id == other.id &&
    backordered_flag == other.backordered_flag &&
    canceled_by == other.canceled_by &&
    canceled_flag == other.canceled_flag &&
    canceled_reason == other.canceled_reason &&
    closed_flag == other.closed_flag &&
    date_canceled == other.date_canceled &&
    date_canceled_utc == other.date_canceled_utc &&
    display_internal_notes_flag == other.display_internal_notes_flag &&
    expected_ship_date == other.expected_ship_date &&
    internal_notes == other.internal_notes &&
    packing_slip == other.packing_slip &&
    product == other.product &&
    purchase_order_id == other.purchase_order_id &&
    received_quantity == other.received_quantity &&
    serial_numbers == other.serial_numbers &&
    ship_date == other.ship_date &&
    shipment_method == other.shipment_method &&
    tax == other.tax &&
    tracking_number == other.tracking_number &&
    unit_cost == other.unit_cost &&
    unit_of_measure == other.unit_of_measure &&
    vendor_order_number == other.vendor_order_number &&
    vendor_sku == other.vendor_sku &&
    warehouse == other.warehouse &&
    warehouse_bin == other.warehouse_bin &&
    ship_set == other.ship_set &&
    date_received == other.date_received &&
    received_status == other.received_status &&
    _info == other._info &&
    custom_fields == other.custom_fields
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



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
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 367

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.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
    # models (e.g. Pet) or oneOf
    klass = ConnectWise.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.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



438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 438

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



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 344

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  attributes = attributes.transform_keys(&:to_sym)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      send("#{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
      send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }) if attributes[self.class.attribute_map[key]].is_a?(Array)
    elsif !attributes[self.class.attribute_map[key]].nil?
      send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


324
325
326
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 324

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



330
331
332
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 330

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

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



253
254
255
256
257
258
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 253

def list_invalid_properties
  invalid_properties = []
  invalid_properties.push('invalid value for "description", description cannot be nil.') if @description.nil?

  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



414
415
416
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 414

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



420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 420

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = 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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



408
409
410
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 408

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



262
263
264
265
266
267
268
269
# File 'lib/connect_wise/models/purchase_order_line_item.rb', line 262

def valid?
  return false if @description.nil?

  received_status_validator = EnumAttributeValidator.new('String', %w[Waiting FullyReceived PartiallyReceiveCancelRest PartiallyReceiveCloneRest])
  return false unless received_status_validator.valid?(@received_status)

  true
end