Class: TalonOne::CreateCouponBlock
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- TalonOne::CreateCouponBlock
- Defined in:
- lib/talon_one_sdk/models/create_coupon_block.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#campaign_id ⇒ Object
Returns the value of attribute campaign_id.
-
#discount_limit ⇒ Object
Returns the value of attribute discount_limit.
-
#expiry_date ⇒ Object
Returns the value of attribute expiry_date.
-
#id ⇒ Object
Unique identifier for this block.
-
#pattern ⇒ Object
The pattern used to generate codes, such as coupon codes, referral codes, and loyalty cards.
-
#recipient_id ⇒ Object
The integration ID of the customer that is allowed to redeem this coupon.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#store_in_session ⇒ Object
When
true, the coupon is stored in the session. -
#tags ⇒ Object
Semantic labels attached to this block.
-
#type ⇒ Object
Identifies the block variant and determines which additional properties are present in it.
-
#usage_limit ⇒ Object
Returns the value of attribute usage_limit.
-
#valid_characters ⇒ Object
Characters used to generate the random parts of a code.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3).
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ CreateCouponBlock
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ CreateCouponBlock
Initializes the object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 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 168 169 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 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 117 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::CreateCouponBlock` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `TalonOne::CreateCouponBlock`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'id') self.id = attributes[:'id'] else self.id = nil end if attributes.key?(:'type') self.type = attributes[:'type'] else self.type = nil end if attributes.key?(:'tags') if (value = attributes[:'tags']).is_a?(Array) self. = value end end if attributes.key?(:'campaign_id') self.campaign_id = attributes[:'campaign_id'] else self.campaign_id = nil end if attributes.key?(:'recipient_id') self.recipient_id = attributes[:'recipient_id'] else self.recipient_id = nil end if attributes.key?(:'store_in_session') self.store_in_session = attributes[:'store_in_session'] else self.store_in_session = nil end if attributes.key?(:'usage_limit') self.usage_limit = attributes[:'usage_limit'] end if attributes.key?(:'discount_limit') self.discount_limit = attributes[:'discount_limit'] end if attributes.key?(:'start_date') self.start_date = attributes[:'start_date'] end if attributes.key?(:'expiry_date') self.expiry_date = attributes[:'expiry_date'] end if attributes.key?(:'attributes') self.attributes = attributes[:'attributes'] end if attributes.key?(:'valid_characters') self.valid_characters = attributes[:'valid_characters'] end if attributes.key?(:'pattern') self.pattern = attributes[:'pattern'] end end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
43 44 45 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 43 def attributes @attributes end |
#campaign_id ⇒ Object
Returns the value of attribute campaign_id.
27 28 29 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 27 def campaign_id @campaign_id end |
#discount_limit ⇒ Object
Returns the value of attribute discount_limit.
37 38 39 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 37 def discount_limit @discount_limit end |
#expiry_date ⇒ Object
Returns the value of attribute expiry_date.
41 42 43 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 41 def expiry_date @expiry_date end |
#id ⇒ Object
Unique identifier for this block.
19 20 21 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 19 def id @id end |
#pattern ⇒ Object
The pattern used to generate codes, such as coupon codes, referral codes, and loyalty cards. The character # is a placeholder and is replaced by a random character from the validCharacters set.
49 50 51 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 49 def pattern @pattern end |
#recipient_id ⇒ Object
The integration ID of the customer that is allowed to redeem this coupon.
30 31 32 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 30 def recipient_id @recipient_id end |
#start_date ⇒ Object
Returns the value of attribute start_date.
39 40 41 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 39 def start_date @start_date end |
#store_in_session ⇒ Object
When true, the coupon is stored in the session.
33 34 35 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 33 def store_in_session @store_in_session end |
#tags ⇒ Object
Semantic labels attached to this block.
25 26 27 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 25 def @tags end |
#type ⇒ Object
Identifies the block variant and determines which additional properties are present in it.
22 23 24 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 22 def type @type end |
#usage_limit ⇒ Object
Returns the value of attribute usage_limit.
35 36 37 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 35 def usage_limit @usage_limit end |
#valid_characters ⇒ Object
Characters used to generate the random parts of a code.
46 47 48 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 46 def valid_characters @valid_characters end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
71 72 73 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 71 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
76 77 78 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 76 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 52 def self.attribute_map { :'id' => :'id', :'type' => :'type', :'tags' => :'tags', :'campaign_id' => :'campaignId', :'recipient_id' => :'recipientId', :'store_in_session' => :'storeInSession', :'usage_limit' => :'usageLimit', :'discount_limit' => :'discountLimit', :'start_date' => :'startDate', :'expiry_date' => :'expiryDate', :'attributes' => :'attributes', :'valid_characters' => :'validCharacters', :'pattern' => :'pattern' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 321 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_all_of ⇒ Object
List of class defined in allOf (OpenAPI v3)
109 110 111 112 113 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 109 def self.openapi_all_of [ :'BaseBlock' ] end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
100 101 102 103 104 105 106 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 100 def self.openapi_nullable Set.new([ :'start_date', :'expiry_date', :'attributes', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 81 def self.openapi_types { :'id' => :'String', :'type' => :'String', :'tags' => :'Array<String>', :'campaign_id' => :'CreateCouponBlock1CampaignId', :'recipient_id' => :'String', :'store_in_session' => :'Boolean', :'usage_limit' => :'CreateCouponBlock1UsageLimit', :'discount_limit' => :'CreateCouponBlock1DiscountLimit', :'start_date' => :'Object', :'expiry_date' => :'Object', :'attributes' => :'Object', :'valid_characters' => :'String', :'pattern' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 288 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && type == o.type && == o. && campaign_id == o.campaign_id && recipient_id == o.recipient_id && store_in_session == o.store_in_session && usage_limit == o.usage_limit && discount_limit == o.discount_limit && start_date == o.start_date && expiry_date == o.expiry_date && attributes == o.attributes && valid_characters == o.valid_characters && pattern == o.pattern end |
#eql?(o) ⇒ Boolean
308 309 310 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 308 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
314 315 316 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 314 def hash [id, type, , campaign_id, recipient_id, store_in_session, usage_limit, discount_limit, start_date, expiry_date, attributes, valid_characters, pattern].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 198 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @type.nil? invalid_properties.push('invalid value for "type", type cannot be nil.') end if @campaign_id.nil? invalid_properties.push('invalid value for "campaign_id", campaign_id cannot be nil.') end if @recipient_id.nil? invalid_properties.push('invalid value for "recipient_id", recipient_id cannot be nil.') end if @store_in_session.nil? invalid_properties.push('invalid value for "store_in_session", store_in_session cannot be nil.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 343 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
226 227 228 229 230 231 232 233 234 |
# File 'lib/talon_one_sdk/models/create_coupon_block.rb', line 226 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @id.nil? return false if @type.nil? return false if @campaign_id.nil? return false if @recipient_id.nil? return false if @store_in_session.nil? true end |