logan 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logan/client.rb +34 -4
- data/lib/logan/event.rb +11 -0
- data/lib/logan/todo.rb +1 -1
- data/lib/logan.rb +5 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c18f6281d3d287226289bbd59f7f1bdf5a3d8e8
|
4
|
+
data.tar.gz: 0d1e7bab238f796dbe1225ec36c035dc9afd6279
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bd3ecf2deb865c21f9cfd9be97a13fc9ab62318ca31680dac5f0364cff4d163b2ee0778cd250fc937612c4fa970679c1ca09b461b5597ce723ebf253b18c4ba
|
7
|
+
data.tar.gz: 8feb5a487550687310efc5862d33e398580949faef8ea18d24322a825161c676b3db27298bdae795c0ff5d64a64a87f4c191e450e5db6263ab8567d89bf573be
|
data/lib/logan/client.rb
CHANGED
@@ -7,13 +7,38 @@ module Logan
|
|
7
7
|
# Initializes the Logan shared client with information required to communicate with Basecamp
|
8
8
|
#
|
9
9
|
# @param basecamp_id [String] the Basecamp company ID
|
10
|
-
# @param
|
11
|
-
# @param password [String] the password to use for the passed username
|
10
|
+
# @param auth_hash [Hash] authorization hash consisting of a username and password combination (:username, :password) or an access_token (:access_token)
|
12
11
|
# @param user_agent [String] the user-agent string to include in header of requests
|
13
|
-
def initialize(basecamp_id,
|
12
|
+
def initialize(basecamp_id, auth_hash, user_agent)
|
14
13
|
self.class.base_uri "https://basecamp.com/#{basecamp_id}/api/v1"
|
15
|
-
self.class.basic_auth username, password
|
16
14
|
self.class.headers 'User-Agent' => user_agent
|
15
|
+
self.auth = auth_hash
|
16
|
+
end
|
17
|
+
|
18
|
+
# Updates authorization information for Logan shared client
|
19
|
+
#
|
20
|
+
# @param auth_hash [Hash] authorization hash consisting of a username and password combination (:username, :password) or an access_token (:access_token)
|
21
|
+
def auth=(auth_hash)
|
22
|
+
# symbolize the keys
|
23
|
+
auth_hash = auth_hash.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
24
|
+
|
25
|
+
if auth_hash.has_key? :access_token
|
26
|
+
# clear the basic_auth, if it's set
|
27
|
+
self.class.default_options.reject!{ |k| k == :basic_auth }
|
28
|
+
|
29
|
+
# set the Authorization headers
|
30
|
+
self.class.headers.merge!("Authorization" => "Bearer #{auth_hash[:access_token]}")
|
31
|
+
elsif auth_hash.has_key?(:username) && auth_hash.has_key?(:password)
|
32
|
+
self.class.basic_auth auth_hash[:username], auth_hash[:password]
|
33
|
+
|
34
|
+
# remove the access_token from the headers, if it exists
|
35
|
+
self.class.headers.reject!{ |k| k == "Authorization" }
|
36
|
+
else
|
37
|
+
raise """
|
38
|
+
Incomplete authorization information passed in authorization hash.
|
39
|
+
You must have either an :access_token or a username password combination (:username, :password).
|
40
|
+
"""
|
41
|
+
end
|
17
42
|
end
|
18
43
|
|
19
44
|
# get projects from Basecamp API
|
@@ -40,5 +65,10 @@ module Logan
|
|
40
65
|
list
|
41
66
|
end
|
42
67
|
end
|
68
|
+
|
69
|
+
def events(since_time, page = 1)
|
70
|
+
response = self.class.get "/events.json?since=#{since_time.to_s}&page=#{page}"
|
71
|
+
response.map { |h| e = Logan::Event.new(h) }
|
72
|
+
end
|
43
73
|
end
|
44
74
|
end
|
data/lib/logan/event.rb
ADDED
data/lib/logan/todo.rb
CHANGED
data/lib/logan.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Birarda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: logan@birarda.com
|
@@ -18,6 +18,7 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- lib/logan.rb
|
20
20
|
- lib/logan/client.rb
|
21
|
+
- lib/logan/event.rb
|
21
22
|
- lib/logan/HashConstructed.rb
|
22
23
|
- lib/logan/person.rb
|
23
24
|
- lib/logan/project.rb
|