Module: Box
- Extended by:
- Memoist
- Defined in:
- lib/box.rb,
lib/box/file.rb,
lib/box/item.rb,
lib/box/client.rb,
lib/box/folder.rb,
lib/box/session.rb,
lib/box/version.rb,
lib/box/exceptions.rb,
lib/box/authorization.rb
Defined Under Namespace
Classes: ArgumentError, Authorization, BoxError, Client, File, Folder, Item, MalformedAuthHeaders, NameConflict, ResourceNotFound, Session
Constant Summary collapse
- API_URL =
'https://api.box.com'- UPLOAD_URL =
'https://upload.box.com/api/2.0'- ISO_8601_TEST =
Regexp.new(/^[0-9]{4}-[0-9]{2}-[0-9]{2}T/)
- VERSION =
"0.0.13"
Class Method Summary collapse
- .client(config = {}) ⇒ Object
-
.create_session(config = {}) ⇒ Object
memoize :client.
- .log(message) ⇒ Object
Class Method Details
.client(config = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/box.rb', line 20 def client(config = {}) # Accounts for both string and Symbol keyed hashes. # This is basically stringify_keys, just less efficient config = Hashie::Mash.new(config) # You can either pass in the config, or set it from the environment variables config = { access_token: config['access_token'] || ENV['BOX_ACCESS_TOKEN'], refresh_token: config['refresh_token'] || ENV['BOX_REFRESH_TOKEN'], client_id: config['client_id'] || ENV['BOX_CLIENT_ID'], client_secret: config['client_secret'] || ENV['BOX_CLIENT_SECRET'], username: config['username'] || ENV['BOX_USERNAME'], password: config['password'] || ENV['BOX_PASSWORD'] } # Box::Authorization.authorize client_id, client_secret session = create_session(config) Box::Client.new(session) end |
.create_session(config = {}) ⇒ Object
memoize :client
40 41 42 |
# File 'lib/box.rb', line 40 def create_session(config = {}) Box::Session.new config end |
.log(message) ⇒ Object
44 45 46 |
# File 'lib/box.rb', line 44 def log() puts "[Box.com] #{}".colorize(:color => :magenta, :background => :black) end |