Class: AdvancedBilling::SubscriptionGroup

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

Overview

SubscriptionGroup Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(customer_id: SKIP, payment_profile: SKIP, payment_collection_method: SKIP, subscription_ids: SKIP, created_at: SKIP, additional_properties: {}) ⇒ SubscriptionGroup

Returns a new instance of SubscriptionGroup.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/advanced_billing/models/subscription_group.rb', line 69

def initialize(customer_id: SKIP, payment_profile: SKIP,
               payment_collection_method: SKIP, subscription_ids: SKIP,
               created_at: SKIP, additional_properties: {})
  @customer_id = customer_id unless customer_id == SKIP
  @payment_profile = payment_profile unless payment_profile == SKIP
  unless payment_collection_method == SKIP
    @payment_collection_method =
      payment_collection_method
  end
  @subscription_ids = subscription_ids unless subscription_ids == SKIP
  @created_at = created_at unless created_at == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#created_atDateTime

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:

  • (DateTime)


40
41
42
# File 'lib/advanced_billing/models/subscription_group.rb', line 40

def created_at
  @created_at
end

#customer_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/advanced_billing/models/subscription_group.rb', line 15

def customer_id
  @customer_id
end

#payment_collection_methodCollectionMethod

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:



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

def payment_collection_method
  @payment_collection_method
end

#payment_profileSubscriptionGroupPaymentProfile

TODO: Write general description for this method



19
20
21
# File 'lib/advanced_billing/models/subscription_group.rb', line 19

def payment_profile
  @payment_profile
end

#subscription_idsArray[Integer]

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Returns:

  • (Array[Integer])


33
34
35
# File 'lib/advanced_billing/models/subscription_group.rb', line 33

def subscription_ids
  @subscription_ids
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/advanced_billing/models/subscription_group.rb', line 88

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  customer_id = hash.key?('customer_id') ? hash['customer_id'] : SKIP
  payment_profile = SubscriptionGroupPaymentProfile.from_hash(hash['payment_profile']) if
    hash['payment_profile']
  payment_collection_method =
    hash.key?('payment_collection_method') ? hash['payment_collection_method'] : SKIP
  subscription_ids =
    hash.key?('subscription_ids') ? hash['subscription_ids'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  SubscriptionGroup.new(customer_id: customer_id,
                        payment_profile: payment_profile,
                        payment_collection_method: payment_collection_method,
                        subscription_ids: subscription_ids,
                        created_at: created_at,
                        additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['customer_id'] = 'customer_id'
  @_hash['payment_profile'] = 'payment_profile'
  @_hash['payment_collection_method'] = 'payment_collection_method'
  @_hash['subscription_ids'] = 'subscription_ids'
  @_hash['created_at'] = 'created_at'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/advanced_billing/models/subscription_group.rb', line 65

def self.nullables
  []
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
# File 'lib/advanced_billing/models/subscription_group.rb', line 54

def self.optionals
  %w[
    customer_id
    payment_profile
    payment_collection_method
    subscription_ids
    created_at
  ]
end

Instance Method Details

#to_custom_created_atObject



117
118
119
# File 'lib/advanced_billing/models/subscription_group.rb', line 117

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end