Class: ConnectWise::Addition

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Addition

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Raises:

  • (ArgumentError)


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

def initialize(attributes = {})
  raise ArgumentError, 'The input argument (attributes) must be a hash in `ConnectWise::Addition` 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::Addition`. 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.bill_customer = attributes[:bill_customer] if attributes.key?(:bill_customer)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  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.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def _info
  @_info
end

#agreement_idObject

Returns the value of attribute agreement_id.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def agreement_id
  @agreement_id
end

#agreement_statusObject

Returns the value of attribute agreement_status.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def agreement_status
  @agreement_status
end

#bill_customerObject

Returns the value of attribute bill_customer.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def bill_customer
  @bill_customer
end

#billed_quantityObject

Returns the value of attribute billed_quantity.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def billed_quantity
  @billed_quantity
end

#cancelled_dateObject

Returns the value of attribute cancelled_date.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def cancelled_date
  @cancelled_date
end

#custom_fieldsObject

Returns the value of attribute custom_fields.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def custom_fields
  @custom_fields
end

#descriptionObject

Returns the value of attribute description.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def description
  @description
end

#effective_dateObject

Returns the value of attribute effective_date.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def effective_date
  @effective_date
end

#ext_costObject

Returns the value of attribute ext_cost.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def ext_cost
  @ext_cost
end

#ext_priceObject

Returns the value of attribute ext_price.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def ext_price
  @ext_price
end

#extended_prorate_costObject

Returns the value of attribute extended_prorate_cost.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def extended_prorate_cost
  @extended_prorate_cost
end

#extended_prorate_priceObject

Returns the value of attribute extended_prorate_price.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def extended_prorate_price
  @extended_prorate_price
end

#idObject

Returns the value of attribute id.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def id
  @id
end

#invoice_descriptionObject

Max length: 6000;



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

def invoice_description
  @invoice_description
end

#invoice_groupingObject

Returns the value of attribute invoice_grouping.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def invoice_grouping
  @invoice_grouping
end

#less_includedObject

Returns the value of attribute less_included.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def less_included
  @less_included
end

#marginObject

Returns the value of attribute margin.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def margin
  @margin
end

#opportunityObject

Returns the value of attribute opportunity.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def opportunity
  @opportunity
end

#productObject

Returns the value of attribute product.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def product
  @product
end

#prorate_costObject

Returns the value of attribute prorate_cost.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def prorate_cost
  @prorate_cost
end

#prorate_current_period_flagObject

Returns the value of attribute prorate_current_period_flag.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def prorate_current_period_flag
  @prorate_current_period_flag
end

#prorate_priceObject

Returns the value of attribute prorate_price.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def prorate_price
  @prorate_price
end

#purchase_item_flagObject

Returns the value of attribute purchase_item_flag.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def purchase_item_flag
  @purchase_item_flag
end

#quantityObject

Returns the value of attribute quantity.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def quantity
  @quantity
end

#sequence_numberObject

Returns the value of attribute sequence_number.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def sequence_number
  @sequence_number
end

#serial_numberObject

Max length: 50;



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

def serial_number
  @serial_number
end

#special_order_flagObject

Returns the value of attribute special_order_flag.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def special_order_flag
  @special_order_flag
end

#taxable_flagObject

Returns the value of attribute taxable_flag.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def taxable_flag
  @taxable_flag
end

#unit_costObject

Returns the value of attribute unit_cost.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def unit_cost
  @unit_cost
end

#unit_priceObject

Returns the value of attribute unit_price.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def unit_price
  @unit_price
end

#uomObject

Returns the value of attribute uom.



16
17
18
# File 'lib/connect_wise/models/addition.rb', line 16

def uom
  @uom
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



84
85
86
# File 'lib/connect_wise/models/addition.rb', line 84

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/connect_wise/models/addition.rb', line 46

