Class: Mailersend::Suppressions

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

Overview

Suppressions endpoint from MailerSend API.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Suppressions.



11
12
13
14
15
16
# File 'lib/mailersend/suppressions/suppressions.rb', line 11

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

Instance Attribute Details

#clientObject

Returns the value of attribute client.



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

def client
  @client
end

#limitObject

Returns the value of attribute limit.



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

def limit
  @limit
end

#pageObject

Returns the value of attribute page.



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

def page
  @page
end

#recipient_idObject

Returns the value of attribute recipient_id.



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

def recipient_id
  @recipient_id
end

Instance Method Details

#add_to_blocklist(recipients: nil, patterns: nil) ⇒ Object



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

def add_to_blocklist(recipients: nil, patterns: nil)
  hash = {
    'recipients' => recipients,
    'patterns' => patterns
  }
  client.http.post("#{MAILERSEND_API_URL}/suppressions/blocklist", json: hash.compact)
end

#add_to_hard_bounces(domain_id: nil, recipients: nil) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/mailersend/suppressions/suppressions.rb', line 51

def add_to_hard_bounces(domain_id: nil, recipients: nil)
  hash = {
    'domain_id' => domain_id,
    'recipients' => recipients
  }
  client.http.post("#{MAILERSEND_API_URL}/suppressions/hard-bounces", json: hash.compact)
end

#add_to_spam_complaints(domain_id: nil, recipients: nil) ⇒ Object



68
69
70
71
72
73
74
# File 'lib/mailersend/suppressions/suppressions.rb', line 68

def add_to_spam_complaints(domain_id: nil, recipients: nil)
  hash = {
    'domain_id' => domain_id,
    'recipients' => recipients
  }
  client.http.post("#{MAILERSEND_API_URL}/suppressions/spam-complaints", json: hash.compact)
end

#add_to_unsubscribers(domain_id: nil, recipients: nil) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/mailersend/suppressions/suppressions.rb', line 85

def add_to_unsubscribers(domain_id: nil, recipients: nil)
  hash = {
    'domain_id' => domain_id,
    'recipients' => recipients
  }
  client.http.post("#{MAILERSEND_API_URL}/suppressions/unsubscribes", json: hash.compact)
end

#delete_from_blocklist(domain_id: nil, ids: nil, all: nil) ⇒ Object



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

def delete_from_blocklist(domain_id: nil, ids: nil, all: nil)
  hash = {
    'domain_id' => domain_id,
    'ids' => ids,
    'all' => all
  }
  client.http.delete("#{MAILERSEND_API_URL}/suppressions/blocklist", json: hash.compact)
end

#delete_from_hard_bounces(domain_id: nil, ids: nil, all: nil) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/mailersend/suppressions/suppressions.rb', line 59

def delete_from_hard_bounces(domain_id: nil, ids: nil, all: nil)
  hash = {
    'domain_id' => domain_id,
    'ids' => ids,
    'all' => all
  }
  client.http.delete("#{MAILERSEND_API_URL}/suppressions/hard-bounces", json: hash.compact)
end

#delete_from_spam_complaints(domain_id: nil, ids: nil, all: nil) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/mailersend/suppressions/suppressions.rb', line 76

def delete_from_spam_complaints(domain_id: nil, ids: nil, all: nil)
  hash = {
    'domain_id' => domain_id,
    'ids' => ids,
    'all' => all
  }
  client.http.delete("#{MAILERSEND_API_URL}/suppressions/spam-complaints", json: hash.compact)
end

#delete_from_unsubscribers(domain_id: nil, ids: nil, all: nil) ⇒ Object



93
94
95
96
97
98
99
100
# File 'lib/mailersend/suppressions/suppressions.rb', line 93

def delete_from_unsubscribers(domain_id: nil, ids: nil, all: nil)
  hash = {
    'domain_id' => domain_id,
    'ids' => ids,
    'all' => all
  }
  client.http.delete("#{MAILERSEND_API_URL}/suppressions/unsubscribes", json: hash.compact)
end

#get_from_blocklistObject



18
19
20
# File 'lib/mailersend/suppressions/suppressions.rb', line 18

def get_from_blocklist(*)
  client.http.get("#{MAILERSEND_API_URL}/suppressions/blocklist")
end

#get_hard_bouncesObject



22
23
24
# File 'lib/mailersend/suppressions/suppressions.rb', line 22

def get_hard_bounces(*)
  client.http.get("#{MAILERSEND_API_URL}/suppressions/hard-bounces")
end

#get_spam_complaintsObject



26
27
28
# File 'lib/mailersend/suppressions/suppressions.rb', line 26

def get_spam_complaints(*)
  client.http.get("#{MAILERSEND_API_URL}/suppressions/spam-complaints")
end

#get_unsubscribesObject



30
31
32
# File 'lib/mailersend/suppressions/suppressions.rb', line 30

def get_unsubscribes(*)
  client.http.get("#{MAILERSEND_API_URL}/suppressions/unsubscribes")
end