Class: CyberSourceMergedSpec::PlanInformation2

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/cyber_source_merged_spec/models/plan_information2.rb

Overview

PlanInformation2 Model.

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(code: SKIP, status: SKIP, name: SKIP, description: SKIP, billing_period: SKIP, billing_cycles: SKIP, additional_properties: nil) ⇒ PlanInformation2

Returns a new instance of PlanInformation2.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 68

def initialize(code: SKIP, status: SKIP, name: SKIP, description: SKIP,
               billing_period: SKIP, billing_cycles: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @code = code unless code == SKIP
  @status = status unless status == SKIP
  @name = name unless name == SKIP
  @description = description unless description == SKIP
  @billing_period = billing_period unless billing_period == SKIP
  @billing_cycles = billing_cycles unless billing_cycles == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#billing_cyclesBillingCycles1

Billing Frequency

Returns:



37
38
39
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 37

def billing_cycles
  @billing_cycles
end

#billing_periodBillingPeriod

Billing Frequency

Returns:



33
34
35
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 33

def billing_period
  @billing_period
end

#codeString

Plan code

Returns:

  • (String)


14
15
16
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 14

def code
  @code
end

#descriptionString

Plan description

Returns:

  • (String)


29
30
31
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 29

def description
  @description
end

#nameString

Plan name

Returns:

  • (String)


25
26
27
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 25

def name
  @name
end

#statusString

Plan Status:

  • DRAFT
  • ACTIVE
  • INACTIVE

Returns:

  • (String)


21
22
23
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 21

def status
  @status
end

Class Method Details

.from_element(root) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 112

def self.from_element(root)
  code = XmlUtilities.from_element(root, 'code', String)
  status = XmlUtilities.from_element(root, 'status', String)
  name = XmlUtilities.from_element(root, 'name', String)
  description = XmlUtilities.from_element(root, 'description', String)
  billing_period = XmlUtilities.from_element(root, 'BillingPeriod',
                                             BillingPeriod)
  billing_cycles = XmlUtilities.from_element(root, 'BillingCycles1',
                                             BillingCycles1)

  new(code: code,
      status: status,
      name: name,
      description: description,
      billing_period: billing_period,
      billing_cycles: billing_cycles,
      additional_properties: additional_properties)
end

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 84

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  code = hash.key?('code') ? hash['code'] : SKIP
  status = hash.key?('status') ? hash['status'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  billing_period = BillingPeriod.from_hash(hash['billingPeriod']) if hash['billingPeriod']
  billing_cycles = BillingCycles1.from_hash(hash['billingCycles']) if hash['billingCycles']

  # 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.
  PlanInformation2.new(code: code,
                       status: status,
                       name: name,
                       description: description,
                       billing_period: billing_period,
                       billing_cycles: billing_cycles,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



40
41
42
43
44
45
46
47
48
49
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 40

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['code'] = 'code'
  @_hash['status'] = 'status'
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['billing_period'] = 'billingPeriod'
  @_hash['billing_cycles'] = 'billingCycles'
  @_hash
end

.nullablesObject

An array for nullable fields



64
65
66
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 64

def self.nullables
  []
end

.optionalsObject

An array for optional fields



52
53
54
55
56
57
58
59
60
61
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 52

def self.optionals
  %w[
    code
    status
    name
    description
    billing_period
    billing_cycles
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



156
157
158
159
160
161
162
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 156

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} code: #{@code.inspect}, status: #{@status.inspect}, name: #{@name.inspect},"\
  " description: #{@description.inspect}, billing_period: #{@billing_period.inspect},"\
  " billing_cycles: #{@billing_cycles.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



148
149
150
151
152
153
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 148

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} code: #{@code}, status: #{@status}, name: #{@name}, description:"\
  " #{@description}, billing_period: #{@billing_period}, billing_cycles: #{@billing_cycles},"\
  " additional_properties: #{@additional_properties}>"
end

#to_xml_element(doc, root_name) ⇒ Object



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/cyber_source_merged_spec/models/plan_information2.rb', line 131

def to_xml_element(doc, root_name)
  root = doc.create_element(root_name)

  XmlUtilities.add_as_subelement(doc, root, 'code', code)
  XmlUtilities.add_as_subelement(doc, root, 'status', status)
  XmlUtilities.add_as_subelement(doc, root, 'name', name)
  XmlUtilities.add_as_subelement(doc, root, 'description', description)
  XmlUtilities.add_as_subelement(doc, root, 'BillingPeriod', billing_period)
  XmlUtilities.add_as_subelement(doc, root, 'BillingCycles1',
                                 billing_cycles)
  XmlUtilities.add_as_subelement(doc, root, 'additional_properties',
                                 additional_properties)

  root
end