Class: AdvancedBilling::SubscriptionIncludedCoupon

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/subscription_included_coupon.rb

Overview

SubscriptionIncludedCoupon Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(code: SKIP, use_count: SKIP, uses_allowed: SKIP, expires_at: SKIP, recurring: SKIP, amount_in_cents: SKIP, percentage: SKIP, additional_properties: {}) ⇒ SubscriptionIncludedCoupon

Returns a new instance of SubscriptionIncludedCoupon.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 75

def initialize(code: SKIP, use_count: SKIP, uses_allowed: SKIP,
               expires_at: SKIP, recurring: SKIP, amount_in_cents: SKIP,
               percentage: SKIP, additional_properties: {})
  @code = code unless code == SKIP
  @use_count = use_count unless use_count == SKIP
  @uses_allowed = uses_allowed unless uses_allowed == SKIP
  @expires_at = expires_at unless expires_at == SKIP
  @recurring = recurring unless recurring == SKIP
  @amount_in_cents = amount_in_cents unless amount_in_cents == SKIP
  @percentage = percentage unless percentage == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#amount_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


34
35
36
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 34

def amount_in_cents
  @amount_in_cents
end

#codeString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 14

def code
  @code
end

#expires_atString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 26

def expires_at
  @expires_at
end

#percentageString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 38

def percentage
  @percentage
end

#recurringTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


30
31
32
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 30

def recurring
  @recurring
end

#use_countInteger

TODO: Write general description for this method

Returns:

  • (Integer)


18
19
20
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 18

def use_count
  @use_count
end

#uses_allowedInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 22

def uses_allowed
  @uses_allowed
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 93

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  code = hash.key?('code') ? hash['code'] : SKIP
  use_count = hash.key?('use_count') ? hash['use_count'] : SKIP
  uses_allowed = hash.key?('uses_allowed') ? hash['uses_allowed'] : SKIP
  expires_at = hash.key?('expires_at') ? hash['expires_at'] : SKIP
  recurring = hash.key?('recurring') ? hash['recurring'] : SKIP
  amount_in_cents =
    hash.key?('amount_in_cents') ? hash['amount_in_cents'] : SKIP
  percentage = hash.key?('percentage') ? hash['percentage'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  SubscriptionIncludedCoupon.new(code: code,
                                 use_count: use_count,
                                 uses_allowed: uses_allowed,
                                 expires_at: expires_at,
                                 recurring: recurring,
                                 amount_in_cents: amount_in_cents,
                                 percentage: percentage,
                                 additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['code'] = 'code'
  @_hash['use_count'] = 'use_count'
  @_hash['uses_allowed'] = 'uses_allowed'
  @_hash['expires_at'] = 'expires_at'
  @_hash['recurring'] = 'recurring'
  @_hash['amount_in_cents'] = 'amount_in_cents'
  @_hash['percentage'] = 'percentage'
  @_hash
end

.nullablesObject

An array for nullable fields



67
68
69
70
71
72
73
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 67

def self.nullables
  %w[
    expires_at
    amount_in_cents
    percentage
  ]
end

.optionalsObject

An array for optional fields



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/advanced_billing/models/subscription_included_coupon.rb', line 54

def self.optionals
  %w[
    code
    use_count
    uses_allowed
    expires_at
    recurring
    amount_in_cents
    percentage
  ]
end