Class: ConnectWise::Order

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Order

Initializes the object

Parameters:

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

    Model attributes in the form of hash

Raises:

  • (ArgumentError)


135
136
137
138
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
# File 'lib/connect_wise/models/order.rb', line 135

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  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/order.rb', line 16

def _info
  @_info
end

#bill_closed_flagObject

Returns the value of attribute bill_closed_flag.



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

def bill_closed_flag
  @bill_closed_flag
end

#bill_shipped_flagObject

Returns the value of attribute bill_shipped_flag.



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

def bill_shipped_flag
  @bill_shipped_flag
end

#bill_to_companyObject

Returns the value of attribute bill_to_company.



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

def bill_to_company
  @bill_to_company
end

#bill_to_contactObject

Returns the value of attribute bill_to_contact.



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

def bill_to_contact
  @bill_to_contact
end

#bill_to_siteObject

Returns the value of attribute bill_to_site.



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

def bill_to_site
  @bill_to_site
end

#billing_termsObject

Returns the value of attribute billing_terms.



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

def billing_terms
  @billing_terms
end

#bottom_comment_flagObject

Returns the value of attribute bottom_comment_flag.



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

def bottom_comment_flag
  @bottom_comment_flag
end

#companyObject

Returns the value of attribute company.



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

def company
  @company
end

#company_locationObject

Returns the value of attribute company_location.



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

def company_location
  @company_location
end

#config_idsObject

Returns the value of attribute config_ids.



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

def config_ids
  @config_ids
end

#contactObject

Returns the value of attribute contact.



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

def contact
  @contact
end

#currencyObject

Returns the value of attribute currency.



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

def currency
  @currency
end

#custom_fieldsObject

Returns the value of attribute custom_fields.



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

def custom_fields
  @custom_fields
end

#departmentObject

Returns the value of attribute department.



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

def department
  @department
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#document_idsObject

Returns the value of attribute document_ids.



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

def document_ids
  @document_ids
end

#due_dateObject

Returns the value of attribute due_date.



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

def due_date
  @due_date
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#invoice_idsObject

Returns the value of attribute invoice_ids.



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

def invoice_ids
  @invoice_ids
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#notesObject

Returns the value of attribute notes.



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

def notes
  @notes
end

#opportunityObject

Returns the value of attribute opportunity.



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

def opportunity
  @opportunity
end

#order_dateObject

Returns the value of attribute order_date.



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

def order_date
  @order_date
end

#phoneObject

Returns the value of attribute phone.



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

def phone
  @phone
end

#phone_extObject

Returns the value of attribute phone_ext.



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

def phone_ext
  @phone_ext
end

#po_numberObject

Max length: 50;



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

def po_number
  @po_number
end

#product_idsObject

Returns the value of attribute product_ids.



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

def product_ids
  @product_ids
end

#restrict_downpayment_flagObject

Returns the value of attribute restrict_downpayment_flag.



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

def restrict_downpayment_flag
  @restrict_downpayment_flag
end

#sales_repObject

Returns the value of attribute sales_rep.



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

def sales_rep
  @sales_rep
end

#ship_to_companyObject

Returns the value of attribute ship_to_company.



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

def ship_to_company
  @ship_to_company
end

#ship_to_contactObject

Returns the value of attribute ship_to_contact.



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

def ship_to_contact
  @ship_to_contact
end

#ship_to_siteObject

Returns the value of attribute ship_to_site.



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

def ship_to_site
  @ship_to_site
end

#siteObject

Returns the value of attribute site.



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

def site
  @site
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#sub_totalObject

Returns the value of attribute sub_total.



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

def sub_total
  @sub_total
end

#tax_codeObject

Returns the value of attribute tax_code.



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

def tax_code
  @tax_code
end

#tax_totalObject

Returns the value of attribute tax_total.



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

def tax_total
  @tax_total
end

#top_comment_flagObject

Returns the value of attribute top_comment_flag.



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

def top_comment_flag
  @top_comment_flag
end

#totalObject

Returns the value of attribute total.



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

def total
  @total
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



69
70
71
# File 'lib/connect_wise/models/order.rb', line 69

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

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



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/connect_wise/models/order.rb', line 22

