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
@@ -0,0 +1,11 @@
1
+ class Podio::Filter < ActivePodio::Base
2
+ property :sort_by, :string
3
+ property :sort_desc, :boolean
4
+ property :filters, :array
5
+
6
+ class << self
7
+ def find_last(app_id)
8
+ member Podio.connection.get("/filter/app/#{app_id}/last").body
9
+ end
10
+ end
11
+ end
@@ -1,12 +1,19 @@
1
1
  class Podio::Form < ActivePodio::Base
2
2
  property :form_id, :integer
3
3
  property :app_id, :integer
4
+ property :space_id, :integer
4
5
  property :settings, :hash
5
6
  property :domains, :array
6
- property :field_ids, :array
7
+ property :fields, :array
7
8
  property :attachments, :boolean
8
-
9
+ property :status, :string
10
+
11
+ # Deprecated
12
+ property :field_ids, :array
13
+
9
14
  alias_method :id, :form_id
15
+ delegate_to_hash :settings, :captcha, :text, :theme, :setter => true
16
+ delegate_to_hash :text, :submit, :success, :heading, :description, :setter => true
10
17
 
11
18
  class << self
12
19
  def create(app_id, attributes)
@@ -18,6 +25,15 @@ class Podio::Form < ActivePodio::Base
18
25
  response.body['form_id']
19
26
  end
20
27
 
28
+ def update(form_id, attributes)
29
+ response = Podio.connection.put do |req|
30
+ req.url "/form/#{form_id}"
31
+ req.body = attributes
32
+ end
33
+
34
+ response.status
35
+ end
36
+
21
37
  def find_all_for_app(app_id)
22
38
  list Podio.connection.get { |req|
23
39
  req.url("/form/app/#{app_id}/")
@@ -27,5 +43,13 @@ class Podio::Form < ActivePodio::Base
27
43
  def find(form_id)
28
44
  member Podio.connection.get("/form/#{form_id}").body
29
45
  end
46
+
47
+ def disable(form_id)
48
+ Podio.connection.post("/form/#{form_id}/deactivate").body
49
+ end
50
+
51
+ def enable(form_id)
52
+ Podio.connection.post("/form/#{form_id}/activate").body
53
+ end
30
54
  end
31
55
  end
@@ -1,4 +1,5 @@
1
1
  class Podio::Item < ActivePodio::Base
2
+ include ActivePodio::Updatable
2
3
 
3
4
  # Included Get Item basic
4
5
  property :item_id, :integer
@@ -33,9 +34,28 @@ class Podio::Item < ActivePodio::Base
33
34
  alias_method :id, :item_id
34
35
  delegate_to_hash :app, :app_id, :app_name, :item_name
35
36
 
37
+ def create
38
+ self.item_id = Item.create(self.app_id, prepare_item_values(self))
39
+ end
40
+
36
41
  def destroy
37
42
  Item.delete(self.id)
38
43
  end
44
+
45
+ def update
46
+ Item.update(self.id, prepare_item_values(self))
47
+ end
48
+
49
+ handle_api_errors_for :create, :update
50
+
51
+ protected
52
+ def prepare_item_values(item)
53
+ fields = item.fields.collect { |field| field.values.nil? ? nil : { :external_id => field.external_id, :values => field.values } }.compact
54
+ file_ids = item[:file_ids]
55
+ tags = item.tags.collect(&:presence).compact
56
+
57
+ {:fields => fields, :file_ids => file_ids, :tags => tags }
58
+ end
39
59
 
40
60
  class << self
41
61
  def find(id)
@@ -46,6 +66,10 @@ class Podio::Item < ActivePodio::Base
46
66
  member Podio.connection.get("/item/#{id}/basic").body
47
67
  end
48
68
 
69
+ def find_basic_hash(id)
70
+ Podio.connection.get("/item/#{id}/basic").body
71
+ end
72
+
49
73
  def find_all_by_external_id(app_id, external_id)
50
74
  collection Podio.connection.get("/item/app/#{app_id}/v2/?external_id=#{external_id}").body
51
75
  end
@@ -69,6 +93,13 @@ class Podio::Item < ActivePodio::Base
69
93
  req.url("/item/field/#{field_id}/top/", options)
70
94
  }.body
71
95
  end
