Class: AdvancedBilling::OverrideSubscription

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

Overview

OverrideSubscription Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(activated_at = SKIP, canceled_at = SKIP, cancellation_message = SKIP, expires_at = SKIP, current_period_starts_at = SKIP) ⇒ OverrideSubscription

Returns a new instance of OverrideSubscription.



69
70
71
72
73
74
75
76
77
# File 'lib/advanced_billing/models/override_subscription.rb', line 69

def initialize(activated_at = SKIP, canceled_at = SKIP,
               cancellation_message = SKIP, expires_at = SKIP,
               current_period_starts_at = SKIP)
  @activated_at = activated_at unless activated_at == SKIP
  @canceled_at = canceled_at unless canceled_at == SKIP
  @cancellation_message = cancellation_message unless cancellation_message == SKIP
  @expires_at = expires_at unless expires_at == SKIP
  @current_period_starts_at = current_period_starts_at unless current_period_starts_at == SKIP
end

Instance Attribute Details

#activated_atString

Can be used to record an external signup date. Chargify uses this field to record when a subscription first goes active (either at signup or at trial end)

Returns:

  • (String)


16
17
18
# File 'lib/advanced_billing/models/override_subscription.rb', line 16

def activated_at
  @activated_at
end

#canceled_atString

Can be used to record an external cancellation date. Chargify sets this field automatically when a subscription is canceled, whether by request or via dunning.

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/override_subscription.rb', line 22

def canceled_at
  @canceled_at
end

#cancellation_messageString

Can be used to record a reason for the original cancellation.

Returns:

  • (String)


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

def cancellation_message
  @cancellation_message
end

#current_period_starts_atString

Can only be used when a subscription is unbilled, which happens when a future initial billing date is passed at subscription creation. The value passed must be before the current date and time. Allows you to set when the period started so mid period component allocations have the correct proration.

Returns:

  • (String)


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

def current_period_starts_at
  @current_period_starts_at
end

#expires_atString

Can be used to record an external expiration date. Chargify sets this field automatically when a subscription expires (ceases billing) after a prescribed amount of time.

Returns:

  • (String)


32
33
34
# File 'lib/advanced_billing/models/override_subscription.rb', line 32

def expires_at
  @expires_at
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/advanced_billing/models/override_subscription.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  activated_at = hash.key?('activated_at') ? hash['activated_at'] : SKIP
  canceled_at = hash.key?('canceled_at') ? hash['canceled_at'] : SKIP
  cancellation_message =
    hash.key?('cancellation_message') ? hash['cancellation_message'] : SKIP
  expires_at = hash.key?('expires_at') ? hash['expires_at'] : SKIP
  current_period_starts_at =
    hash.key?('current_period_starts_at') ? hash['current_period_starts_at'] : SKIP

  # Create object from extracted values.
  OverrideSubscription.new(activated_at,
                           canceled_at,
                           cancellation_message,
                           expires_at,
                           current_period_starts_at)
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/override_subscription.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['activated_at'] = 'activated_at'
  @_hash['canceled_at'] = 'canceled_at'
  @_hash['cancellation_message'] = 'cancellation_message'
  @_hash['expires_at'] = 'expires_at'
  @_hash['current_period_starts_at'] = 'current_period_starts_at'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/advanced_billing/models/override_subscription.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/override_subscription.rb', line 54

def self.optionals
  %w[
    activated_at
    canceled_at
    cancellation_message
    expires_at
    current_period_starts_at
  ]
end