Class: PaypalServerSdk::BillingCycle

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

Overview

The billing cycle providing details of the billing frequency, amount, duration and if the billing cycle is a free, discounted or regular billing cycle. The sequence of the billing cycle will be in the following order - free trial billing cycle(s), discounted trial billing cycle(s), regular billing cycle(s).

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

Returns a new instance of BillingCycle.



75
76
77
78
79
80
81
82
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 75

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

Instance Attribute Details

#pricing_schemePricingScheme

The pricing scheme details.

Returns:



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

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)


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

def sequence
  @sequence
end

#start_dateString

The stand-alone date, in [Internet date and time format](tools.ietf.org/html/rfc3339#section-5.6). To represent special legal values, such as a date of birth, you should use dates with no associated time or time-zone data. Whenever possible, use the standard ‘date_time` type. This regular expression does not validate all dates. For example, February 31 is valid and nothing is known about leap years.

Returns:

  • (String)


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

def start_date
  @start_date
end

#tenure_typeTenureType

The tenure type of the billing cycle identifies if the billing cycle is a trial(free or discounted) or regular billing cycle.

Returns:



19
20
21
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 19

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)


31
32
33
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 31

def total_cycles
  @total_cycles
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  tenure_type = hash.key?('tenure_type') ? hash['tenure_type'] : nil
  pricing_scheme = PricingScheme.from_hash(hash['pricing_scheme']) if hash['pricing_scheme']
  total_cycles = hash['total_cycles'] ||= 1
  sequence = hash['sequence'] ||= 1
  start_date = hash.key?('start_date') ? hash['start_date'] : SKIP

  # Create object from extracted values.
  BillingCycle.new(tenure_type: tenure_type,
                   pricing_scheme: pricing_scheme,
                   total_cycles: total_cycles,
                   sequence: sequence,
                   start_date: start_date)
end

.namesObject

A mapping from model property names to API property names.



50
51
52
53
54
55
56
57
58
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 50

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

.nullablesObject

An array for nullable fields



71
72
73
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 71

def self.nullables
  []
end

.optionalsObject

An array for optional fields



61
62
63
64
65
66
67
68
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 61

def self.optionals
  %w[
    pricing_scheme
    total_cycles
    sequence
    start_date
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



111
112
113
114
115
116
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 111

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

#to_sObject

Provides a human-readable string representation of the object.



104
105
106
107
108
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 104

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