Class: PaypalServerSdk::SubscriptionBillingCycle

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

Overview

The billing cycle details.

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(frequency:, tenure_type:, sequence:, pricing_scheme: SKIP, total_cycles: 1) ⇒ SubscriptionBillingCycle

Returns a new instance of SubscriptionBillingCycle.



64
65
66
67
68
69
70
71
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 64

def initialize(frequency:, tenure_type:, sequence:, pricing_scheme: SKIP,
               total_cycles: 1)
  @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP
  @frequency = frequency
  @tenure_type = tenure_type
  @sequence = sequence
  @total_cycles = total_cycles unless total_cycles == SKIP
end

Instance Attribute Details

#frequencyFrequency

The frequency of the billing cycle.

Returns:



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

def frequency
  @frequency
end

#pricing_schemeSubscriptionPricingScheme

The pricing scheme details.



14
15
16
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 14

def pricing_scheme
  @pricing_scheme
end

#sequenceInteger

The order in which this cycle is to run among other billing cycles. For example, a trial billing cycle has a ‘sequence` of `1` while a regular billing cycle has a `sequence` of `2`, so that trial cycle runs before the regular cycle.

Returns:

  • (Integer)


30
31
32
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 30

def sequence
  @sequence
end

#tenure_typeTenureType

The tenure type of the billing cycle. In case of a plan having trial cycle, only 2 trial cycles are allowed per plan.

Returns:



23
24
25
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 23

def tenure_type
  @tenure_type
end

#total_cyclesInteger

The number of times this billing cycle gets executed. Trial billing cycles can only be executed a finite number of times (value between 1 and 999 for total_cycles). Regular billing cycles can be executed infinite times (value of 0 for total_cycles) or a finite number of times (value between 1 and 999 for total_cycles).

Returns:

  • (Integer)


38
39
40
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 38

def total_cycles
  @total_cycles
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  frequency = Frequency.from_hash(hash['frequency']) if hash['frequency']
  tenure_type = hash.key?('tenure_type') ? hash['tenure_type'] : nil
  sequence = hash.key?('sequence') ? hash['sequence'] : nil
  pricing_scheme = SubscriptionPricingScheme.from_hash(hash['pricing_scheme']) if
    hash['pricing_scheme']
  total_cycles = hash['total_cycles'] ||= 1

  # Create object from extracted values.

  SubscriptionBillingCycle.new(frequency: frequency,
                               tenure_type: tenure_type,
                               sequence: sequence,
                               pricing_scheme: pricing_scheme,
                               total_cycles: total_cycles)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['pricing_scheme'] = 'pricing_scheme'
  @_hash['frequency'] = 'frequency'
  @_hash['tenure_type'] = 'tenure_type'
  @_hash['sequence'] = 'sequence'
  @_hash['total_cycles'] = 'total_cycles'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 60

def self.nullables
  []
end

.optionalsObject

An array for optional fields



52
53
54
55
56
57
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 52

def self.optionals
  %w[
    pricing_scheme
    total_cycles
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



101
102
103
104
105
106
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 101

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} pricing_scheme: #{@pricing_scheme.inspect}, frequency:"\
  " #{@frequency.inspect}, tenure_type: #{@tenure_type.inspect}, sequence:"\
  " #{@sequence.inspect}, total_cycles: #{@total_cycles.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



94
95
96
97
98
# File 'lib/paypal_server_sdk/models/subscription_billing_cycle.rb', line 94

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} pricing_scheme: #{@pricing_scheme}, frequency: #{@frequency}, tenure_type:"\
  " #{@tenure_type}, sequence: #{@sequence}, total_cycles: #{@total_cycles}>"
end