Class: PaypalServerSdk::PlanOverride

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

Overview

An inline plan object to customise the subscription. You can override plan level default attributes by providing customised values for the subscription in this object.

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: SKIP, payment_preferences: SKIP, taxes: SKIP) ⇒ PlanOverride

Returns a new instance of PlanOverride.



51
52
53
54
55
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 51

def initialize(billing_cycles: SKIP, payment_preferences: SKIP, taxes: SKIP)
  @billing_cycles = billing_cycles unless billing_cycles == SKIP
  @payment_preferences = payment_preferences unless payment_preferences == SKIP
  @taxes = taxes unless taxes == SKIP
end

Instance Attribute Details

#billing_cyclesArray[BillingCycleOverride]

An array of billing cycles for trial billing and regular billing. The subscription billing cycle definition has to adhere to the plan billing cycle definition.

Returns:



18
19
20
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 18

def billing_cycles
  @billing_cycles
end

#payment_preferencesPaymentPreferencesOverride

The payment preferences to override at subscription level.



22
23
24
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 22

def payment_preferences
  @payment_preferences
end

#taxesTaxesOverride

The tax details.

Returns:



26
27
28
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 26

def taxes
  @taxes
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

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 << (BillingCycleOverride.from_hash(structure) if structure)
    end
  end

  billing_cycles = SKIP unless hash.key?('billing_cycles')
  payment_preferences = PaymentPreferencesOverride.from_hash(hash['payment_preferences']) if
    hash['payment_preferences']
  taxes = TaxesOverride.from_hash(hash['taxes']) if hash['taxes']

  # Create object from extracted values.
  PlanOverride.new(billing_cycles: billing_cycles,
                   payment_preferences: payment_preferences,
                   taxes: taxes)
end

.namesObject

A mapping from model property names to API property names.



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

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

.nullablesObject

An array for nullable fields



47
48
49
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 47

def self.nullables
  []
end

.optionalsObject

An array for optional fields



38
39
40
41
42
43
44
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 38

def self.optionals
  %w[
    billing_cycles
    payment_preferences
    taxes
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



90
91
92
93
94
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 90

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

#to_sObject

Provides a human-readable string representation of the object.



83
84
85
86
87
# File 'lib/paypal_server_sdk/models/plan_override.rb', line 83

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