Module: Boxr

Defined in:
lib/boxr.rb,
lib/boxr/auth.rb,
lib/boxr/files.rb,
lib/boxr/tasks.rb,
lib/boxr/users.rb,
lib/boxr/client.rb,
lib/boxr/events.rb,
lib/boxr/groups.rb,
lib/boxr/search.rb,
lib/boxr/folders.rb,
lib/boxr/version.rb,
lib/boxr/comments.rb,
lib/boxr/metadata.rb,
lib/boxr/exceptions.rb,
lib/boxr/shared_items.rb,
lib/boxr/collaborations.rb

Defined Under Namespace

Classes: BoxrException, Client

Constant Summary collapse

ROOT =

The root folder in Box is always identified by 0

0
VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.get_tokens(code, grant_type: "authorization_code", username: nil, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET']) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/boxr/auth.rb', line 10

def self.get_tokens(code, grant_type: "authorization_code", username: nil, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET'])
  uri = "https://api.box.com/oauth2/token"
  body = "code=#{code}&grant_type=#{grant_type}&client_id=#{box_client_id}&client_secret=#{box_client_secret}"
  body = body + "&username=#{username}" unless username.nil?

  auth_post(uri, body)
end

.oauth_url(state, response_type: "code", scope: nil, folder_id: nil, box_client_id: ENV['BOX_CLIENT_ID']) ⇒ Object



3
4
5
6
7
8
# File 'lib/boxr/auth.rb', line 3

def self.oauth_url(state, response_type: "code", scope: nil, folder_id: nil, box_client_id: ENV['BOX_CLIENT_ID'])
  uri = "https://app.box.com/api/oauth2/authorize?response_type=#{response_type}&state=#{state}&client_id=#{box_client_id}"
  uri = uri + "&scope=#{scope}" unless scope.nil?
  uri = uri + "&folder_id=#{folder_id}" unless folder_id.nil?
  uri
end

.refresh_tokens(refresh_token, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET']) ⇒ Object



18
19
20
21
22
23
# File 'lib/boxr/auth.rb', line 18

def self.refresh_tokens(refresh_token, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET'])
  uri = "https://api.box.com/oauth2/token"
  body = "grant_type=refresh_token&refresh_token=#{refresh_token}&client_id=#{box_client_id}&client_secret=#{box_client_secret}"

  auth_post(uri, body)
end

.revoke_tokens(token, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET']) ⇒ Object



25
26
27
28
29
30
# File 'lib/boxr/auth.rb', line 25

def self.revoke_tokens(token, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET'])
  uri = "https://api.box.com/oauth2/revoke"
  body = "client_id=#{box_client_id}&client_secret=#{box_client_secret}&token=#{token}"

  auth_post(uri, body)
end