podio 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +1 -4
  4. data/README.md +82 -67
  5. data/lib/podio.rb +15 -2
  6. data/lib/podio/client.rb +11 -7
  7. data/lib/podio/middleware/error_response.rb +3 -1
  8. data/lib/podio/middleware/json_response.rb +6 -1
  9. data/lib/podio/middleware/logger.rb +4 -3
  10. data/lib/podio/middleware/oauth2.rb +5 -5
  11. data/lib/podio/models/answer.rb +8 -0
  12. data/lib/podio/models/app_store_category.rb +2 -2
  13. data/lib/podio/models/app_store_share.rb +1 -0
  14. data/lib/podio/models/application.rb +12 -4
  15. data/lib/podio/models/application_field.rb +10 -0
  16. data/lib/podio/models/batch.rb +1 -0
  17. data/lib/podio/models/calendar_event.rb +6 -5
  18. data/lib/podio/models/campaign.rb +88 -0
  19. data/lib/podio/models/category.rb +1 -1
  20. data/lib/podio/models/contract.rb +18 -20
  21. data/lib/podio/models/contract_attribution.rb +24 -0
  22. data/lib/podio/models/contract_period.rb +22 -0
  23. data/lib/podio/models/contract_price.rb +37 -26
  24. data/lib/podio/models/device.rb +22 -0
  25. data/lib/podio/models/email_subscription_setting.rb +8 -0
  26. data/lib/podio/models/embed.rb +5 -2
  27. data/lib/podio/models/experiment.rb +26 -3
  28. data/lib/podio/models/extension.rb +90 -0
  29. data/lib/podio/models/external_file.rb +3 -3
  30. data/lib/podio/models/file_attachment.rb +25 -2
  31. data/lib/podio/models/form.rb +2 -1
  32. data/lib/podio/models/grant.rb +1 -0
  33. data/lib/podio/models/invoice.rb +13 -0
  34. data/lib/podio/models/item.rb +24 -11
  35. data/lib/podio/models/item_field.rb +6 -0
  36. data/lib/podio/models/item_transaction.rb +34 -0
  37. data/lib/podio/models/live.rb +1 -17
  38. data/lib/podio/models/notification.rb +5 -0
  39. data/lib/podio/models/o_auth.rb +9 -2
  40. data/lib/podio/models/o_auth_client.rb +5 -3
  41. data/lib/podio/models/o_auth_scope.rb +11 -0
  42. data/lib/podio/models/organization.rb +26 -8
  43. data/lib/podio/models/organization_member.rb +6 -0
  44. data/lib/podio/models/organization_membership.rb +15 -0
  45. data/lib/podio/models/profile.rb +2 -0
  46. data/lib/podio/models/promotion.rb +6 -8
  47. data/lib/podio/models/promotion_group.rb +51 -0
  48. data/lib/podio/models/promotion_group_member.rb +32 -0
  49. data/lib/podio/models/rating.rb +4 -2
  50. data/lib/podio/models/reference.rb +2 -1
  51. data/lib/podio/models/space.rb +11 -5
  52. data/lib/podio/models/tag.rb +36 -0
  53. data/lib/podio/models/view.rb +5 -0
  54. data/lib/podio/models/vote.rb +8 -0
  55. data/lib/podio/models/voting.rb +9 -0
  56. data/lib/podio/models/voucher.rb +68 -0
  57. data/lib/podio/version.rb +1 -1
  58. data/podio.gemspec +10 -3
  59. data/test/client_test.rb +14 -0
  60. metadata +31 -13
  61. data/lib/podio/models/contract_price_v2.rb +0 -31
  62. data/lib/podio/models/date_election.rb +0 -35
@@ -2,6 +2,7 @@ class Podio::Live < ActivePodio::Base
2
2
  property :status, :string
3
3
  property :presence, :hash
4
4
  property :provider, :string
5
+ property :provider_id, :string
5
6
  property :push, :hash
6
7
  property :live_id, :integer
7
8
  property :settings, :hash
@@ -39,23 +40,6 @@ class Podio::Live < ActivePodio::Base
39
40
  Podio.connection.post("/live/#{id}/decline").status
40
41
  end
41
42
 
