ruby-box 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.markdown +22 -3
- data/VERSION +1 -1
- data/lib/ruby-box/exceptions.rb +1 -0
- data/lib/ruby-box/folder.rb +9 -0
- data/lib/ruby-box/item.rb +28 -0
- data/ruby-box.gemspec +2 -2
- data/spec/integration_spec.rb +29 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Nzk0MzA1ZmJjZTkyODM4ZjQ0YjcxNTM5ZWQ0MTIyYjFjYTRkN2UxMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTE2NjQ3MTZmN2M2NGM4ZGU0ZWY1YWVjZTBjMzljZDdhZWFhZWE3MQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTAxYTFiMjI2YjNiNDU3ZGIwMjQzNjkzMDI5MjRkMWMxZmE0MDgyOTBhY2Qz
|
10
|
+
ZDgwODQ1Njc2ZGNlNzM1YzcyNWI3ZDExMTVjZmFmMTdlZmI4YTZmZmE0NmJh
|
11
|
+
MmEyMGQ3ZmZlYjhkZGYyYjJmNDZhNzZjYzJkZDE2MDVhNjk1OWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2Y3OTAxMjQ5Zjc1NmJjM2Y1MDkyNTQyNmVmMzkwZjQyNzU5YWJkMDdlYjRl
|
14
|
+
NmU3ZGMwMDAyOTBkOTAyN2U4NzhhN2EyZGJlNTkyNTI5OGFmOTQ0MzViYWMw
|
15
|
+
Yjg2M2RjNzdlYTYyOGFhNGJjYTc5MGU0M2JlN2Y2OTc1YTU0NGQ=
|
data/README.markdown
CHANGED
@@ -31,7 +31,14 @@ p '@token.token' # the access token.
|
|
31
31
|
p '@token.refresh_token' # token that can be exchanged for a new access_token once the access_token expires.
|
32
32
|
|
33
33
|
# refreshing token.
|
34
|
-
|
34
|
+
|
35
|
+
session = RubyBox::Session.new({
|
36
|
+
client_id: 'your-client-id',
|
37
|
+
client_secret: 'your-client-secret',
|
38
|
+
access_token: 'original-access-token'
|
39
|
+
})
|
40
|
+
|
41
|
+
@token = session.refresh_token('your-refresh-token')
|
35
42
|
```
|
36
43
|
|
37
44
|
__3)__ Create a client using a session initialized with the _access\_token_.
|
@@ -86,6 +93,13 @@ discussion = folder.discussions.first
|
|
86
93
|
discussion.comments.each {|comment| p comment.message}
|
87
94
|
```
|
88
95
|
|
96
|
+
* Creating a shared link for a folder.
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
folder = client.folder('image_folder').create_shared_link
|
100
|
+
p folder.shared_link['url'] # https://www.box.com/s/d6de3224958c1755412
|
101
|
+
```
|
102
|
+
|
89
103
|
Files
|
90
104
|
-----
|
91
105
|
|
@@ -126,6 +140,13 @@ comments.each do |comment|
|
|
126
140
|
end
|
127
141
|
```
|
128
142
|
|
143
|
+
* Creating a shared link for a file.
|
144
|
+
|
145
|
+
```ruby
|
146
|
+
file = client.file('/image_folder/an-image.jpg').create_shared_link
|
147
|
+
p file.shared_link['url'] # https://www.box.com/s/d6de3224958c1755412
|
148
|
+
```
|
149
|
+
|
129
150
|
Search
|
130
151
|
------
|
131
152
|
|
@@ -152,8 +173,6 @@ eresp.events.each do |ev|
|
|
152
173
|
end
|
153
174
|
```
|
154
175
|
|
155
|
-
|
156
|
-
|
157
176
|
Contributors
|
158
177
|
============
|
159
178
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/lib/ruby-box/exceptions.rb
CHANGED
data/lib/ruby-box/folder.rb
CHANGED
@@ -51,6 +51,15 @@ module RubyBox
|
|
51
51
|
collaboration.create
|
52
52
|
end
|
53
53
|
|
54
|
+
def create_subfolder(name)
|
55
|
+
url = "#{RubyBox::API_URL}/#{resource_name}"
|
56
|
+
uri = URI.parse(url)
|
57
|
+
request = Net::HTTP::Post.new( uri.request_uri )
|
58
|
+
request.body = JSON.dump({ "name" => name, "parent" => {"id" => id} })
|
59
|
+
resp = @session.request(uri, request)
|
60
|
+
RubyBox::Folder.new(@session, resp)
|
61
|
+
end
|
62
|
+
|
54
63
|
private
|
55
64
|
|
56
65
|
def resource_name
|
data/lib/ruby-box/item.rb
CHANGED
@@ -82,6 +82,34 @@ module RubyBox
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
# see http://developers.box.com/docs/#folders-create-a-shared-link-for-a-folder
|
86
|
+
# for a list of valid options.
|
87
|
+
def create_shared_link(opts={})
|
88
|
+
raise UnshareableResource unless ['folder', 'file'].include?(type)
|
89
|
+
|
90
|
+
opts = {
|
91
|
+
access: 'open'
|
92
|
+
}.merge(opts) if opts
|
93
|
+
|
94
|
+
url = "#{RubyBox::API_URL}/#{resource_name}/#{id}"
|
95
|
+
uri = URI.parse(url)
|
96
|
+
|
97
|
+
request = Net::HTTP::Put.new(uri.path, {
|
98
|
+
"Content-Type" => 'application/json'
|
99
|
+
})
|
100
|
+
|
101
|
+
request.body = JSON.dump({
|
102
|
+
shared_link: opts
|
103
|
+
})
|
104
|
+
|
105
|
+
@raw_item = @session.request(uri, request)
|
106
|
+
self
|
107
|
+
end
|
108
|
+
|
109
|
+
def disable_shared_link(opts={})
|
110
|
+
create_shared_link(nil)
|
111
|
+
end
|
112
|
+
|
85
113
|
protected
|
86
114
|
|
87
115
|
def self.factory(session, entry)
|
data/ruby-box.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "ruby-box"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.5.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Attachments.me"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-07-01"
|
13
13
|
s.description = "ruby gem for box.com 2.0 api"
|
14
14
|
s.email = "ben@attachments.me"
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/integration_spec.rb
CHANGED
@@ -198,5 +198,34 @@ describe RubyBox, :skip => true do
|
|
198
198
|
folder.delete if folder
|
199
199
|
end
|
200
200
|
end
|
201
|
+
|
202
|
+
describe '#shared_link' do
|
203
|
+
it 'should allow a share link to be created for a folder' do
|
204
|
+
folder = @client.create_folder('/ruby-box_gem_testing/shared_folder').create_shared_link
|
205
|
+
|
206
|
+
# share link was successfully created.
|
207
|
+
folder.shared_link['url'].should match /https?:\/\/[\S]+/
|
208
|
+
|
209
|
+
# share link can be disabled.
|
210
|
+
folder.disable_shared_link
|
211
|
+
folder.shared_link.should == nil
|
212
|
+
|
213
|
+
folder.delete if folder
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'should allow a share link to be created for a file' do
|
217
|
+
utf8_file_name = '遠志教授.jpg'
|
218
|
+
file = @client.upload_file('spec/fixtures/' + utf8_file_name, '/ruby-box_gem_testing/cool stuff/').create_shared_link
|
219
|
+
|
220
|
+
# share link was successfully created.
|
221
|
+
file.shared_link['url'].should match /https?:\/\/[\S]+/
|
222
|
+
|
223
|
+
# share link can be disabled.
|
224
|
+
file.disable_shared_link
|
225
|
+
file.shared_link.should == nil
|
226
|
+
|
227
|
+
file.delete
|
228
|
+
end
|
229
|
+
end
|
201
230
|
end
|
202
231
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Attachments.me
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|