Class: Gandi::Domain::Mailbox
- Inherits:
-
Object
- Object
- Gandi::Domain::Mailbox
- Includes:
- GandiObjectMethods
- Defined in:
- lib/gandi/domain/mailbox.rb
Instance Attribute Summary collapse
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#login ⇒ Object
readonly
Returns the value of attribute login.
Class Method Summary collapse
-
.count(domain, opts = {}) ⇒ Object
Count mailboxes for a given domain.
-
.create(domain, login, params) ⇒ Object
Create a mailbox.
-
.list(domain, opts = {}, map_mailboxes = true) ⇒ Object
List mailboxes for a given domain.
Instance Method Summary collapse
-
#delete ⇒ Object
Delete a mailbox.
-
#info ⇒ Object
Get mailbox information for a given login created for a given domain.
-
#initialize(domain, login, attributes = nil) ⇒ Mailbox
constructor
A new instance of Mailbox.
-
#purge ⇒ Object
Purge a mailbox.
-
#update(params) ⇒ Object
Update a mailbox.
Methods included from GandiObjectMethods
#[], included, #inspect, #to_hash
Constructor Details
#initialize(domain, login, attributes = nil) ⇒ Mailbox
Returns a new instance of Mailbox.
8 9 10 11 12 |
# File 'lib/gandi/domain/mailbox.rb', line 8 def initialize(domain, login, attributes = nil) @domain = domain @login = login @attributes = attributes || info end |
Instance Attribute Details
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
6 7 8 |
# File 'lib/gandi/domain/mailbox.rb', line 6 def domain @domain end |
#login ⇒ Object (readonly)
Returns the value of attribute login.
6 7 8 |
# File 'lib/gandi/domain/mailbox.rb', line 6 def login @login end |
Class Method Details
.count(domain, opts = {}) ⇒ Object
Count mailboxes for a given domain. TODO: accept a fqdn string.
50 51 52 |
# File 'lib/gandi/domain/mailbox.rb', line 50 def count(domain, opts = {}) call('domain.mailbox.count', domain.fqdn, opts) end |
.create(domain, login, params) ⇒ Object
Create a mailbox. Return a Mailbox object.
43 44 45 46 |
# File 'lib/gandi/domain/mailbox.rb', line 43 def create(domain, login, params) mailbox = call('domain.mailbox.create', domain.fqdn, login, params) self.new(domain, login, mailbox) end |
.list(domain, opts = {}, map_mailboxes = true) ⇒ Object
List mailboxes for a given domain. Return an array of Mailbox objects or an array of hashes. Note that domain.mailbox.info will be called for each mailbox unless map_mailboxes is set to false (as the info hash returned by domain.mailbox.list does not contain the mailboxes attributes). This may result in a lot of API calls if you have many registered mailboxes for your domain, so using opts to restrict results is advised (or use a raw API call). TODO: accept a fqdn string.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gandi/domain/mailbox.rb', line 59 def list(domain, opts = {}, map_mailboxes = true) mailboxes = call('domain.mailbox.list', domain.fqdn, opts) if map_mailboxes mailboxes.map! do |mailbox| self.new(domain, mailbox['login']) end end return mailboxes end |
Instance Method Details
#delete ⇒ Object
Delete a mailbox. Note: the mailbox is deleted instantly.
16 17 18 |
# File 'lib/gandi/domain/mailbox.rb', line 16 def delete self.class.call('domain.mailbox.delete', @domain.fqdn, @login) end |
#info ⇒ Object
Get mailbox information for a given login created for a given domain.
21 22 23 |
# File 'lib/gandi/domain/mailbox.rb', line 21 def info self.class.call('domain.mailbox.info', @domain.fqdn, @login) end |
#purge ⇒ Object
Purge a mailbox. Create an operation that will delete this mailbox contents. Return a Gandi::Operation object.
28 29 30 31 |
# File 'lib/gandi/domain/mailbox.rb', line 28 def purge operation_hash = self.class.call('domain.mailbox.purge', @domain.fqdn, @login) Gandi::Operation.new(operation_hash['id'], operation_hash) end |
#update(params) ⇒ Object
Update a mailbox. Returns a Gandi::Operation object.
35 36 37 38 |
# File 'lib/gandi/domain/mailbox.rb', line 35 def update(params) operation_hash = self.class.call('domain.mailbox.update', @domain.fqdn, @login, params) Gandi::Operation.new(operation_hash['id'], operation_hash) end |