producteev 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Ruby wrapper for the Producteev REST API
4
4
 
5
- Supports all the API methods. If i have missed any let me know.
5
+ Supports all the API methods. If i have missed any let me know. More information on the API can be found at http://code.google.com/p/producteev-api/wiki/methodsDescriptions#Summary
6
6
 
7
7
  I need to write some tests i know, but if you feel like doing it just raise a merge request.
8
8
  ## Installation
@@ -34,23 +34,29 @@ producteevclient = Producteev.new("api_key_from_producteev","api_secret_from_pro
34
34
  ```
35
35
 
36
36
  Login in as a user
37
+
37
38
  ```ruby
38
39
  producteevclient.login("username","password")
39
40
  ```
40
41
 
41
42
  Get the server time
43
+
42
44
  ```ruby
43
45
  producteevclient.time
44
46
  ```
45
47
 
46
48
  Get as list of tasks
49
+
47
50
  ```ruby
48
51
  producteevclient.tasks.show_list
52
+ producteevclient.tasks.show_list({:page=>1})
49
53
  ```
50
54
 
51
55
  Get as list of lables
56
+
52
57
  ```ruby
53
58
  producteevclient.labels.show_list
59
+ producteevclient.labels.show_list({:page=>1})
54
60
  ```
55
61
 
56
62
  Dashboards, users and activities can also be used in the same way. Please note all httparty exceptions you will have to deal with. All function calls return a hash.
@@ -3,55 +3,54 @@ module Producteev
3
3
  include HTTParty
4
4
  base_uri 'https://api.producteev.com/'
5
5
 
6
- def initialize(apikey,secret, debug)
7
- @apikey = apikey
8
- @secret = secret
9
- @token = nil
10
- @debug = debug
11
- end
12
-
13
- def login(email,password)
14
- param = {:email => email, :password => password}
15
- @token = self.sendRequest("/users/login.json",param)['login']['token']
16
- end
17
-
18
- def generateSig(parameters)
19
- signature = ""
20
-
21
- #sort the hash alphabetically
22
- parameters = parameters.sort
23
-
24
- parameters.each { |key,value|
25
- if (value.kind_of? String or value.kind_of? Integer)
26
- signature = "#{signature}#{key}#{value}"
27
- end
28
- }
29
- signature = signature+@secret
30
- signature = Digest::MD5.hexdigest(signature)
31
- return signature
32
- end
33
-
34
-
35
- def sendRequest(path, options={})
36
- options.merge!({:api_key => @apikey})
6
+ def initialize(apikey,secret, debug)
7
+ @apikey = apikey
8
+ @secret = secret
9
+ @token = nil
10
+ @debug = debug
11
+ end
37
12
 
38
- if @token != nil
39
- options.merge!({:token => @token})
13
+ def login(email,password)
14
+ param = {:email => email, :password => password}
15
+ @token = self.sendRequest("/users/login.json",param)['login']['token']
40
16
  end
41
- options.merge!({:api_sig => generateSig(options)})
42
17
 
43
- if @debug
44
- response = self.class.get(path, {:query => options, :debug_output => $stderr})
45
- else
46
- response = self.class.get(path, {:query => options})
18
+ def generate_signature(parameters)
19
+ signature = ""
20
+
21
+ #sort the hash alphabetically
22
+ parameters = parameters.sort
23
+
24
+ parameters.each { |key,value|
25
+ if (value.kind_of? String or value.kind_of? Integer)
26
+ signature = "#{signature}#{key}#{value}"
27
+ end
28
+ }
29
+ signature = signature+@secret
30
+ signature = Digest::MD5.hexdigest(signature)
31
+ return signature
47
32
  end
48
33
 
49
- if response.success?
50
- return JSON.parse(response.body)
51
- else
52
- raise response.response
34
+
35
+ def sendRequest(path, options={})
36
+ options.merge!({:api_key => @apikey})
37
+
38
+ if @token != nil
39
+ options.merge!({:token => @token})
40
+ end
41
+ options.merge!({:api_sig => generate_signature(options)})
42
+
43
+ if @debug
44
+ response = self.class.get(path, {:query => options, :debug_output => $stderr})
45
+ else
46
+ response = self.class.get(path, {:query => options})
47
+ end
48
+
49
+ if response.success?
50
+ return JSON.parse(response.body)
51
+ else
52
+ raise response.response
53
+ end
53
54
  end
54
-
55
- end
56
55
  end
57
56
  end
@@ -1,115 +1,112 @@
1
1
  module Producteev
2
2
  class Tasks
3
3
  @api = nil
4
- def initialize(api)
5
- @api = api
6
- end
7
-
8
- def create(options = {})
9
- return @api.sendRequest("/tasks/create.json",options)
10
- end
11
-
12
- def delete(options = {})
13
- return @api.sendRequest("/tasks/delete.json",options)
14
- end
15
-
16
- def view(options = {})
17
- return @api.sendRequest("/tasks/view.json",options)
18
- end
19
-
20
- def show_list(options = {})
21
- return @api.sendRequest("/tasks/show_list.json",options)
22
- end
23
-
24
- def my_tasks(options = {})
25
- return @api.sendRequest("/tasks/show_list.json",options)
26
- end
27
-
28
- def my_tasks(options = {})
29
- return @api.sendRequest("/tasks/archived.json",options)
30
- end
31
-
32
- def my_team_tasks(options = {})
33
- return @api.sendRequest("/tasks/my_team_tasks.json",options)
34
- end
35
-
36
- def set_title(options = {})
37
- return @api.sendRequest("/tasks/set_title.json",options)
38
- end
39
-
40
- def set_status(options = {})
41
- return @api.sendRequest("/tasks/set_status.json",options)
42
- end
43
-
44
- def set_star(options = {})
45
- return @api.sendRequest("/tasks/set_star.json",options)
46
- end
47
-
48
- def set_responsible(options = {})
49
- return @api.sendRequest("/tasks/set_responsible.json",options)
50
- end
51
-
52
- def unset_responsible(options = {})
53
- return @api.sendRequest("/tasks/unset_responsible.json",options)
54
- end
55
-
56
- def set_deadline(options = {})
57
- return @api.sendRequest("/tasks/set_deadline.json",options)
58
- end
59
-
60
- def unset_deadline(options = {})
61
- return @api.sendRequest("/tasks/unset_deadline.json",options)
62
- end
63
-
64
- def set_reminder(options = {})
65
- return @api.sendRequest("/tasks/set_reminder.json",options)
66
- end
67
-
68
- def set_repeating(options = {})
69
- return @api.sendRequest("/tasks/set_repeating.json",options)
70
- end
71
-
72
- def unset_repeating(options = {})
73
- return @api.sendRequest("/tasks/unset_repeating.json",options)
74
- end
75
-
76
- def labels(options = {})
77
- return @api.sendRequest("/tasks/labels.json",options)
78
- end
79
-
80
- def change_labels(options = {})
81
- return @api.sendRequest("/tasks/change_labels.json",options)
82
- end
83
-
84
- def set_workspace(options = {})
85
- return @api.sendRequest("/tasks/set_workspace.json",options)
86
- end
87
-
88
- def note_view(options = {})
89
- return @api.sendRequest("/tasks/note_view.json",options)
90
- end
91
-
92
- def notes_get(options = {})
93
- return @api.sendRequest("/tasks/notes_get.json",options)
94
- end
95
-
96
- def note_create(options = {})
97
- return @api.sendRequest("/tasks/note_create.json",options)
98
- end
99
-
100
- def note_delete(options = {})
101
- return @api.sendRequest("/tasks/note_delete.json",options)
102
- end
103
-
104
- def activity_view(options = {})
105
- return @api.sendRequest("/tasks/activity_view.json",options)
106
- end
107
-
108
- def activities_get(options = {})
109
- return @api.sendRequest("/tasks/activities_get.json",options)
110
- end
111
-
112
-
113
-
4
+ def initialize(api)
5
+ @api = api
6
+ end
7
+
8
+ def create(options = {})
9
+ return @api.sendRequest("/tasks/create.json",options)
10
+ end
11
+
12
+ def delete(options = {})
13
+ return @api.sendRequest("/tasks/delete.json",options)
14
+ end
15
+
16
+ def view(options = {})
17
+ return @api.sendRequest("/tasks/view.json",options)
18
+ end
19
+
20
+ def show_list(options = {})
21
+ return @api.sendRequest("/tasks/show_list.json",options)
22
+ end
23
+
24
+ def my_tasks(options = {})
25
+ return @api.sendRequest("/tasks/show_list.json",options)
26
+ end
27
+
28
+ def my_tasks(options = {})
29
+ return @api.sendRequest("/tasks/archived.json",options)
30
+ end
31
+
32
+ def my_team_tasks(options = {})
33
+ return @api.sendRequest("/tasks/my_team_tasks.json",options)
34
+ end
35
+
36
+ def set_title(options = {})
37
+ return @api.sendRequest("/tasks/set_title.json",options)
38
+ end
39
+
40
+ def set_status(options = {})
41
+ return @api.sendRequest("/tasks/set_status.json",options)
42
+ end
43
+
44
+ def set_star(options = {})
45
+ return @api.sendRequest("/tasks/set_star.json",options)
46
+ end
47
+
48
+ def set_responsible(options = {})
49
+ return @api.sendRequest("/tasks/set_responsible.json",options)
50
+ end
51
+
52
+ def unset_responsible(options = {})
53
+ return @api.sendRequest("/tasks/unset_responsible.json",options)
54
+ end
55
+
56
+ def set_deadline(options = {})
57
+ return @api.sendRequest("/tasks/set_deadline.json",options)
58
+ end
59
+
60
+ def unset_deadline(options = {})
61
+ return @api.sendRequest("/tasks/unset_deadline.json",options)
62
+ end
63
+
64
+ def set_reminder(options = {})
65
+ return @api.sendRequest("/tasks/set_reminder.json",options)
66
+ end
67
+
68
+ def set_repeating(options = {})
69
+ return @api.sendRequest("/tasks/set_repeating.json",options)
70
+ end
71
+
72
+ def unset_repeating(options = {})
73
+ return @api.sendRequest("/tasks/unset_repeating.json",options)
74
+ end
75
+
76
+ def labels(options = {})
77
+ return @api.sendRequest("/tasks/labels.json",options)
78
+ end
79
+
80
+ def change_labels(options = {})
81
+ return @api.sendRequest("/tasks/change_labels.json",options)
82
+ end
83
+
84
+ def set_workspace(options = {})
85
+ return @api.sendRequest("/tasks/set_workspace.json",options)
86
+ end
87
+
88
+ def note_view(options = {})
89
+ return @api.sendRequest("/tasks/note_view.json",options)
90
+ end
91
+
92
+ def notes_get(options = {})
93
+ return @api.sendRequest("/tasks/notes_get.json",options)
94
+ end
95
+
96
+ def note_create(options = {})
97
+ return @api.sendRequest("/tasks/note_create.json",options)
98
+ end
99
+
100
+ def note_delete(options = {})
101
+ return @api.sendRequest("/tasks/note_delete.json",options)
102
+ end
103
+
104
+ def activity_view(options = {})
105
+ return @api.sendRequest("/tasks/activity_view.json",options)
106
+ end
107
+
108
+ def activities_get(options = {})
109
+ return @api.sendRequest("/tasks/activities_get.json",options)
110
+ end
114
111
  end
115
112
  end
@@ -6,23 +6,23 @@ module Producteev
6
6
  end
7
7
 
8
8
  def view(options = {})
9
- return @api.sendRequest("/users/view.json",options)
9
+ return @api.send_request("/users/view.json",options)
10
10
  end
11
11
 
12
12
  def set_default_dashboard(options = {})
13
- return @api.sendRequest("/users/set_default_dashboard.json",options)
13
+ return @api.send_request("/users/set_default_dashboard.json",options)
14
14
  end
15
15
 
16
16
  def colleagues(options = {})
17
- return @api.sendRequest("/users/colleagues.json",options)
17
+ return @api.send_request("/users/colleagues.json",options)
18
18
  end
19
19
 
20
20
  def set_sort_by(options = {})
21
- return @api.sendRequest("/users/set_sort_by.json",options)
21
+ return @api.send_request("/users/set_sort_by.json",options)
22
22
  end
23
23
 
24
24
  def set_timezone(options = {})
25
- return @api.sendRequest("/users/set_timezone.json",options)
25
+ return @api.send_request("/users/set_timezone.json",options)
26
26
  end
27
27
  end
28
28
  end
@@ -0,0 +1,10 @@
1
+ module Producteev
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 2
6
+ BUILD = nil
7
+
8
+ STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.');
9
+ end
10
+ end
data/producteev.gemspec CHANGED
@@ -1,6 +1,8 @@
1
+ require File.expand_path('../lib/producteev/version.rb', __FILE__)
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = 'producteev'
3
- s.version = '0.0.1'
5
+ s.version = Producteev::VERSION::STRING.dup
4
6
  s.date = '2012-01-26'
5
7
  s.summary = "Api client for producteev"
6
8
  s.description = "Api client for producteev"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: producteev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &13744140 !ruby/object:Gem::Requirement
16
+ requirement: &21154180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13744140
24
+ version_requirements: *21154180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &13762820 !ruby/object:Gem::Requirement
27
+ requirement: &21153220 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *13762820
35
+ version_requirements: *21153220
36
36
  description: Api client for producteev
37
37
  email: steve@thatbytes.co.uk
38
38
  executables: []
@@ -50,6 +50,7 @@ files:
50
50
  - lib/producteev/labels.rb
51
51
  - lib/producteev/tasks.rb
52
52
  - lib/producteev/users.rb
53
+ - lib/producteev/version.rb
53
54
  - producteev.gemspec
54
55
  homepage: http://github.com/stephenrjohnson/producteev
55
56
  licenses: []
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  version: '0'
72
73
  requirements: []
73
74
  rubyforge_project:
74
- rubygems_version: 1.8.10
75
+ rubygems_version: 1.8.15
75
76
  signing_key:
76
77
  specification_version: 3
77
78
  summary: Api client for producteev