Class: EmailDirect::Publication

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

Overview

Represents a publication and associated functionality

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(publication_id) ⇒ Publication

Returns a new instance of Publication.



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

def initialize(publication_id)
  @publication_id = publication_id
end

Instance Attribute Details

#publication_idObject (readonly)

Returns the value of attribute publication_id.



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

def publication_id
  @publication_id
end

Class Method Details

.all(options = {}) ⇒ Object



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

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

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



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

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

Instance Method Details

#add_emails(email_addresses) ⇒ Object



52
53
54
55
56
# File 'lib/emaildirect/publication.rb', line 52

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

#deleteObject



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

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

#detailsObject



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

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

#members(options = {}) ⇒ Object



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

def members(options = {})
  response = get 'Members', :query => options
  Hashie::Mash.new(response)
end

#remove_emails(email_addresses) ⇒ Object



58
59
60
61
62
# File 'lib/emaildirect/publication.rb', line 58

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

#removes(options = {}) ⇒ Object



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

def removes(options = {})
  response = get 'Removes', :query => options
  Hashie::Mash.new(response)
end

#update(name, options) ⇒ Object



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

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