Class: PaypalServerSdk::Plan
- Defined in:
- lib/paypal_server_sdk/models/plan.rb
Overview
The merchant level Recurring Billing plan metadata for the Billing Agreement.
Instance Attribute Summary collapse
-
#billing_cycles ⇒ Array[BillingCycle]
An array of billing cycles for trial billing and regular billing.
-
#name ⇒ String
Name of the recurring plan.
-
#one_time_charges ⇒ OneTimeCharge
The one-time charge info at the time of checkout.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(billing_cycles:, one_time_charges:, name: SKIP) ⇒ Plan
constructor
A new instance of Plan.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(billing_cycles:, one_time_charges:, name: SKIP) ⇒ Plan
Returns a new instance of Plan.
47 48 49 50 51 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 47 def initialize(billing_cycles:, one_time_charges:, name: SKIP) @billing_cycles = billing_cycles @one_time_charges = one_time_charges @name = name unless name == SKIP end |
Instance Attribute Details
#billing_cycles ⇒ Array[BillingCycle]
An array of billing cycles for trial billing and regular billing. A plan can have at most two trial cycles and only one regular cycle.
16 17 18 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 16 def billing_cycles @billing_cycles end |
#name ⇒ String
Name of the recurring plan.
24 25 26 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 24 def name @name end |
#one_time_charges ⇒ OneTimeCharge
The one-time charge info at the time of checkout.
20 21 22 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 20 def one_time_charges @one_time_charges end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 54 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. # Parameter is an array, so we need to iterate through it billing_cycles = nil unless hash['billing_cycles'].nil? billing_cycles = [] hash['billing_cycles'].each do |structure| billing_cycles << (BillingCycle.from_hash(structure) if structure) end end billing_cycles = nil unless hash.key?('billing_cycles') one_time_charges = OneTimeCharge.from_hash(hash['one_time_charges']) if hash['one_time_charges'] name = hash.key?('name') ? hash['name'] : SKIP # Create object from extracted values. Plan.new(billing_cycles: billing_cycles, one_time_charges: one_time_charges, name: name) end |
.names ⇒ Object
A mapping from model property names to API property names.
27 28 29 30 31 32 33 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 27 def self.names @_hash = {} if @_hash.nil? @_hash['billing_cycles'] = 'billing_cycles' @_hash['one_time_charges'] = 'one_time_charges' @_hash['name'] = 'name' @_hash end |
.nullables ⇒ Object
An array for nullable fields
43 44 45 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 43 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
36 37 38 39 40 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 36 def self.optionals %w[ name ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
86 87 88 89 90 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 86 def inspect class_name = self.class.name.split('::').last "<#{class_name} billing_cycles: #{@billing_cycles.inspect}, one_time_charges:"\ " #{@one_time_charges.inspect}, name: #{@name.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
79 80 81 82 83 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 79 def to_s class_name = self.class.name.split('::').last "<#{class_name} billing_cycles: #{@billing_cycles}, one_time_charges: #{@one_time_charges},"\ " name: #{@name}>" end |