Class: ApiReference::CouponRedemption
- Defined in:
- lib/api_reference/models/coupon_redemption.rb
Overview
CouponRedemption Model.
Instance Attribute Summary collapse
-
#coupon_id ⇒ String
TODO: Write general description for this method.
-
#end_date ⇒ DateTime
TODO: Write general description for this method.
-
#start_date ⇒ DateTime
TODO: Write general description for this method.
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(coupon_id:, start_date:, end_date:, additional_properties: nil) ⇒ CouponRedemption
constructor
A new instance of CouponRedemption.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_end_date ⇒ Object
- #to_custom_start_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(coupon_id:, start_date:, end_date:, additional_properties: nil) ⇒ CouponRedemption
Returns a new instance of CouponRedemption.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 46 def initialize(coupon_id:, start_date:, end_date:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @coupon_id = coupon_id @start_date = start_date @end_date = end_date @additional_properties = additional_properties end |
Instance Attribute Details
#coupon_id ⇒ String
TODO: Write general description for this method
15 16 17 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 15 def coupon_id @coupon_id end |
#end_date ⇒ DateTime
TODO: Write general description for this method
23 24 25 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 23 def end_date @end_date end |
#start_date ⇒ DateTime
TODO: Write general description for this method
19 20 21 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 19 def start_date @start_date end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 58 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. coupon_id = hash.key?('coupon_id') ? hash['coupon_id'] : nil start_date = if hash.key?('start_date') (DateTimeHelper.from_rfc3339(hash['start_date']) if hash['start_date']) end end_date = if hash.key?('end_date') (DateTimeHelper.from_rfc3339(hash['end_date']) if hash['end_date']) end # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. CouponRedemption.new(coupon_id: coupon_id, start_date: start_date, end_date: end_date, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['coupon_id'] = 'coupon_id' @_hash['start_date'] = 'start_date' @_hash['end_date'] = 'end_date' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 43 44 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 40 def self.nullables %w[ end_date ] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 35 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 94 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.coupon_id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.start_date, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.end_date, ->(val) { val.instance_of? DateTime }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['coupon_id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['start_date'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['end_date'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
126 127 128 129 130 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 126 def inspect class_name = self.class.name.split('::').last "<#{class_name} coupon_id: #{@coupon_id.inspect}, start_date: #{@start_date.inspect},"\ " end_date: #{@end_date.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_end_date ⇒ Object
88 89 90 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 88 def to_custom_end_date DateTimeHelper.to_rfc3339(end_date) end |
#to_custom_start_date ⇒ Object
84 85 86 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 84 def to_custom_start_date DateTimeHelper.to_rfc3339(start_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
119 120 121 122 123 |
# File 'lib/api_reference/models/coupon_redemption.rb', line 119 def to_s class_name = self.class.name.split('::').last "<#{class_name} coupon_id: #{@coupon_id}, start_date: #{@start_date}, end_date:"\ " #{@end_date}, additional_properties: #{@additional_properties}>" end |