Class: ApiReference::SubscriptionChangeResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/subscription_change_response.rb

Overview

A subscription change represents a desired new subscription / pending change to an existing subscription. It is a way to first preview the effects on the subscription as well as any changes/creation of invoices (see subscription.changed_resources).

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(id:, status:, expiration_time:, subscription:, change_type:, applied_at: SKIP, cancelled_at: SKIP, effective_date: SKIP, change_option: SKIP, plan_id: SKIP, billing_cycle_alignment: SKIP, additional_properties: nil) ⇒ SubscriptionChangeResponse

Returns a new instance of SubscriptionChangeResponse.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/api_reference/models/subscription_change_response.rb', line 105

def initialize(id:, status:, expiration_time:, subscription:, change_type:,
               applied_at: SKIP, cancelled_at: SKIP, effective_date: SKIP,
               change_option: SKIP, plan_id: SKIP,
               billing_cycle_alignment: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @id = id
  @status = status
  @applied_at = applied_at unless applied_at == SKIP
  @cancelled_at = cancelled_at unless cancelled_at == SKIP
  @expiration_time = expiration_time
  @subscription = subscription
  @change_type = change_type
  @effective_date = effective_date unless effective_date == SKIP
  @change_option = change_option unless change_option == SKIP
  @plan_id = plan_id unless plan_id == SKIP
  @billing_cycle_alignment = billing_cycle_alignment unless billing_cycle_alignment == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#applied_atDateTime

When this change was applied.

Returns:

  • (DateTime)


26
27
28
# File 'lib/api_reference/models/subscription_change_response.rb', line 26

def applied_at
  @applied_at
end

#billing_cycle_alignmentString

Billing cycle alignment for plan changes.

Returns:

  • (String)


61
62
63
# File 'lib/api_reference/models/subscription_change_response.rb', line 61

def billing_cycle_alignment
  @billing_cycle_alignment
end

#cancelled_atDateTime

When this change was cancelled.

Returns:

  • (DateTime)


30
31
32
# File 'lib/api_reference/models/subscription_change_response.rb', line 30

def cancelled_at
  @cancelled_at
end

#change_optionString

How the change is scheduled (e.g., 'immediate', 'end_of_subscription_term', 'requested_date').

Returns:

  • (String)


53
54
55
# File 'lib/api_reference/models/subscription_change_response.rb', line 53

def change_option
  @change_option
end

#change_typeString

The type of change (e.g., 'schedule_plan_change', 'create_subscription').

Returns:

  • (String)


44
45
46
# File 'lib/api_reference/models/subscription_change_response.rb', line 44

def change_type
  @change_type
end

#effective_dateDateTime

When this change will take effect.

Returns:

  • (DateTime)


48
49
50
# File 'lib/api_reference/models/subscription_change_response.rb', line 48

def effective_date
  @effective_date
end

#expiration_timeDateTime

Subscription change will be cancelled at this time and can no longer be applied.

Returns:

  • (DateTime)


35
36
37
# File 'lib/api_reference/models/subscription_change_response.rb', line 35

def expiration_time
  @expiration_time
end

#idString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/api_reference/models/subscription_change_response.rb', line 18

def id
  @id
end

#plan_idString

The target plan ID for plan changes.

Returns:

  • (String)


57
58
59
# File 'lib/api_reference/models/subscription_change_response.rb', line 57

def plan_id
  @plan_id
end

#statusStatus12

TODO: Write general description for this method

Returns:



22
23
24
# File 'lib/api_reference/models/subscription_change_response.rb', line 22

def status
  @status
end

#subscriptionMutatedSubscription

Subscription change will be cancelled at this time and can no longer be applied.

Returns:



40
41
42
# File 'lib/api_reference/models/subscription_change_response.rb', line 40

def subscription
  @subscription
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/api_reference/models/subscription_change_response.rb', line 127

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  status = hash.key?('status') ? hash['status'] : nil
  expiration_time = if hash.key?('expiration_time')
                      (DateTimeHelper.from_rfc3339(hash['expiration_time']) if hash['expiration_time'])
                    end
  subscription = MutatedSubscription.from_hash(hash['subscription']) if hash['subscription']
  change_type = hash.key?('change_type') ? hash['change_type'] : nil
  applied_at = if hash.key?('applied_at')
                 (DateTimeHelper.from_rfc3339(hash['applied_at']) if hash['applied_at'])
               else
                 SKIP
               end
  cancelled_at = if hash.key?('cancelled_at')
                   (DateTimeHelper.from_rfc3339(hash['cancelled_at']) if hash['cancelled_at'])
                 else
                   SKIP
                 end
  effective_date = if hash.key?('effective_date')
                     (DateTimeHelper.from_rfc3339(hash['effective_date']) if hash['effective_date'])
                   else
                     SKIP
                   end
  change_option = hash.key?('change_option') ? hash['change_option'] : SKIP
  plan_id = hash.key?('plan_id') ? hash['plan_id'] : SKIP
  billing_cycle_alignment =
    hash.key?('billing_cycle_alignment') ? hash['billing_cycle_alignment'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  SubscriptionChangeResponse.new(id: id,
                                 status: status,
                                 expiration_time: expiration_time,
                                 subscription: subscription,
                                 change_type: change_type,
                                 applied_at: applied_at,
                                 cancelled_at: cancelled_at,
                                 effective_date: effective_date,
                                 change_option: change_option,
                                 plan_id: plan_id,
                                 billing_cycle_alignment: billing_cycle_alignment,
                                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/api_reference/models/subscription_change_response.rb', line 64

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['status'] = 'status'
  @_hash['applied_at'] = 'applied_at'
  @_hash['cancelled_at'] = 'cancelled_at'
  @_hash['expiration_time'] = 'expiration_time'
  @_hash['subscription'] = 'subscription'
  @_hash['change_type'] = 'change_type'
  @_hash['effective_date'] = 'effective_date'
  @_hash['change_option'] = 'change_option'
  @_hash['plan_id'] = 'plan_id'
  @_hash['billing_cycle_alignment'] = 'billing_cycle_alignment'
  @_hash
end

.nullablesObject

An array for nullable fields



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/api_reference/models/subscription_change_response.rb', line 93

def self.nullables
  %w[
    applied_at
    cancelled_at
    subscription
    effective_date
    change_option
    plan_id
    billing_cycle_alignment
  ]
end

.optionalsObject

An array for optional fields



81
82
83
84
85
86
87
88
89
90
# File 'lib/api_reference/models/subscription_change_response.rb', line 81

def self.optionals
  %w[
    applied_at
    cancelled_at
    effective_date
    change_option
    plan_id
    billing_cycle_alignment
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



207
208
209
210
211
212
213
214
215
# File 'lib/api_reference/models/subscription_change_response.rb', line 207

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, status: #{@status.inspect}, applied_at:"\
  " #{@applied_at.inspect}, cancelled_at: #{@cancelled_at.inspect}, expiration_time:"\
  " #{@expiration_time.inspect}, subscription: #{@subscription.inspect}, change_type:"\
  " #{@change_type.inspect}, effective_date: #{@effective_date.inspect}, change_option:"\
  " #{@change_option.inspect}, plan_id: #{@plan_id.inspect}, billing_cycle_alignment:"\
  " #{@billing_cycle_alignment.inspect}, additional_properties: #{@additional_properties}>"
end

#to_custom_applied_atObject



180
181
182
# File 'lib/api_reference/models/subscription_change_response.rb', line 180

def to_custom_applied_at
  DateTimeHelper.to_rfc3339(applied_at)
end

#to_custom_cancelled_atObject



184
185
186
# File 'lib/api_reference/models/subscription_change_response.rb', line 184

def to_custom_cancelled_at
  DateTimeHelper.to_rfc3339(cancelled_at)
end

#to_custom_effective_dateObject



192
193
194
# File 'lib/api_reference/models/subscription_change_response.rb', line 192

def to_custom_effective_date
  DateTimeHelper.to_rfc3339(effective_date)
end

#to_custom_expiration_timeObject



188
189
190
# File 'lib/api_reference/models/subscription_change_response.rb', line 188

def to_custom_expiration_time
  DateTimeHelper.to_rfc3339(expiration_time)
end

#to_sObject

Provides a human-readable string representation of the object.



197
198
199
200
201
202
203
204
# File 'lib/api_reference/models/subscription_change_response.rb', line 197

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, status: #{@status}, applied_at: #{@applied_at}, cancelled_at:"\
  " #{@cancelled_at}, expiration_time: #{@expiration_time}, subscription: #{@subscription},"\
  " change_type: #{@change_type}, effective_date: #{@effective_date}, change_option:"\
  " #{@change_option}, plan_id: #{@plan_id}, billing_cycle_alignment:"\
  " #{@billing_cycle_alignment}, additional_properties: #{@additional_properties}>"
end