podio 0.5.1 → 0.6.0

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.
Files changed (57) hide show
  1. data/.travis.yml +9 -0
  2. data/Gemfile +2 -0
  3. data/Rakefile +2 -0
  4. data/lib/podio.rb +19 -43
  5. data/lib/podio/active_podio/base.rb +83 -23
  6. data/lib/podio/client.rb +14 -3
  7. data/lib/podio/models/action.rb +15 -0
  8. data/lib/podio/models/activation_status.rb +9 -0
  9. data/lib/podio/models/activity.rb +10 -0
  10. data/lib/podio/models/app_store_share.rb +2 -0
  11. data/lib/podio/models/application.rb +30 -1
  12. data/lib/podio/models/application_field.rb +2 -1
  13. data/lib/podio/models/bulletin.rb +1 -0
  14. data/lib/podio/models/calendar.rb +45 -0
  15. data/lib/podio/models/calendar_mute.rb +27 -0
  16. data/lib/podio/models/comment.rb +1 -0
  17. data/lib/podio/models/connection.rb +7 -1
  18. data/lib/podio/models/contact.rb +9 -1
  19. data/lib/podio/models/contract.rb +113 -0
  20. data/lib/podio/models/contract_accounting.rb +33 -0
  21. data/lib/podio/models/contract_price.rb +46 -0
  22. data/lib/podio/models/email_subscription_setting.rb +2 -0
  23. data/lib/podio/models/file_attachment.rb +16 -7
  24. data/lib/podio/models/filter.rb +11 -0
  25. data/lib/podio/models/form.rb +26 -2
  26. data/lib/podio/models/item.rb +32 -13
  27. data/lib/podio/models/item_diff.rb +4 -0
  28. data/lib/podio/models/item_field.rb +1 -1
  29. data/lib/podio/models/meeting.rb +126 -0
  30. data/lib/podio/models/meeting_participiant.rb +5 -0
  31. data/lib/podio/models/news.rb +2 -1
  32. data/lib/podio/models/notification_group.rb +6 -1
  33. data/lib/podio/models/organization.rb +12 -2
  34. data/lib/podio/models/organization_member.rb +2 -3
  35. data/lib/podio/models/profile.rb +49 -1
  36. data/lib/podio/models/rating.rb +6 -0
  37. data/lib/podio/models/recurrence.rb +25 -0
  38. data/lib/podio/models/reminder.rb +33 -0
  39. data/lib/podio/models/search.rb +20 -0
  40. data/lib/podio/models/space.rb +22 -6
  41. data/lib/podio/models/{space_invite.rb → space_invitation.rb} +1 -3
  42. data/lib/podio/models/space_member.rb +7 -0
  43. data/lib/podio/models/status.rb +16 -0
  44. data/lib/podio/models/stream_mute.rb +27 -0
  45. data/lib/podio/models/stream_object.rb +66 -0
  46. data/lib/podio/models/tag.rb +2 -0
  47. data/lib/podio/models/tag_search.rb +14 -0
  48. data/lib/podio/models/task.rb +33 -0
  49. data/lib/podio/models/user.rb +60 -6
  50. data/lib/podio/models/user_mail.rb +7 -0
  51. data/lib/podio/models/user_status.rb +3 -0
  52. data/lib/podio/models/widget.rb +1 -0
  53. data/lib/podio/version.rb +1 -1
  54. data/podio.gemspec +3 -4
  55. data/test/active_podio_test.rb +36 -9
  56. data/test/models_sanity_test.rb +5 -3
  57. metadata +69 -68
@@ -1,4 +1,10 @@
1
1
  class Podio::Rating < ActivePodio::Base
2
+
3
+ property :rating_id, :integer
4
+ property :type, :string
5
+ property :value, :string
6
+
7
+ alias_method :id, :rating_id
2
8
 
3
9
  class << self
4
10
  def create(ref_type, ref_id, rating_type, value)