96
+
97
+ def xlsx(app_id, options={})
98
+ response = Podio.connection.get { |req|
99
+ req.url("/item/app/#{app_id}/xlsx/", options)
100
+ }
101
+ response.body
102
+ end
72
103
 
73
104
  def search_field(field_id, options={})
74
105
  list Podio.connection.get { |req|
@@ -76,18 +107,6 @@ class Podio::Item < ActivePodio::Base
76
107
  }.body
77
108
  end
78
109
 
79
- # Deprecated. Use method in ItemRevision instead.
80
- # def revisions(item_id)
81
- # collection Podio.connection.get("/item/#{item_id}/revision/").body
82
- # end
83
-
84
- # Deprecated. Use method in ItemDiff instead.
85
- # def revision_difference(item_id, revision_from_id, revision_to_id)
86
- # list Podio.connection.get{ |req|
87
- # req.url("/item/#{item_id}/revision/#{revision_from_id}/#{revision_to_id}")
88
- # }.body
89
- # end
90
-
91
110
  def create(app_id, attributes)
92
111
  response = Podio.connection.post do |req|
93
112
  req.url "/item/app/#{app_id}/"
@@ -119,6 +138,6 @@ class Podio::Item < ActivePodio::Base
119
138
  member Podio.connection.get { |req|
120
139
  req.url("/item/#{current_item_id}/#{operation}", time_options(time))
121
140
  }.body
122
- end
141
+ end
123
142
  end
124
143
  end
@@ -12,5 +12,9 @@ class Podio::ItemDiff < ActivePodio::Base
12
12
  def find_by_item_and_revisions(item_id, revision_from_id, revision_to_id)
13
13
  list Podio.connection.get("/item/#{item_id}/revision/#{revision_from_id}/#{revision_to_id}").body
14
14
  end
15
+
16
+ def revert(item_id, revision_id)
17
+ Podio.connection.delete("/item/#{item_id}/revision/#{revision_id}").body
18
+ end
15
19
  end
16
20
  end
@@ -1,7 +1,7 @@
1
1
  class Podio::ItemField < ActivePodio::Base
2
2
  property :field_id, :integer
3
3
  property :type, :string
4
- property :external_id, :integer
4
+ property :external_id, :string
5
5
  property :label, :string
6
6
  property :values, :array
7
7
 
