Class: TalonOne::CreateReferralBlock

Inherits:
ApiModelBase show all
Defined in:
lib/talon_one_sdk/models/create_referral_block.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ CreateReferralBlock

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



113
114
115
116
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
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 113

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::CreateReferralBlock` 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::CreateReferralBlock`. 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.tags = value
    end
  end

  if attributes.key?(:'campaign_id')
    self.campaign_id = attributes[:'campaign_id']
  else
    self.campaign_id = nil
  end

  if attributes.key?(:'friend_id')
    self.friend_id = attributes[:'friend_id']
  else
    self.friend_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?(:'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

#attributesObject

Returns the value of attribute attributes.



41
42
43
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 41

def attributes
  @attributes
end

#campaign_idObject

Returns the value of attribute campaign_id.



27
28
29
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 27

def campaign_id
  @campaign_id
end

#expiry_dateObject

Returns the value of attribute expiry_date.



39
40
41
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 39

def expiry_date
  @expiry_date
end

#friend_idObject

An optional integration ID of the friend's profile.



30
31
32
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 30

def friend_id
  @friend_id
end

#idObject

Unique identifier for this block.



19
20
21
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 19

def id
  @id
end

#patternObject

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.



47
48
49
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 47

def pattern
  @pattern
end

#start_dateObject

Returns the value of attribute start_date.



37
38
39
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 37

def start_date
  @start_date
end

#store_in_sessionObject

When true, the referral code is stored in the session.



33
34
35
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 33

def store_in_session
  @store_in_session
end

#tagsObject

Semantic labels attached to this block.



25
26
27
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 25

def tags
  @tags
end

#typeObject

Identifies the block variant and determines which additional properties are present in it.



22
23
24
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 22

def type
  @type
end

#usage_limitObject

Returns the value of attribute usage_limit.



35
36
37
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 35

def usage_limit
  @usage_limit
end

#valid_charactersObject

Characters used to generate the random parts of a code.



44
45
46
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 44

def valid_characters
  @valid_characters
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



68
69
70
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 68

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



73
74
75
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 73

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 50

def self.attribute_map
  {
    :'id' => :'id',
    :'type' => :'type',
    :'tags' => :'tags',
    :'campaign_id' => :'campaignId',
    :'friend_id' => :'friendId',
    :'store_in_session' => :'storeInSession',
    :'usage_limit' => :'usageLimit',
    :'start_date' => :'startDate',
    :'expiry_date' => :'expiryDate',
    :'attributes' => :'attributes',
    :'valid_characters' => :'validCharacters',
    :'pattern' => :'pattern'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 312

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_ofObject

List of class defined in allOf (OpenAPI v3)



105
106
107
108
109
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 105

def self.openapi_all_of
  [
  :'BaseBlock'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



96
97
98
99
100
101
102
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 96

def self.openapi_nullable
  Set.new([
    :'start_date',
    :'expiry_date',
    :'attributes',
  ])
end

.openapi_typesObject

Attribute type mapping.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 78

def self.openapi_types
  {
    :'id' => :'String',
    :'type' => :'String',
    :'tags' => :'Array<String>',
    :'campaign_id' => :'CreateReferralBlock1CampaignId',
    :'friend_id' => :'String',
    :'store_in_session' => :'Boolean',
    :'usage_limit' => :'CreateReferralBlock1UsageLimit',
    :'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.

Parameters:

  • Object (Object)

    to be compared



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 280

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      type == o.type &&
      tags == o.tags &&
      campaign_id == o.campaign_id &&
      friend_id == o.friend_id &&
      store_in_session == o.store_in_session &&
      usage_limit == o.usage_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

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


299
300
301
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 299

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



305
306
307
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 305

def hash
  [id, type, tags, campaign_id, friend_id, store_in_session, usage_limit, start_date, expiry_date, attributes, valid_characters, pattern].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



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
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 190

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 @friend_id.nil?
    invalid_properties.push('invalid value for "friend_id", friend_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_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 334

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

Returns:

  • (Boolean)

    true if the model is valid



218
219
220
221
222
223
224
225
226
# File 'lib/talon_one_sdk/models/create_referral_block.rb', line 218

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 @friend_id.nil?
  return false if @store_in_session.nil?
  true
end