42
- def authorize(attributes)
43
- response = Podio.connection.post do |req|
44
- req.url "/live/omega/authorize"
45
- req.body = attributes
46
- end
47
-
48
- response.body
49
- end
50
-
51
- def authorize_all
52
- Podio.connection.post("/live/omega/authorize/all").body
53
- end
54
-
55
- def get_servers
56
- Podio.connection.get("/live/servers").body
57
- end
58
-
59
43
  end
60
44
 
61
45
  end
@@ -34,6 +34,11 @@ class Podio::Notification < ActivePodio::Base
34
34
  Podio.connection.post("/notification/#{id}/viewed").status
35
35
  end
36
36
 
37
+ # @see https://developers.podio.com/doc/notifications/mark-notifications-as-viewed-by-ref-553653
38
+ def mark_as_viewed_by_ref(type, id)
39
+ Podio.connection.post("/notification/#{type}/#{id}/viewed").status
40
+ end
41
+
37
42
  # @see https://developers.podio.com/doc/notifications/mark-all-notifications-as-viewed-58099
38
43
  def mark_all_as_viewed
39
44
  Podio.connection.post("/notification/viewed").status
@@ -1,6 +1,5 @@
1
1
  # @see https://developers.podio.com/doc/oauth-authorization
2
2
  class Podio::OAuth < ActivePodio::Base
3
-
4
3
  class << self
5
4
  def authorize(attributes)
6
5
  response = Podio.connection.post do |req|
@@ -29,6 +28,14 @@ class Podio::OAuth < ActivePodio::Base
29
28
 
30
29
  response.body
31
30
  end
32
- end
33
31
 
32
+ # @see https://developers.podio.com/doc/oauth-authorization/invalidate-grant-7997965
33
+ def invalidate_grant
34
+ response = Podio.connection.post do |req|
35
+ req.url '/oauth/grant/invalidate'
36
+ end
37
+
38
+ response.status
39
+ end
40
+ end
34
41
  end
@@ -9,6 +9,8 @@ class Podio::OAuthClient < ActivePodio::Base
9
9
  property :url, :string
10
10
  property :domain, :string
11
11
 
12
+ has_many :scope, :class => 'OAuthScope'
13
+
12
14
  alias_method :id, :auth_client_id
13
15
 
14
16
  def create
@@ -69,9 +71,9 @@ class Podio::OAuthClient < ActivePodio::Base
69
71
  end
70
72
 
71
73
  def reset(id)
72
- response = Podio.connection.post("/oauth/client/#{id}/reset")
73
- response.status
74
- end
74
+ response = Podio.connection.post("/oauth/client/#{id}/reset")
75
+ response.status
76
+ end
75
77
 
76
78
  def find_granted_clients()
77
79
  list Podio.connection.get("oauth/grant/client/").body
@@ -0,0 +1,11 @@
1
+ # @see https://developers.podio.com/doc/oauth-authorization
2
+ class Podio::OAuthScope < ActivePodio::Base
3
+ include ActivePodio::Updatable
4
+
5
+ property :ref_type, :string
6
+ property :ref_id, :integer
7
+ property :ref_link, :string
8
+ property :ref_name, :string
9
+ property :permission, :string
10
+
11
+ end
@@ -22,12 +22,18 @@ class Podio::Organization < ActivePodio::Base
22
22
  property :verified_domain, :string # TODO: Remove this, it's deprecated
23
23
  property :domains, :array
24
24
  property :rank, :integer
25
+ property :tier, :string
25
26
  property :contract_status, :string
26
27
  property :type, :string
27
28
  property :segment, :string
28
29
  property :segment_size, :integer
29
30
  property :grants_count, :integer
30
31
  property :allow_add_space, :boolean
32
+ property :item_limit, :integer
33
+ property :item_usage, :integer
34
+ property :price_plans, :hash
35
+ property :current_price_plan, :hash
36
+ property :price_plans_variation, :string
31
37
 
32
38
  has_one :created_by, :class => 'ByLine'
33
39
 
@@ -71,8 +77,10 @@ class Podio::Organization < ActivePodio::Base
71
77
  end
72
78
 
73
79
  # @see https://developers.podio.com/doc/organizations/get-organization-22383
74
- def find(id)
75
- member Podio.connection.get("/org/#{id}").body
80
+ def find(id, options={})
81
+ member Podio.connection.get { |req|
82
+ req.url("/org/#{id}", options)
83
+ }.body
76
84
  end
77
85
 
