module SendGrid4r::REST::Whitelabel::Domains

SendGrid Web API v3 Whitelabel Domains

Constants

Dns
Domain
Record
Result
ValidationResult
ValidationResults

Public Class Methods

create_dns(resp) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 55
def self.create_dns(resp)
  return resp if resp.nil?
  Dns.new(
    Domains.create_record(resp['mail_cname']),
    Domains.create_record(resp['spf']),
    Domains.create_record(resp['dkim1']),
    Domains.create_record(resp['dkim2']),
    Domains.create_record(resp['mail_server']),
    Domains.create_record(resp['subdomain_spf']),
    Domains.create_record(resp['domain_spf']),
    Domains.create_record(resp['dkim'])
  )
end
create_domain(resp) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 37
def self.create_domain(resp)
  return resp if resp.nil?
  Domain.new(
    resp['id'],
    resp['domain'],
    resp['subdomain'],
    resp['username'],
    resp['user_id'],
    resp['ips'],
    resp['custom_spf'],
    resp['default'],
    resp['legacy'],
    resp['automatic_security'],
    resp['valid'],
    Domains.create_dns(resp['dns'])
  )
end
create_domains(resp) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 32
def self.create_domains(resp)
  return resp if resp.nil?
  resp.map { |domain| Domains.create_domain(domain) }
end
create_record(resp) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 69
def self.create_record(resp)
  return resp if resp.nil?
  Record.new(resp['host'], resp['type'], resp['data'], resp['valid'])
end
create_result(resp) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 83
def self.create_result(resp)
  return resp if resp.nil?
  Result.new(
    resp['id'],
    resp['valid'],
    Domains.create_validation_results(resp['validation_results'])
  )
end
create_validation_result(resp) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 104
def self.create_validation_result(resp)
  return resp if resp.nil?
  ValidationResult.new(resp['valid'], resp['reason'])
end
create_validation_results(resp) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 92
def self.create_validation_results(resp)
  return resp if resp.nil?
  ValidationResults.new(
    Domains.create_validation_result(resp['mail_cname']),
    Domains.create_validation_result(resp['dkim1']),
    Domains.create_validation_result(resp['dkim2']),
    Domains.create_validation_result(resp['mail_server']),
    Domains.create_validation_result(resp['subdomain_spf']),
    Domains.create_validation_result(resp['dkim'])
  )
end
url(id = nil, ip = nil) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 25
def self.url(id = nil, ip = nil)
  url = "#{BASE_URL}/whitelabel/domains"
  url = "#{url}/#{id}" unless id.nil?
  url = "#{url}/ips/#{ip}" unless ip.nil?
  url
end

Public Instance Methods

add_ip_to_wl_domain(id:, ip:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 168
def add_ip_to_wl_domain(id:, ip:, &block)
  params = { ip: ip }
  resp = post(@auth, "#{Domains.url(id)}/ips", params, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domain(r) }
end
associate_wl_domain(id:, username:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 194
def associate_wl_domain(id:, username:, &block)
  endpoint = "#{Domains.url(id)}/subuser"
  params = { username: username }
  resp = post(@auth, endpoint, params, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domain(r) }
end
delete_wl_domain(id:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 157
def delete_wl_domain(id:, &block)
  delete(@auth, Domains.url(id), &block)
end
disassociate_wl_domain(username:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 189
def disassociate_wl_domain(username:, &block)
  params = { username: username }
  delete(@auth, "#{Domains.url}/subuser", params, &block)
end
get_associated_wl_domain(username:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 183
def get_associated_wl_domain(username:, &block)
  params = { username: username }
  resp = get(@auth, "#{Domains.url}/subuser", params, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domain(r) }
end
get_default_wl_domain(domain: nil, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 161
def get_default_wl_domain(domain: nil, &block)
  params = {}
  params[:domain] = domain unless domain.nil?
  resp = get(@auth, "#{Domains.url}/default", params, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domain(r) }
end
get_wl_domain(id:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 144
def get_wl_domain(id:, &block)
  resp = get(@auth, Domains.url(id), nil, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domain(r) }
end
get_wl_domains( limit: nil, offset: nil, exclude_subusers: nil, username: nil, domain: nil, &block ) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 109
def get_wl_domains(
  limit: nil, offset: nil, exclude_subusers: nil, username: nil,
  domain: nil, &block
)
  params = {}
  params[:limit] = limit unless limit.nil?
  params[:offset] = offset unless offset.nil?
  unless exclude_subusers.nil?
    params[:exclude_subusers] = exclude_subusers
  end
  params[:username] = username unless username.nil?
  params[:domain] = domain unless domain.nil?
  resp = get(@auth, Domains.url, params, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domains(r) }
end
patch_wl_domain(id:, custom_spf: nil, default: nil, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 149
def patch_wl_domain(id:, custom_spf: nil, default: nil, &block)
  params = {}
  params[:custom_spf] = custom_spf unless custom_spf.nil?
  params[:default] = default unless default.nil?
  resp = patch(@auth, Domains.url(id), params, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domain(r) }
end
post_wl_domain( domain:, subdomain:, username: nil, ips: nil, automatic_security: nil, custom_spf: nil, default: nil, &block ) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 125
def post_wl_domain(
  domain:, subdomain:, username: nil, ips: nil, automatic_security: nil,
  custom_spf: nil, default: nil, &block
)
  params = {
    domain: domain,
    subdomain: subdomain
  }
  params[:username] = username unless username.nil?
  params[:ips] = ips unless ips.nil?
  unless automatic_security.nil?
    params[:automatic_security] = automatic_security
  end
  params[:custom_spf] = custom_spf unless custom_spf.nil?
  params[:default] = default unless default.nil?
  resp = post(@auth, Domains.url, params, &block)
  finish(resp, @raw_resp) { |r| Domains.create_domain(r) }
end
remove_ip_from_wl_domain(id:, ip:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 174
def remove_ip_from_wl_domain(id:, ip:, &block)
  delete(@auth, Domains.url(id, ip), &block)
end
validate_wl_domain(id:, &block) click to toggle source
# File lib/sendgrid4r/rest/whitelabel/domains.rb, line 178
def validate_wl_domain(id:, &block)
  resp = post(@auth, "#{Domains.url(id)}/validate", &block)
  finish(resp, @raw_resp) { |r| Domains.create_result(r) }
end