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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e39f8bb1bebade7a2d6d7b2ef6f8149e02cee606
4
- data.tar.gz: d0c5e113b5db76d6b8cf8f9a03a64f27d562539a
3
+ metadata.gz: 9c18f6281d3d287226289bbd59f7f1bdf5a3d8e8
4
+ data.tar.gz: 0d1e7bab238f796dbe1225ec36c035dc9afd6279
5
5
  SHA512:
6
- metadata.gz: 584042077954e3131935bc73b96a95a28dc0875bb29b635036780ba1bf2accbeb3cd7943bc62347dec472f0db8985f98d28de0b9fc27c38b68a6df36c48bf866
7
- data.tar.gz: f71fc834f95e02da617cd974c78daf932a8d90f0a5f6c24ea6a5f6b17ead66cbf0ea922b047dbd6cb90ee10bfce9c237032de6e70228ba61896e85ba5918ea6c
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 username [String] the username to use for requests
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, username, password, user_agent)
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
@@ -0,0 +1,11 @@
1
+ require 'logan/HashConstructed'
2
+
3
+ module Logan
4
+ class Event
5
+ include HashConstructed
6
+
7
+ attr_accessor :id
8
+ attr_accessor :summary
9
+ attr_accessor :url
10
+ end
11
+ end
data/lib/logan/todo.rb CHANGED
@@ -22,8 +22,8 @@ module Logan
22
22
  def put_json
23
23
  {
24
24
  :content => @content,
25
- :assignee => @assignee.to_hash,
26
25
  :due_at => @due_at,
26
+ :assignee => @assignee.to_hash,
27
27
  :completed => @completed
28
28
  }.to_json
29
29
  end
data/lib/logan.rb CHANGED
@@ -2,4 +2,8 @@ require 'httparty'
2
2
  require 'json'
3
3
 
4
4
  require 'logan/client'
5
- require 'logan/project'
5
+ require 'logan/event'
6
+ require 'logan/person'
7
+ require 'logan/project'
8
+ require 'logan/todo'
9
+ require 'logan/todolist'
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.3
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-07-17 00:00:00.000000000 Z
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