Class: Mailersend::SenderIdentity

Inherits:
Object
  • Object
show all
Defined in:
lib/mailersend/sender_identity/sender_identity.rb

Overview

SenderIdentity endpoint from MailerSend API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client = Mailersend::Client.new) ⇒ SenderIdentity

Returns a new instance of SenderIdentity.



13
14
15
16
17
18
19
20
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 13

def initialize(client = Mailersend::Client.new)
  @client = client
  @domain_id = domain_id
  @identity_id = identity_id
  @email = email
  @page = page
  @limit = limit
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



6
7
8
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 6

def client
  @client
end

#domain_idObject

Returns the value of attribute domain_id.



6
7
8
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 6

def domain_id
  @domain_id
end

#emailObject

Returns the value of attribute email.



6
7
8
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 6

def email
  @email
end

#identity_idObject

Returns the value of attribute identity_id.



6
7
8
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 6

def identity_id
  @identity_id
end

#limitObject

Returns the value of attribute limit.



6
7
8
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 6

def limit
  @limit
end

#pageObject

Returns the value of attribute page.



6
7
8
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 6

def page
  @page
end

Instance Method Details

#add(domain_id: nil, name: nil, email: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 48

def add(domain_id: nil, name: nil, email: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil)
  hash = {
    'domain_id' => domain_id,
    'name' => name,
    'email' => email,
    'reply_to_email' => reply_to_email,
    'reply_to_name' => reply_to_name,
    'add_note' => add_note,
    'personal_note' => personal_note
  }
  client.http.post("#{MAILERSEND_API_URL}/identities", json: hash.compact)
end

#delete(identity_id:) ⇒ Object



87
88
89
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 87

def delete(identity_id:)
  client.http.delete(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/#{identity_id}"))
end

#delete_by_email(email:) ⇒ Object



91
92
93
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 91

def delete_by_email(email:)
  client.http.delete(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/email/#{email}"))
end

#list(domain_id: nil, page: nil, limit: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 22

def list(domain_id: nil, page: nil, limit: nil)
  hash = {
    'domain_id' => domain_id,
    'page' => page,
    'limit' => limit
  }
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: '/v1/identities',
                                   query: URI.encode_www_form(hash.compact)))
end

#single(identity_id:) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 32

def single(identity_id:)
  hash = {
    'identity_id' => identity_id
  }
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/#{identity_id}",
                                   query: URI.encode_www_form(hash.compact)))
end

#single_by_email(email:) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 40

def single_by_email(email:)
  hash = {
    'email' => email
  }
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/identities/email/#{email}",
                                   query: URI.encode_www_form(hash.compact)))
end

#update(identity_id:, domain_id: nil, name: nil, email: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 61

def update(identity_id:, domain_id: nil, name: nil, email: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil)
  hash = {
    'domain_id' => domain_id,
    'name' => name,
    'email' => email,
    'reply_to_email' => reply_to_email,
    'reply_to_name' => reply_to_name,
    'add_note' => add_note,
    'personal_note' => personal_note
  }
  client.http.put("#{MAILERSEND_API_URL}/identities/#{identity_id}", json: hash.compact)
end

#update_by_email(email:, domain_id: nil, name: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/mailersend/sender_identity/sender_identity.rb', line 74

def update_by_email(email:, domain_id: nil, name: nil, reply_to_email: nil, reply_to_name: nil, add_note: nil, personal_note: nil)
  hash = {
    'domain_id' => domain_id,
    'name' => name,
    'email' => email,
    'reply_to_email' => reply_to_email,
    'reply_to_name' => reply_to_name,
    'add_note' => add_note,
    'personal_note' => personal_note
  }
  client.http.put("#{MAILERSEND_API_URL}/identities/email/#{email}", json: hash.compact)
end