@@ -0,0 +1,25 @@
1
+ class Podio::Recurrence < ActivePodio::Base
2
+ property :recurrence_id, :integer
3
+ property :name, :string
4
+ property :config, :hash
5
+ property :step, :integer
6
+ property :until, :date
7
+
8
+ alias_method :id, :recurrence_id
9
+ delegate_to_hash :config, :days, :repeat_on, :setter => true
10
+
11
+ class << self
12
+ def delete(ref_type, ref_id)
13
+ Podio.connection.delete("/recurrence/#{ref_type}/#{ref_id}").body
14
+ end
15
+
16
+ def update(ref_type, ref_id, attributes)
17
+ response = Podio.connection.put do |req|
18
+ req.url "/recurrence/#{ref_type}/#{ref_id}"
19
+ req.body = attributes
20
+ end
21
+ response.status
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,33 @@
1
+ class Podio::Reminder < ActivePodio::Base
2
+ property :reminder_id, :integer
3
+ property :remind_delta, :integer
4
+
5
+ alias_method :id, :reminder_id
6
+
7
+ class << self
8
+ def delete(ref_type, ref_id)
9
+ Podio.connection.delete("/reminder/#{ref_type}/#{ref_id}").body
10
+ end
11
+
12
+ def snooze(id)
13
+ Podio.connection.post("/reminder/#{id}/snooze").body
14
+ end
15
+
16
+ def create(ref_type, ref_id, attributes)
17
+ response = Podio.connection.post do |req|
18
+ req.url "/reminder/#{ref_type}/#{ref_id}"
19
+ req.body = attributes
20
+ end
21
+ response.status
22
+ end
23
+
24
+ def update(ref_type, ref_id, attributes)
25
+ response = Podio.connection.put do |req|
26
+ req.url "/reminder/#{ref_type}/#{ref_id}"
27
+ req.body = attributes
28
+ end
29
+ response.status
30
+ end
31
+ end
32
+
33
+ end
@@ -1,4 +1,15 @@
1
1
  class Podio::Search < ActivePodio::Base
2
+ property :type, :string
3
+ property :id, :integer
4
+ property :title, :string
5
+ property :created_on, :datetime
6
+ property :link, :string
7
+ property :space, :hash
8
+ property :org, :hash
9
+ property :app, :hash
10
+
11
+ has_one :created_by, :class => 'ByLine'
12
+
2
13
 
3
14
  class << self
4
15
  def in_org(org_id, words)
@@ -9,6 +20,15 @@ class Podio::Search < ActivePodio::Base
9
20
 
10
21
  list response.body
11
22
  end
23
+
24
+ def in_space(space_id, words)
25
+ response = Podio.connection.post do |req|
26
+ req.url "/search/space/#{space_id}/"
27
+ req.body = words
28
+ end
29
+
30
+ list response.body
31
+ end
12
32
  end
13
33
 
14
34
  end
@@ -1,4 +1,6 @@
1
1
  class Podio::Space < ActivePodio::Base
2
+ include ActivePodio::Updatable
3
+
2
4
  property :space_id, :integer
3
5
  property :name, :string
4
6
  property :url, :string
@@ -8,21 +10,26 @@ class Podio::Space < ActivePodio::Base
8
10
  property :members, :integer
9
11
  property :role, :string
10
12
  property :rights, :array
11
- property :post_on_new_app, :bool
12
- property :post_on_new_member, :bool
13
+ property :post_on_new_app, :boolean
14
+ property :post_on_new_member, :boolean
15
+ property :subscribed, :boolean
16
+ property :privacy, :string
17
+ property :auto_join, :boolean
18
+ property :type, :string
19
+ property :premium, :boolean
13
20
 
14
21
  has_one :created_by, :class => 'ByLine'
15
22
 
16
23
  alias_method :id, :space_id
17
24
 
18
25
  def create
19
- response = Space.create(:org_id => org_id, :name => name)
26
+ response = Space.create(:org_id => org_id, :name => name, :privacy => self.privacy, :auto_join => self.auto_join)
20
27
  self.url = response['url']
