Class: AdvancedBilling::ActivateEventBasedComponent

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

Overview

ActivateEventBasedComponent 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(price_point_id: SKIP, billing_schedule: SKIP, custom_price: SKIP, additional_properties: {}) ⇒ ActivateEventBasedComponent

Returns a new instance of ActivateEventBasedComponent.



51
52
53
54
55
56
57
58
59
60
61
# File 'lib/advanced_billing/models/activate_event_based_component.rb', line 51

def initialize(price_point_id: SKIP, billing_schedule: SKIP,
               custom_price: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @price_point_id = price_point_id unless price_point_id == SKIP
  @billing_schedule = billing_schedule unless billing_schedule == SKIP
  @custom_price = custom_price unless custom_price == SKIP
end

Instance Attribute Details

#billing_scheduleBillingSchedule

This attribute is particularly useful when you need to align billing events for different components on distinct schedules within a subscription. Please note this only works for site with Multifrequency enabled

Returns:



21
22
23
# File 'lib/advanced_billing/models/activate_event_based_component.rb', line 21

def billing_schedule
  @billing_schedule
end

#custom_priceComponentCustomPrice

Create or update custom pricing unique to the subscription. Used in place of ‘price_point_id`.



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

def custom_price
  @custom_price
end

#price_point_idInteger

The Chargify id of the price point

Returns:

  • (Integer)


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

def price_point_id
  @price_point_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/advanced_billing/models/activate_event_based_component.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  price_point_id =
    hash.key?('price_point_id') ? hash['price_point_id'] : SKIP
  billing_schedule = BillingSchedule.from_hash(hash['billing_schedule']) if
    hash['billing_schedule']
  custom_price = ComponentCustomPrice.from_hash(hash['custom_price']) if hash['custom_price']

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

  # Create object from extracted values.
  ActivateEventBasedComponent.new(price_point_id: price_point_id,
                                  billing_schedule: billing_schedule,
                                  custom_price: custom_price,
                                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
# File 'lib/advanced_billing/models/activate_event_based_component.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['price_point_id'] = 'price_point_id'
  @_hash['billing_schedule'] = 'billing_schedule'
  @_hash['custom_price'] = 'custom_price'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
# File 'lib/advanced_billing/models/activate_event_based_component.rb', line 47

def self.nullables
  []
end

.optionalsObject

An array for optional fields



38
39
40
41
42
43
44
# File 'lib/advanced_billing/models/activate_event_based_component.rb', line 38

def self.optionals
  %w[
    price_point_id
    billing_schedule
    custom_price
  ]
end