boxr 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/examples/enterprise_events.rb +2 -10
- data/lib/boxr/events.rb +17 -1
- data/lib/boxr/files.rb +2 -1
- data/lib/boxr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cf35b1411c6c6798f2f415a2d825717096965e5
|
4
|
+
data.tar.gz: 3e142582aa2436842010086cbbd7dd3cfb647d27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14e361ab0e968bc98fb80f2448646f916829080aa609c96cb69c551b248c66e81ac681a44e8f47f306ecfa0bfb364be44cb55acec41aa8270c0e7db8983d0cf4
|
7
|
+
data.tar.gz: 70317eac3258db263123244e1ad57d955a2a1299330838f12c96b5906f0d3cc9b5418f40eb338696763930c30ea03ef7bb0b9d03f0edc503430e902fe34906c5
|
data/README.md
CHANGED
@@ -223,7 +223,7 @@ pending_collaborations()
|
|
223
223
|
```ruby
|
224
224
|
user_events(stream_position: 0, stream_type: :all, limit: 100)
|
225
225
|
|
226
|
-
enterprise_events(
|
226
|
+
enterprise_events(created_after, created_before)
|
227
227
|
```
|
228
228
|
#### [Shared Items](https://developers.box.com/docs/#shared-items)
|
229
229
|
```ruby
|
@@ -8,14 +8,6 @@ now = Time.now
|
|
8
8
|
start_date = now - (60*60*24) #one day ago
|
9
9
|
end_date = now
|
10
10
|
|
11
|
-
stream_position = 0
|
12
11
|
puts "fetching enterprise events..."
|
13
|
-
|
14
|
-
|
15
|
-
event_response.events.each do |event|
|
16
|
-
puts "#{event.event_type}, #{event.created_by.name}"
|
17
|
-
end
|
18
|
-
stream_position = event_response.next_stream_position
|
19
|
-
|
20
|
-
break if event_response.events.empty?
|
21
|
-
end
|
12
|
+
events = client.enterprise_events(start_date.utc, end_date.utc)
|
13
|
+
events.each{|event| ap event; puts;}
|
data/lib/boxr/events.rb
CHANGED
@@ -8,7 +8,23 @@ module Boxr
|
|
8
8
|
Hashie::Mash.new({events: events["entries"], chunk_size: events["chunk_size"], next_stream_position: events["next_stream_position"]})
|
9
9
|
end
|
10
10
|
|
11
|
-
def enterprise_events(
|
11
|
+
def enterprise_events(created_after, created_before, event_type: nil, limit: 100)
|
12
|
+
events = []
|
13
|
+
stream_position = 0
|
14
|
+
loop do
|
15
|
+
event_response = get_enterprise_events_for_date_range(stream_position, limit, created_after, created_before, event_type)
|
16
|
+
event_response.events.each{|event| events << event}
|
17
|
+
stream_position = event_response.next_stream_position
|
18
|
+
|
19
|
+
break if event_response.events.empty?
|
20
|
+
end
|
21
|
+
events
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def get_enterprise_events_for_date_range(stream_position, limit, created_after, created_before, event_type)
|
12
28
|
query = {stream_position: stream_position, stream_type: :admin_logs, limit: limit}
|
13
29
|
query['event_type'] = event_type unless event_type.nil?
|
14
30
|
query['created_after'] = created_after.to_datetime.rfc3339 unless created_after.nil?
|
data/lib/boxr/files.rb
CHANGED
@@ -86,6 +86,7 @@ module Boxr
|
|
86
86
|
|
87
87
|
File.open(path_to_file) do |file|
|
88
88
|
content_md5 = send_content_md5 ? Digest::SHA1.file(file).hexdigest : nil
|
89
|
+
|
89
90
|
attributes = {filename: file, parent_id: parent_id}
|
90
91
|
attributes[:content_created_at] = content_created_at.to_datetime.rfc3339 unless content_created_at.nil?
|
91
92
|
attributes[:content_modified_at] = content_modified_at.to_datetime.rfc3339 unless content_modified_at.nil?
|
@@ -221,7 +222,7 @@ module Boxr
|
|
221
222
|
def preflight_check(path_to_file, parent_id)
|
222
223
|
size = File.size(path_to_file)
|
223
224
|
|
224
|
-
#TODO: need to make sure that figuring out the filename from the path_to_file works for people using
|
225
|
+
#TODO: need to make sure that figuring out the filename from the path_to_file works for people using Windows
|
225
226
|
filename = File.basename(path_to_file)
|
226
227
|
attributes = {"name" => filename, "parent" => {"id" => "#{parent_id}"}, "size" => size}
|
227
228
|
body_json, res = options("#{FILES_URI}/content", attributes)
|
data/lib/boxr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Burnette
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|