Class: UnivapayClientSdk::SubscriptionScheduleSettings

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/univapay_client_sdk/models/subscription_schedule_settings.rb

Overview

Schedule settings applied to a subscription.

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(start_on: SKIP, zone_id: SKIP, preserve_end_of_month: SKIP, retry_interval: SKIP, termination_mode: SubscriptionTerminationMode::IMMEDIATE, additional_properties: nil) ⇒ SubscriptionScheduleSettings

Returns a new instance of SubscriptionScheduleSettings.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 60

def initialize(start_on: SKIP, zone_id: SKIP, preserve_end_of_month: SKIP,
               retry_interval: SKIP,
               termination_mode: SubscriptionTerminationMode::IMMEDIATE,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @start_on = start_on unless start_on == SKIP
  @zone_id = zone_id unless zone_id == SKIP
  @preserve_end_of_month = preserve_end_of_month unless preserve_end_of_month == SKIP
  @retry_interval = retry_interval unless retry_interval == SKIP
  @termination_mode = termination_mode unless termination_mode == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#preserve_end_of_monthTrueClass | FalseClass

If true, subsequent charges will always occur on the last day of the month.

Returns:

  • (TrueClass | FalseClass)


23
24
25
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 23

def preserve_end_of_month
  @preserve_end_of_month
end

#retry_intervalString

ISO-8601 Duration for retry interval if payment fails (e.g., P5D).

Returns:

  • (String)


27
28
29
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 27

def retry_interval
  @retry_interval
end

#start_onDate

Date when the recurring schedule starts (YYYY-MM-DD).

Returns:

  • (Date)


14
15
16
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 14

def start_on
  @start_on
end

#termination_modeSubscriptionTerminationMode

Subscription Termination Mode schema.



31
32
33
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 31

def termination_mode
  @termination_mode
end

#zone_idString

IANA Timezone ID.

Returns:

  • (String)


18
19
20
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 18

def zone_id
  @zone_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 76

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  start_on = hash.key?('start_on') ? hash['start_on'] : SKIP
  zone_id = hash.key?('zone_id') ? hash['zone_id'] : SKIP
  preserve_end_of_month =
    hash.key?('preserve_end_of_month') ? hash['preserve_end_of_month'] : SKIP
  retry_interval =
    hash.key?('retry_interval') ? hash['retry_interval'] : SKIP
  termination_mode =
    hash['termination_mode'] ||= SubscriptionTerminationMode::IMMEDIATE

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  SubscriptionScheduleSettings.new(start_on: start_on,
                                   zone_id: zone_id,
                                   preserve_end_of_month: preserve_end_of_month,
                                   retry_interval: retry_interval,
                                   termination_mode: termination_mode,
                                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['start_on'] = 'start_on'
  @_hash['zone_id'] = 'zone_id'
  @_hash['preserve_end_of_month'] = 'preserve_end_of_month'
  @_hash['retry_interval'] = 'retry_interval'
  @_hash['termination_mode'] = 'termination_mode'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
51
52
53
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 45

def self.optionals
  %w[
    start_on
    zone_id
    preserve_end_of_month
    retry_interval
    termination_mode
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



107
108
109
110
111
112
113
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 107

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



124
125
126
127
128
129
130
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 124

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} start_on: #{@start_on.inspect}, zone_id: #{@zone_id.inspect},"\
  " preserve_end_of_month: #{@preserve_end_of_month.inspect}, retry_interval:"\
  " #{@retry_interval.inspect}, termination_mode: #{@termination_mode.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



116
117
118
119
120
121
# File 'lib/univapay_client_sdk/models/subscription_schedule_settings.rb', line 116

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} start_on: #{@start_on}, zone_id: #{@zone_id}, preserve_end_of_month:"\
  " #{@preserve_end_of_month}, retry_interval: #{@retry_interval}, termination_mode:"\
  " #{@termination_mode}, additional_properties: #{@additional_properties}>"
end