Class: SendGrid4r::CLI::Settings::Tracking

Inherits:
SendGrid4r::CLI::SgThor show all
Defined in:
lib/sendgrid4r/cli/settings/tracking.rb

Overview

SendGrid Web API v3 Settings Tracking

Instance Method Summary collapse

Methods inherited from SendGrid4r::CLI::SgThor

#initialize

Constructor Details

This class inherits a constructor from SendGrid4r::CLI::SgThor

Instance Method Details

#click(action) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sendgrid4r/cli/settings/tracking.rb', line 17

def click(action)
  case action
  when 'get'
    puts @client.get_settings_click
  when 'enable', 'disable'
    params = { enabled: action == 'enable' }
    puts @client.patch_settings_click(params: params)
  else
    puts "error: #{action} is not supported in action parameter"
  end
rescue RestClient::ExceptionWithResponse => e
  puts e.inspect
end

#ganalytics(action) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/sendgrid4r/cli/settings/tracking.rb', line 37

def ganalytics(action)
  case action
  when 'get'
    puts @client.get_settings_google_analytics
  when 'enable', 'disable'
    params = parameterise(options)
    params[:enabled] = action == 'enable'
    puts @client.patch_settings_google_analytics(params: params)
  else
    puts "error: #{action} is not supported in action parameter"
  end
rescue RestClient::ExceptionWithResponse => e
  puts e.inspect
end

#listObject



10
11
12
13
14
# File 'lib/sendgrid4r/cli/settings/tracking.rb', line 10

def list
  puts @client.get_tracking_settings(parameterise(options))
rescue RestClient::ExceptionWithResponse => e
  puts e.inspect
end

#open(action) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/sendgrid4r/cli/settings/tracking.rb', line 53

def open(action)
  case action
  when 'get'
    puts @client.get_settings_open
  when 'enable', 'disable'
    params = { enabled: action == 'enable' }
    puts @client.patch_settings_open(params: params)
  else
    puts "error: #{action} is not supported in action parameter"
  end
rescue RestClient::ExceptionWithResponse => e
  puts e.inspect
end

#subscription(action) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/sendgrid4r/cli/settings/tracking.rb', line 76

def subscription(action)
  case action
  when 'get'
    puts @client.get_settings_subscription
  when 'enable', 'disable'
    params = parameterise(options)
    params[:enabled] = action == 'enable'
    puts @client.patch_settings_subscription(params: params)
  else
    puts "error: #{action} is not supported in action parameter"
  end
rescue RestClient::ExceptionWithResponse => e
  puts e.inspect
end