Class: TenantManagerControlPlane::Models::Promotion

Inherits:
Object
  • Object
show all
Defined in:
lib/oci/tenant_manager_control_plane/models/promotion.rb

Overview

Promotion information for a subscription.

Constant Summary collapse

STATUS_ENUM =
[
  STATUS_INITIALIZED = 'INITIALIZED'.freeze,
  STATUS_ACTIVE = 'ACTIVE'.freeze,
  STATUS_EXPIRED = 'EXPIRED'.freeze,
  STATUS_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze
].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Promotion

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash

Options Hash (attributes):

  • :duration (Integer)

    The value to assign to the #duration property

  • :duration_unit (String)

    The value to assign to the #duration_unit property

  • :amount (Float)

    The value to assign to the #amount property

  • :status (String)

    The value to assign to the #status property

  • :is_intent_to_pay (BOOLEAN)

    The value to assign to the #is_intent_to_pay property

  • :currency_unit (String)

    The value to assign to the #currency_unit property

  • :time_started (DateTime)

    The value to assign to the #time_started property

  • :time_expired (DateTime)

    The value to assign to the #time_expired property



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 96

def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }

  self.duration = attributes[:'duration'] if attributes[:'duration']

  self.duration_unit = attributes[:'durationUnit'] if attributes[:'durationUnit']

  raise 'You cannot provide both :durationUnit and :duration_unit' if attributes.key?(:'durationUnit') && attributes.key?(:'duration_unit')

  self.duration_unit = attributes[:'duration_unit'] if attributes[:'duration_unit']

  self.amount = attributes[:'amount'] if attributes[:'amount']

  self.status = attributes[:'status'] if attributes[:'status']

  self.is_intent_to_pay = attributes[:'isIntentToPay'] unless attributes[:'isIntentToPay'].nil?

  raise 'You cannot provide both :isIntentToPay and :is_intent_to_pay' if attributes.key?(:'isIntentToPay') && attributes.key?(:'is_intent_to_pay')

  self.is_intent_to_pay = attributes[:'is_intent_to_pay'] unless attributes[:'is_intent_to_pay'].nil?

  self.currency_unit = attributes[:'currencyUnit'] if attributes[:'currencyUnit']

  raise 'You cannot provide both :currencyUnit and :currency_unit' if attributes.key?(:'currencyUnit') && attributes.key?(:'currency_unit')

  self.currency_unit = attributes[:'currency_unit'] if attributes[:'currency_unit']

  self.time_started = attributes[:'timeStarted'] if attributes[:'timeStarted']

  raise 'You cannot provide both :timeStarted and :time_started' if attributes.key?(:'timeStarted') && attributes.key?(:'time_started')

  self.time_started = attributes[:'time_started'] if attributes[:'time_started']

  self.time_expired = attributes[:'timeExpired'] if attributes[:'timeExpired']

  raise 'You cannot provide both :timeExpired and :time_expired' if attributes.key?(:'timeExpired') && attributes.key?(:'time_expired')

  self.time_expired = attributes[:'time_expired'] if attributes[:'time_expired']
end

Instance Attribute Details

#amountFloat

Total amount of credit for the promotion related to the subscription if there is one.

Returns:

  • (Float)


28
29
30
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 28

def amount
  @amount
end

#currency_unitString

Currency unit associated with the promotion.

Returns:

  • (String)


40
41
42
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 40

def currency_unit
  @currency_unit
end

#durationInteger

How long the promotion related to the subscription, if any, is valid in duration units.

Returns:

  • (Integer)


20
21
22
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 20

def duration
  @duration
end

#duration_unitString

Unit for the duration.

Returns:

  • (String)


24
25
26
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 24

def duration_unit
  @duration_unit
end

#is_intent_to_payBOOLEAN

Whether or not customer intends to pay once the promotion is done.

Returns:

  • (BOOLEAN)


36
37
38
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 36

def is_intent_to_pay
  @is_intent_to_pay
end

#statusString

Current status of the promotion related to the subscription if there is one.

Returns:

  • (String)


32
33
34
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 32

def status
  @status
end

#time_expiredDateTime

Date-time for when the promotion ends.

Returns:

  • (DateTime)


48
49
50
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 48

def time_expired
  @time_expired
end

#time_startedDateTime

Date-time for when the promotion starts.

Returns:

  • (DateTime)


44
45
46
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 44

def time_started
  @time_started
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 51

def self.attribute_map
  {
    # rubocop:disable Style/SymbolLiteral
    'duration': :'duration',
    'duration_unit': :'durationUnit',
    'amount': :'amount',
    'status': :'status',
    'is_intent_to_pay': :'isIntentToPay',
    'currency_unit': :'currencyUnit',
    'time_started': :'timeStarted',
    'time_expired': :'timeExpired'
    # rubocop:enable Style/SymbolLiteral
  }
end

.swagger_typesObject

Attribute type mapping.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 67

def self.swagger_types
  {
    # rubocop:disable Style/SymbolLiteral
    'duration': :'Integer',
    'duration_unit': :'String',
    'amount': :'Float',
    'status': :'String',
    'is_intent_to_pay': :'BOOLEAN',
    'currency_unit': :'String',
    'time_started': :'DateTime',
    'time_expired': :'DateTime'
    # rubocop:enable Style/SymbolLiteral
  }
end

Instance Method Details

#==(other) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • other (Object)

    the other object to be compared



159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 159

def ==(other)
  return true if equal?(other)

  self.class == other.class &&
    duration == other.duration &&
    duration_unit == other.duration_unit &&
    amount == other.amount &&
    status == other.status &&
    is_intent_to_pay == other.is_intent_to_pay &&
    currency_unit == other.currency_unit &&
    time_started == other.time_started &&
    time_expired == other.time_expired
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 196

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)

  self.class.swagger_types.each_pair do |key, type|
    if type =~ /^Array<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        public_method("#{key}=").call(
          attributes[self.class.attribute_map[key]]
            .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) }
        )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      public_method("#{key}=").call(
        OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]])
      )
    end
    # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    the other object to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


176
177
178
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 176

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



185
186
187
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 185

def hash
  [duration, duration_unit, amount, status, is_intent_to_pay, currency_unit, time_started, time_expired].hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



229
230
231
232
233
234
235
236
237
238
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 229

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = public_method(attr).call
    next if value.nil? && !instance_variable_defined?("@#{attr}")

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



223
224
225
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 223

def to_s
  to_hash.to_s
end