Class: ConnectWise::Commission

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Commission

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

end

Instance Attribute Details

#_infoObject

Metadata of the entity



66
67
68
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 66

def _info
  @_info
end

#agreementObject

Returns the value of attribute agreement.



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

def agreement
  @agreement
end

#agreement_typeObject

Returns the value of attribute agreement_type.



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

def agreement_type
  @agreement_type
end

#agreements_flagObject

Returns the value of attribute agreements_flag.



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

def agreements_flag
  @agreements_flag
end

#billing_methodObject

Returns the value of attribute billing_method.



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

def billing_method
  @billing_method
end

#commission_basisObject

Returns the value of attribute commission_basis.



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

def commission_basis
  @commission_basis
end

#commission_percentObject

Returns the value of attribute commission_percent.



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

def commission_percent
  @commission_percent
end

#companyObject

Returns the value of attribute company.



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

def company
  @company
end

#date_endObject

Returns the value of attribute date_end.



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

def date_end
  @date_end
end

#date_startObject

Returns the value of attribute date_start.



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

def date_start
  @date_start
end

#departmentObject

Returns the value of attribute department.



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

def department
  @department
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#invoice_optionObject

Returns the value of attribute invoice_option.



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

def invoice_option
  @invoice_option
end

#itemObject

Returns the value of attribute item.



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

def item
  @item
end

#locationObject

Returns the value of attribute location.



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

def location
  @location
end

#memberObject

Returns the value of attribute member.



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

def member
  @member
end

#my_opportunities_flagObject

Returns the value of attribute my_opportunities_flag.



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

def my_opportunities_flag
  @my_opportunities_flag
end

#number_of_monthsObject

Returns the value of attribute number_of_months.



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

def number_of_months
  @number_of_months
end

#product_categoryObject

Returns the value of attribute product_category.



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

def product_category
  @product_category
end

#product_sub_categoryObject

Returns the value of attribute product_sub_category.



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

def product_sub_category
  @product_sub_category
end

#products_flagObject

Returns the value of attribute products_flag.



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

def products_flag
  @products_flag
end

#projectObject

Returns the value of attribute project.



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

def project
  @project
end

#project_boardObject

Returns the value of attribute project_board.



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

def project_board
  @project_board
end

#project_typeObject

Returns the value of attribute project_type.



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

def project_type
  @project_type
end

#service_boardObject

Returns the value of attribute service_board.



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

def service_board
  @service_board
end

#service_typeObject

Returns the value of attribute service_type.



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

def service_type
  @service_type
end

#services_flagObject

Returns the value of attribute services_flag.



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

def services_flag
  @services_flag
end

#siteObject

Returns the value of attribute site.



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

def site
  @site
end

#territoryObject

Returns the value of attribute territory.



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

def territory
  @territory
end

#ticketObject

Returns the value of attribute ticket.



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

def ticket
  @ticket
end

Class Method Details

.attribute_mapObject

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



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/connectwise-ruby-sdk/models/commission.rb', line 91

def self.attribute_map
  {
    :'id' => :'id',
    :'member' => :'member',
    :'commission_percent' => :'commissionPercent',
    :'date_start' => :'dateStart',
    :'date_end' => :'dateEnd',
    :'location' => :'location',
    :'department' => :'department',
    :'company' => :'company',
    :'site' => :'site',
    :'agreement' => :'agreement',
    :'project' => :'project',
    :'service_board' => :'serviceBoard',
    :'ticket' => :'ticket',
    :'territory' => :'territory',
    :'billing_method' => :'billingMethod',
    :'service_type' => :'serviceType',
    :'project_board' => :'projectBoard',
    :'project_type' => :'projectType',
    :'agreement_type' => :'agreementType',
    :'number_of_months' => :'numberOfMonths',
    :'product_category' => :'productCategory',
    :'product_sub_category' => :'productSubCategory',
    :'item' => :'item',
    :'commission_basis' => :'commissionBasis',
    :'invoice_option' => :'invoiceOption',
    :'services_flag' => :'servicesFlag',
    :'agreements_flag' => :'agreementsFlag',
    :'products_flag' => :'productsFlag',
    :'my_opportunities_flag' => :'myOpportunitiesFlag',
    :'_info' => :'_info'
  }