78
86
  # @see https://developers.podio.com/doc/organizations/get-organization-by-url-22384
@@ -80,8 +88,12 @@ class Podio::Organization < ActivePodio::Base
80
88
  member Podio.connection.get("/org/url?url=#{url}").body
81
89
  end
82
90
 
83
- def find_by_url_slug(org_slug)
84
- member Podio.connection.get('/org/url', :org_slug => org_slug).body
91
+ def find_by_url_slug(org_slug, options={})
92
+ options['org_slug'] = org_slug
93
+
94
+ member Podio.connection.get { |req|
95
+ req.url('/org/url', options)
96
+ }.body
85
97
  end
86
98
 
87
99
  def validate_url_label(url_label)
@@ -92,8 +104,10 @@ class Podio::Organization < ActivePodio::Base
92
104
  end
93
105
 
94
106
  # @see https://developers.podio.com/doc/organizations/get-organizations-22344
95
- def find_all
96
- list Podio.connection.get("/org/").body
107
+ def find_all(options={})
108
+ list Podio.connection.get { |req|
109
+ req.url("/org/", options)
110
+ }.body
97
111
  end
98
112
 
99
113
  def get_login_report(id, options = {})
@@ -121,10 +135,14 @@ class Podio::Organization < ActivePodio::Base
121
135
  def get_statistics(id)
122
136
  Podio.connection.get("/org/#{id}/statistics/v2").body
123
137
  end
124
-
138
+
125
139
  def find_for_user(user_id)
126
140
  list Podio.connection.get("/org/user/#{user_id}/").body
127
141
  end
128
-
142
+
143
+ def change_to_user_model(id)
144
+ Podio.connection.post("/org/#{id}/change_to_user_model").body
145
+ end
146
+
129
147
  end
130
148
  end
@@ -27,6 +27,12 @@ class Podio::OrganizationMember < ActivePodio::Base
27
27
  }.body
28
28
  end
29
29
 
30
+ def export(org_id, options = {})
31
+ Podio.connection.get { |req|
32
+ req.url("/org/#{org_id}/member/export", options)
33
+ }.body
34
+ end
35
+
30
36
  # @see https://developers.podio.com/doc/organizations/get-organization-member-50908
31
37
  def find(org_id, user_id)
32
38
  member Podio.connection.get("/org/#{org_id}/member/#{user_id}").body
@@ -0,0 +1,15 @@
1
+ class Podio::OrganizationMembership < ActivePodio::Base
2
+ property :employee, :boolean
3
+ property :tier, :string
4
+ property :space_memberships, :integer
5
+
6
+ has_one :org, :class => 'Organization'
7
+
8
+ class << self
9
+ def find_all_for_user(user_id, options = {})
10
+ list Podio.connection.get { |req|
11
+ req.url("/org/user/#{user_id}/membership/", options)
12
+ }.body
13
+ end
14
+ end
15
+ end
@@ -34,6 +34,8 @@ class Podio::Profile < ActivePodio::Base
34
34
  property :last_seen_on, :datetime
35
35
  property :is_employee, :boolean
36
36
 
37
+ property :push, :hash
38
+
37
39
  alias_method :employee?, :is_employee
38
40
 
39
41
  class << self
@@ -5,14 +5,15 @@ class Podio::Promotion < ActivePodio::Base
5
5
  property :display_type, :string
6
6
  property :display_data, :hash
7
7
  property :context, :string
8
- property :contextual, :boolean
9
8
  property :priority, :integer
10
9
  property :max_views, :integer
11
- property :max_uses, :integer
12
- property :max_duration, :integer
10
+ property :max_duration, :boolean
11
+ property :end_on_use, :boolean
13
12
  property :sleep, :integer
14
13
  property :condition_set_ids, :array
15
14
 
15
+ has_many :condition_sets, :class => 'ConditionSet'
16
+
16
17
  alias_method :id, :promotion_id
17
18
 
18
19
  class << self
@@ -56,11 +57,8 @@ class Podio::Promotion < ActivePodio::Base
56
57
  Podio.connection.get("/promotion/#{promotion_id}/stats").body
57
58
  end
58
59
 
59
- def assign(promotion_id, user_id, body)
60
- Podio.connection.post { |req|
61
- req.url("/promotion/#{promotion_id}/assign/#{user_id}")
62
- req.body = body
63
- }
60
+ def assign(promotion_id, user_id)
61
+ Podio.connection.post("/promotion/#{promotion_id}/assign/#{user_id}")
64
62
  end
