Class: PaypalServerSdk::OrderBillingPlan

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/paypal_server_sdk/models/order_billing_plan.rb

Overview

Metadata for merchant-managed recurring billing plans. Valid only during the saved payment method token or billing agreement creation.

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(billing_cycles:, setup_fee: SKIP, name: SKIP) ⇒ OrderBillingPlan

Returns a new instance of OrderBillingPlan.



49
50
51
52
53
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 49

def initialize(billing_cycles:, setup_fee: SKIP, name: SKIP)
  @billing_cycles = billing_cycles
  @setup_fee = setup_fee unless setup_fee == SKIP
  @name = name unless name == SKIP
end

Instance Attribute Details

#billing_cyclesArray[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.

Returns:



16
17
18
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 16

def billing_cycles
  @billing_cycles
end

#nameString

Name of the recurring plan.

Returns:

  • (String)


25
26
27
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 25

def name
  @name
end

#setup_feeMoney

The currency and amount for a financial transaction, such as a balance or payment due.

Returns:



21
22
23
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 21

def setup_fee
  @setup_fee
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 56

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')
  setup_fee = Money.from_hash(hash['setup_fee']) if hash['setup_fee']
  name = hash.key?('name') ? hash['name'] : SKIP

  # Create object from extracted values.
  OrderBillingPlan.new(billing_cycles: billing_cycles,
                       setup_fee: setup_fee,
                       name: name)
end

.namesObject

A mapping from model property names to API property names.



28
29
30
31
32
33
34
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 28

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['billing_cycles'] = 'billing_cycles'
  @_hash['setup_fee'] = 'setup_fee'
  @_hash['name'] = 'name'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



37
38
39
40
41
42
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 37

def self.optionals
  %w[
    setup_fee
    name
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



87
88
89
90
91
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 87

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} billing_cycles: #{@billing_cycles.inspect}, setup_fee:"\
  " #{@setup_fee.inspect}, name: #{@name.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



80
81
82
83
84
# File 'lib/paypal_server_sdk/models/order_billing_plan.rb', line 80

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} billing_cycles: #{@billing_cycles}, setup_fee: #{@setup_fee}, name:"\
  " #{@name}>"
end