Class: ContextIO::Lite::UserCollection

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

Instance Attribute Summary

Attributes included from API::ResourceCollection

#api, #resource_url, #where_constraints

Instance Method Summary collapse

Methods included from API::ResourceCollection

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

Instance Method Details

#create(options = {}) ⇒ Account

Creates a new email account for your Context.IO account.

Parameters:

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

    Information you can provide at creation: email, first_name and/or last_name. If the collection isn’t already limited by email, then you must provide it.

Returns:

  • (Account)

    A new email account instance based on the data you input.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/contextio/lite/user_collection.rb', line 20

def create(options={})
  email = options.delete(:email) || options.delete('email') ||
    where_constraints[:email] || where_constraints['email']

  if email.nil?
    raise ArgumentError, 'You must provide an email for new Users.'
  end

  result_hash = api.request(
    :post,
    resource_url,
    options.merge(email: email)
  )

  result_hash.delete('success')

  resource_class.new(api, result_hash)
end