Class: EmailDirect::List

Inherits:
Object
  • Object
show all
Defined in:
lib/emaildirect/list.rb

Overview

Represents a list and associated functionality

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list_id) ⇒ List

Returns a new instance of List.



22
23
24
# File 'lib/emaildirect/list.rb', line 22

def initialize(list_id)
  @list_id = list_id
end

Instance Attribute Details

#list_idObject (readonly)

Returns the value of attribute list_id.



20
21
22
# File 'lib/emaildirect/list.rb', line 20

def list_id
  @list_id
end

Class Method Details

.all(options = {}) ⇒ Object



8
9
10
11
# File 'lib/emaildirect/list.rb', line 8

def all(options = {})
  response = EmailDirect.get '/Lists', :query => options
  Hashie::Mash.new(response)
end

.create(name, options = {}) ⇒ Object



13
14
15
16
17
# File 'lib/emaildirect/list.rb', line 13

def create(name, options = {})
  options.merge! :Name => name
  response = EmailDirect.post '/Lists', :body => options.to_json
  Hashie::Mash.new(response)
end

Instance Method Details

#add_emails(email_addresses) ⇒ Object



47
48
49
50
51
# File 'lib/emaildirect/list.rb', line 47

def add_emails(email_addresses)
  options = { :EmailAddresses => Array(email_addresses) }
  response = post 'AddEmails', :body => options.to_json
  Hashie::Mash.new(response)
end

#deleteObject



42
43
44
45
# File 'lib/emaildirect/list.rb', line 42

def delete
  response = EmailDirect.delete uri_for, {}
  Hashie::Mash.new(response)
end

#detailsObject



26
27
28
29
# File 'lib/emaildirect/list.rb', line 26

def details
  response = get
  Hashie::Mash.new(response)
end

#membersObject



31
32
33
34
# File 'lib/emaildirect/list.rb', line 31

def members
  response = get 'Members'
  Hashie::Mash.new(response)
end

#remove_emails(email_addresses) ⇒ Object



53
54
55
56
57
# File 'lib/emaildirect/list.rb', line 53

def remove_emails(email_addresses)
  options = { :EmailAddresses => Array(email_addresses) }
  response = post 'RemoveEmails', :body => options.to_json
  Hashie::Mash.new(response)
end

#update(name, options) ⇒ Object



36
37
38
39
40
# File 'lib/emaildirect/list.rb', line 36

def update(name, options)
  options.merge! :Name => name
  response = EmailDirect.put uri_for, :body => options.to_json
  Hashie::Mash.new(response)
end