Module: SendGrid4r::REST::Webhooks::Parse

Includes:
Request
Included in:
API
Defined in:
lib/sendgrid4r/rest/webhooks/parse.rb

Overview

SendGrid Web API v3 Webhooks Parse

Defined Under Namespace

Classes: ParseSetting, ParseSettings

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_parse_setting(resp) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 31

def self.create_parse_setting(resp)
  return resp if resp.nil?
  ParseSetting.new(
    resp['url'],
    resp['hostname'],
    resp['spam_check'],
    resp['send_raw']
  )
end

.create_parse_settings(resp) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 23

def self.create_parse_settings(resp)
  return resp if resp.nil?
  parse_settings = resp['result'].map do |setting|
    Parse.create_parse_setting(setting)
  end
  ParseSettings.new(parse_settings)
end

.url(hostname = nil) ⇒ Object



17
18
19
20
21
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 17

def self.url(hostname = nil)
  url = "#{BASE_URL}/user/webhooks/parse/settings"
  url = "#{url}/#{hostname}" unless hostname.nil?
  url
end

Instance Method Details

#delete_parse_setting(hostname:, &block) ⇒ Object



78
79
80
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 78

def delete_parse_setting(hostname:, &block)
  delete(@auth, Parse.url(hostname), &block)
end

#get_parse_setting(hostname:, &block) ⇒ Object



62
63
64
65
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 62

def get_parse_setting(hostname:, &block)
  resp = get(@auth, Parse.url(hostname), &block)
  finish(resp, @raw_resp) { |r| Parse.create_parse_setting(r) }
end

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



41
42
43
44
45
46
47
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 41

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

#patch_parse_setting(hostname:, url: nil, spam_check: nil, send_raw: nil, &block) ⇒ Object



67
68
69
70
71
72
73
74
75
76
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 67

def patch_parse_setting(
  hostname:, url: nil, spam_check: nil, send_raw: nil, &block
)
  params = {}
  params[:url] = url unless url.nil?
  params[:spam_check] = spam_check unless spam_check.nil?
  params[:send_raw] = send_raw unless send_raw.nil?
  resp = patch(@auth, Parse.url(hostname), params, &block)
  finish(resp, @raw_resp) { |r| Parse.create_parse_setting(r) }
end

#post_parse_setting(hostname:, url:, spam_check:, send_raw:, &block) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sendgrid4r/rest/webhooks/parse.rb', line 49

def post_parse_setting(
  hostname:, url:, spam_check:, send_raw:, &block
)
  params = {
    hostname: hostname,
    url: url,
    spam_check: spam_check,
    send_raw: send_raw
  }
  resp = post(@auth, Parse.url, params, &block)
  finish(resp, @raw_resp) { |r| Parse.create_parse_setting(r) }
end