Class: ContextIO::ConnectTokenCollection

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

Overview

Represents a collection of connect tokens for your account. You can use this to create a new token, fetch a specific one or iterate over them.

Examples:

You can iterate over them with each:

contextio.connect_tokens.each do |connect_token|
  puts connect_token.email
end

You can lazily access a specific one with square brackets:

connect_token = contextio.connect_tokens['some_token']

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(callback_url, options = {}) ⇒ ConnectToken

Creates a new connect token for your account.

Parameters:

  • callback_url (String)

    The url that the user will be redirected to after OAuthing their account with Context.IO.

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

    Optional information you can provide at creation: email, service level, first_name and/or last_name.

Returns:

  • (ConnectToken)

    A new token instance based on the data you input.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/contextio/connect_token_collection.rb', line 32

def create(callback_url, options={})
  result_hash = api.request(
    :post,
    resource_url,
    options.merge(callback_url: callback_url)
  )

  result_hash.delete('success')

  resource_class.new(api, result_hash)
end