Class: ContextIO::AccountCollection
- Inherits:
-
Object
- Object
- ContextIO::AccountCollection
- Includes:
- ContextIO::API::ResourceCollection
- Defined in:
- lib/contextio/account_collection.rb
Overview
Represents a collection of email accounts for your Context.IO account. You can use this to add a new one to your account, iterate over them, or fetch a specific one.
You can also limit which accounts belongin the collection using the where
method. Valid keys are: email, status, status_ok, limit and offset. See
the Context.IO documentation for
more explanation of what each key means.
Instance Attribute Summary
Attributes included from ContextIO::API::ResourceCollection
#resource_url, #where_constraints
Instance Method Summary collapse
-
#create(options = {}) ⇒ Account
Creates a new email account for your Context.IO account.
Methods included from ContextIO::API::ResourceCollection
#[], #each, #empty?, #size, #where
Instance Method Details
#create(options = {}) ⇒ Account
Creates a new email account for your Context.IO account.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/contextio/account_collection.rb', line 38 def create(={}) email = .delete(:email) || .delete('email') || where_constraints[:email] || where_constraints['email'] if email.nil? raise ArgumentError, "You must provide an email for new Accounts." end result_hash = api.request( :post, resource_url, .merge(email: email) ) result_hash.delete('success') resource_class.new(api, result_hash) end |