65
63
 
66
64
  def find_for_context(context_name, options = {})
@@ -0,0 +1,51 @@
1
+ class Podio::PromotionGroup < ActivePodio::Base
2
+
3
+ property :promotion_group_id, :integer
4
+ property :name, :string
5
+ property :description, :string
6
+ property :status, :string
7
+
8
+ alias_method :id, :promotion_group_id
9
+
10
+ class << self
11
+
12
+ def find_all(options={})
13
+ list Podio.connection.get { |req|
14
+ req.url("/promotion_group/", options)
15
+ }.body
16
+ end
17
+
18
+ def find(promotion_group_id)
19
+ member Podio.connection.get("/promotion_group/#{promotion_group_id}").body
20
+ end
21
+
22
+ def create(attributes)
23
+ member Podio.connection.post { |req|
24
+ req.url("/promotion_group/")
25
+ req.body = attributes
26
+ }.body
27
+ end
28
+
29
+ def update(promotion_group_id, attributes)
30
+ puts promotion_group_id, attributes
31
+ member Podio.connection.put { |req|
32
+ req.url("/promotion_group/#{promotion_group_id}")
33
+ req.body = attributes
34
+ }.body
35
+ end
36
+
37
+ def enable(promotion_group_id)
38
+ member Podio.connection.post("/promotion_group/#{promotion_group_id}/enable").body
39
+ end
40
+
41
+ def disable(promotion_group_id)
42
+ member Podio.connection.post("/promotion_group/#{promotion_group_id}/disable").body
43
+ end
44
+
45
+ def delete(promotion_group_id)
46
+ Podio.connection.delete("/promotion_group/#{promotion_group_id}")
47
+ end
48
+
49
+ end
50
+
51
+ end
@@ -0,0 +1,32 @@
1
+ class Podio::PromotionGroupMember < ActivePodio::Base
2
+
3
+ property :promotion_group_id, :integer
4
+ property :member_id, :integer
5
+
6
+ alias_method :id, :promotion_group_id
7
+
8
+ class << self
9
+
10
+ def create(attributes)
11
+ member Podio.connection.post { |req|
12
+ req.url("/promotion_group/#{attributes[:promotion_group_id]}/add")
13
+ req.body = attributes
14
+ }.body
15
+ end
16
+
17
+ def find_all(promotion_group_id, options = {})
18
+ Podio.connection.get { |req|
19
+ req.url("/promotion_group/#{promotion_group_id}/members", options)
20
+ }.body
21
+ end
22
+
23
+ def add_members(promotion_group_id, attributes)
24
+ Podio.connection.post { |req|
25
+ req.url "/promotion_group/#{promotion_group_id}/members/add"
26
+ req.body = attributes
27
+ }.status
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -44,8 +44,10 @@ class Podio::Rating < ActivePodio::Base
44
44
  end
45
45
 
46
46
  # @see https://developers.podio.com/doc/comments/get-who-liked-a-comment-29007011
47
- def liked_by(ref_type, ref_id)
48
- Podio.connection.get("/rating/#{ref_type}/#{ref_id}/liked_by/").body.map{|values| Podio::Contact.new(values)}
47
+ def liked_by(ref_type, ref_id, options={})
48
+ Podio.connection.get { |req|
49
+ req.url("/rating/#{ref_type}/#{ref_id}/liked_by/", options)
50
+ }.body.map{|values| Podio::Contact.new(values)}
49
51
  end
50
52
 
51
53
  # @see https://developers.podio.com/doc/ratings/get-like-count-32161225
@@ -21,7 +21,7 @@ class Podio::Reference < ActivePodio::Base
21
21
  end
22
22
 
23
23
  # @see https://developers.podio.com/doc/reference/search-references-13312595
24
- def search(target, query, limit, target_params = nil)
24
+ def search(target, query, limit, target_params = nil, subfield = nil)
25
25
  response = Podio.connection.post do |req|
26
26
  req.url "/reference/search"
27
27
  req.body = {
@@ -30,6 +30,7 @@ class Podio::Reference < ActivePodio::Base
30
30
  :limit => limit
31
31
  }
32
32
  req.body[:target_params] = target_params if target_params.present?