@@ -0,0 +1,126 @@
1
+ class Podio::Meeting < ActivePodio::Base
2
+ include ActivePodio::Updatable, HasReference
3
+
4
+ property :meeting_id, :integer
5
+ property :title, :string
6
+ property :starts_on, :datetime, :convert_incoming_local_datetime_to_utc => true
7
+ property :ends_on, :datetime, :convert_incoming_local_datetime_to_utc => true
8
+ property :participant_ids, :array
9
+ property :is_remote, :boolean
10
+ property :status, :string
11
+ property :location, :string
12
+ property :agenda, :string
13
+ property :notes, :string
14
+ property :transcript, :string
15
+ property :external_id, :string
16
+ property :external_url, :string
17
+ property :external_phone, :string
18
+ property :external_password, :string
19
+ property :external_recording_url, :string
20
+ property :created_on, :datetime
21
+ property :deleted_on, :datetime
22
+ property :link, :string
23
+ property :ref, :hash
24
+ property :space_id, :integer
25
+
26
+ # For creation only
27
+ property :ref_id, :integer
28
+ property :ref_type, :string
29
+ property :file_ids, :array
30
+
31
+ has_one :created_by, :class => 'User'
32
+ has_one :created_via, :class => 'Via'
33
+ has_one :deleted_by, :class => 'User'
34
+ has_one :deleted_via, :class => 'Via'
35
+ has_many :participants, :class => 'MeetingParticipant'
36
+ has_many :files, :class => 'FileAttachment'
37
+ has_many :comments, :class => 'Comment'
38
+
39
+ alias_method :id, :meeting_id
40
+
41
+ def create
42
+ compacted_attributes = remove_nil_values(self.attributes)
43
+ created_model = if(self.ref_type.present? && self.ref_id.present?)
44
+ self.class.create_with_ref(self.ref_type, self.ref_id, compacted_attributes)
45
+ else
46
+ self.class.create(compacted_attributes)
47
+ end
48
+
49
+ self.attributes = created_model.attributes
50
+ end
51
+
52
+ def update
53
+ compacted_attributes = remove_nil_values(self.attributes)
54
+ updated_model = self.class.update(self.id, compacted_attributes)
55
+ self.attributes = updated_model.attributes
56
+ end
57
+
58
+ def destroy
59
+ self.class.delete(self.id)
60
+ end
61
+
62
+ def start
63
+ self.class.start(self.id)
64
+ end
65
+
66
+ def stop
67
+ self.class.stop(self.id)
68
+ end
69
+
70
+ handle_api_errors_for :create, :destroy, :start, :stop # Call must be made after the methods to handle have been defined
71
+
72
+ class << self
73
+ def create(attributes)
74
+ response = Podio.connection.post do |req|
75
+ req.url "/meeting/"
76
+ req.body = attributes
77
+ end
78
+
79
+ member response.body
80
+ end
81
+
82
+ def create_with_ref(ref_type, ref_id, attributes)
83
+ response = Podio.connection.post do |req|
84
+ req.url "/meeting/#{ref_type}/#{ref_id}/"
85
+ req.body = attributes
86
+ end
87
+
88
+ member response.body
89
+ end
90
+
91
+ def update(id, attributes)
92
+ response = Podio.connection.put do |req|
93
+ req.url "/meeting/#{id}"
94
+ req.body = attributes
95
+ end
96
+
97
+ member response.body
98
+ end
99
+
100
+ def delete(id)
101
+ Podio.connection.delete("/meeting/#{id}").status
102
+ end
103
+
104
+ def start(id)
105
+ Podio.connection.post("/meeting/#{id}/start").body
106
+ end
107
+
108
+ def stop(id)
109
+ Podio.connection.post("/meeting/#{id}/stop").body
110
+ end
111
+
112
+ def find(id)
113
+ member Podio.connection.get("/meeting/#{id}").body
114
+ end
115
+
116
+ def find_for_reference(ref_type, ref_id)
117
+ list Podio.connection.get("/meeting/#{ref_type}/#{ref_id}/").body
118
+ end
119
+
120
+ def find_all(options={})
121
+ list Podio.connection.get { |req|
122
+ req.url('/meeting/', options)
123
+ }.body
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,5 @@
1
+ class Podio::MeetingParticipant < Podio::Profile
2
+ alias_method :id, :profile_id
3
+
4
+ property :user_id, :integer
5
+ end
@@ -19,7 +19,8 @@ class Podio::News < ActivePodio::Base
19
19
 
20
20
  class << self
21
21
  def find_stream()
22
- Podio.connection.get("/news/stream").body
22
+ result = Podio.connection.get("/news/stream").body
23
+ result.blank? ? nil : member(result)
23
24
  end
24
25
 
25
26
  def get_news_redirect(news_id, type=nil)
@@ -2,7 +2,7 @@
2
2
  class Podio::NotificationGroup < ActivePodio::Base
3
3
  property :context, :hash
4
4
  property :notifications, :hash
5
- delegate_to_hash :context, :ref, :data
5
+ delegate_to_hash :context, :ref, :data, :comment_count
6
6
  delegate_to_hash :data, :link
7
7
 
8
8
  class << self
@@ -11,6 +11,11 @@ class Podio::NotificationGroup < ActivePodio::Base
11
11
  req.url('/notification/', options)
12
12
  }.body
13
13
  end
14
+
15
+ def find(id)
16
+ member Podio.connection.get("/notification/#{id}/v2").body
17
+ end
18
+
14
19
 
15
20
  def mark_as_viewed_by_ref(ref_type, ref_id)
16
21
  Podio.connection.post("/notification/#{ref_type}/#{ref_id}/viewed").status
@@ -17,13 +17,19 @@ class Podio::Organization < ActivePodio::Base
17
17
  property :member_count, :integer
18
18
  property :contact_count, :integer
19
19
  property :billing_interval, :integer
20
+ property :rights, :array
21
+ property :verified_domain, :string
22
+ property :rank, :integer
23
+ property :contract_status, :string
24
+ property :type, :string
25
+ property :segment, :string
20
26
 
21
27
  has_one :created_by, :class => 'ByLine'
22
28
 
23
29
  alias_method :id, :org_id
24
30
 
25
31
  def create
26
- attributes = Organization.create(:name => name)
32
+ attributes = Organization.create(:name => name, :logo => logo)
27
33
  self.org_id = attributes['org_id']
28
34
  self.url = attributes['url']
29
35
  self.url_label = attributes['url_label']