21
28
  self.space_id = response['space_id']
22
29
  end
23
30
 
24
31
  def update
25
- self.class.update(self.space_id, :name => self.name, :post_on_new_app => self.post_on_new_app, :post_on_new_member => self.post_on_new_member, :url_label => self.url_label)
32
+ self.class.update(self.space_id, :name => self.name, :post_on_new_app => self.post_on_new_app, :post_on_new_member => self.post_on_new_member, :url_label => self.url_label, :privacy => self.privacy, :auto_join => self.auto_join)
26
33
  end
27
34
 
28
35
  class << self
@@ -46,14 +53,23 @@ class Podio::Space < ActivePodio::Base
46
53
  def find(id)
47
54
  member Podio.connection.get("/space/#{id}").body
48
55
  end
56
+
57
+ def join(space_id)
58
+ Podio.connection.post("/space/#{space_id}/join").body
59
+ end
49
60
 
50
- def find_by_url(url)
51
- member Podio.connection.get("/space/url?url=#{ERB::Util.url_encode(url)}").body
61
+ def find_by_url(url, info = false)
62
+ info = info ? 1 : 0
63
+ member Podio.connection.get("/space/url?url=#{ERB::Util.url_encode(url)}&info=#{info}").body
52
64
  end
53
65
 
54
66
  def find_all_for_org(org_id)
55
67
  list Podio.connection.get("/org/#{org_id}/space/").body
56
68
  end
69
+
70
+ def find_open_for_org(org_id)
71
+ list Podio.connection.get("/space/org/#{org_id}/available/").body
72
+ end
57
73
 
58
74
  def validate_url_label(org_id, url_label)
59
75
  Podio.connection.post { |req|
@@ -1,4 +1,4 @@
1
- class Podio::SpaceInvite < ActivePodio::Base
1
+ class Podio::SpaceInvitation < ActivePodio::Base
2
2
  include ActivePodio::Updatable
3
3
 
4
4
  property :space_id, :integer
@@ -64,8 +64,6 @@ class Podio::SpaceInvite < ActivePodio::Base
64
64
 
65
65
  def decline_member(invite_code)
66
66
  Podio.connection.delete("/space/membership?invite_code=#{invite_code}").status
67
-
68
- response.body
69
67
  end
70
68
 
71
69
  def find(invite_code)
@@ -3,6 +3,7 @@ class Podio::SpaceMember < ActivePodio::Base
3
3
  property :role, :string
4
4
  property :invited_on, :datetime
5
5
  property :started_on, :datetime
6
+ property :ended_on, :datetime
6
7
 
7
8
  has_one :user, :class => 'User'
8
9
 
@@ -17,6 +18,12 @@ class Podio::SpaceMember < ActivePodio::Base
17
18
  }.body
18
19
  end
19
20
 
21
+ def find_all_ended(space_id)
22
+ list Podio.connection.get { |req|
23
+ req.url("/space/#{space_id}/member/ended/")
24
+ }.body
25
+ end
26
+
20
27
  def update_role(space_id, user_id, role)
21
28
  response = Podio.connection.put do |req|
22
29
  req.url "/space/#{space_id}/member/#{user_id}"
@@ -1,6 +1,7 @@
1
1
  class Podio::Status < ActivePodio::Base
2
2
  property :status_id, :integer
3
3
  property :value, :string
4
+ property :rich_value, :string
4
5
  property :link, :string
5
6
  property :created_on, :datetime
6
7
  property :alerts, :array
@@ -8,6 +9,11 @@ class Podio::Status < ActivePodio::Base
8
9
  property :subscribed, :boolean
9
10
  property :user_ratings, :hash
10
11
 
12
+ # Properties for create
13
+ property :file_ids, :array
14
+ property :embed_id, :integer
15
+ property :embed_file_id, :integer
16
+
11
17
  has_one :created_by, :class => 'Contact'
