boxview 0.0.0 → 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/boxview.rb +24 -25
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81a660b74514e60ec9eff1fc4e58b6ac6c23b936
4
- data.tar.gz: e2beed09a1be58f1a1a17ca74e33a8a71f20e12c
3
+ metadata.gz: f7f96d70192aec96b8ab00dcea53d124c9de52d0
4
+ data.tar.gz: d91ec71c482cb609dcd22829be15ff874069547f
5
5
  SHA512:
6
- metadata.gz: 3681dc79314c057ae7bb1f319d70e435d820767d17c78e997b5f219f933160fb9a95c5f16ed2d93dcc5b5b6007885da9fbbb717563fa4dadf8b32bf3e3bd1b36
7
- data.tar.gz: bd93e74c8421631c9791743456925e635c080375162e5b0121e8b38a052f47fc7ef525ae47165e85b24c3b3be7aa030bbd2d4fb833ff3fe1e832b7280fa67412
6
+ metadata.gz: a39b7dc435469f08101f3dd16d7caac1ace439db00776e5d2c3718aeff2aadcb89fa5afd98421539e3692815c37044ee7a6b303b4a2c5b613c55f34fbb2d5149
7
+ data.tar.gz: 09dd6ef7d06308243ff440d60b31ffc9eadb347820c5f8e8182943de0038cc7cb5e349ea24cc488f4b7b4c3611a0c1e26107becde3a2358801bdb860873f7c8f
data/lib/boxview.rb CHANGED
@@ -1,36 +1,35 @@
1
1
  require 'faraday_middleware'
2
2
 
3
- module Box
4
- module View
5
- def self.init token
6
- @@api_token = token
7
- end
3
+ module BoxView
4
+ def self.init token
5
+ @@api_token = token
6
+ end
8
7
 
9
- def self.api_url
10
- "https://view-api.box.com/1"
11
- end
8
+ def self.api_url
9
+ "https://view-api.box.com/1"
10
+ end
12
11
 
13
- def self.conn
14
- Faraday.new(:url => self.api_url) do |conn|
15
- conn.basic_auth @@api_id, @@api_secret
16
- conn.request :url_encoded # convert request params as "www-form-urlencoded"
17
- conn.response :mashify
18
- conn.response :json, :content_type => /\bjson$/
19
- conn.adapter Faraday.default_adapter
20
- end
12
+ def self.connection
13
+ connection = Faraday.new(:url => BoxView.api_url) do |conn|
14
+ #conn.request :url_encoded # convert request params as "www-form-urlencoded"
15
+ conn.response :mashify
16
+ conn.response :json, :content_type => /\bjson$/
17
+ conn.adapter Faraday.default_adapter
21
18
  end
19
+ connection.headers['Authorization'] = "Token #{@@api_token}"
20
+ connection.headers['Content-Type'] = 'application/json'
21
+ return connection
22
+ end
22
23
 
23
- module Documents
24
+ module Documents
25
+ @@endpoint = "documents"
24
26
 
25
- def create url
26
- Box::View.connection.post do |req|
27
- req.url 'documents'
28
- req.headers['Content-Type'] = 'application/json'
29
- req.headers['Authorization'] = "Token #{Box::View.token}"
30
- req.body = '{"url": "' + url + '"}'
31
- end
27
+ def self.create url
28
+ BoxView.connection.post do |request|
29
+ request.url @@endpoint
30
+ request.body = '{"url": "' + url + '"}'
32
31
  end
33
-
34
32
  end
33
+
35
34
  end
36
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrus Karbassiyoon