Class: Ari::Mailbox

Inherits:
Resource show all
Defined in:
lib/ari/resources/mailbox.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#add_listener, client, #client, #remove_all_listeners!, #remove_listener

Methods inherited from Model

#attributes=, #initialize

Constructor Details

This class inherits a constructor from Ari::Model

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/ari/resources/mailbox.rb', line 15

def name
  @name
end

#new_messagesObject (readonly)

Returns the value of attribute new_messages.



15
16
17
# File 'lib/ari/resources/mailbox.rb', line 15

def new_messages
  @new_messages
end

#old_messagesObject (readonly)

Returns the value of attribute old_messages.



15
16
17
# File 'lib/ari/resources/mailbox.rb', line 15

def old_messages
  @old_messages
end

Class Method Details

.delete(options = {}) ⇒ Object

DELETE /mailboxes/%mailboxName

Mailbox state

Parameters:

mailboxName (required) - Name of the mailbox



81
82
83
84
85
86
87
# File 'lib/ari/resources/mailbox.rb', line 81

def self.delete(options = {})
  raise ArgumentError.new("Parameter mailboxName must be passed in options hash.") unless options[:mailboxName]
  path = '/mailboxes/%{mailboxName}' % options
  response = client(options).delete(path, options)
rescue Ari::RequestError => e
  raise unless e.code == '404'
end

.get(options = {}) ⇒ Object

GET /mailboxes/%mailboxName

Mailbox state

Parameters:

mailboxName (required) - Name of the mailbox

Raises:

  • (ArgumentError)


38
39
40
41
42
43
# File 'lib/ari/resources/mailbox.rb', line 38

def self.get(options = {})
  raise ArgumentError.new("Parameter mailboxName must be passed in options hash.") unless options[:mailboxName]
  path = '/mailboxes/%{mailboxName}' % options
  response = client(options).get(path, options)
  Mailbox.new(response.merge(client: options[:client]))
end

.list(options = {}) ⇒ Object

GET /mailboxes

Mailboxes



23
24
25
26
27
# File 'lib/ari/resources/mailbox.rb', line 23

def self.list(options = {})
  path = '/mailboxes'
  response = client(options).get(path, options)
  response.map { |hash| Mailbox.new(hash.merge(client: options[:client])) }
end

.update(options = {}) ⇒ Object

PUT /mailboxes/%mailboxName

Mailbox state

Parameters:

mailboxName (required) - Name of the mailbox oldMessages (required) - Count of old messages in the mailbox newMessages (required) - Count of new messages in the mailbox

Raises:

  • (ArgumentError)


60
61
62
63
64
65
66
# File 'lib/ari/resources/mailbox.rb', line 60

def self.update(options = {})
  raise ArgumentError.new("Parameter mailboxName must be passed in options hash.") unless options[:mailboxName]
  raise ArgumentError.new("Parameter oldMessages must be passed in options hash.") unless options[:oldMessages]
  raise ArgumentError.new("Parameter newMessages must be passed in options hash.") unless options[:newMessages]
  path = '/mailboxes/%{mailboxName}' % options
  response = client(options).put(path, options)
end

Instance Method Details

#delete(options = {}) ⇒ Object



89
90
91
# File 'lib/ari/resources/mailbox.rb', line 89

def delete(options = {})
  self.class.delete(options.merge(mailboxId: self.id, client: @client))
end

#get(options = {}) ⇒ Object



45
46
47
# File 'lib/ari/resources/mailbox.rb', line 45

def get(options = {})
  self.class.get(options.merge(mailboxId: self.id, client: @client))
end

#update(options = {}) ⇒ Object



68
69
70
# File 'lib/ari/resources/mailbox.rb', line 68

def update(options = {})
  self.class.update(options.merge(mailboxId: self.id, client: @client))
end