Class: ContextIO::SourceCollection

Inherits:
Object
  • Object
show all
Includes:
API::ResourceCollection
Defined in:
lib/contextio/source_collection.rb

Instance Attribute Summary

Attributes included from API::ResourceCollection

#resource_url, #where_constraints

Instance Method Summary collapse

Methods included from API::ResourceCollection

#[], #each, #empty?, #size, #where

Instance Method Details

#create(email, server, username, use_ssl, port, type, options = {}) ⇒ Object

Creates a new source for an account.

Parameters:

  • email (String)

    The email address for the new source.

  • server (String)

    The address of the server for the source.

  • username (String)

    The name for logging into the server. Often the same as the email.

  • use_ssl (Boolean)

    Whether to use SSL for the new source.

  • port (Numeric, String)

    The port to connect on.

  • type (String)

    Currently, only 'IMAP' is supported.

  • options (Hash{String, Symbol => String}) (defaults to: {})

    Information you can provide at creation. Check out the Context.IO documentation for what's required and what's optional.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/contextio/source_collection.rb', line 25

def create(email, server, username, use_ssl, port, type, options={})
  api_args = options.merge(
    :email => email,
    :server => server,
    :username => username,
    :use_ssl => use_ssl ? '1' : '0',
    :port => port.to_s,
    :type => type
  )

  result_hash = api.request(:post, resource_url, api_args)

  result_hash.delete('success')

  resource_class.new(api, result_hash)
end