Class: ContextIO::OAuthProviderCollection

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

Overview

Represents a collection of OAuth providers for an account. You can use this to create a proider, fetch a specific one or iterate over them.

Examples:

You can iterate over them with each:

contextio.oauth_providers.each do |oauth_provider|
  puts oauth_provider.type
end

You can lazily access a specific one with square brackets:

provider = contextio.oauth_providers['some_provider_consumer_key']

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(type, provider_consumer_key, provider_consumer_secret) ⇒ OAuthProvider

Creates a new OAuth provider for your account.

Parameters:

  • type (String)

    The type of provider. As of this writing, the API only accepts 'GMAIL' and 'GOOGLEAPPSMARKETPLACE'.

  • provider_consumer_key (String)

    The Provider Consumer Key you got when you OAuthed the user.

  • provider_consumer_secret (String)

    The Provider Consumer Secret you got when you OAuthed the user.

Returns:

  • (OAuthProvider)

    A new provider instance based on the data you input.



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

def create(type, provider_consumer_key, provider_consumer_secret)
  result_hash = api.request(
    :post,
    resource_url,
    type: type,
    provider_consumer_key: provider_consumer_key,
    provider_consumer_secret: provider_consumer_secret
  )

  result_hash.delete('success')

  resource_class.new(api, result_hash)
end