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.
-
#product ⇒ Object
Product details associated with any one-time product purchase.
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:, product: SKIP, 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:, product: SKIP, name: SKIP) ⇒ Plan
Returns a new instance of Plan.
53 54 55 56 57 58 59 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 53 def initialize(billing_cycles:, one_time_charges:, product: SKIP, name: SKIP) @billing_cycles = billing_cycles @product = product unless product == SKIP @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.
28 29 30 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 28 def name @name end |
#one_time_charges ⇒ OneTimeCharge
The one-time charge info at the time of checkout.
24 25 26 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 24 def one_time_charges @one_time_charges end |
#product ⇒ Object
Product details associated with any one-time product purchase.
20 21 22 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 20 def product @product end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 62 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'] product = hash.key?('product') ? hash['product'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP # Create object from extracted values. Plan.new(billing_cycles: billing_cycles, one_time_charges: one_time_charges, product: product, name: name) end |
.names ⇒ Object
A mapping from model property names to API property names.
31 32 33 34 35 36 37 38 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 31 def self.names @_hash = {} if @_hash.nil? @_hash['billing_cycles'] = 'billing_cycles' @_hash['product'] = 'product' @_hash['one_time_charges'] = 'one_time_charges' @_hash['name'] = 'name' @_hash end |
.nullables ⇒ Object
An array for nullable fields
49 50 51 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 49 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
41 42 43 44 45 46 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 41 def self.optionals %w[ product name ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
96 97 98 99 100 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 96 def inspect class_name = self.class.name.split('::').last "<#{class_name} billing_cycles: #{@billing_cycles.inspect}, product: #{@product.inspect},"\ " one_time_charges: #{@one_time_charges.inspect}, name: #{@name.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
89 90 91 92 93 |
# File 'lib/paypal_server_sdk/models/plan.rb', line 89 def to_s class_name = self.class.name.split('::').last "<#{class_name} billing_cycles: #{@billing_cycles}, product: #{@product}, one_time_charges:"\ " #{@one_time_charges}, name: #{@name}>" end |