Module: SendGrid4r::REST::Subusers
- Includes:
- Request
- Included in:
- API
- Defined in:
- lib/sendgrid4r/rest/subusers.rb
Overview
SendGrid Web API v3 Subusers
Defined Under Namespace
Classes: Ips, Monitor, Subuser
Constant Summary
Constants included
from Request
Request::BASE_URL
Class Method Summary
collapse
Instance Method Summary
collapse
-
#delete_subuser(username:, &block) ⇒ Object
-
#delete_subuser_monitor(username:, &block) ⇒ Object
-
#get_subuser_monitor(username:, email:, frequency:, &block) ⇒ Object
-
#get_subuser_reputation(usernames:, &block) ⇒ Object
-
#get_subusers(limit: nil, offset: nil, username: nil, &block) ⇒ Object
-
#patch_subuser(username:, disabled:, &block) ⇒ Object
-
#post_subuser(username:, email:, password:, ips:, &block) ⇒ Object
-
#post_subuser_monitor(username:, email:, frequency:, &block) ⇒ Object
-
#put_subuser_assigned_ips(username:, ips:, &block) ⇒ Object
-
#put_subuser_monitor(username:, email:, frequency:, &block) ⇒ Object
Methods included from Request
#create_args, #delete, #execute, #get, #patch, #post, #process_array_params, #process_url_params, #put
Class Method Details
.create_monitor(resp) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 46
def self.create_monitor(resp)
return resp if resp.nil?
Monitor.new(
resp['email'],
resp['frequency']
)
end
|
.create_subuser(resp) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 31
def self.create_subuser(resp)
return resp if resp.nil?
Subuser.new(
resp['id'],
resp['username'],
resp['email'],
resp['password'],
resp['ips'],
resp['reputation'],
resp['disabled']
)
end
|
.create_subusers(resp) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 22
def self.create_subusers(resp)
return resp if resp.nil?
subusers = []
resp.each do |subuser|
subusers.push(SendGrid4r::REST::Subusers.create_subuser(subuser))
end
subusers
end
|
.url(subuser_name = nil) ⇒ Object
16
17
18
19
20
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 16
def self.url(subuser_name = nil)
url = "#{BASE_URL}/subusers"
url = "#{url}/#{subuser_name}" unless subuser_name.nil?
url
end
|
Instance Method Details
#delete_subuser(username:, &block) ⇒ Object
81
82
83
84
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 81
def delete_subuser(username:, &block)
endpoint = SendGrid4r::REST::Subusers.url(username)
delete(@auth, endpoint, &block)
end
|
#delete_subuser_monitor(username:, &block) ⇒ Object
116
117
118
119
120
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 116
def delete_subuser_monitor(username:, &block)
endpoint = SendGrid4r::REST::Subusers.url(username)
endpoint = "#{endpoint}/monitor"
delete(@auth, endpoint, &block)
end
|
#get_subuser_monitor(username:, email:, frequency:, &block) ⇒ Object
86
87
88
89
90
91
92
93
94
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 86
def get_subuser_monitor(username:, email:, frequency:, &block)
endpoint = SendGrid4r::REST::Subusers.url(username)
endpoint = "#{endpoint}/monitor"
payload = {}
payload['email'] = email
payload['frequency'] = frequency
resp = post(@auth, endpoint, payload, &block)
SendGrid4r::REST::Subusers.create_monitor(resp)
end
|
#get_subuser_reputation(usernames:, &block) ⇒ Object
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 122
def get_subuser_reputation(usernames:, &block)
params = ''
usernames.each do |username|
params += "usernames=#{username}&"
end
endpoint = SendGrid4r::REST::Subusers.url
endpoint = "#{endpoint}/reputations?#{params}"
resp = get(@auth, endpoint, usernames, &block)
SendGrid4r::REST::Subusers.create_subusers(resp)
end
|
#get_subusers(limit: nil, offset: nil, username: nil, &block) ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 54
def get_subusers(limit: nil, offset: nil, username: nil, &block)
params = {}
params['limit'] = limit unless limit.nil?
params['offset'] = offset unless offset.nil?
params['username'] = username unless username.nil?
resp = get(@auth, SendGrid4r::REST::Subusers.url, params, &block)
SendGrid4r::REST::Subusers.create_subusers(resp)
end
|
#patch_subuser(username:, disabled:, &block) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 73
def patch_subuser(username:, disabled:, &block)
endpoint = SendGrid4r::REST::Subusers.url(username)
payload = {}
payload['disabled'] = disabled
resp = patch(@auth, endpoint, payload, &block)
SendGrid4r::REST::Subusers.create_subuser(resp)
end
|
#post_subuser(username:, email:, password:, ips:, &block) ⇒ Object
63
64
65
66
67
68
69
70
71
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 63
def post_subuser(username:, email:, password:, ips:, &block)
params = {}
params['username'] = username
params['email'] = email
params['password'] = password
params['ips'] = ips
resp = post(@auth, SendGrid4r::REST::Subusers.url, params, &block)
SendGrid4r::REST::Subusers.create_subuser(resp)
end
|
#post_subuser_monitor(username:, email:, frequency:, &block) ⇒ Object
96
97
98
99
100
101
102
103
104
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 96
def post_subuser_monitor(username:, email:, frequency:, &block)
endpoint = SendGrid4r::REST::Subusers.url(username)
endpoint = "#{endpoint}/monitor"
payload = {}
payload['email'] = email
payload['frequency'] = frequency
resp = post(@auth, endpoint, payload, &block)
SendGrid4r::REST::Subusers.create_monitor(resp)
end
|
#put_subuser_assigned_ips(username:, ips:, &block) ⇒ Object
133
134
135
136
137
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 133
def put_subuser_assigned_ips(username:, ips:, &block)
endpoint = "#{SendGrid4r::REST::Subusers.url(username)}/ips"
resp = put(@auth, endpoint, ips, &block)
SendGrid4r::REST::Subusers.create_subuser(resp)
end
|
#put_subuser_monitor(username:, email:, frequency:, &block) ⇒ Object
106
107
108
109
110
111
112
113
114
|
# File 'lib/sendgrid4r/rest/subusers.rb', line 106
def put_subuser_monitor(username:, email:, frequency:, &block)
endpoint = SendGrid4r::REST::Subusers.url(username)
endpoint = "#{endpoint}/monitor"
payload = {}
payload['email'] = email
payload['frequency'] = frequency
resp = put(@auth, endpoint, payload, &block)
SendGrid4r::REST::Subusers.create_monitor(resp)
end
|