secureshare-ruby 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/secureshare.rb +12 -1
- data/lib/secureshare/exception.rb +11 -0
- data/secureshare-ruby.gemspec +1 -1
- metadata +3 -2
data/lib/secureshare.rb
CHANGED
@@ -2,6 +2,7 @@ require 'rest_client'
|
|
2
2
|
require 'secureshare/bucket'
|
3
3
|
require 'secureshare/document'
|
4
4
|
require "net/http"
|
5
|
+
require 'secureshare/exception'
|
5
6
|
|
6
7
|
module SecureShare
|
7
8
|
@@config = {}
|
@@ -13,10 +14,20 @@ module SecureShare
|
|
13
14
|
def self.fetch_bucket bucket_id
|
14
15
|
resource = RestClient::Resource.new "#{@@config[:endpoint]}/api/v1/buckets/#{bucket_id}"
|
15
16
|
response = resource.get :authorization => %{Token token="#{@@config[:access_token]}"}, :content_type => :json, :accept => :json
|
16
|
-
Rails.logger.info response.inspect
|
17
17
|
bucket = Bucket.new(JSON.parse(response.body))
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.follow_bucket bucket_id, email
|
21
|
+
resource = RestClient::Resource.new "#{@@config[:endpoint]}/api/v1/buckets/#{bucket_id}/follow"
|
22
|
+
begin
|
23
|
+
resource.post({ :email => email, :site_name => 'some website' }, {:authorization => %{Token token="#{@@config[:access_token]}"}, :content_type => :json, :accept => :json})
|
24
|
+
rescue RestClient::UnprocessableEntity => e
|
25
|
+
error_json = JSON.parse e.http_body
|
26
|
+
raise SecureShare::RestException.new(*error_json.first)
|
27
|
+
end
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
20
31
|
def self.available?
|
21
32
|
begin
|
22
33
|
url = URI.parse(@@config[:endpoint])
|
data/secureshare-ruby.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "secureshare-ruby"
|
7
|
-
gem.version = "0.0.
|
7
|
+
gem.version = "0.0.7"
|
8
8
|
gem.authors = ["Chris Aitchison"]
|
9
9
|
gem.email = ["chris.aitchison@sodalis.com.au"]
|
10
10
|
gem.description = %q{SecureShare Ruby API}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secureshare-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rest-client
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/secureshare.rb
|
60
60
|
- lib/secureshare/bucket.rb
|
61
61
|
- lib/secureshare/document.rb
|
62
|
+
- lib/secureshare/exception.rb
|
62
63
|
- secureshare-ruby.gemspec
|
63
64
|
- spec/secureshare/ruby_spec.rb
|
64
65
|
- spec/spec_helper.rb
|