sharefile_connect 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2854e6d977b443111a4302d4e140767adcc31f51
4
- data.tar.gz: 46f1156230026391f189c1f354e7189134f9f751
3
+ metadata.gz: 3c8c189c1d7ea9716956665ff4d7fd8e20540873
4
+ data.tar.gz: 2d89993887add8a3c7ebc873bd683f99aed831e1
5
5
  SHA512:
6
- metadata.gz: ce70f2a748da3d6b402409201fb1259e04a3d2d59f2bc9fbb4738b873df625471a8cae9b3d3229496f983818684b022eca1b55dca94567ac8e0d4251851251e6
7
- data.tar.gz: fec1c11dac80359826044705b07c8469df1ea233c6d7435ee211f6d9b2798eed94656ac31390f053eabe283ebcb980ad95ab746bab14f37c932d08c21c82df7d
6
+ metadata.gz: 09a97f3a62411a4e5f0a8d66869f5c63f854219a8765484fd64f977ba04d13a201a37cca56d39f413491aaca8fa201e04f282d0ecffba520031955188a3da870
7
+ data.tar.gz: d51bf175514dbaf13498e6b1fdcd566f08410ddf4dbdfd7d5c0fcd9ae230864154ffb93083304091ce4efb72632090c3d8510317ba0d84784976a2d4291d4fb3
@@ -1,7 +1,6 @@
1
- require 'dotenv'
2
- Dotenv.load
1
+ # require 'dotenv'
2
+ # Dotenv.load
3
3
  require 'httparty'
4
- require 'oauth2'
5
4
  require 'net/https'
6
5
  require 'uri'
7
6
 
@@ -10,6 +9,5 @@ Dir[File.dirname(__FILE__) + '/sharefile_connect/*.rb'].each do |file|
10
9
  end
11
10
 
12
11
  module SharefileConnect
13
- BASE_URI = "https://#{ENV['API_ENDPOINT_DOMAIN']}.sf-api.com/sf/v3"
14
12
  end
15
13
 
@@ -0,0 +1,8 @@
1
+ module SharefileConnect
2
+ class Config
3
+ attr_accessor :sharefile_key, :sharefile_secret, :sharefile_user, :sharefile_user_pass, :domain
4
+ def initialize(sharefile_key, sharefile_secret, sharefile_user, sharefile_user_pass, domain)
5
+ @sharefile_key, @sharefile_secret, @sharefile_user, @sharefile_user_pass, @domain = sharefile_key, sharefile_secret, sharefile_user, sharefile_user_pass, domain
6
+ end
7
+ end
8
+ end
@@ -1,16 +1,17 @@
1
1
  module SharefileConnect
2
2
  class Connection
3
- attr_reader :token
3
+ attr_reader :token, :config
4
4
  include HTTParty
5
5
  # base_uri "https://#{ENV['API_ENDPOINT_DOMAIN']}.sf-api.com"
6
6
 
7
- def initialize
7
+ def initialize(config)
8
+ @config = config # || SharefileConnect::Config.new(ENV['SHAREFILE_KEY'], ENV['SHAREFILE_SECRET'], ENV['SHAREFILE_USER_NAME'], ENV['SHAREFILE_USER_PASS'], ENV['API_ENDPOINT_DOMAIN'])
8
9
  response = HTTParty.post(authentication_uri, authentication_content)
9
10
  @token = JSON.parse response.body
10
11
  end
11
12
 
12
13
  def hostname
13
- "#{ENV['API_ENDPOINT_DOMAIN']}.sf-api.com"
14
+ "#{config.domain}.sf-api.com"
14
15
  end
15
16
 
16
17
  def authentication_uri
@@ -22,10 +23,10 @@ module SharefileConnect
22
23
  {
23
24
  :body => {
24
25
  "grant_type" => "password",
25
- "client_id" => ENV['SHAREFILE_KEY'],
26
- "client_secret" => ENV['SHAREFILE_SECRET'],
27
- "username" => ENV['SHAREFILE_USER_NAME'],
28
- "password" => ENV['SHAREFILE_USER_PASS']
26
+ "client_id" => config.sharefile_key,
27
+ "client_secret" => config.sharefile_secret,
28
+ "username" => config.sharefile_user,
29
+ "password" => config.sharefile_user_pass
29
30
  },
30
31
  :headers => {
31
32
  "Content-Type" => "application/x-www-form-urlencoded"
@@ -1,7 +1,13 @@
1
1
  module SharefileConnect
2
2
  class Data
3
+ attr_accessor :config
3
4
  include HTTParty
4
5
 
6
+
7
+ def initialize(config = nil)
8
+ @config = config || SharefileConnect::Config.new(ENV['SHAREFILE_KEY'], ENV['SHAREFILE_SECRET'], ENV['SHAREFILE_USER_NAME'], ENV['SHAREFILE_USER_PASS'], ENV['API_ENDPOINT_DOMAIN'])
9
+ end
10
+
5
11
  def root(id = nil)
6
12
  parse_get("/Items(#{id || 'allshared'})?$expand=Children&$select=Id,Name,Children/Id,Children/Name").body
7
13
  end
@@ -95,11 +101,11 @@ module SharefileConnect
95
101
 
96
102
 
97
103
  def connection
98
- @connection ||= SharefileConnect::Connection.new.token
104
+ @connection ||= SharefileConnect::Connection.new(config).token
99
105
  end
100
106
 
101
107
  def full path
102
- "#{BASE_URI}#{path}"
108
+ "https://#{config.domain}.sf-api.com/sf/v3#{path}"
103
109
  end
104
110
 
105
111
  def parse_get(path)
@@ -114,6 +120,5 @@ module SharefileConnect
114
120
  return { "Authorization" => "Bearer #{connection['access_token']}" }
115
121
  end
116
122
 
117
-
118
123
  end
119
124
  end
@@ -1,3 +1,3 @@
1
1
  module SharefileConnect
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sharefile_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - tubedude
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -104,6 +104,7 @@ files:
104
104
  - bin/console
105
105
  - bin/setup
106
106
  - lib/sharefile_connect.rb
107
+ - lib/sharefile_connect/config.rb
107
108
  - lib/sharefile_connect/connection.rb
108
109
  - lib/sharefile_connect/data.rb
109
110
  - lib/sharefile_connect/version.rb