Class: Sendeez::Emails

Inherits:
Object
  • Object
show all
Defined in:
lib/sendeez/emails.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Emails

Returns a new instance of Emails.



5
6
7
# File 'lib/sendeez/emails.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#list(limit: nil, after: nil, timeout: nil) ⇒ Object



23
24
25
# File 'lib/sendeez/emails.rb', line 23

def list(limit: nil, after: nil, timeout: nil)
  @client.request("GET", "/v1/emails", query: { "limit" => limit, "after" => after }, timeout: timeout)
end

#retrieve(id, timeout: nil) ⇒ Object



19
20
21
# File 'lib/sendeez/emails.rb', line 19

def retrieve(id, timeout: nil)
  @client.request("GET", "/v1/emails/#{URI.encode_www_form_component(id)}", timeout: timeout)
end

#send_email(input, idempotency_key: nil, timeout: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/sendeez/emails.rb', line 9

def send_email(input, idempotency_key: nil, timeout: nil)
  @client.request(
    "POST",
    "/v1/emails",
    body: input,
    idempotency_key: idempotency_key || Client.new_idempotency_key,
    timeout: timeout
  )
end

#simulate_event(email_id, input, idempotency_key: nil, timeout: nil) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/sendeez/emails.rb', line 27

def simulate_event(email_id, input, idempotency_key: nil, timeout: nil)
  @client.request(
    "POST",
    "/v1/emails/#{URI.encode_www_form_component(email_id)}/events",
    body: input,
    idempotency_key: idempotency_key || Client.new_idempotency_key,
    timeout: timeout
  )
end