Class: AdvancedBilling::CreateOrUpdateFlatAmountCoupon
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CreateOrUpdateFlatAmountCoupon
- Defined in:
- lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb
Overview
CreateOrUpdateFlatAmountCoupon Model.
Instance Attribute Summary collapse
-
#allow_negative_balance ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#amount_in_cents ⇒ Integer
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#apply_on_cancel_at_end_of_period ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#apply_on_subscription_expiration ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#code ⇒ String
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#compounding_strategy ⇒ CompoundingStrategy
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#description ⇒ String
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#end_date ⇒ DateTime
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#exclude_mid_period_allocations ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#name ⇒ String
the name of the coupon.
-
#product_family_id ⇒ String
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#recurring ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
-
#stackable ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(name:, code:, amount_in_cents:, description: SKIP, allow_negative_balance: SKIP, recurring: SKIP, end_date: SKIP, product_family_id: SKIP, stackable: SKIP, compounding_strategy: SKIP, exclude_mid_period_allocations: SKIP, apply_on_cancel_at_end_of_period: SKIP, apply_on_subscription_expiration: SKIP, additional_properties: {}) ⇒ CreateOrUpdateFlatAmountCoupon
constructor
A new instance of CreateOrUpdateFlatAmountCoupon.
- #to_custom_end_date ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(name:, code:, amount_in_cents:, description: SKIP, allow_negative_balance: SKIP, recurring: SKIP, end_date: SKIP, product_family_id: SKIP, stackable: SKIP, compounding_strategy: SKIP, exclude_mid_period_allocations: SKIP, apply_on_cancel_at_end_of_period: SKIP, apply_on_subscription_expiration: SKIP, additional_properties: {}) ⇒ CreateOrUpdateFlatAmountCoupon
Returns a new instance of CreateOrUpdateFlatAmountCoupon.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 132 def initialize(name:, code:, amount_in_cents:, description: SKIP, allow_negative_balance: SKIP, recurring: SKIP, end_date: SKIP, product_family_id: SKIP, stackable: SKIP, compounding_strategy: SKIP, exclude_mid_period_allocations: SKIP, apply_on_cancel_at_end_of_period: SKIP, apply_on_subscription_expiration: SKIP, additional_properties: {}) @name = name @code = code @description = description unless description == SKIP @amount_in_cents = amount_in_cents @allow_negative_balance = allow_negative_balance unless allow_negative_balance == SKIP @recurring = recurring unless recurring == SKIP @end_date = end_date unless end_date == SKIP @product_family_id = product_family_id unless product_family_id == SKIP @stackable = stackable unless stackable == SKIP @compounding_strategy = compounding_strategy unless compounding_strategy == SKIP unless exclude_mid_period_allocations == SKIP @exclude_mid_period_allocations = exclude_mid_period_allocations end unless apply_on_cancel_at_end_of_period == SKIP @apply_on_cancel_at_end_of_period = apply_on_cancel_at_end_of_period end unless apply_on_subscription_expiration == SKIP @apply_on_subscription_expiration = apply_on_subscription_expiration end # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#allow_negative_balance ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
39 40 41 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 39 def allow_negative_balance @allow_negative_balance end |
#amount_in_cents ⇒ Integer
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
33 34 35 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 33 def amount_in_cents @amount_in_cents end |
#apply_on_cancel_at_end_of_period ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
81 82 83 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 81 def apply_on_cancel_at_end_of_period @apply_on_cancel_at_end_of_period end |
#apply_on_subscription_expiration ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
87 88 89 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 87 def apply_on_subscription_expiration @apply_on_subscription_expiration end |
#code ⇒ String
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
21 22 23 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 21 def code @code end |
#compounding_strategy ⇒ CompoundingStrategy
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
69 70 71 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 69 def compounding_strategy @compounding_strategy end |
#description ⇒ String
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
27 28 29 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 27 def description @description end |
#end_date ⇒ DateTime
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
51 52 53 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 51 def end_date @end_date end |
#exclude_mid_period_allocations ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
75 76 77 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 75 def exclude_mid_period_allocations @exclude_mid_period_allocations end |
#name ⇒ String
the name of the coupon
15 16 17 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 15 def name @name end |
#product_family_id ⇒ String
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
57 58 59 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 57 def product_family_id @product_family_id end |
#recurring ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
45 46 47 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 45 def recurring @recurring end |
#stackable ⇒ TrueClass | FalseClass
may contain uppercase alphanumeric characters and these special characters (which allow for email addresses to be used): “%”, “@”, “+”, “-”, “_”, and “.”
63 64 65 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 63 def stackable @stackable end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 170 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil code = hash.key?('code') ? hash['code'] : nil amount_in_cents = hash.key?('amount_in_cents') ? hash['amount_in_cents'] : nil description = hash.key?('description') ? hash['description'] : SKIP allow_negative_balance = hash.key?('allow_negative_balance') ? hash['allow_negative_balance'] : SKIP recurring = hash.key?('recurring') ? hash['recurring'] : SKIP end_date = if hash.key?('end_date') (DateTimeHelper.from_rfc3339(hash['end_date']) if hash['end_date']) else SKIP end product_family_id = hash.key?('product_family_id') ? hash['product_family_id'] : SKIP stackable = hash.key?('stackable') ? hash['stackable'] : SKIP compounding_strategy = hash.key?('compounding_strategy') ? hash['compounding_strategy'] : SKIP exclude_mid_period_allocations = hash.key?('exclude_mid_period_allocations') ? hash['exclude_mid_period_allocations'] : SKIP apply_on_cancel_at_end_of_period = hash.key?('apply_on_cancel_at_end_of_period') ? hash['apply_on_cancel_at_end_of_period'] : SKIP apply_on_subscription_expiration = hash.key?('apply_on_subscription_expiration') ? hash['apply_on_subscription_expiration'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CreateOrUpdateFlatAmountCoupon.new(name: name, code: code, amount_in_cents: amount_in_cents, description: description, allow_negative_balance: allow_negative_balance, recurring: recurring, end_date: end_date, product_family_id: product_family_id, stackable: stackable, compounding_strategy: compounding_strategy, exclude_mid_period_allocations: exclude_mid_period_allocations, apply_on_cancel_at_end_of_period: apply_on_cancel_at_end_of_period, apply_on_subscription_expiration: apply_on_subscription_expiration, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 90 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['code'] = 'code' @_hash['description'] = 'description' @_hash['amount_in_cents'] = 'amount_in_cents' @_hash['allow_negative_balance'] = 'allow_negative_balance' @_hash['recurring'] = 'recurring' @_hash['end_date'] = 'end_date' @_hash['product_family_id'] = 'product_family_id' @_hash['stackable'] = 'stackable' @_hash['compounding_strategy'] = 'compounding_strategy' @_hash['exclude_mid_period_allocations'] = 'exclude_mid_period_allocations' @_hash['apply_on_cancel_at_end_of_period'] = 'apply_on_cancel_at_end_of_period' @_hash['apply_on_subscription_expiration'] = 'apply_on_subscription_expiration' @_hash end |
.nullables ⇒ Object
An array for nullable fields
128 129 130 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 128 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 112 def self.optionals %w[ description allow_negative_balance recurring end_date product_family_id stackable compounding_strategy exclude_mid_period_allocations apply_on_cancel_at_end_of_period apply_on_subscription_expiration ] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 225 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.name, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.code, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.amount_in_cents, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['name'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['code'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['amount_in_cents'], ->(val) { val.instance_of? Integer }) ) end |
Instance Method Details
#to_custom_end_date ⇒ Object
219 220 221 |
# File 'lib/advanced_billing/models/create_or_update_flat_amount_coupon.rb', line 219 def to_custom_end_date DateTimeHelper.to_rfc3339(end_date) end |