Class: AdvancedBilling::GroupSettings
- Defined in:
- lib/advanced_billing/models/group_settings.rb
Overview
GroupSettings Model.
Instance Attribute Summary collapse
-
#billing ⇒ GroupBilling
Optional attributes related to billing date and accrual.
-
#target ⇒ GroupTarget
Attributes of the target customer who will be the responsible payer of the created subscription.
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(target:, billing: SKIP, additional_properties: {}) ⇒ GroupSettings
constructor
A new instance of GroupSettings.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(target:, billing: SKIP, additional_properties: {}) ⇒ GroupSettings
Returns a new instance of GroupSettings.
42 43 44 45 46 47 48 49 50 |
# File 'lib/advanced_billing/models/group_settings.rb', line 42 def initialize(target:, billing: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @target = target @billing = billing unless billing == SKIP end |
Instance Attribute Details
#billing ⇒ GroupBilling
Optional attributes related to billing date and accrual. Note: Only applicable for new subscriptions.
20 21 22 |
# File 'lib/advanced_billing/models/group_settings.rb', line 20 def billing @billing end |
#target ⇒ GroupTarget
Attributes of the target customer who will be the responsible payer of the created subscription. Required.
15 16 17 |
# File 'lib/advanced_billing/models/group_settings.rb', line 15 def target @target end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/advanced_billing/models/group_settings.rb', line 53 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. target = GroupTarget.from_hash(hash['target']) if hash['target'] billing = GroupBilling.from_hash(hash['billing']) if hash['billing'] # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(k) } # Create object from extracted values. GroupSettings.new(target: target, billing: billing, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
23 24 25 26 27 28 |
# File 'lib/advanced_billing/models/group_settings.rb', line 23 def self.names @_hash = {} if @_hash.nil? @_hash['target'] = 'target' @_hash['billing'] = 'billing' @_hash end |
.nullables ⇒ Object
An array for nullable fields
38 39 40 |
# File 'lib/advanced_billing/models/group_settings.rb', line 38 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
31 32 33 34 35 |
# File 'lib/advanced_billing/models/group_settings.rb', line 31 def self.optionals %w[ billing ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/advanced_billing/models/group_settings.rb', line 71 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.target, ->(val) { GroupTarget.validate(val) }, is_model_hash: true) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['target'], ->(val) { GroupTarget.validate(val) }, is_model_hash: true) end |