module SendGrid4r::REST::Subusers
Constants
- Ips
- Monitor
- Subuser
Public Class Methods
create_monitor(resp)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 44 def self.create_monitor(resp) return resp if resp.nil? Monitor.new(resp['email'], resp['frequency']) end
create_subuser(resp)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 29 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)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 24 def self.create_subusers(resp) return resp if resp.nil? resp.map { |subuser| Subusers.create_subuser(subuser) } end
url(subuser_name = nil)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 14 def self.url(subuser_name = nil) url = "#{BASE_URL}/subusers" url = "#{url}/#{subuser_name}" unless subuser_name.nil? url end
url_monitor(username)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 20 def self.url_monitor(username) "#{Subusers.url(username)}/monitor" end
Public Instance Methods
delete_subuser(username:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 75 def delete_subuser(username:, &block) delete(@auth, Subusers.url(username), &block) end
delete_subuser_monitor(username:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 99 def delete_subuser_monitor(username:, &block) delete(@auth, Subusers.url_monitor(username), &block) end
get_subuser_monitor(username:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 79 def get_subuser_monitor(username:, &block) endpoint = Subusers.url_monitor(username) resp = get(@auth, endpoint, nil, &block) finish(resp, @raw_resp) { |r| Subusers.create_monitor(r) } end
get_subuser_reputation(usernames:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 103 def get_subuser_reputation(usernames:, &block) params = '' usernames.each { |username| params += "usernames=#{username}&" } endpoint = "#{Subusers.url}/reputations?#{params}" resp = get(@auth, endpoint, nil, &block) finish(resp, @raw_resp) { |r| Subusers.create_subusers(r) } end
get_subusers(limit: nil, offset: nil, username: nil, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 49 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, Subusers.url, params, &block) finish(resp, @raw_resp) { |r| Subusers.create_subusers(r) } end
patch_subuser(username:, disabled:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 69 def patch_subuser(username:, disabled:, &block) payload = { disabled: disabled } resp = patch(@auth, Subusers.url(username), payload, &block) finish(resp, @raw_resp) { |r| Subusers.create_subuser(r) } end
post_subuser(username:, email:, password:, ips:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 58 def post_subuser(username:, email:, password:, ips:, &block) params = { username: username, email: email, password: password, ips: ips } resp = post(@auth, Subusers.url, params, &block) finish(resp, @raw_resp) { |r| Subusers.create_subuser(r) } end
post_subuser_monitor(username:, email:, frequency:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 85 def post_subuser_monitor(username:, email:, frequency:, &block) endpoint = Subusers.url_monitor(username) payload = { email: email, frequency: frequency } resp = post(@auth, endpoint, payload, &block) finish(resp, @raw_resp) { |r| Subusers.create_monitor(r) } end
put_subuser_assigned_ips(username:, ips:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 111 def put_subuser_assigned_ips(username:, ips:, &block) resp = put(@auth, "#{Subusers.url(username)}/ips", ips, &block) finish(resp, @raw_resp) { |r| Subusers.create_subuser(r) } end
put_subuser_monitor(username:, email:, frequency:, &block)
click to toggle source
# File lib/sendgrid4r/rest/subusers.rb, line 92 def put_subuser_monitor(username:, email:, frequency:, &block) endpoint = Subusers.url_monitor(username) payload = { email: email, frequency: frequency } resp = put(@auth, endpoint, payload, &block) finish(resp, @raw_resp) { |r| Subusers.create_monitor(r) } end