def self.attribute_map
  {
    bill_customer: :billCustomer,
    id: :id,
    product: :product,
    quantity: :quantity,
    less_included: :lessIncluded,
    unit_price: :unitPrice,
    unit_cost: :unitCost,
    effective_date: :effectiveDate,
    cancelled_date: :cancelledDate,
    taxable_flag: :taxableFlag,
    serial_number: :serialNumber,
    invoice_description: :invoiceDescription,
    purchase_item_flag: :purchaseItemFlag,
    special_order_flag: :specialOrderFlag,
    agreement_id: :agreementId,
    description: :description,
    billed_quantity: :billedQuantity,
    uom: :uom,
    ext_price: :extPrice,
    ext_cost: :extCost,
    sequence_number: :sequenceNumber,
    margin: :margin,
    prorate_cost: :prorateCost,
    prorate_price: :proratePrice,
    extended_prorate_cost: :extendedProrateCost,
    extended_prorate_price: :extendedProratePrice,
    prorate_current_period_flag: :prorateCurrentPeriodFlag,
    opportunity: :opportunity,
    agreement_status: :agreementStatus,
    invoice_grouping: :invoiceGrouping,
    _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



325
326
327
# File 'lib/connect_wise/models/addition.rb', line 325

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

.openapi_nullableObject

List of attributes with nullable: true



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/connect_wise/models/addition.rb', line 127

def self.openapi_nullable
  Set.new(i[
            bill_customer
            quantity
            less_included
            unit_price
            unit_cost
            taxable_flag
            purchase_item_flag
            special_order_flag
            agreement_id
            billed_quantity
            ext_price
            ext_cost
            sequence_number
            margin
            prorate_cost
            prorate_price
            extended_prorate_cost
            extended_prorate_price
            prorate_current_period_flag
            agreement_status
          ])
end

.openapi_typesObject

Attribute type mapping.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/connect_wise/models/addition.rb', line 89

def self.openapi_types
  {
    bill_customer: :String,
    id: :Integer,
    product: :IvItemReference,
    quantity: :Float,
    less_included: :Float,
    unit_price: :Float,
    unit_cost: :Float,
    effective_date: :Time,
    cancelled_date: :Time,
    taxable_flag: :Boolean,
    serial_number: :String,
    invoice_description: :String,
    purchase_item_flag: :Boolean,
    special_order_flag: :Boolean,
    agreement_id: :Integer,
    description: :String,
    billed_quantity: :Float,
    uom: :String,
    ext_price: :Float,
    ext_cost: :Float,
    sequence_number: :Float,
    margin: :Float,
    prorate_cost: :Float,
    prorate_price: :Float,
    extended_prorate_cost: :Float,
    extended_prorate_price: :Float,
    prorate_current_period_flag: :Boolean,
    opportunity: :OpportunityReference,
    agreement_status: :String,
    invoice_grouping: :InvoiceGroupingReference,
    _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



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

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

  self.class == other.class &&
    bill_customer == other.bill_customer &&
    id == other.id &&
    product == other.product &&
    quantity == other.quantity &&
    less_included == other.less_included &&
    unit_price == other.unit_price &&
    unit_cost == other.unit_cost &&
    effective_date == other.effective_date &&
    cancelled_date == other.cancelled_date &&
    taxable_flag == other.taxable_flag &&
    serial_number == other.serial_number &&
    invoice_description == other.invoice_description &&
    purchase_item_flag == other.purchase_item_flag &&
    special_order_flag == other.special_order_flag &&
    agreement_id == other.agreement_id &&
    description == other.description &&
    billed_quantity == other.billed_quantity &&
    uom == other.uom &&
    ext_price == other.ext_price &&
    ext_cost == other.ext_cost &&
    sequence_number == other.sequence_number &&
    margin == other.margin &&
    prorate_cost == other.prorate_cost &&
    prorate_price == other.prorate_price &&
    extended_prorate_cost == other.extended_prorate_cost &&
    extended_prorate_price == other.extended_prorate_price &&
    prorate_current_period_flag == other.prorate_current_period_flag &&
    opportunity == other.opportunity &&
    agreement_status == other.agreement_status &&
    invoice_grouping == other.invoice_grouping &&
    _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



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

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



426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/connect_wise/models/addition.rb', line 426

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



332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/connect_wise/models/addition.rb', line 332

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


312
313
314
# File 'lib/connect_wise/models/addition.rb', line 312

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



318
319
320
# File 'lib/connect_wise/models/addition.rb', line 318

def hash
  [bill_customer, id, product, quantity, less_included, unit_price, unit_cost, effective_date, cancelled_date, taxable_flag, serial_number, invoice_description, purchase_item_flag, special_order_flag, agreement_id, description, billed_quantity, uom, ext_price, ext_cost, sequence_number, margin, prorate_cost, prorate_price, extended_prorate_cost, extended_prorate_price, prorate_current_period_flag, opportunity, agreement_status, invoice_grouping, _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



236
237
238
# File 'lib/connect_wise/models/addition.rb', line 236

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



402
403
404
# File 'lib/connect_wise/models/addition.rb', line 402

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



408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/connect_wise/models/addition.rb', line 408

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



396
397
398
# File 'lib/connect_wise/models/addition.rb', line 396

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



242
243
244
245
246
247
248
249
250
# File 'lib/connect_wise/models/addition.rb', line 242

def valid?
  bill_customer_validator = EnumAttributeValidator.new('String', %w[Billable DoNotBill NoCharge])
  return false unless bill_customer_validator.valid?(@bill_customer)

  agreement_status_validator = EnumAttributeValidator.new('String', %w[Active Cancelled Expired Inactive])
  return false unless agreement_status_validator.valid?(@agreement_status)

  true
end