Class: ContextIO::OAuthProvider
- Defined in:
- lib/context-io/oauth_provider.rb
Instance Attribute Summary collapse
-
#consumer_key ⇒ String
readonly
The OAuth consumer key.
-
#consumer_secret ⇒ String
readonly
The OAuth consumer secret.
-
#type ⇒ String
readonly
The identification of the OAuth provider.
Class Method Summary collapse
-
.all ⇒ Array<ContextIO::OAuthProvider>
Get all OAuth providers configured.
-
.create(type, consumer_key, consumer_secret) ⇒ true, false
Create an OAuth provider.
-
.find(consumer_key) ⇒ ContextIO::OAuthProvider
Retrieve an OAuth provider.
-
.from_json(json) ⇒ ContextIO::OAuthProvider
private
Create an OAuth provider with the JSON data from Context.IO.
Instance Method Summary collapse
-
#destroy ⇒ true, false
Destroy the OAuth provider.
Methods included from Request
#delete, #get, #post, #put, #request
Instance Attribute Details
#consumer_key ⇒ String (readonly)
Returns The OAuth consumer key.
10 11 12 |
# File 'lib/context-io/oauth_provider.rb', line 10 def consumer_key @consumer_key end |
#consumer_secret ⇒ String (readonly)
Returns The OAuth consumer secret.
14 15 16 |
# File 'lib/context-io/oauth_provider.rb', line 14 def consumer_secret @consumer_secret end |
#type ⇒ String (readonly)
Returns The identification of the OAuth provider. This must be either “GMAIL” or “GOOGLEAPPSMARKETPLACE”.
6 7 8 |
# File 'lib/context-io/oauth_provider.rb', line 6 def type @type end |
Class Method Details
.all ⇒ Array<ContextIO::OAuthProvider>
Get all OAuth providers configured
21 22 23 |
# File 'lib/context-io/oauth_provider.rb', line 21 def self.all get('/2.0/oauth_providers').map { |provider| from_json(provider) } end |
.create(type, consumer_key, consumer_secret) ⇒ true, false
Create an OAuth provider
35 36 37 38 39 40 41 |
# File 'lib/context-io/oauth_provider.rb', line 35 def self.create(type, consumer_key, consumer_secret) post('/2.0/oauth_providers', { :type => type.to_s.upcase, :provider_consumer_key => consumer_key.to_s, :provider_consumer_secret => consumer_secret.to_s })['success'] end |
.find(consumer_key) ⇒ ContextIO::OAuthProvider
Retrieve an OAuth provider
50 51 52 |
# File 'lib/context-io/oauth_provider.rb', line 50 def self.find(consumer_key) from_json(get("/2.0/oauth_providers/#{consumer_key}")) end |
.from_json(json) ⇒ ContextIO::OAuthProvider
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create an OAuth provider with the JSON data from Context.IO.
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/context-io/oauth_provider.rb', line 72 def self.from_json(json) provider = new provider.instance_eval do @type = json['type'] @consumer_key = json['provider_consumer_key'] @consumer_secret = json['provider_consumer_secret'] end provider end |
Instance Method Details
#destroy ⇒ true, false
Destroy the OAuth provider
59 60 61 |
# File 'lib/context-io/oauth_provider.rb', line 59 def destroy delete("/2.0/oauth_providers/#@consumer_key")['success'] end |