Module: SendGrid4r::REST::Bounces
- Includes:
- Request
- Included in:
- API
- Defined in:
- lib/sendgrid4r/rest/bounces.rb
Overview
SendGrid Web API v3 Subusers
Defined Under Namespace
Classes: Bounce
Constant Summary
Constants included
from Request
Request::BASE_URL
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Request
#create_args, #delete, #execute, #finish, #get, #patch, #post, #process_array_params, #process_url_params, #put
Class Method Details
.create_bounce(resp) ⇒ Object
23
24
25
26
27
|
# File 'lib/sendgrid4r/rest/bounces.rb', line 23
def self.create_bounce(resp)
return resp if resp.nil?
created = Time.at(resp['created']) unless resp['created'].nil?
Bounce.new(created, resp['email'], resp['reason'], resp['status'])
end
|
.create_bounces(resp) ⇒ Object
18
19
20
21
|
# File 'lib/sendgrid4r/rest/bounces.rb', line 18
def self.create_bounces(resp)
return resp if resp.nil?
resp.map { |bounce| Bounces.create_bounce(bounce) }
end
|
.url(email = nil) ⇒ Object
12
13
14
15
16
|
# File 'lib/sendgrid4r/rest/bounces.rb', line 12
def self.url(email = nil)
url = "#{BASE_URL}/suppression/bounces"
url = "#{url}/#{email}" unless email.nil?
url
end
|
Instance Method Details
#delete_bounce(email:, &block) ⇒ Object
51
52
53
|
# File 'lib/sendgrid4r/rest/bounces.rb', line 51
def delete_bounce(email:, &block)
delete(@auth, Bounces.url(email), &block)
end
|
#delete_bounces(delete_all: nil, emails: nil, &block) ⇒ Object
37
38
39
40
41
42
43
44
|
# File 'lib/sendgrid4r/rest/bounces.rb', line 37
def delete_bounces(delete_all: nil, emails: nil, &block)
if delete_all
payload = { delete_all: delete_all }
else
payload = { emails: emails }
end
delete(@auth, Bounces.url, nil, payload, &block)
end
|
#get_bounce(email:, &block) ⇒ Object
46
47
48
49
|
# File 'lib/sendgrid4r/rest/bounces.rb', line 46
def get_bounce(email:, &block)
resp = get(@auth, Bounces.url(email), &block)
finish(resp, @raw_resp) { |r| Bounces.create_bounces(r) }
end
|
#get_bounces(start_time: nil, end_time: nil, &block) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/sendgrid4r/rest/bounces.rb', line 29
def get_bounces(start_time: nil, end_time: nil, &block)
params = {}
params[:start_time] = start_time.to_i unless start_time.nil?
params[:end_time] = end_time.to_i unless end_time.nil?
resp = get(@auth, Bounces.url, params, &block)
finish(resp, @raw_resp) { |r| Bounces.create_bounces(r) }
end
|