Class: Svix::MessageIn

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ MessageIn

Returns a new instance of MessageIn.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/svix/models/message_in.rb', line 48

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    fail(ArgumentError, "The input argument (attributes) must be a hash in `Svix::MessageIn` 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::MessageIn")
    end

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

Instance Attribute Details

#applicationObject

Optionally creates a new application alongside the message.

If the application id or uid that is used in the path already exists, this argument is ignored.



10
11
12
# File 'lib/svix/models/message_in.rb', line 10

def application
  @application
end

#channelsObject

List of free-form identifiers that endpoints can filter by



12
13
14
# File 'lib/svix/models/message_in.rb', line 12

def channels
  @channels
end

#deliver_atObject

The date and time at which the message will be delivered.

Note that this time is best-effort-only. Must be at least one minute and no more than 24 hours in the future.



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

def deliver_at
  @deliver_at
end

#event_idObject

Optional unique identifier for the message



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

def event_id
  @event_id
end

#event_typeObject

The event type’s name



20
21
22
# File 'lib/svix/models/message_in.rb', line 20

def event_type
  @event_type
end

#payloadObject

JSON payload to send as the request body of the webhook.

We also support sending non-JSON payloads. Please contact us for more information.



24
25
26
# File 'lib/svix/models/message_in.rb', line 24

def payload
  @payload
end

#payload_retention_hoursObject

Optional number of hours to retain the message payload. Note that this is mutually exclusive with ‘payloadRetentionPeriod`.



26
27
28
# File 'lib/svix/models/message_in.rb', line 26

def payload_retention_hours
  @payload_retention_hours
end

#payload_retention_periodObject

Optional number of days to retain the message payload. Defaults to 90. Note that this is mutually exclusive with ‘payloadRetentionHours`.



28
29
30
# File 'lib/svix/models/message_in.rb', line 28

def payload_retention_period
  @payload_retention_period
end

#tagsObject

List of free-form tags that can be filtered by when listing messages



30
31
32
# File 'lib/svix/models/message_in.rb', line 30

def tags
  @tags
end

#transformations_paramsObject

Extra parameters to pass to Transformations (for future use)



32
33
34
# File 'lib/svix/models/message_in.rb', line 32

def transformations_params
  @transformations_params
end

Class Method Details

.deserialize(attributes = {}) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/svix/models/message_in.rb', line 63

def self.deserialize(attributes = {})
  attributes = attributes.transform_keys(&:to_s)
  attrs = Hash.new
  attrs["application"] = Svix::ApplicationIn.deserialize(attributes["application"]) if attributes["application"]
  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["payload"] = attributes["payload"]
  attrs["payload_retention_hours"] = attributes["payloadRetentionHours"]
  attrs["payload_retention_period"] = attributes["payloadRetentionPeriod"]
  attrs["tags"] = attributes["tags"]
  attrs["transformations_params"] = attributes["transformationsParams"]
  new(attrs)
end

Instance Method Details

#serializeObject



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

def serialize
  out = Hash.new
  out["application"] = Svix::serialize_schema_ref(@application) if @application
  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["payload"] = Svix::serialize_primitive(@payload) if @payload
  out["payloadRetentionHours"] = Svix::serialize_primitive(@payload_retention_hours) if @payload_retention_hours
  out["payloadRetentionPeriod"] = Svix::serialize_primitive(@payload_retention_period) if @payload_retention_period
  out["tags"] = Svix::serialize_primitive(@tags) if @tags
  out["transformationsParams"] = Svix::serialize_primitive(@transformations_params) if @transformations_params
  out
end

#to_jsonObject

Serializes the object to a json string

Returns:

  • String



96
97
98
# File 'lib/svix/models/message_in.rb', line 96

def to_json
  JSON.dump(serialize)
end