33
+ req.body[:subfield] = subfield if subfield.present?
33
34
  end
34
35
  response.body
35
36
  end
@@ -18,6 +18,7 @@ class Podio::Space < ActivePodio::Base
18
18
  property :subscribed, :boolean
19
19
  property :privacy, :string
20
20
  property :auto_join, :boolean
21
+ property :archived, :boolean
21
22
  property :type, :string
22
23
  property :premium, :boolean
23
24
  property :last_activity_on, :datetime
@@ -75,8 +76,8 @@ class Podio::Space < ActivePodio::Base
75
76
  end
76
77
 
77
78
  # @see https://developers.podio.com/doc/spaces/get-space-22389
78
- def find(id)
79
- member Podio.connection.get("/space/#{id}").body
79
+ def find(id, params={})
80
+ member Podio.connection.get("/space/#{id}", params).body
80
81
  end
81
82
 
82
83
  # @see https://developers.podio.com/doc/space-members/join-space-1927286
@@ -94,8 +95,9 @@ class Podio::Space < ActivePodio::Base
94
95
  member Podio.connection.get("/space/url?url=#{ERB::Util.url_encode(url)}").body
95
96
  end
96
97
 
97
- def find_by_url_slug(org_slug, space_slug)
98
- member Podio.connection.get("/space/url", :org_slug => org_slug, :space_slug => space_slug).body
98
+ def find_by_url_slug(org_slug, space_slug, params={})
99
+ params = params.merge(:org_slug => org_slug, :space_slug => space_slug)
100
+ member Podio.connection.get("/space/url", params).body
99
101
  end
100
102
 
101
103
  def find_all_for_org(org_id)
@@ -123,7 +125,11 @@ class Podio::Space < ActivePodio::Base
123
125
  end
124
126
 
125
127
  def get_count(org_id)
126
- Podio.connection.get("/space/org/#{org_id}").body['count']
128
+ Podio.connection.get("/space/org/#{org_id}/count").body['count']
129
+ end
130
+
131
+ def get_available_seats(space_id)
132
+ Podio.connection.get("/space/#{space_id}/available").body
127
133
  end
128
134
 
129
135
  end
@@ -35,5 +35,41 @@ class Podio::Tag < ActivePodio::Base
35
35
  text = CGI.escape(text) if text
36
36
  Podio.connection.get("/tag/app/#{app_id}/top/?limit=#{limit}&text=#{text}").body
37
37
  end
38
+
39
+ # @see https://developers.podio.com/doc/tags/get-tags-on-space-22466
40
+ def find_by_space(space_id, limit, text)
41
+ text = CGI.escape(text) if text
42
+ list Podio.connection.get("/tag/space/#{space_id}/?limit=#{limit}&text=#{text}").body
43
+ end
44
+
45
+ # @see https://developers.podio.com/doc/tags/get-tags-on-organization-48473
46
+ def find_by_org(org_id, limit, text)
47
+ text = CGI.escape(text) if text
48
+ list Podio.connection.get("/tag/org/#{org_id}/?limit=#{limit}&text=#{text}").body
49
+ end
50
+
51
+ # @see https://developers.podio.com/doc/tags/get-objects-on-app-with-tag-22469
52
+ def find_tagged_objects_on_app(app_id, attributes)
53
+ Podio.connection.get("/tag/app/#{app_id}/search/", attributes).body
54
+ end
55
+
56
+ # @see https://developers.podio.com/doc/tags/get-objects-on-space-with-tag-22468
57
+ def find_tagged_objects_on_space(space_id, attributes)
58
+ Podio.connection.get("/tag/space/#{space_id}/search/", attributes).body
59
+ end
60
+
61
+ # @see https://developers.podio.com/doc/tags/get-objects-on-organization-with-tag-48478
62
+ def find_tagged_objects_on_org(org_id, attributes)
63
+ Podio.connection.get("/tag/org/#{org_id}/search/", attributes).body
64
+ end
65
+
66
+ # @see https://developers.podio.com/doc/tags/remove-tag-22465
67
+ def delete(tagable_type, tagable_id, attributes)
68
+ response = Podio.connection.delete do |req|
69
+ req.url("/tag/#{tagable_type}/#{tagable_id}/", attributes)
70
+ end
71
+
72
+ response.status
73
+ end
38
74
  end
39
75
  end