Class: SendGrid4r::CLI::Campaign::Contact::List

Inherits:
SgThor
  • Object
show all
Defined in:
lib/sendgrid4r/cli/campaign/contact/list.rb

Overview

SendGrid Web API v3 Marketing Campaigns - List

Instance Method Summary collapse

Methods inherited from SgThor

#initialize

Constructor Details

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

Instance Method Details

#createObject



10
11
12
13
14
# File 'lib/sendgrid4r/cli/campaign/contact/list.rb', line 10

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

#deleteObject



42
43
44
45
46
# File 'lib/sendgrid4r/cli/campaign/contact/list.rb', line 42

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

#getObject



25
26
27
28
29
# File 'lib/sendgrid4r/cli/campaign/contact/list.rb', line 25

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

#listObject



17
18
19
20
21
# File 'lib/sendgrid4r/cli/campaign/contact/list.rb', line 17

def list
  puts @client.get_lists
rescue RestClient::ExceptionWithResponse => e
  puts e.inspect
end

#recipient(action) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/sendgrid4r/cli/campaign/contact/list.rb', line 54

def recipient(action)
  case action
  when 'add'
    puts @client.post_recipients_to_list(parameterise(options))
  when 'remove'
    puts @client.delete_recipient_from_list(parameterise(options))
  when 'list'
    puts @client.get_recipients_from_list(parameterise(options))
  else
    puts "error: #{action} is not supported in action parameter"
  end
rescue RestClient::ExceptionWithResponse => e
  puts e.inspect
end

#renameObject



34
35
36
37
38
# File 'lib/sendgrid4r/cli/campaign/contact/list.rb', line 34

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