@@ -75,10 +81,14 @@ class Podio::Organization < ActivePodio::Base
75
81
  def find_all
76
82
  list Podio.connection.get("/org/").body
77
83
  end
78
-
84
+
79
85
  def get_statistics(id)
80
86
  Podio.connection.get("/org/#{id}/statistics").body
81
87
  end
88
+
89
+ def get_member_count(id)
90
+ Podio.connection.get("/org/#{id}/member/count").body
91
+ end
82
92
 
83
93
  def get_login_report(id, options = {})
84
94
  Podio.connection.get { |req|
@@ -1,14 +1,13 @@
1
1
  # Encapsulates a user's indirect membership (through spaces) of an organization.
2
2
  class Podio::OrganizationMember < ActivePodio::Base
3
- property :spaces, :hash
4
3
  property :profile, :hash
5
4
  property :admin, :boolean
6
5
 
7
6
  has_one :user, :class => 'User'
8
7
  has_one :contact, :class => 'Contact', :property => :profile
9
8
 
10
- delegate :user_id, :mail, :last_active_on, :to => :user
11
- delegate :name, :avatar, :title, :organization, :title_and_org, :avatar_url, :to => :contact
9
+ delegate :user_id, :mail, :to => :user
10
+ delegate :name, :avatar, :title, :organization, :title_and_org, :default_title, :avatar_url, :last_seen_on, :to => :contact
12
11
 
13
12
  class << self
14
13
  def find_all_for_org(org_id, options = {})
@@ -13,13 +13,28 @@ class Podio::Profile < ActivePodio::Base
13
13
  property :zip, :string
14
14
  property :city, :string
15
15
  property :country, :string
16
+ property :state, :string
16
17
  property :im, :array
17
18
  property :location, :array
18
19
  property :mail, :array
19
20
  property :phone, :array
20
21
  property :title, :array
21
22
  property :url, :array
23
+ property :skill, :array
24
+ property :linkedin, :string
25
+ property :twitter, :string
22
26
 
27
+ property :app_store_about, :string
28
+ property :app_store_organization, :string
29
+ property :app_store_location, :string
30
+ property :app_store_title, :string
31
+ property :app_store_url, :string
32
+
33
+ property :last_seen_on, :datetime
34
+ property :is_employee, :boolean
35
+
36
+ alias_method :employee?, :is_employee
37
+
23
38
  class << self
24
39
  def all(options={})
25
40
  options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )
@@ -35,8 +50,31 @@ class Podio::Profile < ActivePodio::Base
35
50
  }.body
36
51
  end
37
52
 
53
+ def top_for_space(space_id, options={})
54
+ list Podio.connection.get { |req|
55
+ req.url("/contact/space/#{space_id}/top/", options)
56
+ }.body
57
+ end
58
+
59
+ def top_for_org(org_id, options={})
60
+ list Podio.connection.get { |req|
61
+ req.url("/contact/org/#{org_id}/top/", options)
62
+ }.body
63
+ end
64
+
65
+ def top_for_personal(options={})
66
+ list Podio.connection.get { |req|
67
+ req.url("/contact/personal/top/", options)
68
+ }.body
69
+ end
70
+
38
71
  def find(profile_id)
39
- member Podio.connection.get("/contact/#{profile_id}/v2").body
72
+ result = Podio.connection.get("/contact/#{profile_id}/v2").body
73
+ if result.is_a?(Array)
74
+ return list result
75
+ else
76
+ return member result
77
+ end
40
78
  end
41
79
 
42
80
  def find_all_for_org(org_id, options={})
@@ -89,10 +127,20 @@ class Podio::Profile < ActivePodio::Base
89
127
  Podio.connection.get("/contact/totals/").body
90
128
  end
91
129
 
130
+ def totals_by_space_v2(space_id)
131
+ Podio.connection.get("/contact/space/#{space_id}/totals/space").body
132
+ end
133
+
92
134
  def totals_by_org_and_space
93
135
  Podio.connection.get("/contact/totals/v2/").body
94
136
  end
95
137
 
138
+ def skills(options)
139
+ Podio.connection.get { |req|
140
+ req.url("/contact/skill/", options)
141
+ }.body
142
+ end
143
+
96
144
  def totals_by_space(space_id, options = {})
97
145
  options[:exclude_self] = (options[:exclude_self] == false ? "0" : "1" )
98
146