Class: SharefileConnect::Connection
- Inherits:
-
Object
- Object
- SharefileConnect::Connection
- Includes:
- HTTParty
- Defined in:
- lib/sharefile_connect/connection.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #authentication_content ⇒ Object
- #authentication_uri ⇒ Object
- #hostname ⇒ Object
-
#initialize ⇒ Connection
constructor
base_uri “https://#'API_ENDPOINT_DOMAIN'.sf-api.com”.
Constructor Details
#initialize ⇒ Connection
base_uri “https://#'API_ENDPOINT_DOMAIN'.sf-api.com”
7 8 9 10 |
# File 'lib/sharefile_connect/connection.rb', line 7 def initialize response = HTTParty.post(authentication_uri, authentication_content) @token = JSON.parse response.body end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
3 4 5 |
# File 'lib/sharefile_connect/connection.rb', line 3 def token @token end |
Instance Method Details
#authentication_content ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sharefile_connect/connection.rb', line 21 def authentication_content { :body => { "grant_type" => "password", "client_id" => ENV['SHAREFILE_KEY'], "client_secret" => ENV['SHAREFILE_SECRET'], "username" => ENV['SHAREFILE_USER_NAME'], "password" => ENV['SHAREFILE_USER_PASS'] }, :headers => { "Content-Type" => "application/x-www-form-urlencoded" } } end |
#authentication_uri ⇒ Object
16 17 18 19 |
# File 'lib/sharefile_connect/connection.rb', line 16 def authentication_uri "https://#{hostname}/oauth/token" # "/oauth/token" end |
#hostname ⇒ Object
12 13 14 |
# File 'lib/sharefile_connect/connection.rb', line 12 def hostname "#{ENV['API_ENDPOINT_DOMAIN']}.sf-api.com" end |