Class: Mailersend::DmarcMonitoring

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

Overview

DMARC Monitoring endpoint from MailerSend API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of DmarcMonitoring.



8
9
10
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 8

def initialize(client = Mailersend::Client.new)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#ipObject

Returns the value of attribute ip.



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

def ip
  @ip
end

#limitObject

Returns the value of attribute limit.



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

def limit
  @limit
end

#monitor_idObject

Returns the value of attribute monitor_id.



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

def monitor_id
  @monitor_id
end

#pageObject

Returns the value of attribute page.



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

def page
  @page
end

Instance Method Details

#add_favorite(monitor_id:, ip:) ⇒ Object



51
52
53
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 51

def add_favorite(monitor_id:, ip:)
  client.http.put("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}/favorite/#{ip}")
end

#create(domain_id:) ⇒ Object



19
20
21
22
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 19

def create(domain_id:)
  client.http.post("#{MAILERSEND_API_URL}/dmarc-monitoring",
                   json: { 'domain_id' => domain_id })
end

#delete(monitor_id:) ⇒ Object



29
30
31
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 29

def delete(monitor_id:)
  client.http.delete("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}")
end

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



12
13
14
15
16
17
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 12

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

#remove_favorite(monitor_id:, ip:) ⇒ Object



55
56
57
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 55

def remove_favorite(monitor_id:, ip:)
  client.http.delete("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}/favorite/#{ip}")
end

#report(monitor_id:, page: nil, limit: nil) ⇒ Object



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

def report(monitor_id:, page: nil, limit: nil)
  hash = { 'page' => page, 'limit' => limit }
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST,
                                   path: "/v1/dmarc-monitoring/#{monitor_id}/report",
                                   query: URI.encode_www_form(hash.compact)))
end

#report_by_ip(monitor_id:, ip:, page: nil, limit: nil) ⇒ Object



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

def report_by_ip(monitor_id:, ip:, page: nil, limit: nil)
  hash = { 'page' => page, 'limit' => limit }
  client.http.get(URI::HTTPS.build(host: MAILERSEND_API_BASE_HOST,
                                   path: "/v1/dmarc-monitoring/#{monitor_id}/report/#{ip}",
                                   query: URI.encode_www_form(hash.compact)))
end

#report_sources(monitor_id:) ⇒ Object



47
48
49
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 47

def report_sources(monitor_id:)
  client.http.get("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}/report-sources")
end

#update(monitor_id:, wanted_dmarc_record:) ⇒ Object



24
25
26
27
# File 'lib/mailersend/dmarc_monitoring/dmarc_monitoring.rb', line 24

def update(monitor_id:, wanted_dmarc_record:)
  client.http.put("#{MAILERSEND_API_URL}/dmarc-monitoring/#{monitor_id}",
                  json: { 'wanted_dmarc_record' => wanted_dmarc_record })
end