Class: EmailDirect::Source

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

Overview

Represents a source and associated functionality

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_id) ⇒ Source

Returns a new instance of Source.



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

def initialize(source_id)
  @source_id = source_id
end

Instance Attribute Details

#source_idObject (readonly)

Returns the value of attribute source_id.



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

def source_id
  @source_id
end

Class Method Details

.allObject



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

def all
  response = EmailDirect.get '/Sources'
  Hashie::Mash.new(response)
end

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



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

def create(name, options = {})
  options.merge! :Name => name
  response = EmailDirect.post '/Sources', :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/source.rb', line 47

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

#deleteObject



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

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

#detailsObject



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

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

#members(options = {}) ⇒ Object



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

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

#update(name, options) ⇒ Object



36
37
38
39
40
# File 'lib/emaildirect/source.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