Class: Pingram::WebhookEvent

Inherits:
ApiModelBase show all
Defined in:
lib/pingram/models/webhook_event.rb

Overview

Webhook event payload sent to customer endpoints. Use this type with SDK webhook verification methods (e.g., verify from ‘pingram/webhooks’).

Defined Under Namespace

Classes: EnumAttributeValidator

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 = {}) ⇒ WebhookEvent

Initializes the object

Parameters:

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

    Model attributes in the form of hash



109
110
111
112
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
# File 'lib/pingram/models/webhook_event.rb', line 109

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Pingram::WebhookEvent` 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 `Pingram::WebhookEvent`. 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?(:'event_type')
    self.event_type = attributes[:'event_type']
  else
    self.event_type = nil
  end

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

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

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

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

  if attributes.key?(:'failure_code')
    self.failure_code = attributes[:'failure_code']
  end

  if attributes.key?(:'clicked_link')
    self.clicked_link = attributes[:'clicked_link']
  end

  if attributes.key?(:'clicked_link_tags')
    if (value = attributes[:'clicked_link_tags']).is_a?(Hash)
      self.clicked_link_tags = value
    end
  end
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



21
22
23
# File 'lib/pingram/models/webhook_event.rb', line 21

def channel
  @channel
end

Clicked URL for EMAIL_CLICK events.



36
37
38
# File 'lib/pingram/models/webhook_event.rb', line 36

def clicked_link
  @clicked_link
end

Link tags for EMAIL_CLICK events.



39
40
41
# File 'lib/pingram/models/webhook_event.rb', line 39

def clicked_link_tags
  @clicked_link_tags
end

#event_typeObject

Returns the value of attribute event_type.



19
20
21
# File 'lib/pingram/models/webhook_event.rb', line 19

def event_type
  @event_type
end

#failure_codeObject

Failure code for *_FAILED events.



33
34
35
# File 'lib/pingram/models/webhook_event.rb', line 33

def failure_code
  @failure_code
end

#notification_idObject

Notification type ID.



27
28
29
# File 'lib/pingram/models/webhook_event.rb', line 27

def notification_id
  @notification_id
end

#tracking_idObject

Unique tracking ID for this notification instance.



30
31
32
# File 'lib/pingram/models/webhook_event.rb', line 30

def tracking_id
  @tracking_id
end

#user_idObject

User ID the notification was sent to.



24
25
26
# File 'lib/pingram/models/webhook_event.rb', line 24

def user_id
  @user_id
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



78
79
80
# File 'lib/pingram/models/webhook_event.rb', line 78

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



83
84
85
# File 'lib/pingram/models/webhook_event.rb', line 83

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/pingram/models/webhook_event.rb', line 64

def self.attribute_map
  {
    :'event_type' => :'eventType',
    :'channel' => :'channel',
    :'user_id' => :'userId',
    :'notification_id' => :'notificationId',
    :'tracking_id' => :'trackingId',
    :'failure_code' => :'failureCode',
    :'clicked_link' => :'clickedLink',
    :'clicked_link_tags' => :'clickedLinkTags'
  }
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



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/pingram/models/webhook_event.rb', line 290

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_nullableObject

List of attributes with nullable: true



102
103
104
105
# File 'lib/pingram/models/webhook_event.rb', line 102

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/pingram/models/webhook_event.rb', line 88

def self.openapi_types
  {
    :'event_type' => :'String',
    :'channel' => :'ChannelsEnum',
    :'user_id' => :'String',
    :'notification_id' => :'String',
    :'tracking_id' => :'String',
    :'failure_code' => :'String',
    :'clicked_link' => :'String',
    :'clicked_link_tags' => :'Hash<String, Array<String>>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/pingram/models/webhook_event.rb', line 262

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      event_type == o.event_type &&
      channel == o.channel &&
      user_id == o.user_id &&
      notification_id == o.notification_id &&
      tracking_id == o.tracking_id &&
      failure_code == o.failure_code &&
      clicked_link == o.clicked_link &&
      clicked_link_tags == o.clicked_link_tags
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


277
278
279
# File 'lib/pingram/models/webhook_event.rb', line 277

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



283
284
285
# File 'lib/pingram/models/webhook_event.rb', line 283

def hash
  [event_type, channel, user_id, notification_id, tracking_id, failure_code, clicked_link, clicked_link_tags].hash
end

#list_invalid_propertiesObject

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

Returns:

  • Array for valid properties with the reasons



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/pingram/models/webhook_event.rb', line 170

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @event_type.nil?
    invalid_properties.push('invalid value for "event_type", event_type cannot be nil.')
  end

  if @channel.nil?
    invalid_properties.push('invalid value for "channel", channel cannot be nil.')
  end

  if @user_id.nil?
    invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
  end

  if @notification_id.nil?
    invalid_properties.push('invalid value for "notification_id", notification_id cannot be nil.')
  end

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



312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/pingram/models/webhook_event.rb', line 312

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



198
199
200
201
202
203
204
205
206
207
208
# File 'lib/pingram/models/webhook_event.rb', line 198

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @event_type.nil?
  event_type_validator = EnumAttributeValidator.new('String', ["EMAIL_OPEN", "EMAIL_CLICK", "EMAIL_FAILED", "EMAIL_DELIVERED", "EMAIL_UNSUBSCRIBE", "EMAIL_INBOUND", "INAPP_WEB_FAILED", "INAPP_WEB_UNSUBSCRIBE", "SMS_DELIVERED", "SMS_FAILED", "SMS_UNSUBSCRIBE", "SMS_SUBSCRIBE", "SMS_INBOUND", "PUSH_FAILED", "PUSH_UNSUBSCRIBE", "CALL_FAILED", "CALL_UNSUBSCRIBE", "WEB_PUSH_FAILED", "WEB_PUSH_UNSUBSCRIBE", "SLACK_FAILED", "SLACK_UNSUBSCRIBE", "VOICE_INBOUND"])
  return false unless event_type_validator.valid?(@event_type)
  return false if @channel.nil?
  return false if @user_id.nil?
  return false if @notification_id.nil?
  return false if @tracking_id.nil?
  true
end