Sha256: 2d70dff75338e05b4bc67d5b91ad6e6319b4c711b7b1cff2e8e301e12f11cee0
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
require 'oauth2' require 'cortex/connection' require 'cortex/request' require 'cortex/resource' require 'cortex/posts' require 'cortex/users' require 'cortex/webpages' require 'cortex/result' module Cortex class Client attr_reader :posts, :users, :webpages attr_accessor :access_token, :base_url, :auth_method @key = '' @secret = '' @scopes = '' include Cortex::Connection include Cortex::Request def initialize(hasharg) @base_url = hasharg[:base_url] || 'http://cortex.dev/api/v1' if hasharg.has_key? :access_token @access_token = hasharg[:access_token] else @key = hasharg[:key] @secret = hasharg[:secret] @scopes ||= hasharg[:scopes] @access_token = get_cc_token end @posts = Cortex::Posts.new(self) @users = Cortex::Users.new(self) @webpages = Cortex::Webpages.new(self) end def get_cc_token begin client = OAuth2::Client.new(@key, @secret, site: @base_url) client.client_credentials.get_token({scope: @scopes}) rescue Faraday::ConnectionFailed raise Cortex::Exceptions::ConnectionFailed.new(base_url: @base_url) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cortex-client-0.10.3 | lib/cortex/client.rb |
cortex-client-0.10.2 | lib/cortex/client.rb |
cortex-client-0.10.1 | lib/cortex/client.rb |