Module: SendGrid4r::REST::Settings::Tracking
- Includes:
- Request
- Included in:
- API
- Defined in:
- lib/sendgrid4r/rest/settings/tracking.rb
Overview
SendGrid Web API v3 Settings - Tracking
Defined Under Namespace
Classes: Click, GoogleAnalytics, Open, Subscription
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_click(resp) ⇒ Object
13
14
15
16
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 13
def self.create_click(resp)
return resp if resp.nil?
Click.new(resp['enabled'])
end
|
.create_google_analytics(resp) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 23
def self.create_google_analytics(resp)
return resp if resp.nil?
GoogleAnalytics.new(
resp['enabled'], resp['utm_source'], resp['utm_medium'],
resp['utm_term'], resp['utm_content'], resp['utm_campaign']
)
end
|
.create_open(resp) ⇒ Object
33
34
35
36
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 33
def self.create_open(resp)
return resp if resp.nil?
Open.new(resp['enabled'])
end
|
.create_subscription(resp) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 42
def self.create_subscription(resp)
return resp if resp.nil?
Subscription.new(
resp['enabled'], resp['landing'], resp['url'], resp['replace'],
resp['html_content'], resp['plain_content']
)
end
|
.url(name = nil) ⇒ Object
50
51
52
53
54
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 50
def self.url(name = nil)
url = "#{BASE_URL}/tracking_settings"
url = "#{url}/#{name}" unless name.nil?
url
end
|
Instance Method Details
#get_settings_click(&block) ⇒ Object
#get_settings_google_analytics(&block) ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 75
def get_settings_google_analytics(&block)
endpoint = Settings::Tracking.url(:google_analytics)
resp = get(@auth, endpoint, &block)
finish(resp, @raw_resp) do |r|
Settings::Tracking.create_google_analytics(r)
end
end
|
#get_settings_open(&block) ⇒ Object
#get_settings_subscription(&block) ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 101
def get_settings_subscription(&block)
endpoint = Settings::Tracking.url(:subscription)
resp = get(@auth, endpoint, &block)
finish(resp, @raw_resp) do |r|
Settings::Tracking.create_subscription(r)
end
end
|
#get_tracking_settings(limit: nil, offset: nil, &block) ⇒ Object
56
57
58
59
60
61
62
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 56
def get_tracking_settings(limit: nil, offset: nil, &block)
params = {}
params[:limit] = limit unless limit.nil?
params[:offset] = offset unless offset.nil?
resp = get(@auth, Settings::Tracking.url, params, &block)
finish(resp, @raw_resp) { |r| Settings.create_results(r) }
end
|
#patch_settings_click(params:, &block) ⇒ Object
69
70
71
72
73
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 69
def patch_settings_click(params:, &block)
endpoint = Settings::Tracking.url(:click)
resp = patch(@auth, endpoint, params.to_h, &block)
finish(resp, @raw_resp) { |r| Settings::Tracking.create_click(r) }
end
|
#patch_settings_google_analytics(params:, &block) ⇒ Object
83
84
85
86
87
88
89
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 83
def patch_settings_google_analytics(params:, &block)
endpoint = Settings::Tracking.url(:google_analytics)
resp = patch(@auth, endpoint, params.to_h, &block)
finish(resp, @raw_resp) do |r|
Settings::Tracking.create_google_analytics(r)
end
end
|
#patch_settings_open(params:, &block) ⇒ Object
96
97
98
99
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 96
def patch_settings_open(params:, &block)
resp = patch(@auth, Settings::Tracking.url(:open), params.to_h, &block)
finish(resp, @raw_resp) { |r| Settings::Tracking.create_open(r) }
end
|
#patch_settings_subscription(params:, &block) ⇒ Object
109
110
111
112
113
114
115
|
# File 'lib/sendgrid4r/rest/settings/tracking.rb', line 109
def patch_settings_subscription(params:, &block)
endpoint = Settings::Tracking.url(:subscription)
resp = patch(@auth, endpoint, params.to_h, &block)
finish(resp, @raw_resp) do |r|
Settings::Tracking.create_subscription(r)
end
end
|