12
18
  has_one :created_via, :class => 'Via'
13
19
  has_one :embed, :class => 'Embed'
@@ -17,8 +23,13 @@ class Podio::Status < ActivePodio::Base
17
23
  has_many :tasks, :class => 'Task'
18
24
  has_many :shares, :class => 'AppStoreShare'
19
25
  has_many :files, :class => 'FileAttachment'
26
+ has_many :questions, :class => 'Question'
20
27
 
21
28
  alias_method :id, :status_id
29
+
30
+ def destroy
31
+ Status.delete(self.id)
32
+ end
22
33
 
23
34
  class << self
24
35
  def find(id)
@@ -33,5 +44,10 @@ class Podio::Status < ActivePodio::Base
33
44
 
34
45
  response.body['status_id']
35
46
  end
47
+
48
+ def delete(id)
49
+ Podio.connection.delete("/status/#{id}").body
50
+ end
36
51
  end
52
+
37
53
  end
@@ -0,0 +1,27 @@
1
+ class Podio::StreamMute < ActivePodio::Base
2
+ property :id, :integer
3
+ property :type, :string
4
+ property :title, :string
5
+ property :data, :hash
6
+ property :item, :boolean
7
+ property :status, :boolean
8
+ property :task, :boolean
9
+
10
+ class << self
11
+ def find_all
12
+ list Podio.connection.get('/stream/mute/v2/').body
13
+ end
14
+
15
+ def create(scope_type, scope_id, object_type = nil)
16
+ path = "/stream/mute/#{scope_type}/#{scope_id}"
17
+ path += "/#{object_type}" unless object_type.nil?
18
+ Podio.connection.post(path).status
19
+ end
20
+
21
+ def delete(scope_type, scope_id, object_type = nil)
22
+ path = "/stream/mute/#{scope_type}/#{scope_id}"
23
+ path += "/#{object_type}" unless object_type.nil?
24
+ Podio.connection.delete(path).status
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,66 @@
1
+ class Podio::StreamObject < ActivePodio::Base
2
+ property :id, :integer
3
+ property :type, :string
4
+ property :last_update_on, :datetime
5
+ property :title, :string
6
+ property :link, :string
7
+ property :rights, :array
8
+ property :data, :hash
9
+ property :comments_allowed, :boolean
10
+ property :user_ratings, :hash
11
+ property :created_on, :datetime
12
+
13
+ has_one :created_by, :class => 'ByLine'
14
+ has_one :created_via, :class => 'Via'
15
+ has_one :app, :class => 'Application'
16
+ has_one :space, :class => 'Space'
17
+ has_one :org, :class => 'Organization'
18
+
19
+ has_many :comments, :class => 'Comment'
20
+ has_many :files, :class => 'FileAttachment'
21
+ has_many :activity, :class => 'Activity'
22
+
23
+ alias_method :activities, :activity
24
+
25
+ class << self
26
+ def find_all(options={})
27
+ list Podio.connection.get { |req|
28
+ req.url("/stream/v2/", options)
29
+ }.body
30
+ end
31
+
32
+ def find_all_by_space_id(space_id, options={})
33
+ list Podio.connection.get { |req|
34
+ req.url("/stream/space/#{space_id}/v2/", options)
35
+ }.body
36
+ end
37
+
38
+ def find_all_by_org_id(org_id, options={})
39
+ list Podio.connection.get { |req|
40
+ req.url("/stream/org/#{org_id}/v2/", options)
41
+ }.body
42
+ end
43
+
44
+ def find_all_by_app_id(app_id, options={})
45
+ list Podio.connection.get { |req|
46
+ req.url("/stream/app/#{app_id}/", options)
47
+ }.body
48
+ end
49
+
50
+ def find_all_by_user_id(user_id, options={})
51
+ list Podio.connection.get { |req|
52
+ req.url("/stream/user/#{user_id}/", options)
53
+ }.body
54
+ end
55
+
56
+ def find_by_ref(ref_type, ref_id)
57
+ member Podio.connection.get("/stream/#{ref_type}/#{ref_id}/v2").body
58
+ end
59
+
60
+ def find_all_personal(options={})
61
+ list Podio.connection.get { |req|
62
+ req.url("/stream/personal/", options)
63
+ }.body
64
+ end
65
+ end
66
+ end
@@ -22,10 +22,12 @@ class Podio::Tag < ActivePodio::Base
22
22
  end
