Module: SendGrid4r::REST::Settings::Mail

Includes:
Request
Included in:
API
Defined in:
lib/sendgrid4r/rest/settings/mail.rb

Overview

SendGrid Web API v3 Settings - Mail

Defined Under Namespace

Classes: AddressWhitelist, Bcc, BouncePurge, Footer, ForwardBounce, ForwardSpam, PlainContent, SpamCheck, Template

Constant Summary

Constants included from Request

Request::BASE_URL

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Request

#create_args, #delete, #execute, #finish, #get, #patch, #post, #process_array_params, #process_url_params, #put

Class Method Details

.create_address_whitelist(resp) ⇒ Object



13
14
15
16
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 13

def self.create_address_whitelist(resp)
  return resp if resp.nil?
  AddressWhitelist.new(resp['enabled'], resp['list'])
end

.create_bcc(resp) ⇒ Object



20
21
22
23
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 20

def self.create_bcc(resp)
  return resp if resp.nil?
  Bcc.new(resp['enabled'], resp['email'])
end

.create_bounce_purge(resp) ⇒ Object



27
28
29
30
31
32
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 27

def self.create_bounce_purge(resp)
  return resp if resp.nil?
  BouncePurge.new(
    resp['enabled'], resp['hard_bounces'], resp['soft_bounces']
  )
end


36
37
38
39
40
41
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 36

def self.create_footer(resp)
  return resp if resp.nil?
  Footer.new(
    resp['enabled'], resp['html_content'], resp['plain_content']
  )
end

.create_forward_bounce(resp) ⇒ Object



45
46
47
48
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 45

def self.create_forward_bounce(resp)
  return resp if resp.nil?
  ForwardBounce.new(resp['enabled'], resp['email'])
end

.create_forward_spam(resp) ⇒ Object



52
53
54
55
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 52

def self.create_forward_spam(resp)
  return resp if resp.nil?
  ForwardSpam.new(resp['enabled'], resp['email'])
end

.create_plain_content(resp) ⇒ Object



73
74
75
76
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 73

def self.create_plain_content(resp)
  return resp if resp.nil?
  PlainContent.new(resp['enabled'])
end

.create_spam_check(resp) ⇒ Object



59
60
61
62
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 59

def self.create_spam_check(resp)
  return resp if resp.nil?
  SpamCheck.new(resp['enabled'], resp['url'], resp['max_score'])
end

.create_template(resp) ⇒ Object



66
67
68
69
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 66

def self.create_template(resp)
  return resp if resp.nil?
  Template.new(resp['enabled'], resp['html_content'])
end

.url(name = nil) ⇒ Object



78
79
80
81
82
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 78

def self.url(name = nil)
  url = "#{BASE_URL}/mail_settings"
  url = "#{url}/#{name}" unless name.nil?
  url
end

Instance Method Details

#get_mail_settings(limit: nil, offset: nil, &block) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 84

def get_mail_settings(limit: nil, offset: nil, &block)
  params = {}
  params[:limit] = limit unless limit.nil?
  params[:offset] = offset unless offset.nil?
  resp = get(@auth, Settings::Mail.url, params, &block)
  finish(resp, @raw_resp) { |r| Settings.create_results(r) }
end

#get_settings_address_whitelist(&block) ⇒ Object



92
93
94
95
96
97
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 92

def get_settings_address_whitelist(&block)
  resp = get(@auth, Settings::Mail.url(:address_whitelist), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_address_whitelist(r)
  end
end

#get_settings_bcc(&block) ⇒ Object



107
108
109
110
111
112
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 107

def get_settings_bcc(&block)
  resp = get(@auth, Settings::Mail.url(:bcc), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_bcc(r)
  end
end

#get_settings_bounce_purge(&block) ⇒ Object



122
123
124
125
126
127
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 122

def get_settings_bounce_purge(&block)
  resp = get(@auth, Settings::Mail.url(:bounce_purge), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_bounce_purge(r)
  end
end


137
138
139
140
141
142
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 137

def get_settings_footer(&block)
  resp = get(@auth, Settings::Mail.url(:footer), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_footer(r)
  end
end

#get_settings_forward_bounce(&block) ⇒ Object



151
152
153
154
155
156
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 151

def get_settings_forward_bounce(&block)
  resp = get(@auth, Settings::Mail.url(:forward_bounce), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_forward_bounce(r)
  end
end

#get_settings_forward_spam(&block) ⇒ Object



166
167
168
169
170
171
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 166

def get_settings_forward_spam(&block)
  resp = get(@auth, Settings::Mail.url(:forward_spam), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_forward_spam(r)
  end
end

#get_settings_plain_content(&block) ⇒ Object



211
212
213
214
215
216
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 211

def get_settings_plain_content(&block)
  resp = get(@auth, Settings::Mail.url(:plain_content), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_plain_content(r)
  end
end

#get_settings_spam_check(&block) ⇒ Object



181
182
183
184
185
186
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 181

def get_settings_spam_check(&block)
  resp = get(@auth, Settings::Mail.url(:spam_check), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_spam_check(r)
  end
end

#get_settings_template(&block) ⇒ Object



196
197
198
199
200
201
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 196

def get_settings_template(&block)
  resp = get(@auth, Settings::Mail.url(:template), &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_template(r)
  end
end

#patch_settings_address_whitelist(params:, &block) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 99

def patch_settings_address_whitelist(params:, &block)
  endpoint = Settings::Mail.url(:address_whitelist)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_address_whitelist(r)
  end
end

#patch_settings_bcc(params:, &block) ⇒ Object



114
115
116
117
118
119
120
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 114

def patch_settings_bcc(params:, &block)
  endpoint = Settings::Mail.url(:bcc)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_bcc(r)
  end
end

#patch_settings_bounce_purge(params:, &block) ⇒ Object



129
130
131
132
133
134
135
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 129

def patch_settings_bounce_purge(params:, &block)
  endpoint = Settings::Mail.url(:bounce_purge)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_bounce_purge(r)
  end
end


144
145
146
147
148
149
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 144

def patch_settings_footer(params:, &block)
  resp = patch(@auth, Settings::Mail.url(:footer), params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_footer(r)
  end
end

#patch_settings_forward_bounce(params:, &block) ⇒ Object



158
159
160
161
162
163
164
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 158

def patch_settings_forward_bounce(params:, &block)
  endpoint = Settings::Mail.url(:forward_bounce)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_forward_bounce(r)
  end
end

#patch_settings_forward_spam(params:, &block) ⇒ Object



173
174
175
176
177
178
179
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 173

def patch_settings_forward_spam(params:, &block)
  endpoint = Settings::Mail.url(:forward_spam)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_forward_spam(r)
  end
end

#patch_settings_plain_content(params:, &block) ⇒ Object



218
219
220
221
222
223
224
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 218

def patch_settings_plain_content(params:, &block)
  endpoint = Settings::Mail.url(:plain_content)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_plain_content(r)
  end
end

#patch_settings_spam_check(params:, &block) ⇒ Object



188
189
190
191
192
193
194
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 188

def patch_settings_spam_check(params:, &block)
  endpoint = Settings::Mail.url(:spam_check)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_spam_check(r)
  end
end

#patch_settings_template(params:, &block) ⇒ Object



203
204
205
206
207
208
209
# File 'lib/sendgrid4r/rest/settings/mail.rb', line 203

def patch_settings_template(params:, &block)
  endpoint = Settings::Mail.url(:template)
  resp = patch(@auth, endpoint, params.to_h, &block)
  finish(resp, @raw_resp) do |r|
    Settings::Mail.create_template(r)
  end
end