podio 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/podio.rb +27 -3
- data/lib/podio/areas/application.rb +15 -0
- data/lib/podio/areas/bulletin.rb +48 -0
- data/lib/podio/areas/comment.rb +36 -0
- data/lib/podio/areas/contact.rb +67 -10
- data/lib/podio/areas/conversation.rb +32 -0
- data/lib/podio/areas/file.rb +12 -0
- data/lib/podio/areas/integration.rb +43 -0
- data/lib/podio/areas/item.rb +4 -0
- data/lib/podio/areas/organization.rb +7 -3
- data/lib/podio/areas/organization_profile.rb +32 -0
- data/lib/podio/areas/space.rb +31 -0
- data/lib/podio/areas/status.rb +10 -0
- data/lib/podio/areas/task.rb +104 -0
- data/lib/podio/areas/user.rb +6 -2
- data/lib/podio/client.rb +11 -5
- data/lib/podio/middleware/error_response.rb +2 -2
- data/lib/podio/middleware/json_request.rb +1 -6
- data/lib/podio/middleware/json_response.rb +6 -9
- data/lib/podio/middleware/logger.rb +1 -9
- data/lib/podio/version.rb +1 -1
- data/podio.gemspec +1 -0
- metadata +24 -25
data/Rakefile
CHANGED
data/lib/podio.rb
CHANGED
@@ -35,6 +35,21 @@ module Podio
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
class StdoutLogger
|
39
|
+
def initialize(debug)
|
40
|
+
@debug = debug
|
41
|
+
end
|
42
|
+
|
43
|
+
def log(env)
|
44
|
+
begin
|
45
|
+
puts "\n==> #{env[:method].to_s.upcase} #{env[:url]} \n\n" if @debug
|
46
|
+
yield
|
47
|
+
ensure
|
48
|
+
puts "\n== (#{env[:status]}) ==> #{env[:body]}\n\n" if @debug
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
38
53
|
class OAuthToken < Struct.new(:access_token, :refresh_token, :expires_at)
|
39
54
|
def initialize(params = {})
|
40
55
|
self.access_token = params['access_token']
|
@@ -43,22 +58,31 @@ module Podio
|
|
43
58
|
end
|
44
59
|
end
|
45
60
|
|
46
|
-
autoload :Client,
|
47
|
-
autoload :Error,
|
48
|
-
autoload :ResponseWrapper,
|
61
|
+
autoload :Client, 'podio/client'
|
62
|
+
autoload :Error, 'podio/error'
|
63
|
+
autoload :ResponseWrapper, 'podio/response_wrapper'
|
49
64
|
|
50
65
|
autoload :Application, 'podio/areas/application'
|
66
|
+
autoload :Bulletin, 'podio/areas/bulletin'
|
51
67
|
autoload :Category, 'podio/areas/app_store'
|
68
|
+
autoload :Comment, 'podio/areas/comment'
|
52
69
|
autoload :Connection, 'podio/areas/connection'
|
53
70
|
autoload :Contact, 'podio/areas/contact'
|
71
|
+
autoload :Conversation, 'podio/areas/conversation'
|
54
72
|
autoload :File, 'podio/areas/file'
|
55
73
|
autoload :Form, 'podio/areas/form'
|
56
74
|
autoload :Item, 'podio/areas/item'
|
75
|
+
autoload :Integration, 'podio/areas/integration'
|
57
76
|
autoload :Organization, 'podio/areas/organization'
|
58
77
|
autoload :OrganizationMember, 'podio/areas/organization_member'
|
78
|
+
autoload :OrganizationProfile, 'podio/areas/organization_profile'
|
59
79
|
autoload :Search, 'podio/areas/search'
|
60
80
|
autoload :Space, 'podio/areas/space'
|
61
81
|
autoload :SpaceInvite, 'podio/areas/space'
|
82
|
+
autoload :SpaceMember, 'podio/areas/space'
|
83
|
+
autoload :Status, 'podio/areas/status'
|
84
|
+
autoload :Task, 'podio/areas/task'
|
85
|
+
autoload :TaskLabel, 'podio/areas/task'
|
62
86
|
autoload :User, 'podio/areas/user'
|
63
87
|
autoload :UserStatus, 'podio/areas/user_status'
|
64
88
|
autoload :Widget, 'podio/areas/widget'
|
@@ -14,6 +14,21 @@ module Podio
|
|
14
14
|
req.url("/app/", options)
|
15
15
|
}.body
|
16
16
|
end
|
17
|
+
|
18
|
+
def find_all_for_space(space_id, options = {})
|
19
|
+
list Podio.connection.get { |req|
|
20
|
+
req.url("/app/space/#{space_id}/", options)
|
21
|
+
}.body
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_order(space_id, app_ids = [])
|
25
|
+
response = Podio.connection.put do |req|
|
26
|
+
req.url "/app/space/#{space_id}/order"
|
27
|
+
req.body = app_ids
|
28
|
+
end
|
29
|
+
|
30
|
+
response.body
|
31
|
+
end
|
17
32
|
|
18
33
|
end
|
19
34
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Podio
|
2
|
+
module Bulletin
|
3
|
+
include Podio::ResponseWrapper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def create(attributes)
|
7
|
+
response = Podio.connection.post do |req|
|
8
|
+
req.url "/bulletin/"
|
9
|
+
req.body = attributes
|
10
|
+
end
|
11
|
+
|
12
|
+
response.body['bulletin_id']
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(id, attributes)
|
16
|
+
response = Podio.connection.put do |req|
|
17
|
+
req.url "/bulletin/#{id}"
|
18
|
+
req.body = attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
response.status
|
22
|
+
end
|
23
|
+
|
24
|
+
def find(id, options={})
|
25
|
+
member Podio.connection.get("/bulletin/#{id}").body
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_visible
|
29
|
+
list Podio.connection.get("/bulletin/").body
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_all
|
33
|
+
list Podio.connection.get("/bulletin/?show_drafts=1").body
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_all_by_locale(locale)
|
37
|
+
list Podio.connection.get("/bulletin/?locale=locale").body
|
38
|
+
end
|
39
|
+
|
40
|
+
def preview!(id)
|
41
|
+
Podio.connection.post("/bulletin/#{id}/preview").body
|
42
|
+
end
|
43
|
+
|
44
|
+
def send!(id)
|
45
|
+
Podio.connection.post("/bulletin/#{id}/send").body
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Podio
|
2
|
+
module Comment
|
3
|
+
include Podio::ResponseWrapper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def create(commentable_type, commentable_id, attributes)
|
7
|
+
response = Podio.connection.post do |req|
|
8
|
+
req.url "/comment/#{commentable_type}/#{commentable_id}"
|
9
|
+
req.body = attributes
|
10
|
+
end
|
11
|
+
|
12
|
+
response.body['comment_id']
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(id, attributes)
|
16
|
+
response = Podio.connection.put do |req|
|
17
|
+
req.url "/comment/#{id}"
|
18
|
+
req.body = attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
response.status
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete(id)
|
25
|
+
Podio.connection.delete("/comment/#{id}").status
|
26
|
+
end
|
27
|
+
|
28
|
+
def find(id)
|
29
|
+
member Podio.connection.get("/comment/#{id}").body
|
30
|
+
end
|
31
|
+
|
32
|
+
def find_all_for(commentable_type, commentable_id)
|
33
|
+
list Podio.connection.get("/comment/#{commentable_type}/#{commentable_id}").body
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/podio/areas/contact.rb
CHANGED
@@ -4,20 +4,30 @@ module Podio
|
|
4
4
|
extend self
|
5
5
|
|
6
6
|
def all(options={})
|
7
|
-
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order)
|
7
|
+
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order, :name, :email, :required, :contact_type, :exclude_self)
|
8
|
+
options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )
|
8
9
|
|
9
10
|
list Podio.connection.get { |req|
|
10
11
|
req.url("/contact/", options)
|
11
12
|
}.body
|
12
13
|
end
|
13
14
|
|
15
|
+
def top(options={})
|
16
|
+
options.assert_valid_keys(:limit, :type)
|
17
|
+
|
18
|
+
list Podio.connection.get { |req|
|
19
|
+
req.url("/contact/top/", options)
|
20
|
+
}.body
|
21
|
+
end
|
22
|
+
|
14
23
|
def find(profile_id)
|
15
24
|
member Podio.connection.get("/contact/#{profile_id}/v2").body
|
16
25
|
end
|
17
26
|
|
18
27
|
def find_all_for_org(org_id, options={})
|
19
|
-
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order)
|
28
|
+
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order, :name, :email, :contact_type, :exclude_self)
|
20
29
|
options[:type] ||= 'full'
|
30
|
+
options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )
|
21
31
|
|
22
32
|
list Podio.connection.get { |req|
|
23
33
|
req.url("/contact/org/#{org_id}", options)
|
@@ -25,26 +35,41 @@ module Podio
|
|
25
35
|
end
|
26
36
|
|
27
37
|
def find_all_for_space(space_id, options={})
|
28
|
-
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order)
|
38
|
+
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order, :name, :email, :required, :contact_type, :exclude_self)
|
29
39
|
options[:type] ||= 'full'
|
40
|
+
options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )
|
30
41
|
|
31
42
|
list Podio.connection.get { |req|
|
32
43
|
req.url("/contact/space/#{space_id}", options)
|
33
44
|
}.body
|
34
45
|
end
|
35
46
|
|
36
|
-
def find_all_for_connection(connection_id)
|
37
|
-
|
38
|
-
|
47
|
+
def find_all_for_connection(connection_id, options={})
|
48
|
+
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order, :name, :email)
|
49
|
+
options[:type] ||= 'full'
|
39
50
|
|
40
|
-
|
41
|
-
|
51
|
+
list Podio.connection.get { |req|
|
52
|
+
req.url("/contact/connection/#{connection_id}", options)
|
53
|
+
}.body
|
42
54
|
end
|
43
55
|
|
44
|
-
def
|
45
|
-
|
56
|
+
def find_all_for_connection_type(connection_type, options={})
|
57
|
+
options.assert_valid_keys(:key, :value, :limit, :offset, :type, :order, :name, :email)
|
58
|
+
options[:type] ||= 'full'
|
59
|
+
|
60
|
+
list Podio.connection.get { |req|
|
61
|
+
req.url("/contact/connection/#{connection_type}", options)
|
62
|
+
}.body
|
46
63
|
end
|
47
64
|
|
65
|
+
def find_for_org(org_id)
|
66
|
+
member Podio.connection.get("/org/#{org_id}/billing").body
|
67
|
+
end
|
68
|
+
|
69
|
+
def find_for_user(user_id)
|
70
|
+
member Podio.connection.get("/contact/user/#{user_id}").body
|
71
|
+
end
|
72
|
+
|
48
73
|
def totals_by_org
|
49
74
|
Podio.connection.get("/contact/totals/").body
|
50
75
|
end
|
@@ -52,6 +77,38 @@ module Podio
|
|
52
77
|
def totals_by_org_and_space
|
53
78
|
Podio.connection.get("/contact/totals/v2/").body
|
54
79
|
end
|
80
|
+
|
81
|
+
def totals_by_space(space_id, options = {})
|
82
|
+
options.assert_valid_keys(:exclude_self)
|
83
|
+
options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )
|
84
|
+
|
85
|
+
Podio.connection.get { |req|
|
86
|
+
req.url("/contact/space/#{space_id}/totals/", options)
|
87
|
+
}.body
|
88
|
+
end
|
89
|
+
|
90
|
+
def create_space_contact(space_id, attributes)
|
91
|
+
response = Podio.connection.post do |req|
|
92
|
+
req.url "/contact/space/#{space_id}/"
|
93
|
+
req.body = attributes
|
94
|
+
end
|
95
|
+
|
96
|
+
response.body
|
97
|
+
end
|
98
|
+
|
99
|
+
def delete_contact(profile_id)
|
100
|
+
Podio.connection.delete("/contact/#{profile_id}").body
|
101
|
+
end
|
102
|
+
|
103
|
+
def update_contact(profile_id, attributes)
|
104
|
+
response = Podio.connection.put do |req|
|
105
|
+
req.url "/contact/#{profile_id}"
|
106
|
+
req.body = attributes
|
107
|
+
end
|
108
|
+
|
109
|
+
response.body
|
110
|
+
end
|
55
111
|
|
56
112
|
end
|
113
|
+
|
57
114
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Podio
|
2
|
+
module Conversation
|
3
|
+
include Podio::ResponseWrapper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def find(conversation_id)
|
7
|
+
member Podio.connection.get("/conversation/#{conversation_id}").body
|
8
|
+
end
|
9
|
+
|
10
|
+
def find_all_for_reference(ref_type, ref_id)
|
11
|
+
list Podio.connection.get("/conversation/#{ref_type}/#{ref_id}/").body
|
12
|
+
end
|
13
|
+
|
14
|
+
def create(attributes)
|
15
|
+
response = Podio.connection.post do |req|
|
16
|
+
req.url '/conversation/'
|
17
|
+
req.body = attributes
|
18
|
+
end
|
19
|
+
response.body
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_for_reference(ref_type, ref_id, attributes)
|
23
|
+
response = Podio.connection.post do |req|
|
24
|
+
req.url "/conversation/#{ref_type}/#{ref_id}/"
|
25
|
+
req.body = attributes
|
26
|
+
end
|
27
|
+
|
28
|
+
response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/podio/areas/file.rb
CHANGED
@@ -19,5 +19,17 @@ module Podio
|
|
19
19
|
Podio.connection.post "/file/#{file_id}/available"
|
20
20
|
end
|
21
21
|
|
22
|
+
# Attach a file to an existing reference
|
23
|
+
def attach(file_id, ref_type, ref_id)
|
24
|
+
Podio.connection.post do |req|
|
25
|
+
req.url "/file/#{file_id}/attach"
|
26
|
+
req.body = { :ref_type => ref_type, :ref_id => ref_id }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy(file_id)
|
31
|
+
Podio.connection.post("/file/#{file_id}/copy").body['file_id']
|
32
|
+
end
|
33
|
+
|
22
34
|
end
|
23
35
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Podio
|
2
|
+
module Integration
|
3
|
+
include Podio::ResponseWrapper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def create(app_id, attributes)
|
7
|
+
response = Podio.connection.post do |req|
|
8
|
+
req.url "/integration/#{app_id}"
|
9
|
+
req.body = {:type => attributes[:type], :silent => attributes[:silent], :config => attributes[:config]}
|
10
|
+
end
|
11
|
+
|
12
|
+
response.body['integration_id']
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(app_id, attributes)
|
16
|
+
response = Podio.connection.put do |req|
|
17
|
+
req.url "/integration/#{app_id}"
|
18
|
+
req.body = {:silent => attributes[:silent], :config => attributes[:config]}
|
19
|
+
end
|
20
|
+
|
21
|
+
response.body
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_mapping(app_id, attributes)
|
25
|
+
response = Podio.connection.put do |req|
|
26
|
+
req.url "/integration/#{app_id}/mapping"
|
27
|
+
req.body = attributes[:mapping]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def find(app_id)
|
32
|
+
member Podio.connection.get("/integration/#{app_id}").body
|
33
|
+
end
|
34
|
+
|
35
|
+
def find_available_fields_for(app_id)
|
36
|
+
list Podio.connection.get("/integration/#{app_id}/field/").body
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete(app_id)
|
40
|
+
Podio.connection.delete("/integration/#{app_id}").status
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/podio/areas/item.rb
CHANGED
@@ -7,6 +7,10 @@ module Podio
|
|
7
7
|
member Podio.connection.get("/item/#{id}").body
|
8
8
|
end
|
9
9
|
|
10
|
+
def find_basic(id)
|
11
|
+
member Podio.connection.get("/item/#{id}/basic").body
|
12
|
+
end
|
13
|
+
|
10
14
|
def find_all_by_external_id(app_id, external_id)
|
11
15
|
collection Podio.connection.get("/item/app/#{app_id}/v2/?external_id=#{external_id}").body
|
12
16
|
end
|
@@ -55,13 +55,17 @@ module Podio
|
|
55
55
|
}.body
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
58
|
+
def update_billing_profile(id, attributes)
|
59
59
|
response = Podio.connection.put do |req|
|
60
|
-
req.url "/org/#{id}/
|
60
|
+
req.url "/org/#{id}/billing"
|
61
61
|
req.body = attributes
|
62
62
|
end
|
63
63
|
response.status
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
|
+
def upgrade(id)
|
67
|
+
Podio.connection.post("/org/#{id}/upgrade").body
|
68
|
+
end
|
69
|
+
|
66
70
|
end
|
67
71
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Podio
|
2
|
+
module OrganizationProfile
|
3
|
+
include Podio::ResponseWrapper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def find(org_id)
|
7
|
+
member Podio.connection.get("/org/#{org_id}/appstore").body
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(org_id, attributes)
|
11
|
+
response = Podio.connection.post do |req|
|
12
|
+
req.url "/org/#{org_id}/appstore"
|
13
|
+
req.body = attributes
|
14
|
+
end
|
15
|
+
|
16
|
+
response.body
|
17
|
+
end
|
18
|
+
|
19
|
+
def update(org_id, attributes)
|
20
|
+
response = Podio.connection.put do |req|
|
21
|
+
req.url "/org/#{org_id}/appstore"
|
22
|
+
req.body = attributes
|
23
|
+
end
|
24
|
+
response.status
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete(org_id)
|
28
|
+
Podio.connection.delete("/org/#{org_id}/appstore").status
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/podio/areas/space.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
1
3
|
module Podio
|
2
4
|
module Space
|
3
5
|
include Podio::ResponseWrapper
|
@@ -16,9 +18,14 @@ module Podio
|
|
16
18
|
member Podio.connection.get("/space/#{id}").body
|
17
19
|
end
|
18
20
|
|
21
|
+
def find_by_url(url)
|
22
|
+
member Podio.connection.get("/space/url?url=#{ERB::Util.url_encode(url)}").body
|
23
|
+
end
|
24
|
+
|
19
25
|
def find_all_for_org(org_id)
|
20
26
|
list Podio.connection.get("/org/#{org_id}/space/").body
|
21
27
|
end
|
28
|
+
|
22
29
|
end
|
23
30
|
|
24
31
|
module SpaceInvite
|
@@ -43,4 +50,28 @@ module Podio
|
|
43
50
|
response.body
|
44
51
|
end
|
45
52
|
end
|
53
|
+
|
54
|
+
module SpaceMember
|
55
|
+
include Podio::ResponseWrapper
|
56
|
+
extend self
|
57
|
+
|
58
|
+
def find_all_for_role(space_id, role)
|
59
|
+
list Podio.connection.get { |req|
|
60
|
+
req.url("/space/#{space_id}/member/#{role}/")
|
61
|
+
}.body
|
62
|
+
end
|
63
|
+
|
64
|
+
def update_role(space_id, user_id, role)
|
65
|
+
response = Podio.connection.put do |req|
|
66
|
+
req.url "/space/#{space_id}/member/#{user_id}"
|
67
|
+
req.body = { :role => role.to_s }
|
68
|
+
end
|
69
|
+
response.status
|
70
|
+
end
|
71
|
+
|
72
|
+
def end_membership(space_id, user_id)
|
73
|
+
Podio.connection.delete("/space/#{space_id}/member/#{user_id}").status
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
46
77
|
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Podio
|
2
|
+
module Task
|
3
|
+
include Podio::ResponseWrapper
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def create(attributes)
|
7
|
+
response = Podio.connection.post do |req|
|
8
|
+
req.url "/task/"
|
9
|
+
req.body = attributes
|
10
|
+
end
|
11
|
+
|
12
|
+
response.body['task_id']
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_with_ref(ref_type, ref_id, attributes)
|
16
|
+
response = Podio.connection.post do |req|
|
17
|
+
req.url "/task/#{ref_type}/#{ref_id}/"
|
18
|
+
req.body = attributes
|
19
|
+
end
|
20
|
+
|
21
|
+
response.body['task_id']
|
22
|
+
end
|
23
|
+
|
24
|
+
def update_description(id, description)
|
25
|
+
Podio.connection.put("/task/#{id}/description", {:description => description}).status
|
26
|
+
end
|
27
|
+
|
28
|
+
def update_text(id, text)
|
29
|
+
Podio.connection.put("/task/#{id}/text", {:text => text}).status
|
30
|
+
end
|
31
|
+
|
32
|
+
def update_private(id, private_flag)
|
33
|
+
Podio.connection.put("/task/#{id}/private", {:private => private_flag}).status
|
34
|
+
end
|
35
|
+
|
36
|
+
def update_due_date(id, due_date)
|
37
|
+
Podio.connection.put("/task/#{id}/due_date", {:due_date => due_date}).status
|
38
|
+
end
|
39
|
+
|
40
|
+
def update_assignee(id, user_id)
|
41
|
+
Podio.connection.post("/task/#{id}/assign", {:responsible => user_id}).status
|
42
|
+
end
|
43
|
+
|
44
|
+
def update_labels(id, label_ids)
|
45
|
+
Podio.connection.put("/task/#{id}/label/", label_ids).status
|
46
|
+
end
|
47
|
+
|
48
|
+
def delete(id)
|
49
|
+
Podio.connection.delete("/task/#{id}").status
|
50
|
+
end
|
51
|
+
|
52
|
+
def complete(id)
|
53
|
+
Podio.connection.post("/task/#{id}/complete").body
|
54
|
+
end
|
55
|
+
|
56
|
+
def incomplete(id)
|
57
|
+
Podio.connection.post("/task/#{id}/incomplete").body
|
58
|
+
end
|
59
|
+
|
60
|
+
def rank(id, before_task_id, after_task_id)
|
61
|
+
Podio.connection.post("/task/#{id}/rank", {:before => before_task_id, :after => after_task_id}).body
|
62
|
+
end
|
63
|
+
|
64
|
+
def find(id)
|
65
|
+
member Podio.connection.get("/task/#{id}").body
|
66
|
+
end
|
67
|
+
|
68
|
+
def find_all(options={})
|
69
|
+
list Podio.connection.get { |req|
|
70
|
+
req.url('/task/', options)
|
71
|
+
}.body
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
module TaskLabel
|
76
|
+
include Podio::ResponseWrapper
|
77
|
+
extend self
|
78
|
+
|
79
|
+
def find_all_labels
|
80
|
+
list Podio.connection.get { |req|
|
81
|
+
req.url("/task/label/")
|
82
|
+
}.body
|
83
|
+
end
|
84
|
+
|
85
|
+
def create(attributes)
|
86
|
+
response = Podio.connection.post do |req|
|
87
|
+
req.url "/task/label/"
|
88
|
+
req.body = attributes
|
89
|
+
end
|
90
|
+
|
91
|
+
response.body['label_id']
|
92
|
+
end
|
93
|
+
|
94
|
+
def delete(label_id)
|
95
|
+
Podio.connection.delete("/task/label/#{label_id}").status
|
96
|
+
end
|
97
|
+
|
98
|
+
def update(label_id, text, color)
|
99
|
+
Podio.connection.put("/task/label/#{label_id}", {:text => text, :color => color}).status
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
data/lib/podio/areas/user.rb
CHANGED
@@ -7,13 +7,17 @@ module Podio
|
|
7
7
|
member Podio.connection.get("/user/").body
|
8
8
|
end
|
9
9
|
|
10
|
-
def create(
|
10
|
+
def create(attributes)
|
11
11
|
response = Podio.connection.post do |req|
|
12
12
|
req.url '/user/'
|
13
|
-
req.body = attributes
|
13
|
+
req.body = attributes
|
14
14
|
end
|
15
15
|
|
16
16
|
response.body['user_id']
|
17
17
|
end
|
18
|
+
|
19
|
+
def find_all_admins_for_org(org_id)
|
20
|
+
list Podio.connection.get("/org/#{org_id}/admin/").body
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
data/lib/podio/client.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Podio
|
2
2
|
class Client
|
3
|
-
attr_reader :api_url, :api_key, :api_secret, :
|
4
|
-
attr_accessor :oauth_token, :stubs
|
3
|
+
attr_reader :api_url, :api_key, :api_secret, :connection
|
4
|
+
attr_accessor :oauth_token, :stubs, :current_http_client
|
5
5
|
|
6
6
|
def initialize(options = {})
|
7
7
|
@api_url = options[:api_url] || Podio.api_url || 'https://api.podio.com'
|
8
8
|
@api_key = options[:api_key] || Podio.api_key
|
9
9
|
@api_secret = options[:api_secret] || Podio.api_secret
|
10
|
-
@
|
10
|
+
@logger = options[:logger] || Podio::StdoutLogger.new(options[:debug] || Podio.debug)
|
11
11
|
@oauth_token = options[:oauth_token]
|
12
|
+
@headers = options[:custom_headers] || {}
|
13
|
+
@adapter = options[:adapter] || Faraday.default_adapter
|
12
14
|
|
13
15
|
if options[:enable_stubs]
|
14
16
|
@enable_stubs = true
|
@@ -20,6 +22,10 @@ module Podio
|
|
20
22
|
setup_connections
|
21
23
|
end
|
22
24
|
|
25
|
+
def log(env, &block)
|
26
|
+
@logger.log(env, &block)
|
27
|
+
end
|
28
|
+
|
23
29
|
def reset
|
24
30
|
setup_connections
|
25
31
|
end
|
@@ -56,7 +62,7 @@ module Podio
|
|
56
62
|
end
|
57
63
|
|
58
64
|
def configured_headers
|
59
|
-
headers =
|
65
|
+
headers = @headers.dup
|
60
66
|
headers['User-Agent'] = 'Podio Ruby Library'
|
61
67
|
headers['authorization'] = "OAuth2 #{oauth_token.access_token}" if oauth_token
|
62
68
|
headers['X-Podio-Dry-Run'] = '1' if @test_mode
|
@@ -86,7 +92,7 @@ module Podio
|
|
86
92
|
end
|
87
93
|
|
88
94
|
def default_adapter
|
89
|
-
@enable_stubs ? [:test, @stubs] :
|
95
|
+
@enable_stubs ? [:test, @stubs] : @adapter
|
90
96
|
end
|
91
97
|
|
92
98
|
def configure_oauth_connection
|
@@ -12,10 +12,10 @@ module Podio
|
|
12
12
|
if finished_env[:body]['error_description'] =~ /expired_token/
|
13
13
|
raise Error::TokenExpired, finished_env[:body].inspect
|
14
14
|
else
|
15
|
-
raise Error::AuthorizationError, finished_env[:body]
|
15
|
+
raise Error::AuthorizationError, finished_env[:body]
|
16
16
|
end
|
17
17
|
when 403
|
18
|
-
raise Error::AuthorizationError, finished_env[:body]
|
18
|
+
raise Error::AuthorizationError, finished_env[:body]
|
19
19
|
when 404
|
20
20
|
raise Error::NotFoundError, "#{finished_env[:method].to_s.upcase} #{finished_env[:url]}"
|
21
21
|
when 410
|
@@ -1,12 +1,7 @@
|
|
1
1
|
module Podio
|
2
2
|
module Middleware
|
3
3
|
class JsonRequest < Faraday::Middleware
|
4
|
-
|
5
|
-
require 'multi_json'
|
6
|
-
|
7
|
-
rescue LoadError, NameError => e
|
8
|
-
self.load_error = e
|
9
|
-
end
|
4
|
+
require 'multi_json'
|
10
5
|
|
11
6
|
def call(env)
|
12
7
|
env[:request_headers]['Content-Type'] = 'application/json'
|
@@ -4,18 +4,14 @@
|
|
4
4
|
module Podio
|
5
5
|
module Middleware
|
6
6
|
class JsonResponse < Faraday::Response::Middleware
|
7
|
-
|
8
|
-
require 'multi_json'
|
7
|
+
require 'multi_json'
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
9
|
+
def self.register_on_complete(env)
|
10
|
+
env[:response].on_complete do |finished_env|
|
11
|
+
if finished_env[:body].is_a?(String) && finished_env[:status] < 500
|
12
|
+
finished_env[:body] = parse(finished_env[:body])
|
15
13
|
end
|
16
14
|
end
|
17
|
-
rescue LoadError, NameError => e
|
18
|
-
self.load_error = e
|
19
15
|
end
|
20
16
|
|
21
17
|
def initialize(app)
|
@@ -24,6 +20,7 @@ module Podio
|
|
24
20
|
end
|
25
21
|
|
26
22
|
def self.parse(body)
|
23
|
+
return nil if body !~ /\S/ # json gem doesn't like decoding blank strings
|
27
24
|
MultiJson.decode(body)
|
28
25
|
rescue Object => err
|
29
26
|
raise Faraday::Error::ParsingError.new(err)
|
@@ -4,16 +4,8 @@ module Podio
|
|
4
4
|
module Middleware
|
5
5
|
class Logger < Faraday::Middleware
|
6
6
|
def call(env)
|
7
|
-
|
8
|
-
puts "\n==> #{env[:method].to_s.upcase} #{env[:url]} \n\n"
|
9
|
-
end
|
10
|
-
|
11
|
-
begin
|
7
|
+
env[:request][:client].log(env) do
|
12
8
|
@app.call(env)
|
13
|
-
ensure
|
14
|
-
if env[:request][:client].debug
|
15
|
-
puts "\n== (#{env[:status]}) ==> #{env[:body]}\n\n"
|
16
|
-
end
|
17
9
|
end
|
18
10
|
end
|
19
11
|
|
data/lib/podio/version.rb
CHANGED
data/podio.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_runtime_dependency 'faraday', '~> 0.5.1'
|
19
19
|
s.add_runtime_dependency 'activesupport', '~> 3.0'
|
20
|
+
s.add_runtime_dependency 'i18n', '>= 0.4.2'
|
20
21
|
s.add_runtime_dependency 'multi_json', '~> 0.0.5'
|
21
22
|
|
22
23
|
s.description = <<desc
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: podio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 1
|
9
|
-
version: 0.2.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.3.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Florian Munz
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-04-05 00:00:00 +02:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ~>
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 5
|
31
|
-
- 1
|
32
24
|
version: 0.5.1
|
33
25
|
type: :runtime
|
34
26
|
version_requirements: *id001
|
@@ -40,27 +32,31 @@ dependencies:
|
|
40
32
|
requirements:
|
41
33
|
- - ~>
|
42
34
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 3
|
45
|
-
- 0
|
46
35
|
version: "3.0"
|
47
36
|
type: :runtime
|
48
37
|
version_requirements: *id002
|
49
38
|
- !ruby/object:Gem::Dependency
|
50
|
-
name:
|
39
|
+
name: i18n
|
51
40
|
prerelease: false
|
52
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.4.2
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: multi_json
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ~>
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
segments:
|
58
|
-
- 0
|
59
|
-
- 0
|
60
|
-
- 5
|
61
57
|
version: 0.0.5
|
62
58
|
type: :runtime
|
63
|
-
version_requirements: *
|
59
|
+
version_requirements: *id004
|
64
60
|
description: |
|
65
61
|
The humble beginnings of the Ruby wrapper for the Podio API.
|
66
62
|
|
@@ -80,15 +76,22 @@ files:
|
|
80
76
|
- lib/podio.rb
|
81
77
|
- lib/podio/areas/app_store.rb
|
82
78
|
- lib/podio/areas/application.rb
|
79
|
+
- lib/podio/areas/bulletin.rb
|
80
|
+
- lib/podio/areas/comment.rb
|
83
81
|
- lib/podio/areas/connection.rb
|
84
82
|
- lib/podio/areas/contact.rb
|
83
|
+
- lib/podio/areas/conversation.rb
|
85
84
|
- lib/podio/areas/file.rb
|
86
85
|
- lib/podio/areas/form.rb
|
86
|
+
- lib/podio/areas/integration.rb
|
87
87
|
- lib/podio/areas/item.rb
|
88
88
|
- lib/podio/areas/organization.rb
|
89
89
|
- lib/podio/areas/organization_member.rb
|
90
|
+
- lib/podio/areas/organization_profile.rb
|
90
91
|
- lib/podio/areas/search.rb
|
91
92
|
- lib/podio/areas/space.rb
|
93
|
+
- lib/podio/areas/status.rb
|
94
|
+
- lib/podio/areas/task.rb
|
92
95
|
- lib/podio/areas/user.rb
|
93
96
|
- lib/podio/areas/user_status.rb
|
94
97
|
- lib/podio/areas/widget.rb
|
@@ -127,21 +130,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
130
|
requirements:
|
128
131
|
- - ">="
|
129
132
|
- !ruby/object:Gem::Version
|
130
|
-
segments:
|
131
|
-
- 0
|
132
133
|
version: "0"
|
133
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
134
135
|
none: false
|
135
136
|
requirements:
|
136
137
|
- - ">="
|
137
138
|
- !ruby/object:Gem::Version
|
138
|
-
segments:
|
139
|
-
- 0
|
140
139
|
version: "0"
|
141
140
|
requirements: []
|
142
141
|
|
143
142
|
rubyforge_project:
|
144
|
-
rubygems_version: 1.
|
143
|
+
rubygems_version: 1.5.0
|
145
144
|
signing_key:
|
146
145
|
specification_version: 3
|
147
146
|
summary: Ruby wrapper for the Podio API
|