Class: AdvancedBilling::ScheduledRenewalConfiguration

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

Overview

ScheduledRenewalConfiguration Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id: SKIP, site_id: SKIP, subscription_id: SKIP, starts_at: SKIP, ends_at: SKIP, lock_in_at: SKIP, created_at: SKIP, status: SKIP, scheduled_renewal_configuration_items: SKIP, contract: SKIP, additional_properties: {}) ⇒ ScheduledRenewalConfiguration

Returns a new instance of ScheduledRenewalConfiguration.



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

def initialize(id: SKIP, site_id: SKIP, subscription_id: SKIP,
               starts_at: SKIP, ends_at: SKIP, lock_in_at: SKIP,
               created_at: SKIP, status: SKIP,
               scheduled_renewal_configuration_items: SKIP, contract: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @id = id unless id == SKIP
  @site_id = site_id unless site_id == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @starts_at = starts_at unless starts_at == SKIP
  @ends_at = ends_at unless ends_at == SKIP
  @lock_in_at = lock_in_at unless lock_in_at == SKIP
  @created_at = created_at unless created_at == SKIP
  @status = status unless status == SKIP
  unless scheduled_renewal_configuration_items == SKIP
    @scheduled_renewal_configuration_items =
      scheduled_renewal_configuration_items
  end
  @contract = contract unless contract == SKIP
end

Instance Attribute Details

#contractContract

Contract linked to the scheduled renewal configuration.

Returns:



51
52
53
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 51

def contract
  @contract
end

#created_atDateTime

The id of the subscription.

Returns:

  • (DateTime)


39
40
41
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 39

def created_at
  @created_at
end

#ends_atDateTime

The id of the subscription.

Returns:

  • (DateTime)


31
32
33
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 31

def ends_at
  @ends_at
end

#idInteger

ID of the renewal.

Returns:

  • (Integer)


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

def id
  @id
end

#lock_in_atDateTime

The id of the subscription.

Returns:

  • (DateTime)


35
36
37
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 35

def lock_in_at
  @lock_in_at
end

#scheduled_renewal_configuration_itemsArray[ScheduledRenewalConfigurationItem]

The id of the subscription.



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

def scheduled_renewal_configuration_items
  @scheduled_renewal_configuration_items
end

#site_idInteger

ID of the site to which the renewal belongs.

Returns:

  • (Integer)


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

def site_id
  @site_id
end

#starts_atDateTime

The id of the subscription.

Returns:

  • (DateTime)


27
28
29
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 27

def starts_at
  @starts_at
end

#statusString

The id of the subscription.

Returns:

  • (String)


43
44
45
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 43

def status
  @status
end

#subscription_idInteger

The id of the subscription.

Returns:

  • (Integer)


23
24
25
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 23

def subscription_id
  @subscription_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



117
118
119
120
121
122
123
124
125
126
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
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 117

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  starts_at = if hash.key?('starts_at')
                (DateTimeHelper.from_rfc3339(hash['starts_at']) if hash['starts_at'])
              else
                SKIP
              end
  ends_at = if hash.key?('ends_at')
              (DateTimeHelper.from_rfc3339(hash['ends_at']) if hash['ends_at'])
            else
              SKIP
            end
  lock_in_at = if hash.key?('lock_in_at')
                 (DateTimeHelper.from_rfc3339(hash['lock_in_at']) if hash['lock_in_at'])
               else
                 SKIP
               end
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  status = hash.key?('status') ? hash['status'] : SKIP
  # Parameter is an array, so we need to iterate through it
  scheduled_renewal_configuration_items = nil
  unless hash['scheduled_renewal_configuration_items'].nil?
    scheduled_renewal_configuration_items = []
    hash['scheduled_renewal_configuration_items'].each do |structure|
      scheduled_renewal_configuration_items << (ScheduledRenewalConfigurationItem.from_hash(structure) if structure)
    end
  end

  scheduled_renewal_configuration_items = SKIP unless hash.key?('scheduled_renewal_configuration_items')
  contract = Contract.from_hash(hash['contract']) if hash['contract']

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

  # Create object from extracted values.
  ScheduledRenewalConfiguration.new(id: id,
                                    site_id: site_id,
                                    subscription_id: subscription_id,
                                    starts_at: starts_at,
                                    ends_at: ends_at,
                                    lock_in_at: lock_in_at,
                                    created_at: created_at,
                                    status: status,
                                    scheduled_renewal_configuration_items: scheduled_renewal_configuration_items,
                                    contract: contract,
                                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 54

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['site_id'] = 'site_id'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['starts_at'] = 'starts_at'
  @_hash['ends_at'] = 'ends_at'
  @_hash['lock_in_at'] = 'lock_in_at'
  @_hash['created_at'] = 'created_at'
  @_hash['status'] = 'status'
  @_hash['scheduled_renewal_configuration_items'] =
    'scheduled_renewal_configuration_items'
  @_hash['contract'] = 'contract'
  @_hash
end

.nullablesObject

An array for nullable fields



87
88
89
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 87

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    id
    site_id
    subscription_id
    starts_at
    ends_at
    lock_in_at
    created_at
    status
    scheduled_renewal_configuration_items
    contract
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



202
203
204
205
206
207
208
209
210
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 202

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id.inspect}, site_id: #{@site_id.inspect}, subscription_id:"\
  " #{@subscription_id.inspect}, starts_at: #{@starts_at.inspect}, ends_at:"\
  " #{@ends_at.inspect}, lock_in_at: #{@lock_in_at.inspect}, created_at:"\
  " #{@created_at.inspect}, status: #{@status.inspect}, scheduled_renewal_configuration_items:"\
  " #{@scheduled_renewal_configuration_items.inspect}, contract: #{@contract.inspect},"\
  " additional_properties: #{get_additional_properties}>"
end

#to_custom_created_atObject



187
188
189
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 187

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_ends_atObject



179
180
181
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 179

def to_custom_ends_at
  DateTimeHelper.to_rfc3339(ends_at)
end

#to_custom_lock_in_atObject



183
184
185
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 183

def to_custom_lock_in_at
  DateTimeHelper.to_rfc3339(lock_in_at)
end

#to_custom_starts_atObject



175
176
177
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 175

def to_custom_starts_at
  DateTimeHelper.to_rfc3339(starts_at)
end

#to_sObject

Provides a human-readable string representation of the object.



192
193
194
195
196
197
198
199
# File 'lib/advanced_billing/models/scheduled_renewal_configuration.rb', line 192

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} id: #{@id}, site_id: #{@site_id}, subscription_id: #{@subscription_id},"\
  " starts_at: #{@starts_at}, ends_at: #{@ends_at}, lock_in_at: #{@lock_in_at}, created_at:"\
  " #{@created_at}, status: #{@status}, scheduled_renewal_configuration_items:"\
  " #{@scheduled_renewal_configuration_items}, contract: #{@contract}, additional_properties:"\
  " #{get_additional_properties}>"
end