23
23
 
24
24
  def find_by_app(app_id, limit, text)
25
+ text = CGI.escape(text) if text
25
26
  list Podio.connection.get("/tag/app/#{app_id}/?limit=#{limit}&text=#{text}").body
26
27
  end
27
28
 
28
29
  def find_top_by_app(app_id, limit, text)
30
+ text = CGI.escape(text) if text
29
31
  Podio.connection.get("/tag/app/#{app_id}/top/?limit=#{limit}&text=#{text}").body
30
32
  end
31
33
  end
@@ -0,0 +1,14 @@
1
+ class Podio::TagSearch < ActivePodio::Base
2
+ property :id, :integer
3
+ property :type, :string
4
+ property :title, :string
5
+ property :link, :string
6
+ property :created_on, :datetime
7
+
8
+ class << self
9
+ def search_by_space(space_id, text)
10
+ text = CGI.escape(text) if text
11
+ list Podio.connection.get("/tag/space/#{space_id}/search/?text=#{text}").body
12
+ end
13
+ end
14
+ end
@@ -8,6 +8,7 @@ class Podio::Task < ActivePodio::Base
8
8
  property :description, :string
9
9
  property :private, :boolean
10
10
  property :due_date, :date
11
+ property :due_on, :datetime, :convert_incoming_local_datetime_to_utc => true
11
12
  property :responsible, :hash
12
13
  property :space_id, :integer
13
14
  property :link, :string
@@ -16,6 +17,7 @@ class Podio::Task < ActivePodio::Base
16
17
  property :file_ids, :array # when inputting tasks
17
18
  property :label_ids, :array # when inputting tasks
18
19
  property :labels, :array # when outputting tasks
20
+ property :external_id, :string
19
21
 
20
22
  # old references
21
23
  property :ref_type, :string
@@ -35,6 +37,8 @@ class Podio::Task < ActivePodio::Base
35
37
  has_many :label_list, :class => 'TaskLabel', :property => :labels
36
38
  has_many :files, :class => 'FileAttachment'
37
39
  has_many :comments, :class => 'Comment'
40
+ has_one :reminder, :class => 'Reminder'
41
+ has_one :recurrence, :class => 'Recurrence'
38
42
 
39
43
  alias_method :id, :task_id
40
44
 
@@ -108,6 +112,10 @@ class Podio::Task < ActivePodio::Base
108
112
  Podio.connection.put("/task/#{id}/due_date", {:due_date => due_date}).status
109
113
  end
110
114
 
115
+ def update_due_on(id, due_on)
116
+ Podio.connection.put("/task/#{id}/due_on", {:due_on => due_on}).status
117
+ end
118
+
111
119
  def update_assignee(id, user_id)
112
120
  Podio.connection.post("/task/#{id}/assign", {:responsible => user_id}).status
113
121
  end
@@ -149,5 +157,30 @@ class Podio::Task < ActivePodio::Base
149
157
  req.url('/task/', options)
150
158
  }.body
151
159
  end
