Class: Mailersend::Domains

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

Overview

Domains endpoint from MailerSend API

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Domains.



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

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

Instance Attribute Details

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#domain_idObject

Returns the value of attribute domain_id.



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

def domain_id
  @domain_id
end

#limitObject

Returns the value of attribute limit.



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

def limit
  @limit
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#pageObject

Returns the value of attribute page.



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

def page
  @page
end

#verifiedObject

Returns the value of attribute verified.



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

def verified
  @verified
end

Instance Method Details

#add(name: nil, return_path_subdomain: nil, custom_tracking_subdomain: nil, inbound_routing_subdomain: nil) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/mailersend/domains/domains.rb', line 42

def add(name: nil, return_path_subdomain: nil, custom_tracking_subdomain: nil, inbound_routing_subdomain: nil)
  hash = {
    'name' => name,
    'return_path_subdomain' => return_path_subdomain,
    'custom_tracking_subdomain' => custom_tracking_subdomain,
    'inbound_routing_subdomain' => inbound_routing_subdomain
  }
  client.http.post("#{MAILERSEND_API_URL}/domains", json: hash.compact)
end

#delete(domain_id:) ⇒ Object



52
53
54
# File 'lib/mailersend/domains/domains.rb', line 52

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

#dns(domain_id:) ⇒ Object



81
82
83
# File 'lib/mailersend/domains/domains.rb', line 81

def dns(domain_id:)
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/domains/#{domain_id}/dns-records"))
end

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



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

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

#recipients(domain_id:) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/mailersend/domains/domains.rb', line 56

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

#settings(domain_id:, send_paused: nil, track_clicks: nil, track_opens: nil, track_unsubscribe: nil, track_unsubscribe_html: nil, track_unsubscribe_plain: nil, track_content: nil, custom_tracking_enabled: nil, custom_tracking_subdomain: nil, precedence_bulk: nil) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/mailersend/domains/domains.rb', line 65

def settings(domain_id:, send_paused: nil, track_clicks: nil, track_opens: nil, track_unsubscribe: nil, track_unsubscribe_html: nil, track_unsubscribe_plain: nil, track_content: nil, custom_tracking_enabled: nil, custom_tracking_subdomain: nil, precedence_bulk: nil)
  hash = {
    'send_paused' => send_paused,
    'track_clicks' => track_clicks,
    'track_opens' => track_opens,
    'track_unsubscribe' => track_unsubscribe,
    'track_unsubscribe_html' => track_unsubscribe_html,
    'track_unsubscribe_plain' => track_unsubscribe_plain,
    'track_content' => track_content,
    'custom_tracking_enabled' => custom_tracking_enabled,
    'custom_tracking_subdomain' => custom_tracking_subdomain,
    'precedence_bulk' => precedence_bulk
  }
  client.http.put("#{MAILERSEND_API_URL}/domains/#{domain_id}/settings", json: hash.compact)
end

#single(domain_id:, page: nil, limit: nil, verified: nil) ⇒ Object



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

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

#verify(domain_id:) ⇒ Object



85
86
87
# File 'lib/mailersend/domains/domains.rb', line 85

def verify(domain_id:)
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST, path: "/v1/domains/#{domain_id}/verify"))
end