Class: ApiReference::NewPlan

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

Overview

NewPlan 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(name:, currency:, prices:, metadata: SKIP, description: SKIP, default_invoice_memo: SKIP, net_terms: SKIP, external_plan_id: SKIP, status: Status17::ACTIVE, plan_phases: SKIP, adjustments: SKIP) ⇒ NewPlan

Returns a new instance of NewPlan.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/api_reference/models/new_plan.rb', line 113

def initialize(name:, currency:, prices:, metadata: SKIP, description: SKIP,
               default_invoice_memo: SKIP, net_terms: SKIP,
               external_plan_id: SKIP, status: Status17::ACTIVE,
               plan_phases: SKIP, adjustments: SKIP)
  @metadata =  unless  == SKIP
  @name = name
  @description = description unless description == SKIP
  @default_invoice_memo = default_invoice_memo unless default_invoice_memo == SKIP
  @net_terms = net_terms unless net_terms == SKIP
  @currency = currency
  @prices = prices
  @external_plan_id = external_plan_id unless external_plan_id == SKIP
  @status = status unless status == SKIP
  @plan_phases = plan_phases unless plan_phases == SKIP
  @adjustments = adjustments unless adjustments == SKIP
end

Instance Attribute Details

#adjustmentsArray[AddPlanAdjustmentParams]

Adjustments for this plan. If the plan has phases, this includes adjustments across all phases of the plan.

Returns:



67
68
69
# File 'lib/api_reference/models/new_plan.rb', line 67

def adjustments
  @adjustments
end

#currencyString

An ISO 4217 currency string for invoices generated by subscriptions on this plan.

Returns:

  • (String)


42
43
44
# File 'lib/api_reference/models/new_plan.rb', line 42

def currency
  @currency
end

#default_invoice_memoString

Free-form text which is available on the invoice PDF and the Orb invoice portal.

Returns:

  • (String)


31
32
33
# File 'lib/api_reference/models/new_plan.rb', line 31

def default_invoice_memo
  @default_invoice_memo
end

#descriptionString

An optional user-defined description of the plan.

Returns:

  • (String)


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

def description
  @description
end

#external_plan_idString

Prices for this plan. If the plan has phases, this includes prices across all phases of the plan.

Returns:

  • (String)


52
53
54
# File 'lib/api_reference/models/new_plan.rb', line 52

def external_plan_id
  @external_plan_id
end

#metadataHash[String, String]

User-specified key/value pairs for the resource. Individual keys can be removed by setting the value to null, and the entire metadata mapping can be cleared by setting metadata to null.

Returns:

  • (Hash[String, String])


16
17
18
# File 'lib/api_reference/models/new_plan.rb', line 16

def 
  @metadata
end

#nameString

User-specified key/value pairs for the resource. Individual keys can be removed by setting the value to null, and the entire metadata mapping can be cleared by setting metadata to null.

Returns:

  • (String)


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

def name
  @name
end

#net_termsInteger

The net terms determines the difference between the invoice date and the issue date for the invoice. If you intend the invoice to be due on issue, set this to 0.

Returns:

  • (Integer)


37
38
39
# File 'lib/api_reference/models/new_plan.rb', line 37

def net_terms
  @net_terms
end

#plan_phasesArray[NewPlanPhase]

Configuration of pre-defined phases, each with their own prices and adjustments. Leave unspecified for plans with a single phase.

Returns:



62
63
64
# File 'lib/api_reference/models/new_plan.rb', line 62

def plan_phases
  @plan_phases
end

#pricesArray[AddPlanPriceParams]

Prices for this plan. If the plan has phases, this includes prices across all phases of the plan.

Returns:



47
48
49
# File 'lib/api_reference/models/new_plan.rb', line 47

def prices
  @prices
end

#statusStatus17

The status of the plan to create (either active or draft). If not specified, this defaults to active.

Returns:



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