end

.swagger_typesObject

Attribute type mapping.



127
128
129
130
131
132
133
134
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
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 127

def self.swagger_types
  {
    :'id' => :'Integer',
    :'member' => :'MemberReference',
    :'commission_percent' => :'Float',
    :'date_start' => :'DateTime',
    :'date_end' => :'DateTime',
    :'location' => :'SystemLocationReference',
    :'department' => :'SystemDepartmentReference',
    :'company' => :'CompanyReference',
    :'site' => :'SiteReference',
    :'agreement' => :'AgreementReference',
    :'project' => :'ProjectReference',
    :'service_board' => :'BoardReference',
    :'ticket' => :'TicketReference',
    :'territory' => :'SystemLocationReference',
    :'billing_method' => :'String',
    :'service_type' => :'ServiceTypeReference',
    :'project_board' => :'ProjectBoardReference',
    :'project_type' => :'ProjectTypeReference',
    :'agreement_type' => :'AgreementTypeReference',
    :'number_of_months' => :'Integer',
    :'product_category' => :'ProductCategoryReference',
    :'product_sub_category' => :'ProductSubCategoryReference',
    :'item' => :'IvItemReference',
    :'commission_basis' => :'String',
    :'invoice_option' => :'String',
    :'services_flag' => :'BOOLEAN',
    :'agreements_flag' => :'BOOLEAN',
    :'products_flag' => :'BOOLEAN',
    :'my_opportunities_flag' => :'BOOLEAN',
    :'_info' => :'Metadata'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



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

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      member == o.member &&
      commission_percent == o.commission_percent &&
      date_start == o.date_start &&
      date_end == o.date_end &&
      location == o.location &&
      department == o.department &&
      company == o.company &&
      site == o.site &&
      agreement == o.agreement &&
      project == o.project &&
      service_board == o.service_board &&
      ticket == o.ticket &&
      territory == o.territory &&
      billing_method == o.billing_method &&
      service_type == o.service_type &&
      project_board == o.project_board &&
      project_type == o.project_type &&
      agreement_type == o.agreement_type &&
      number_of_months == o.number_of_months &&
      product_category == o.product_category &&
      product_sub_category == o.product_sub_category &&
      item == o.item &&
      commission_basis == o.commission_basis &&
      invoice_option == o.invoice_option &&
      services_flag == o.services_flag &&
      agreements_flag == o.agreements_flag &&
      products_flag == o.products_flag &&
      my_opportunities_flag == o.my_opportunities_flag &&
      _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



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
451
452
453
454
455
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 419

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



485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 485

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



398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 398

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


385
386
387
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 385

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



391
392
393
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 391

def hash
  [id, member, commission_percent, date_start, date_end, location, department, company, site, agreement, project, service_board, ticket, territory, billing_method, service_type, project_board, project_type, agreement_type, number_of_months, product_category, product_sub_category, item, commission_basis, invoice_option, services_flag, agreements_flag, products_flag, my_opportunities_flag, _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



294
295
296
297
298
299
300
301
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 294

def list_invalid_properties
  invalid_properties = Array.new
  if @member.nil?
    invalid_properties.push("invalid value for 'member', member cannot be nil.")
  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



465
466
467
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 465

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



471
472
473
474
475
476
477
478
479
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 471

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



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

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



305
306
307
308
309
310
311
312
313
314
# File 'lib/connectwise-ruby-sdk/models/commission.rb', line 305

def valid?
  return false if @member.nil?
  billing_method_validator = EnumAttributeValidator.new('String', ["Agreement", "CreditMemo", "DownPayment", "Miscellaneous", "Progress", "Standard"])
  return false unless billing_method_validator.valid?(@billing_method)
  commission_basis_validator = EnumAttributeValidator.new('String', ["SalesAmount", "GrossProfit"])
  return false unless commission_basis_validator.valid?(@commission_basis)
  invoice_option_validator = EnumAttributeValidator.new('String', ["PaidInvoices", "AllInvoices"])
  return false unless invoice_option_validator.valid?(@invoice_option)
  return true
end