Class: OCI::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



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
138
# File 'lib/oci/tenant_manager_control_plane/models/promotion.rb', line 97

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

If a subscription is present, indicates the total amount of promotional subscription credits.

Returns:

  • (Float)


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

def amount
  @amount
end

#currency_unitString

Currency unit associated with the promotion.

Returns:

  • (String)


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

def currency_unit
  @currency_unit
end

#durationInteger

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

Returns:

  • (Integer)


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

def duration
  @duration
end

#duration_unitString

Unit for the duration.

Returns:

  • (String)


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

def duration_unit
  @duration_unit
end

#is_intent_to_payBOOLEAN

Speficies whether or not the customer intends to pay after the promotion has expired.

Returns:

  • (BOOLEAN)


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

def is_intent_to_pay
  @is_intent_to_pay
end

#statusString

If a subscription is present, indicates the current status of the subscription promotion.

Returns:

  • (String)


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

def status
  @status
end

#time_expiredDateTime

Date and time when the promotion ends.

Returns:

  • (DateTime)


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

def time_expired
  @time_expired
end

#time_startedDateTime

Date and time when the promotion starts.

Returns:

  • (DateTime)


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

def time_started
  @time_started
end

Class Method Details

.attribute_mapObject

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



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

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.



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

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



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

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



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

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


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

def eql?(other)
  self == other
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



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

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



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

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



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

def to_s
  to_hash.to_s
end