def status
  @status
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
179
180
181
182
183
184
185
186
187
188
# File 'lib/api_reference/models/new_plan.rb', line 131

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  currency = hash.key?('currency') ? hash['currency'] : nil
  # Parameter is an array, so we need to iterate through it
  prices = nil
  unless hash['prices'].nil?
    prices = []
    hash['prices'].each do |structure|
      prices << (AddPlanPriceParams.from_hash(structure) if structure)
    end
  end

  prices = nil unless hash.key?('prices')
   = hash.key?('metadata') ? hash['metadata'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  default_invoice_memo =
    hash.key?('default_invoice_memo') ? hash['default_invoice_memo'] : SKIP
  net_terms = hash.key?('net_terms') ? hash['net_terms'] : SKIP
  external_plan_id =
    hash.key?('external_plan_id') ? hash['external_plan_id'] : SKIP
  status = hash['status'] ||= Status17::ACTIVE
  # Parameter is an array, so we need to iterate through it
  plan_phases = nil
  unless hash['plan_phases'].nil?
    plan_phases = []
    hash['plan_phases'].each do |structure|
      plan_phases << (NewPlanPhase.from_hash(structure) if structure)
    end
  end

  plan_phases = SKIP unless hash.key?('plan_phases')
  # Parameter is an array, so we need to iterate through it
  adjustments = nil
  unless hash['adjustments'].nil?
    adjustments = []
    hash['adjustments'].each do |structure|
      adjustments << (AddPlanAdjustmentParams.from_hash(structure) if structure)
    end
  end

  adjustments = SKIP unless hash.key?('adjustments')

  # Create object from extracted values.
  NewPlan.new(name: name,
              currency: currency,
              prices: prices,
              metadata: ,
              description: description,
              default_invoice_memo: default_invoice_memo,
              net_terms: net_terms,
              external_plan_id: external_plan_id,
              status: status,
              plan_phases: plan_phases,
              adjustments: adjustments)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['metadata'] = 'metadata'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['default_invoice_memo'] = 'default_invoice_memo'
  @_hash['net_terms'] = 'net_terms'
  @_hash['currency'] = 'currency'
  @_hash['prices'] = 'prices'
  @_hash['external_plan_id'] = 'external_plan_id'
  @_hash['status'] = 'status'
  @_hash['plan_phases'] = 'plan_phases'
  @_hash['adjustments'] = 'adjustments'
  @_hash
end

.nullablesObject

An array for nullable fields



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/api_reference/models/new_plan.rb', line 101

def self.nullables
  %w[
    metadata
    description
    default_invoice_memo
    net_terms
    external_plan_id
    plan_phases
    adjustments
  ]
end

.optionalsObject

An array for optional fields



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/api_reference/models/new_plan.rb', line 87

def self.optionals
  %w[
    metadata
    description
    default_invoice_memo
    net_terms
    external_plan_id
    status
    plan_phases
    adjustments
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



200
201
202
203
204
205
206
207
208
# File 'lib/api_reference/models/new_plan.rb', line 200

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} metadata: #{@metadata.inspect}, name: #{@name.inspect}, description:"\
  " #{@description.inspect}, default_invoice_memo: #{@default_invoice_memo.inspect},"\
  " net_terms: #{@net_terms.inspect}, currency: #{@currency.inspect}, prices:"\
  " #{@prices.inspect}, external_plan_id: #{@external_plan_id.inspect}, status:"\
  " #{@status.inspect}, plan_phases: #{@plan_phases.inspect}, adjustments:"\
  " #{@adjustments.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



191
192
193
194
195
196
197
# File 'lib/api_reference/models/new_plan.rb', line 191

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} metadata: #{@metadata}, name: #{@name}, description: #{@description},"\
  " default_invoice_memo: #{@default_invoice_memo}, net_terms: #{@net_terms}, currency:"\
  " #{@currency}, prices: #{@prices}, external_plan_id: #{@external_plan_id}, status:"\
  " #{@status}, plan_phases: #{@plan_phases}, adjustments: #{@adjustments}>"
end