Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ruby-box

Build Status: [![Build Status](https://travis-ci.org/attachmentsme/ruby-box.png)](https://travis-ci.org/attachmentsme/ruby-box)

Mainted by: [Attachments.me](http://attachments.me)
Maintained by: [Adrien Giboire](http://adriengiboire.com)

RubyBox provides a simple, chainable, feature-rich client for [Box's 2.0 API](http://developers.box.com/docs/).

Expand All @@ -15,7 +15,7 @@ RubyBox uses Box's OAuth2 Implementaton, Here are the steps involved in authoriz
__1)__ Get the authorization url.

```ruby
require 'ruby-box'
require 'ruby-box-updated'

session = RubyBox::Session.new({
client_id: 'your-client-id',
Expand Down Expand Up @@ -48,7 +48,7 @@ save_me_somehow(@token.refresh_token)
__3)__ Create a client using a session initialized with the _access\_token_.

```ruby
require 'ruby-box'
require 'ruby-box-updated'

session = RubyBox::Session.new({
client_id: 'your-client-id',
Expand Down Expand Up @@ -153,7 +153,14 @@ discussion.comments.each {|comment| p comment.message}

```ruby
folder = client.folder('image_folder').create_shared_link # lookups by id are more efficient
p folder.shared_link['url'] # https://www.box.com/s/d6de3224958c1755412
p folder.shared_link.url # https://www.box.com/s/d6de3224958c1755412
```

* Creating an email to upload files in a folder.

```ruby
folder = client.folder('documents_folder').create_folder_upload_email # lookups by id are more efficient
p folder.folder_upload_email.email # upload.adrien_.8kge3wck1h@u.box.com
```

Files
Expand Down Expand Up @@ -319,7 +326,7 @@ An array of Ruby:Box users in an enterprise (Supports Filtering, Limit and Offse
users = client.users
```

* Remeber the API filters "name" and "login" by the start of the string. ie: to get "sean+awesome@gmail.com" an approriate filter term would be "sean"
* Remember the API filters "name" and "login" by the start of the string. ie: to get "sean+awesome@gmail.com" an approriate filter term would be "sean"

```ruby
users = client.users("sean" , 10 , 1)
Expand All @@ -334,7 +341,7 @@ Contributing to ruby-box
========================

RubyBox does not yet support all of Box's API Version 2.0 functionality, be liberal with your contributions.

* Rename account.example to account.yml and fill in your Box credentials
* Type bundle install
* Type rake.. tests should pass
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby-box/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def create_folder(path)
folder = root_folder
folder_names = split_path(path)
folder_names.each do |folder_name|
new_folder = folder.folders(folder_name).first
new_folder = folder.folders(folder_name).first
if !new_folder
begin
new_folder = folder.create_subfolder(folder_name)
Expand Down Expand Up @@ -158,6 +158,6 @@ def fmt_events_args(stream_position, stream_type, limit)
limit = limit.kind_of?(Fixnum) ? limit : 100
"stream_position=#{stream_position}&stream_type=#{stream_type}&limit=#{limit}"
end

end
end
22 changes: 21 additions & 1 deletion lib/ruby-box/folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def upload_file(filename, data, overwrite=true)
begin
resp = file.upload_content(data) #write a new file. If there is a conflict, update the conflicted file.
rescue RubyBox::ItemNameInUse => e

# if overwrite flag is false, simply raise exception.
raise e unless overwrite

Expand Down Expand Up @@ -76,6 +76,26 @@ def copy_to(destination, name=nil)
RubyBox::Folder.new(@session, post(folder_method(:copy), parent))
end

def create_folder_upload_email(opts = {})
opts = {
access: 'open'
}.merge(opts) if opts

url = "#{RubyBox::API_URL}/#{resource_name}/#{id}"
uri = URI.parse(url)

request = Net::HTTP::Put.new(uri.path, {
'Content-Type' => 'application/jso'
})

request.body = JSON.dump({
folder_upload_email: opts
})

resp = @session.request(uri, request)
RubyBox::Folder.new(@session, resp)
end

private
def post(extra_url, body)
uri = URI.parse("#{RubyBox::API_URL}/#{extra_url}")
Expand Down
10 changes: 5 additions & 5 deletions ruby-box.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

Gem::Specification.new do |s|
s.name = "ruby-box"
s.version = "1.15.0"
s.version = "1.16.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib"]
s.authors = ["Attachments.me"]
s.date = "2014-10-16"
s.authors = ["Attachments.me", "Adrien Giboire"]
s.date = "2014-12-17"
s.description = "ruby gem for box.com 2.0 api"
s.email = "ben@attachments.me"
s.email = "adrien.giboire@gmail.com"
s.extra_rdoc_files = [
"LICENSE.txt",
"README.markdown"
Expand Down Expand Up @@ -60,7 +60,7 @@ Gem::Specification.new do |s|
"spec/spec_helper.rb",
"spec/users_spec.rb"
]
s.homepage = "http://github.com/attachmentsme/ruby-box"
s.homepage = "http://github.com/adriengiboire/ruby-box"
s.licenses = ["MIT"]
s.rubygems_version = "2.2.2"
s.summary = "ruby gem for box.com 2.0 api"
Expand Down