Class: AdvancedBilling::GroupTarget
- Defined in:
- lib/advanced_billing/models/group_target.rb
Overview
Attributes of the target customer who will be the responsible payer of the created subscription. Required.
Instance Attribute Summary collapse
-
#id ⇒ Integer
The id of the target customer or subscription to group the existing subscription with.
-
#type ⇒ GroupTargetType
The type of object indicated by the id attribute.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(type:, id: SKIP, additional_properties: {}) ⇒ GroupTarget
constructor
A new instance of GroupTarget.
Methods inherited from BaseModel
Constructor Details
#initialize(type:, id: SKIP, additional_properties: {}) ⇒ GroupTarget
Returns a new instance of GroupTarget.
43 44 45 46 47 48 49 50 51 |
# File 'lib/advanced_billing/models/group_target.rb', line 43 def initialize(type:, id: SKIP, additional_properties: {}) @type = type @id = id unless id == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#id ⇒ Integer
The id of the target customer or subscription to group the existing subscription with. Ignored and should not be included if type is “self” , “parent”, or “eldest”
21 22 23 |
# File 'lib/advanced_billing/models/group_target.rb', line 21 def id @id end |
#type ⇒ GroupTargetType
The type of object indicated by the id attribute.
15 16 17 |
# File 'lib/advanced_billing/models/group_target.rb', line 15 def type @type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/advanced_billing/models/group_target.rb', line 54 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. type = hash.key?('type') ? hash['type'] : nil id = hash.key?('id') ? hash['id'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. GroupTarget.new(type: type, id: id, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
24 25 26 27 28 29 |
# File 'lib/advanced_billing/models/group_target.rb', line 24 def self.names @_hash = {} if @_hash.nil? @_hash['type'] = 'type' @_hash['id'] = 'id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
39 40 41 |
# File 'lib/advanced_billing/models/group_target.rb', line 39 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
32 33 34 35 36 |
# File 'lib/advanced_billing/models/group_target.rb', line 32 def self.optionals %w[ id ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/advanced_billing/models/group_target.rb', line 72 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.type, ->(val) { GroupTargetType.validate(val) }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['type'], ->(val) { GroupTargetType.validate(val) }) end |