Class: Svix::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/svix/api/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Message

Returns a new instance of Message.



37
38
39
40
# File 'lib/svix/api/message.rb', line 37

def initialize(client)
  @client = client
  @poller = MessagePoller.new(client)
end

Instance Attribute Details

#pollerObject

Returns the value of attribute poller.



36
37
38
# File 'lib/svix/api/message.rb', line 36

def poller
  @poller
end

Instance Method Details

#create(app_id, message_in, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/svix/api/message.rb', line 61

def create(app_id, message_in, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/app/#{app_id}/msg",
    query_params: {
      "with_content" => options["with_content"]
    },
    headers: {
      "idempotency-key" => options["idempotency-key"]
    },
    body: message_in
  )
  MessageOut.deserialize(res)
end

#expunge_all_contents(app_id, options = {}) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/svix/api/message.rb', line 77

def expunge_all_contents(app_id, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "POST",
    "/api/v1/app/#{app_id}/msg/expunge-all-contents",
    headers: {
      "idempotency-key" => options["idempotency-key"]
    }
  )
  ExpungeAllContentsOut.deserialize(res)
end

#expunge_content(app_id, msg_id) ⇒ Object



101
102
103
104
105
106
# File 'lib/svix/api/message.rb', line 101

def expunge_content(app_id, msg_id)
  @client.execute_request(
    "DELETE",
    "/api/v1/app/#{app_id}/msg/#{msg_id}/content"
  )
end

#get(app_id, msg_id, options = {}) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/svix/api/message.rb', line 89

def get(app_id, msg_id, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/msg/#{msg_id}",
    query_params: {
      "with_content" => options["with_content"]
    }
  )
  MessageOut.deserialize(res)
end

#list(app_id, options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/svix/api/message.rb', line 42

def list(app_id, options = {})
  options = options.transform_keys(&:to_s)
  res = @client.execute_request(
    "GET",
    "/api/v1/app/#{app_id}/msg",
    query_params: {
      "limit" => options["limit"],
      "iterator" => options["iterator"],
      "channel" => options["channel"],
      "before" => options["before"],
      "after" => options["after"],
      "with_content" => options["with_content"],
      "tag" => options["tag"],
      "event_types" => options["event_types"]
    }
  )
  ListResponseMessageOut.deserialize(res)
end