Class: ConnectWise::Purchasing

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

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Purchasing

Initializes the object

Parameters:

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

    Model attributes in the form of hash



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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

end

Instance Attribute Details

#_infoObject

Metadata of the entity



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

def _info
  @_info
end

#auto_approve_purchase_order_flagObject

Returns the value of attribute auto_approve_purchase_order_flag.



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

def auto_approve_purchase_order_flag
  @auto_approve_purchase_order_flag
end

#auto_close_purchase_order_flagObject

Returns the value of attribute auto_close_purchase_order_flag.



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

def auto_close_purchase_order_flag
  @auto_close_purchase_order_flag
end

#auto_close_purchase_order_item_flagObject

Returns the value of attribute auto_close_purchase_order_item_flag.



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

def auto_close_purchase_order_item_flag
  @auto_close_purchase_order_item_flag
end

#costing_methodObject

Returns the value of attribute costing_method.



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

def costing_method
  @costing_method
end

#disable_cost_updates_flagObject

Returns the value of attribute disable_cost_updates_flag.



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

def disable_cost_updates_flag
  @disable_cost_updates_flag
end

#disable_negative_inventory_flagObject

Returns the value of attribute disable_negative_inventory_flag.



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

def disable_negative_inventory_flag
  @disable_negative_inventory_flag
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#num_decimal_placesObject

Returns the value of attribute num_decimal_places.



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

def num_decimal_places
  @num_decimal_places
end

#prefix_suffix_typeObject

Returns the value of attribute prefix_suffix_type.



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

def prefix_suffix_type
  @prefix_suffix_type
end

#purchase_order_prefixObject

Returns the value of attribute purchase_order_prefix.



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

def purchase_order_prefix
  @purchase_order_prefix
end

#purchase_order_suffixObject

Returns the value of attribute purchase_order_suffix.



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

def purchase_order_suffix
  @purchase_order_suffix
end

#starting_purchase_order_numObject

Returns the value of attribute starting_purchase_order_num.



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

def starting_purchase_order_num
  @starting_purchase_order_num
end

#tax_freight_flagObject

Returns the value of attribute tax_freight_flag.



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

def tax_freight_flag
  @tax_freight_flag
end

#tax_purchase_order_flagObject

Returns the value of attribute tax_purchase_order_flag.



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

def tax_purchase_order_flag
  @tax_purchase_order_flag
end

#use_vendor_tax_code_flagObject

Returns the value of attribute use_vendor_tax_code_flag.



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

def use_vendor_tax_code_flag
  @use_vendor_tax_code_flag
end

Class Method Details

.attribute_mapObject

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



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 63

def self.attribute_map
  {
    :'id' => :'id',
    :'starting_purchase_order_num' => :'startingPurchaseOrderNum',
    :'purchase_order_prefix' => :'purchaseOrderPrefix',
    :'purchase_order_suffix' => :'purchaseOrderSuffix',
    :'prefix_suffix_type' => :'prefixSuffixType',
    :'disable_cost_updates_flag' => :'disableCostUpdatesFlag',
    :'disable_negative_inventory_flag' => :'disableNegativeInventoryFlag',
    :'costing_method' => :'costingMethod',
    :'auto_close_purchase_order_flag' => :'autoClosePurchaseOrderFlag',
    :'auto_close_purchase_order_item_flag' => :'autoClosePurchaseOrderItemFlag',
    :'auto_approve_purchase_order_flag' => :'autoApprovePurchaseOrderFlag',
    :'tax_purchase_order_flag' => :'taxPurchaseOrderFlag',
    :'tax_freight_flag' => :'taxFreightFlag',
    :'use_vendor_tax_code_flag' => :'useVendorTaxCodeFlag',
    :'num_decimal_places' => :'numDecimalPlaces',
    :'_info' => :'_info'
  }
end

.swagger_typesObject

Attribute type mapping.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 85

