forked from sendgrid/sendgrid-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tracking_settings.rb
39 lines (32 loc) · 935 Bytes
/
tracking_settings.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require 'json'
module SendGrid
class TrackingSettings
attr_writer :click_tracking, :open_tracking, :subscription_tracking, :ganalytics
def initialize
@click_tracking = nil
@open_tracking = nil
@subscription_tracking = nil
@ganalytics = nil
end
def click_tracking
@click_tracking.nil? ? nil : @click_tracking.to_json
end
def open_tracking
@open_tracking.nil? ? nil : @open_tracking.to_json
end
def subscription_tracking
@subscription_tracking.nil? ? nil : @subscription_tracking.to_json
end
def ganalytics
@ganalytics.nil? ? nil : @ganalytics.to_json
end
def to_json(*)
{
'click_tracking' => click_tracking,
'open_tracking' => open_tracking,
'subscription_tracking' => subscription_tracking,
'ganalytics' => ganalytics
}.delete_if { |_, value| value.to_s.strip == '' }
end
end
end