Class: Cortex::Client
- Inherits:
-
Object
- Object
- Cortex::Client
- Includes:
- Connection, Request
- Defined in:
- lib/cortex/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#auth_method ⇒ Object
Returns the value of attribute auth_method.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#posts ⇒ Object
readonly
Returns the value of attribute posts.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #get_cc_token ⇒ Object
-
#initialize(hasharg) ⇒ Client
constructor
A new instance of Client.
Methods included from Request
#delete, #delete!, #get, #parse_response, #post, #put, #save
Methods included from Connection
Constructor Details
#initialize(hasharg) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cortex/client.rb', line 18 def initialize(hasharg) @base_url = hasharg[:base_url] || 'https://cbcortex.com/api/v1/' if hasharg.has_key? :access_token @access_token = hasharg[:access_token] else @key = hasharg[:key] @secret = hasharg[:secret] @access_token = get_cc_token end @posts = Cortex::Posts.new(self) @users = Cortex::Users.new(self) end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
11 12 13 |
# File 'lib/cortex/client.rb', line 11 def access_token @access_token end |
#auth_method ⇒ Object
Returns the value of attribute auth_method.
11 12 13 |
# File 'lib/cortex/client.rb', line 11 def auth_method @auth_method end |
#base_url ⇒ Object
Returns the value of attribute base_url.
11 12 13 |
# File 'lib/cortex/client.rb', line 11 def base_url @base_url end |
#posts ⇒ Object (readonly)
Returns the value of attribute posts.
10 11 12 |
# File 'lib/cortex/client.rb', line 10 def posts @posts end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
10 11 12 |
# File 'lib/cortex/client.rb', line 10 def users @users end |
Instance Method Details
#get_cc_token ⇒ Object
31 32 33 34 |
# File 'lib/cortex/client.rb', line 31 def get_cc_token client = OAuth2::Client.new(@key, @secret, site: @base_url) client.client_credentials.get_token end |