def self.swagger_types
  {
    :'id' => :'Integer',
    :'starting_purchase_order_num' => :'Integer',
    :'purchase_order_prefix' => :'String',
    :'purchase_order_suffix' => :'String',
    :'prefix_suffix_type' => :'String',
    :'disable_cost_updates_flag' => :'BOOLEAN',
    :'disable_negative_inventory_flag' => :'BOOLEAN',
    :'costing_method' => :'String',
    :'auto_close_purchase_order_flag' => :'BOOLEAN',
    :'auto_close_purchase_order_item_flag' => :'BOOLEAN',
    :'auto_approve_purchase_order_flag' => :'BOOLEAN',
    :'tax_purchase_order_flag' => :'BOOLEAN',
    :'tax_freight_flag' => :'BOOLEAN',
    :'use_vendor_tax_code_flag' => :'BOOLEAN',
    :'num_decimal_places' => :'Integer',
    :'_info' => :'Metadata'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 314

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      starting_purchase_order_num == o.starting_purchase_order_num &&
      purchase_order_prefix == o.purchase_order_prefix &&
      purchase_order_suffix == o.purchase_order_suffix &&
      prefix_suffix_type == o.prefix_suffix_type &&
      disable_cost_updates_flag == o.disable_cost_updates_flag &&
      disable_negative_inventory_flag == o.disable_negative_inventory_flag &&
      costing_method == o.costing_method &&
      auto_close_purchase_order_flag == o.auto_close_purchase_order_flag &&
      auto_close_purchase_order_item_flag == o.auto_close_purchase_order_item_flag &&
      auto_approve_purchase_order_flag == o.auto_approve_purchase_order_flag &&
      tax_purchase_order_flag == o.tax_purchase_order_flag &&
      tax_freight_flag == o.tax_freight_flag &&
      use_vendor_tax_code_flag == o.use_vendor_tax_code_flag &&
      num_decimal_places == o.num_decimal_places &&
      _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



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
405
406
407
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 371

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



437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 437

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



350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 350

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


337
338
339
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 337

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



343
344
345
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 343

def hash
  [id, starting_purchase_order_num, purchase_order_prefix, purchase_order_suffix, prefix_suffix_type, disable_cost_updates_flag, disable_negative_inventory_flag, costing_method, auto_close_purchase_order_flag, auto_close_purchase_order_item_flag, auto_approve_purchase_order_flag, tax_purchase_order_flag, tax_freight_flag, use_vendor_tax_code_flag, num_decimal_places, _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



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

def list_invalid_properties
  invalid_properties = Array.new
  if @starting_purchase_order_num.nil?
    invalid_properties.push("invalid value for 'starting_purchase_order_num', starting_purchase_order_num cannot be nil.")
  end

  if @starting_purchase_order_num > 2147483647
    invalid_properties.push("invalid value for 'starting_purchase_order_num', must be smaller than or equal to 2147483647.")
  end

  if @starting_purchase_order_num < 0
    invalid_properties.push("invalid value for 'starting_purchase_order_num', must be greater than or equal to 0.")
  end

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

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

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

  if !@num_decimal_places.nil? && @num_decimal_places > 2147483647
    invalid_properties.push("invalid value for 'num_decimal_places', must be smaller than or equal to 2147483647.")
  end

  if !@num_decimal_places.nil? && @num_decimal_places < 0
    invalid_properties.push("invalid value for 'num_decimal_places', must be greater than or equal to 0.")
  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



417
418
419
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 417

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



423
424
425
426
427
428
429
430
431
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 423

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



411
412
413
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 411

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



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/connectwise-ruby-sdk/models/purchasing.rb', line 221

def valid?
  return false if @starting_purchase_order_num.nil?
  return false if @starting_purchase_order_num > 2147483647
  return false if @starting_purchase_order_num < 0
  return false if !@purchase_order_prefix.nil? && @purchase_order_prefix.to_s.length > 5
  return false if !@purchase_order_suffix.nil? && @purchase_order_suffix.to_s.length > 5
  prefix_suffix_type_validator = EnumAttributeValidator.new('String', ["Prefix", "Suffix"])
  return false unless prefix_suffix_type_validator.valid?(@prefix_suffix_type)
  return false if @costing_method.nil?
  costing_method_validator = EnumAttributeValidator.new('String', ["FIFO", "LIFO", "AverageCosting"])
  return false unless costing_method_validator.valid?(@costing_method)
  return false if !@num_decimal_places.nil? && @num_decimal_places > 2147483647
  return false if !@num_decimal_places.nil? && @num_decimal_places < 0
  return true
end