Module: SendGrid4r::REST::Whitelabel::Links
- Includes:
- Request
- Included in:
- API
- Defined in:
- lib/sendgrid4r/rest/whitelabel/links.rb
Overview
SendGrid Web API v3 Whitelabel Links
Defined Under Namespace
Classes: Dns, Link, Record, Result, ValidationResult, ValidationResults
Constant Summary
Constants included
from Request
Request::BASE_URL
Class Method Summary
collapse
Instance Method Summary
collapse
-
#associate_wl_link(id:, username:, &block) ⇒ Object
-
#delete_wl_link(id:, &block) ⇒ Object
-
#disassociate_wl_link(username:, &block) ⇒ Object
-
#get_associated_wl_link(username:, &block) ⇒ Object
-
#get_default_wl_link(domain: nil, &block) ⇒ Object
-
#get_wl_link(id:, &block) ⇒ Object
-
#get_wl_links(limit: nil, offset: nil, exclude_subusers: nil, username: nil, domain: nil, &block) ⇒ Object
-
#patch_wl_link(id:, default:, &block) ⇒ Object
-
#post_wl_link(subdomain:, domain:, default: nil, &block) ⇒ Object
-
#validate_wl_link(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
47
48
49
50
51
52
53
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 47
def self.create_dns(resp)
return resp if resp.nil?
Dns.new(
Links.create_record(resp['domain_cname']),
Links.create_record(resp['owner_cname'])
)
end
|
.create_link(resp) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 32
def self.create_link(resp)
return resp if resp.nil?
Link.new(
resp['id'],
resp['domain'],
resp['subdomain'],
resp['username'],
resp['user_id'],
resp['default'],
resp['valid'],
resp['legacy'],
Links.create_dns(resp['dns'])
)
end
|
.create_links(resp) ⇒ Object
27
28
29
30
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 27
def self.create_links(resp)
return resp if resp.nil?
resp.map { |link| Links.create_link(link) }
end
|
.create_record(resp) ⇒ Object
55
56
57
58
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 55
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
64
65
66
67
68
69
70
71
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 64
def self.create_result(resp)
return resp if resp.nil?
Result.new(
resp['id'],
resp['valid'],
Links.create_validation_results(resp['validation_results'])
)
end
|
.create_validation_result(resp) ⇒ Object
81
82
83
84
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 81
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) ⇒ Object
21
22
23
24
25
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 21
def self.url(id = nil)
url = "#{BASE_URL}/whitelabel/links"
url = "#{url}/#{id}" unless id.nil?
url
end
|
Instance Method Details
#associate_wl_link(id:, username:, &block) ⇒ Object
150
151
152
153
154
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 150
def associate_wl_link(id:, username:, &block)
params = { username: username }
resp = post(@auth, "#{Links.url(id)}/subuser", params, &block)
finish(resp, @raw_resp) { |r| Links.create_link(r) }
end
|
#delete_wl_link(id:, &block) ⇒ Object
123
124
125
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 123
def delete_wl_link(id:, &block)
delete(@auth, Links.url(id), &block)
end
|
#disassociate_wl_link(username:, &block) ⇒ Object
145
146
147
148
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 145
def disassociate_wl_link(username:, &block)
params = { username: username }
delete(@auth, "#{Links.url}/subuser", params, &block)
end
|
#get_associated_wl_link(username:, &block) ⇒ Object
139
140
141
142
143
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 139
def get_associated_wl_link(username:, &block)
params = { username: username }
resp = get(@auth, "#{Links.url}/subuser", params, &block)
finish(resp, @raw_resp) { |r| Links.create_link(r) }
end
|
#get_default_wl_link(domain: nil, &block) ⇒ Object
127
128
129
130
131
132
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 127
def get_default_wl_link(domain: nil, &block)
params = {}
params[:domain] = domain unless domain.nil?
resp = get(@auth, "#{Links.url}/default", params, &block)
finish(resp, @raw_resp) { |r| Links.create_link(r) }
end
|
#get_wl_link(id:, &block) ⇒ Object
112
113
114
115
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 112
def get_wl_link(id:, &block)
resp = get(@auth, Links.url(id), nil, &block)
finish(resp, @raw_resp) { |r| Links.create_link(r) }
end
|
#get_wl_links(limit: nil, offset: nil, exclude_subusers: nil, username: nil, domain: nil, &block) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 86
def get_wl_links(
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, Links.url, params, &block)
finish(resp, @raw_resp) { |r| Links.create_links(r) }
end
|
#patch_wl_link(id:, default:, &block) ⇒ Object
117
118
119
120
121
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 117
def patch_wl_link(id:, default:, &block)
params = { default: default }
resp = patch(@auth, Links.url(id), params, &block)
finish(resp, @raw_resp) { |r| Links.create_link(r) }
end
|
#post_wl_link(subdomain:, domain:, default: nil, &block) ⇒ Object
102
103
104
105
106
107
108
109
110
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 102
def post_wl_link(subdomain:, domain:, default: nil, &block)
params = {
subdomain: subdomain,
domain: domain
}
params[:default] = default unless default.nil?
resp = post(@auth, Links.url, params, &block)
finish(resp, @raw_resp) { |r| Links.create_link(r) }
end
|
#validate_wl_link(id:, &block) ⇒ Object
134
135
136
137
|
# File 'lib/sendgrid4r/rest/whitelabel/links.rb', line 134
def validate_wl_link(id:, &block)
resp = post(@auth, "#{Links.url(id)}/validate", &block)
finish(resp, @raw_resp) { |r| Links.create_result(r) }
end
|