Class: Svix::MessageOut

Inherits:
Object
  • Object
show all
Defined in:
lib/svix/models/message_out.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ MessageOut

Returns a new instance of MessageOut.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/svix/models/message_out.rb', line 23

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    fail(ArgumentError, "The input argument (attributes) must be a hash in `Svix::MessageOut` new method")
  end

  attributes.each do |k, v|
    unless ALL_FIELD.include?(k.to_s)
      fail(ArgumentError, "The field #{k} is not part of Svix::MessageOut")
    end

    instance_variable_set("@#{k}", v)
    instance_variable_set("@__#{k}_is_defined", true)
  end
end

Instance Attribute Details

#channelsObject

List of free-form identifiers that endpoints can filter by



8
9
10
# File 'lib/svix/models/message_out.rb', line 8

def channels
  @channels
end

#deliver_atObject

Returns the value of attribute deliver_at.



9
10
11
# File 'lib/svix/models/message_out.rb', line 9

def deliver_at
  @deliver_at
end

#event_idObject

Optional unique identifier for the message



11
12
13
# File 'lib/svix/models/message_out.rb', line 11

def event_id
  @event_id
end

#event_typeObject

The event type’s name



13
14
15
# File 'lib/svix/models/message_out.rb', line 13

def event_type
  @event_type
end

#idObject

The Message’s ID.



15
16
17
# File 'lib/svix/models/message_out.rb', line 15

def id
  @id
end

#payloadObject

Returns the value of attribute payload.



16
17
18
# File 'lib/svix/models/message_out.rb', line 16

def payload
  @payload
end

#tagsObject

Returns the value of attribute tags.



17
18
19
# File 'lib/svix/models/message_out.rb', line 17

def tags
  @tags
end

#timestampObject

Returns the value of attribute timestamp.



18
19
20
# File 'lib/svix/models/message_out.rb', line 18

def timestamp
  @timestamp
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/svix/models/message_out.rb', line 38

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["channels"] = attributes["channels"]
  attrs["deliver_at"] = DateTime.rfc3339(attributes["deliverAt"]).to_time if attributes["deliverAt"]
  attrs["event_id"] = attributes["eventId"]
  attrs["event_type"] = attributes["eventType"]
  attrs["id"] = attributes["id"]
  attrs["payload"] = attributes["payload"]
  attrs["tags"] = attributes["tags"]
  attrs["timestamp"] = DateTime.rfc3339(attributes["timestamp"]).to_time
  new(attrs)
end

Instance Method Details

#serializeObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/svix/models/message_out.rb', line 52

def serialize
  out = Hash.new
  out["channels"] = Svix::serialize_primitive(@channels) if @channels
  out["deliverAt"] = Svix::serialize_primitive(@deliver_at) if @deliver_at
  out["eventId"] = Svix::serialize_primitive(@event_id) if @event_id
  out["eventType"] = Svix::serialize_primitive(@event_type) if @event_type
  out["id"] = Svix::serialize_primitive(@id) if @id
  out["payload"] = Svix::serialize_primitive(@payload) if @payload
  out["tags"] = Svix::serialize_primitive(@tags) if @tags
  out["timestamp"] = Svix::serialize_primitive(@timestamp) if @timestamp
  out
end

#to_jsonObject

Serializes the object to a json string

Returns:

  • String



67
68
69
# File 'lib/svix/models/message_out.rb', line 67

def to_json
  JSON.dump(serialize)
end