Class: AdvancedBilling::SaleRep
- Defined in:
- lib/advanced_billing/models/sale_rep.rb
Overview
SaleRep Model.
Instance Attribute Summary collapse
-
#full_name ⇒ String
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#subscriptions ⇒ Array[SaleRepSubscription]
TODO: Write general description for this method.
-
#subscriptions_count ⇒ Integer
TODO: Write general description for this method.
-
#test_mode ⇒ TrueClass | FalseClass
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(id: SKIP, full_name: SKIP, subscriptions_count: SKIP, test_mode: SKIP, subscriptions: SKIP, additional_properties: {}) ⇒ SaleRep
constructor
A new instance of SaleRep.
Methods inherited from BaseModel
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: {}) @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 # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#full_name ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/sale_rep.rb', line 18 def full_name @full_name end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/sale_rep.rb', line 14 def id @id end |
#subscriptions ⇒ Array[SaleRepSubscription]
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/sale_rep.rb', line 30 def subscriptions @subscriptions end |
#subscriptions_count ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/sale_rep.rb', line 22 def subscriptions_count @subscriptions_count end |
#test_mode ⇒ TrueClass | FalseClass
TODO: Write general description for this method
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. names.each_value { |k| hash.delete(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: hash) end |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
55 56 57 |
# File 'lib/advanced_billing/models/sale_rep.rb', line 55 def self.nullables [] end |
.optionals ⇒ Object
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 |