Module: SendGrid4r::REST::Whitelabel::Domains
- Includes:
- Request
- Included in:
- API
- Defined in:
- lib/sendgrid4r/rest/whitelabel/domains.rb
Overview
SendGrid Web API v3 Whitelabel Domains
Defined Under Namespace
Classes: Dns, Domain, Record, Result, ValidationResult, ValidationResults
Constant Summary
Constants included
from Request
Request::BASE_URL
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add_ip_to_wl_domain(id:, ip:, &block) ⇒ Object
-
#associate_wl_domain(id:, username:, &block) ⇒ Object
-
#delete_wl_domain(id:, &block) ⇒ Object
-
#disassociate_wl_domain(username:, &block) ⇒ Object
-
#get_associated_wl_domain(username:, &block) ⇒ Object
-
#get_default_wl_domain(domain: nil, &block) ⇒ Object
-
#get_wl_domain(id:, &block) ⇒ Object
-
#get_wl_domains(limit: nil, offset: nil, exclude_subusers: nil, username: nil, domain: nil, &block) ⇒ Object
-
#patch_wl_domain(id:, custom_spf: nil, default: nil, &block) ⇒ Object
-
#post_wl_domain(domain:, subdomain:, username: nil, ips: nil, automatic_security: nil, custom_spf: nil, default: nil, &block) ⇒ Object
-
#remove_ip_from_wl_domain(id:, ip:, &block) ⇒ Object
-
#validate_wl_domain(id:, &block) ⇒ Object
Methods included from Request
#create_args, #delete, #execute, #finish, #get, #patch, #post, #process_array_params, #process_url_params, #put
Class Method Details
.create_dns(resp) ⇒ Object
.create_domain(resp) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 38
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) ⇒ Object
33
34
35
36
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 33
def self.create_domains(resp)
return resp if resp.nil?
resp.map { |domain| Domains.create_domain(domain) }
end
|
.create_record(resp) ⇒ Object
70
71
72
73
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 70
def self.create_record(resp)
return resp if resp.nil?
Record.new(resp['host'], resp['type'], resp['data'], resp['valid'])
end
|
.create_result(resp) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 84
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) ⇒ Object
105
106
107
108
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 105
def self.create_validation_result(resp)
return resp if resp.nil?
ValidationResult.new(resp['valid'], resp['reason'])
end
|
.create_validation_results(resp) ⇒ Object
.url(id = nil, ip = nil) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 26
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
|
Instance Method Details
#add_ip_to_wl_domain(id:, ip:, &block) ⇒ Object
169
170
171
172
173
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 169
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) ⇒ Object
195
196
197
198
199
200
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 195
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) ⇒ Object
158
159
160
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 158
def delete_wl_domain(id:, &block)
delete(@auth, Domains.url(id), &block)
end
|
#disassociate_wl_domain(username:, &block) ⇒ Object
190
191
192
193
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 190
def disassociate_wl_domain(username:, &block)
params = { username: username }
delete(@auth, "#{Domains.url}/subuser", params, &block)
end
|
#get_associated_wl_domain(username:, &block) ⇒ Object
184
185
186
187
188
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 184
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) ⇒ Object
162
163
164
165
166
167
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 162
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) ⇒ Object
145
146
147
148
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 145
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) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 110
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) ⇒ Object
150
151
152
153
154
155
156
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 150
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) ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 126
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) ⇒ Object
175
176
177
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 175
def remove_ip_from_wl_domain(id:, ip:, &block)
delete(@auth, Domains.url(id, ip), &block)
end
|
#validate_wl_domain(id:, &block) ⇒ Object
179
180
181
182
|
# File 'lib/sendgrid4r/rest/whitelabel/domains.rb', line 179
def validate_wl_domain(id:, &block)
resp = post(@auth, "#{Domains.url(id)}/validate", &block)
finish(resp, @raw_resp) { |r| Domains.create_result(r) }
end
|