lib/VoucherifySdk/models/simple_voucher.rb in voucherify-5.0.0 vs lib/VoucherifySdk/models/simple_voucher.rb in voucherify-6.0.0
- old
+ new
@@ -12,10 +12,11 @@
require 'date'
require 'time'
module VoucherifySdk
+ # Simplified voucher data.
class SimpleVoucher
# A unique identifier that represents the voucher assigned by Voucherify.
attr_accessor :id
# Voucher code.
@@ -23,35 +24,57 @@
attr_accessor :gift
attr_accessor :discount
- # Defines the loyalty card details.
attr_accessor :loyalty_card
- # Type of the object.
+ # Type of the voucher.
attr_accessor :type
- # Campaign object
+ # Campaign name.
attr_accessor :campaign
# Campaign unique ID.
attr_accessor :campaign_id
# Flag indicating whether this voucher is a referral code; `true` for campaign type `REFERRAL_PROGRAM`.
attr_accessor :is_referral_code
- # Unique customer ID of campaign owner.
+ # Unique customer identifier of the redeemable holder. It equals to the customer ID assigned by Voucherify.
attr_accessor :holder_id
- # Unique referrer ID.
+ # Unique identifier of the referrer assigned by Voucherify.
attr_accessor :referrer_id
- # Timestamp representing the date and time when the order was created in ISO 8601 format.
+ # Unique identifier of the category that this voucher belongs to.
+ attr_accessor :category_id
+
+ # Contains details about the category.
+ attr_accessor :categories
+
+ # Shows whether the voucher is on or off. `true` indicates an *active* voucher and `false` indicates an *inactive* voucher.
+ attr_accessor :active
+
+ # Timestamp representing the date and time when the order was created in the ISO 8601 format.
attr_accessor :created_at
- # The type of object represented by JSON.
+ # Timestamp representing the date and time when the order was created. The value is shown in the ISO 8601 format.
+ attr_accessor :updated_at
+
+ attr_accessor :redemption
+
+ # Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is *inactive before* this date.
+ attr_accessor :start_date
+
+ # Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is *inactive after* this date.
+ attr_accessor :expiration_date
+
+ # A set of custom key/value pairs that you can attach to a voucher. The metadata object stores all custom attributes assigned to the voucher.
+ attr_accessor :metadata
+
+ # The type of the object represented by JSON.
attr_accessor :object
class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values
@@ -86,11 +109,19 @@
:'campaign' => :'campaign',
:'campaign_id' => :'campaign_id',
:'is_referral_code' => :'is_referral_code',
:'holder_id' => :'holder_id',
:'referrer_id' => :'referrer_id',
+ :'category_id' => :'category_id',
+ :'categories' => :'categories',
+ :'active' => :'active',
:'created_at' => :'created_at',
+ :'updated_at' => :'updated_at',
+ :'redemption' => :'redemption',
+ :'start_date' => :'start_date',
+ :'expiration_date' => :'expiration_date',
+ :'metadata' => :'metadata',
:'object' => :'object'
}
end
# Returns all the JSON keys this model knows about
@@ -103,51 +134,68 @@
{
:'id' => :'String',
:'code' => :'String',
:'gift' => :'Gift',
:'discount' => :'Discount',
- :'loyalty_card' => :'Object',
+ :'loyalty_card' => :'SimpleLoyaltyCard',
:'type' => :'String',
- :'campaign' => :'Object',
+ :'campaign' => :'String',
:'campaign_id' => :'String',
:'is_referral_code' => :'Boolean',
:'holder_id' => :'String',
:'referrer_id' => :'String',
+ :'category_id' => :'String',
+ :'categories' => :'Array<Category>',
+ :'active' => :'Boolean',
:'created_at' => :'Time',
+ :'updated_at' => :'Time',
+ :'redemption' => :'SimpleVoucherRedemption',
+ :'start_date' => :'Time',
+ :'expiration_date' => :'Time',
+ :'metadata' => :'Object',
:'object' => :'String'
}
end
# List of attributes with nullable: true
def self.openapi_nullable
Set.new([
+ :'id',
+ :'code',
+ :'type',
+ :'campaign',
+ :'campaign_id',
+ :'is_referral_code',
+ :'holder_id',
+ :'referrer_id',
+ :'category_id',
+ :'categories',
+ :'active',
+ :'created_at',
+ :'updated_at',
+ :'redemption',
+ :'start_date',
+ :'expiration_date',
+ :'metadata',
+ :'object'
])
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
- if (!attributes.is_a?(Hash))
- fail ArgumentError, "The input argument (attributes) must be a hash in `VoucherifySdk::SimpleVoucher` initialize method"
- end
-
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
- if (!self.class.attribute_map.key?(k.to_sym))
- fail ArgumentError, "`#{k}` is not a valid attribute in `VoucherifySdk::SimpleVoucher`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
- end
h[k.to_sym] = v
}
if attributes.key?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'code')
self.code = attributes[:'code']
- else
- self.code = nil
end
if attributes.key?(:'gift')
self.gift = attributes[:'gift']
end
@@ -160,12 +208,10 @@
self.loyalty_card = attributes[:'loyalty_card']
end
if attributes.key?(:'type')
self.type = attributes[:'type']
- else
- self.type = 'voucher'
end
if attributes.key?(:'campaign')
self.campaign = attributes[:'campaign']
end
@@ -184,14 +230,48 @@
if attributes.key?(:'referrer_id')
self.referrer_id = attributes[:'referrer_id']
end
+ if attributes.key?(:'category_id')
+ self.category_id = attributes[:'category_id']
+ end
+
+ if attributes.key?(:'categories')
+ if (value = attributes[:'categories']).is_a?(Array)
+ self.categories = value
+ end
+ end
+
+ if attributes.key?(:'active')
+ self.active = attributes[:'active']
+ end
+
if attributes.key?(:'created_at')
self.created_at = attributes[:'created_at']
end
+ if attributes.key?(:'updated_at')
+ self.updated_at = attributes[:'updated_at']
+ end
+
+ if attributes.key?(:'redemption')
+ self.redemption = attributes[:'redemption']
+ end
+
+ if attributes.key?(:'start_date')
+ self.start_date = attributes[:'start_date']
+ end
+
+ if attributes.key?(:'expiration_date')
+ self.expiration_date = attributes[:'expiration_date']
+ end
+
+ if attributes.key?(:'metadata')
+ self.metadata = attributes[:'metadata']
+ end
+
if attributes.key?(:'object')
self.object = attributes[:'object']
else
self.object = 'voucher'
end
@@ -200,49 +280,24 @@
# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
def list_invalid_properties
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
invalid_properties = Array.new
- if @code.nil?
- invalid_properties.push('invalid value for "code", code cannot be nil.')
- end
-
invalid_properties
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
def valid?
warn '[DEPRECATED] the `valid?` method is obsolete'
- return false if @code.nil?
- type_validator = EnumAttributeValidator.new('String', ["voucher"])
+ type_validator = EnumAttributeValidator.new('String', ["DISCOUNT_VOUCHER", "LOYALTY_CARD", "GIFT_VOUCHER"])
return false unless type_validator.valid?(@type)
object_validator = EnumAttributeValidator.new('String', ["voucher"])
return false unless object_validator.valid?(@object)
true
end
- # Custom attribute writer method checking allowed values (enum).
- # @param [Object] type Object to be assigned
- def type=(type)
- validator = EnumAttributeValidator.new('String', ["voucher"])
- unless validator.valid?(type)
- fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
- end
- @type = type
- end
-
- # Custom attribute writer method checking allowed values (enum).
- # @param [Object] object Object to be assigned
- def object=(object)
- validator = EnumAttributeValidator.new('String', ["voucher"])
- unless validator.valid?(object)
- fail ArgumentError, "invalid value for \"object\", must be one of #{validator.allowable_values}."
- end
- @object = object
- end
-
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
@@ -255,11 +310,19 @@
campaign == o.campaign &&
campaign_id == o.campaign_id &&
is_referral_code == o.is_referral_code &&
holder_id == o.holder_id &&
referrer_id == o.referrer_id &&
+ category_id == o.category_id &&
+ categories == o.categories &&
+ active == o.active &&
created_at == o.created_at &&
+ updated_at == o.updated_at &&
+ redemption == o.redemption &&
+ start_date == o.start_date &&
+ expiration_date == o.expiration_date &&
+ metadata == o.metadata &&
object == o.object
end
# @see the `==` method
# @param [Object] Object to be compared
@@ -268,10 +331,10 @@
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
- [id, code, gift, discount, loyalty_card, type, campaign, campaign_id, is_referral_code, holder_id, referrer_id, created_at, object].hash
+ [id, code, gift, discount, loyalty_card, type, campaign, campaign_id, is_referral_code, holder_id, referrer_id, category_id, categories, active, created_at, updated_at, redemption, start_date, expiration_date, metadata, object].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself