Class: PaypalServerSdk::Frequency

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

Overview

The frequency of the billing cycle.

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(interval_unit:, interval_count: 1) ⇒ Frequency

Returns a new instance of Frequency.



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

def initialize(interval_unit:, interval_count: 1)
  @interval_unit = interval_unit
  @interval_count = interval_count unless interval_count == SKIP
end

Instance Attribute Details

#interval_countInteger

The number of intervals after which a subscriber is billed. For example, if the ‘interval_unit` is `DAY` with an `interval_count` of `2`, the subscription is billed once every two days. The following table lists the maximum allowed values for the `interval_count` for each `interval_unit`: Interval unit Maximum interval count DAY 365 WEEK 52 MONTH 12 YEAR 1

Returns:

  • (Integer)


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

def interval_count
  @interval_count
end

#interval_unitIntervalUnit

The interval at which the subscription is charged or billed.

Returns:



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

def interval_unit
  @interval_unit
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  interval_unit = hash.key?('interval_unit') ? hash['interval_unit'] : nil
  interval_count = hash['interval_count'] ||= 1

  # Create object from extracted values.
  Frequency.new(interval_unit: interval_unit,
                interval_count: interval_count)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
# File 'lib/paypal_server_sdk/models/frequency.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['interval_unit'] = 'interval_unit'
  @_hash['interval_count'] = 'interval_count'
  @_hash
end

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/paypal_server_sdk/models/frequency.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



33
34
35
36
37
# File 'lib/paypal_server_sdk/models/frequency.rb', line 33

def self.optionals
  %w[
    interval_count
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



69
70
71
72
73
# File 'lib/paypal_server_sdk/models/frequency.rb', line 69

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

#to_sObject

Provides a human-readable string representation of the object.



63
64
65
66
# File 'lib/paypal_server_sdk/models/frequency.rb', line 63

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