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

Returns a new instance of BillingCycle.



81
82
83
84
85
86
87
88
89
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 81

def initialize(tenure_type:, pricing_scheme: SKIP, frequency: SKIP,
               total_cycles: 1, sequence: 1, start_date: SKIP)
  @tenure_type = tenure_type
  @pricing_scheme = pricing_scheme unless pricing_scheme == SKIP
  @frequency = frequency unless frequency == 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

#frequencyObject

The frequency details for this billing cycle.

Returns:

  • (Object)


27
28
29
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 27

def frequency
  @frequency
end

#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)


42
43
44
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 42

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)


51
52
53
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 51

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)


35
36
37
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 35

def total_cycles
  @total_cycles
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 92

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']
  frequency = hash.key?('frequency') ? hash['frequency'] : SKIP
  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,
                   frequency: frequency,
                   total_cycles: total_cycles,
                   sequence: sequence,
                   start_date: start_date)
end

.namesObject

A mapping from model property names to API property names.



54
55
56
57
58
59
60
61
62
63
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 54

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

.nullablesObject

An array for nullable fields



77
78
79
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 77

def self.nullables
  []
end

.optionalsObject

An array for optional fields



66
67
68
69
70
71
72
73
74
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 66

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

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



121
122
123
124
125
126
127
# File 'lib/paypal_server_sdk/models/billing_cycle.rb', line 121

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} tenure_type: #{@tenure_type.inspect}, pricing_scheme:"\
  " #{@pricing_scheme.inspect}, frequency: #{@frequency.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.



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

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