Class: ApiReference::RedeemCouponParams
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- ApiReference::RedeemCouponParams
- Defined in:
- lib/api_reference/models/redeem_coupon_params.rb
Overview
RedeemCouponParams Model.
Instance Attribute Summary collapse
-
#allow_invoice_credit_or_void ⇒ TrueClass | FalseClass
If false, this request will fail if it would void an issued invoice or create a credit note.
-
#change_date ⇒ DateTime
The date that the coupon discount should take effect.
-
#change_option ⇒ ChangeOption1
Redemption code of the coupon to be redeemed for this subscription.
-
#coupon_id ⇒ String
Coupon ID to be redeemed for this subscription.
-
#coupon_redemption_code ⇒ String
Redemption code of the coupon to be redeemed for this subscription.
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.
Instance Method Summary collapse
-
#initialize(change_option:, coupon_id: SKIP, coupon_redemption_code: SKIP, change_date: SKIP, allow_invoice_credit_or_void: true) ⇒ RedeemCouponParams
constructor
A new instance of RedeemCouponParams.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_change_date ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(change_option:, coupon_id: SKIP, coupon_redemption_code: SKIP, change_date: SKIP, allow_invoice_credit_or_void: true) ⇒ RedeemCouponParams
Returns a new instance of RedeemCouponParams.
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 67 def initialize(change_option:, coupon_id: SKIP, coupon_redemption_code: SKIP, change_date: SKIP, allow_invoice_credit_or_void: true) @coupon_id = coupon_id unless coupon_id == SKIP @coupon_redemption_code = coupon_redemption_code unless coupon_redemption_code == SKIP @change_option = change_option @change_date = change_date unless change_date == SKIP unless allow_invoice_credit_or_void == SKIP @allow_invoice_credit_or_void = allow_invoice_credit_or_void end end |
Instance Attribute Details
#allow_invoice_credit_or_void ⇒ TrueClass | FalseClass
If false, this request will fail if it would void an issued invoice or create a credit note. Consider using this as a safety mechanism if you do not expect existing invoices to be changed.
34 35 36 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 34 def allow_invoice_credit_or_void @allow_invoice_credit_or_void end |
#change_date ⇒ DateTime
The date that the coupon discount should take effect. This parameter can
only be passed if the change_option is requested_date.
28 29 30 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 28 def change_date @change_date end |
#change_option ⇒ ChangeOption1
Redemption code of the coupon to be redeemed for this subscription.
23 24 25 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 23 def change_option @change_option end |
#coupon_id ⇒ String
Coupon ID to be redeemed for this subscription.
15 16 17 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 15 def coupon_id @coupon_id end |
#coupon_redemption_code ⇒ String
Redemption code of the coupon to be redeemed for this subscription.
19 20 21 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 19 def coupon_redemption_code @coupon_redemption_code end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 81 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. change_option = hash.key?('change_option') ? hash['change_option'] : nil coupon_id = hash.key?('coupon_id') ? hash['coupon_id'] : SKIP coupon_redemption_code = hash.key?('coupon_redemption_code') ? hash['coupon_redemption_code'] : SKIP change_date = if hash.key?('change_date') (DateTimeHelper.from_rfc3339(hash['change_date']) if hash['change_date']) else SKIP end allow_invoice_credit_or_void = hash['allow_invoice_credit_or_void'] ||= true # Create object from extracted values. RedeemCouponParams.new(change_option: change_option, coupon_id: coupon_id, coupon_redemption_code: coupon_redemption_code, change_date: change_date, allow_invoice_credit_or_void: allow_invoice_credit_or_void) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['coupon_id'] = 'coupon_id' @_hash['coupon_redemption_code'] = 'coupon_redemption_code' @_hash['change_option'] = 'change_option' @_hash['change_date'] = 'change_date' @_hash['allow_invoice_credit_or_void'] = 'allow_invoice_credit_or_void' @_hash end |
.nullables ⇒ Object
An array for nullable fields
58 59 60 61 62 63 64 65 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 58 def self.nullables %w[ coupon_id coupon_redemption_code change_date allow_invoice_credit_or_void ] end |
.optionals ⇒ Object
An array for optional fields
48 49 50 51 52 53 54 55 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 48 def self.optionals %w[ coupon_id coupon_redemption_code change_date allow_invoice_credit_or_void ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
118 119 120 121 122 123 124 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 118 def inspect class_name = self.class.name.split('::').last "<#{class_name} coupon_id: #{@coupon_id.inspect}, coupon_redemption_code:"\ " #{@coupon_redemption_code.inspect}, change_option: #{@change_option.inspect}, change_date:"\ " #{@change_date.inspect}, allow_invoice_credit_or_void:"\ " #{@allow_invoice_credit_or_void.inspect}>" end |
#to_custom_change_date ⇒ Object
105 106 107 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 105 def to_custom_change_date DateTimeHelper.to_rfc3339(change_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
110 111 112 113 114 115 |
# File 'lib/api_reference/models/redeem_coupon_params.rb', line 110 def to_s class_name = self.class.name.split('::').last "<#{class_name} coupon_id: #{@coupon_id}, coupon_redemption_code:"\ " #{@coupon_redemption_code}, change_option: #{@change_option}, change_date:"\ " #{@change_date}, allow_invoice_credit_or_void: #{@allow_invoice_credit_or_void}>" end |