160
+
161
+ def find_summary
162
+ response = Podio.connection.get("/task/summary").body
163
+ response['overdue']['tasks'] = list(response['overdue']['tasks'])
164
+ response['today']['tasks'] = list(response['today']['tasks'])
165
+ response['other']['tasks'] = list(response['other']['tasks'])
166
+ response
167
+ end
168
+
169
+ def find_summary_for_reference(ref_type, ref_id)
170
+ response = Podio.connection.get("/task/#{ref_type}/#{ref_id}/summary").body
171
+ response['overdue']['tasks'] = list(response['overdue']['tasks'])
172
+ response['today']['tasks'] = list(response['today']['tasks'])
173
+ response['other']['tasks'] = list(response['other']['tasks'])
174
+ response
175
+ end
176
+
177
+ def find_personal_summary
178
+ response = Podio.connection.get("/task/personal/summary").body
179
+ response['overdue']['tasks'] = list(response['overdue']['tasks'])
180
+ response['today']['tasks'] = list(response['today']['tasks'])
181
+ response['other']['tasks'] = list(response['other']['tasks'])
182
+ response
183
+ end
184
+
152
185
  end
153
186
  end
@@ -4,20 +4,26 @@ class Podio::User < ActivePodio::Base
4
4
  property :status, :string
5
5
  property :locale, :string
6
6
  property :timezone, :string
7
+ property :password, :string
8
+ property :old_password, :string
9
+ property :new_password, :string
7
10
  property :flags, :array
8
11
  property :created_on, :datetime
9
- property :last_active_on, :datetime
10
12
  property :name, :string
11
13
  property :link, :string
12
14
  property :avatar, :integer
13
15
  property :profile_id, :integer
14
16
  property :type, :string
15
-
17
+
18
+ has_many :mails, :class => 'UserMail'
19
+ has_one :profile, :class => 'Contact'
20
+
16
21
  # Only settable on creation
17
22
  property :landing, :string
18
23
  property :referrer, :string
19
- property :initial, :hash
20
-
24
+ property :internal, :hash
25
+ property :marketo_cookie, :string
26
+
21
27
  alias_method :id, :user_id
22
28
 
23
29
  class << self
@@ -34,13 +40,30 @@ class Podio::User < ActivePodio::Base
34
40
  response.body['user_id']
35
41
  end
36
42
 
43
+ def create_inactive(attributes)
44
+ response = Podio.connection.post do |req|
45
+ req.url '/user/inactive/'
46
+ req.body = attributes
47
+ end
48
+
49
+ response.body['user_id']
50
+ end
51
+
52
+ def update(attributes)
53
+ Podio.connection.put("/user/", attributes).status
54
+ end
55
+
56
+ def update_profile(attributes)
57
+ Podio.connection.put("/user/profile/", attributes).status
58
+ end
59
+
37
60
  def activate(attributes)
38
61
  response = Podio.connection.post do |req|
39
62
  req.url '/user/activate_user'
40
63
  req.body = attributes
41
64
  end
42
65
 
43
- response.body['user_id']
66
+ member response.body
44
67
  end
45
68
 
46
69
  def find_all_admins_for_org(org_id)
@@ -58,7 +81,38 @@ class Podio::User < ActivePodio::Base
58
81
  def remove_property(name)
59
82
  Podio.connection.delete("/user/property/#{name}", {}).status
60
83
  end
61
-
84
+
85
+ def mail_verification(attributes)
86
+ response = Podio.connection.post do |req|
87
+ req.url '/user/mail_verification/'
88
+ req.body = attributes
89
+ end
90
+
91
+ response.body
92
+ end
93
+
94
+ def verify(verification_code)
95
+ Podio.connection.post("/user/mail_verification/#{verification_code}").status
96
+ end
97
+
98
+ def recover(mail)
99
+ response = Podio.connection.post do |req|
100
+ req.url '/user/recover_password'
101
+ req.body = {:mail => mail}
102
+ end
103
+
104
+ response.status
105
+ end
106
+
107
+ def reset(password, recovery_code)
108
+ response = Podio.connection.post do |req|
109
+ req.url '/user/reset_password'
110
+ req.body = {:password => password, :recovery_code => recovery_code}
111
+ end
112
+
113
+ response.body
114
+ end
115
+
62
116
  def delete
63
117
  Podio.connection.delete("/user/").status
64
118
  end