Class: AdvancedBilling::SaleRep

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/sale_rep.rb

Overview

SaleRep Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id: SKIP, full_name: SKIP, subscriptions_count: SKIP, test_mode: SKIP, subscriptions: SKIP, additional_properties: {}) ⇒ SaleRep

Returns a new instance of SaleRep.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/sale_rep.rb', line 59

def initialize(id: SKIP, full_name: SKIP, subscriptions_count: SKIP,
               test_mode: SKIP, subscriptions: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @id = id unless id == SKIP
  @full_name = full_name unless full_name == SKIP
  @subscriptions_count = subscriptions_count unless subscriptions_count == SKIP
  @test_mode = test_mode unless test_mode == SKIP
  @subscriptions = subscriptions unless subscriptions == SKIP
end

Instance Attribute Details

#full_nameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/sale_rep.rb', line 18

def full_name
  @full_name
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/sale_rep.rb', line 14

def id
  @id
end

#subscriptionsArray[SaleRepSubscription]

TODO: Write general description for this method

Returns:



30
31
32
# File 'lib/advanced_billing/models/sale_rep.rb', line 30

def subscriptions
  @subscriptions
end

#subscriptions_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/sale_rep.rb', line 22

def subscriptions_count
  @subscriptions_count
end

#test_modeTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


26
27
28
# File 'lib/advanced_billing/models/sale_rep.rb', line 26

def test_mode
  @test_mode
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/advanced_billing/models/sale_rep.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  full_name = hash.key?('full_name') ? hash['full_name'] : SKIP
  subscriptions_count =
    hash.key?('subscriptions_count') ? hash['subscriptions_count'] : SKIP
  test_mode = hash.key?('test_mode') ? hash['test_mode'] : SKIP
  # Parameter is an array, so we need to iterate through it
  subscriptions = nil
  unless hash['subscriptions'].nil?
    subscriptions = []
    hash['subscriptions'].each do |structure|
      subscriptions << (SaleRepSubscription.from_hash(structure) if structure)
    end
  end

  subscriptions = SKIP unless hash.key?('subscriptions')

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  SaleRep.new(id: id,
              full_name: full_name,
              subscriptions_count: subscriptions_count,
              test_mode: test_mode,
              subscriptions: subscriptions,
              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
40
41
# File 'lib/advanced_billing/models/sale_rep.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['full_name'] = 'full_name'
  @_hash['subscriptions_count'] = 'subscriptions_count'
  @_hash['test_mode'] = 'test_mode'
  @_hash['subscriptions'] = 'subscriptions'
  @_hash
end

.nullablesObject

An array for nullable fields



55
56
57
# File 'lib/advanced_billing/models/sale_rep.rb', line 55

def self.nullables
  []
end

.optionalsObject

An array for optional fields



44
45
46
47
48
49
50
51
52
# File 'lib/advanced_billing/models/sale_rep.rb', line 44

def self.optionals
  %w[
    id
    full_name
    subscriptions_count
    test_mode
    subscriptions
  ]
end