def self.attribute_map
  {
    id: :id,
    company: :company,
    contact: :contact,
    phone: :phone,
    phone_ext: :phoneExt,
    email: :email,
    site: :site,
    status: :status,
    opportunity: :opportunity,
    order_date: :orderDate,
    due_date: :dueDate,
    billing_terms: :billingTerms,
    tax_code: :taxCode,
    po_number: :poNumber,
    location: :location,
    department: :department,
    sales_rep: :salesRep,
    notes: :notes,
    bill_closed_flag: :billClosedFlag,
    bill_shipped_flag: :billShippedFlag,
    restrict_downpayment_flag: :restrictDownpaymentFlag,
    description: :description,
    top_comment_flag: :topCommentFlag,
    bottom_comment_flag: :bottomCommentFlag,
    ship_to_company: :shipToCompany,
    ship_to_contact: :shipToContact,
    ship_to_site: :shipToSite,
    bill_to_company: :billToCompany,
    bill_to_contact: :billToContact,
    bill_to_site: :billToSite,
    product_ids: :productIds,
    document_ids: :documentIds,
    invoice_ids: :invoiceIds,
    config_ids: :configIds,
    total: :total,
    tax_total: :taxTotal,
    currency: :currency,
    company_location: :companyLocation,
    sub_total: :subTotal,
    _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



317
318
319
# File 'lib/connect_wise/models/order.rb', line 317

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

.openapi_nullableObject

List of attributes with nullable: true



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/connect_wise/models/order.rb', line 121

def self.openapi_nullable
  Set.new(i[
            bill_closed_flag
            bill_shipped_flag
            restrict_downpayment_flag
            top_comment_flag
            bottom_comment_flag
            total
            tax_total
          ])
end

.openapi_typesObject

Attribute type mapping.



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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/connect_wise/models/order.rb', line 74

def self.openapi_types
  {
    id: :Integer,
    company: :CompanyReference,
    contact: :ContactReference,
    phone: :String,
    phone_ext: :String,
    email: :String,
    site: :SiteReference,
    status: :OrderStatusReference,
    opportunity: :OpportunityReference,
    order_date: :Time,
    due_date: :Time,
    billing_terms: :BillingTermsReference,
    tax_code: :TaxCodeReference,
    po_number: :String,
    location: :SystemLocationReference,
    department: :SystemDepartmentReference,
    sales_rep: :MemberReference,
    notes: :String,
    bill_closed_flag: :Boolean,
    bill_shipped_flag: :Boolean,
    restrict_downpayment_flag: :Boolean,
    description: :String,
    top_comment_flag: :Boolean,
    bottom_comment_flag: :Boolean,
    ship_to_company: :CompanyReference,
    ship_to_contact: :ContactReference,
    ship_to_site: :SiteReference,
    bill_to_company: :CompanyReference,
    bill_to_contact: :ContactReference,
    bill_to_site: :SiteReference,
    product_ids: :'Array<Integer>',
    document_ids: :'Array<Integer>',
    invoice_ids: :'Array<Integer>',
    config_ids: :'Array<Integer>',
    total: :Float,
    tax_total: :Float,
    currency: :CurrencyReference,
    company_location: :SystemLocationReference,
    sub_total: :Float,
    _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



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

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

  self.class == other.class &&
    id == other.id &&
    company == other.company &&
    contact == other.contact &&
    phone == other.phone &&
    phone_ext == other.phone_ext &&
    email == other.email &&
    site == other.site &&
    status == other.status &&
    opportunity == other.opportunity &&
    order_date == other.order_date &&
    due_date == other.due_date &&
    billing_terms == other.billing_terms &&
    tax_code == other.tax_code &&
    po_number == other.po_number &&
    location == other.location &&
    department == other.department &&
    sales_rep == other.sales_rep &&
    notes == other.notes &&
    bill_closed_flag == other.bill_closed_flag &&
    bill_shipped_flag == other.bill_shipped_flag &&
    restrict_downpayment_flag == other.restrict_downpayment_flag &&
    description == other.description &&
    top_comment_flag == other.top_comment_flag &&
    bottom_comment_flag == other.bottom_comment_flag &&
    ship_to_company == other.ship_to_company &&
    ship_to_contact == other.ship_to_contact &&
    ship_to_site == other.ship_to_site &&
    bill_to_company == other.bill_to_company &&
    bill_to_contact == other.bill_to_contact &&
    bill_to_site == other.bill_to_site &&
    product_ids == other.product_ids &&
    document_ids == other.document_ids &&
    invoice_ids == other.invoice_ids &&
    config_ids == other.config_ids &&
    total == other.total &&
    tax_total == other.tax_total &&
    currency == other.currency &&
    company_location == other.company_location &&
    sub_total == other.sub_total &&
    _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



347
348
349
350
351
352
353
354
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
# File 'lib/connect_wise/models/order.rb', line 347

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



418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/connect_wise/models/order.rb', line 418

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



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/connect_wise/models/order.rb', line 324

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


304
305
306
# File 'lib/connect_wise/models/order.rb', line 304

def eql?(other)
  self == other
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



310
311
312
# File 'lib/connect_wise/models/order.rb', line 310

def hash
  [id, company, contact, phone, phone_ext, email, site, status, opportunity, order_date, due_date, billing_terms, tax_code, po_number, location, department, sales_rep, notes, bill_closed_flag, bill_shipped_flag, restrict_downpayment_flag, description, top_comment_flag, bottom_comment_flag, ship_to_company, ship_to_contact, ship_to_site, bill_to_company, bill_to_contact, bill_to_site, product_ids, document_ids, invoice_ids, config_ids, total, tax_total, currency, company_location, sub_total, _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



243
244
245
# File 'lib/connect_wise/models/order.rb', line 243

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



394
395
396
# File 'lib/connect_wise/models/order.rb', line 394

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



400
401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/connect_wise/models/order.rb', line 400

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



388
389
390
# File 'lib/connect_wise/models/order.rb', line 388

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



249
250
251
# File 'lib/connect_wise/models/order.rb', line 249

def valid?
  true
end