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