/
subscription.rb
37 lines (31 loc) · 1.32 KB
/
subscription.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# @see https://developers.podio.com/doc/subscriptions
class Podio::Subscription < ActivePodio::Base
property :started_on, :datetime
property :notifications, :integer
property :ref, :hash
class << self
# @see https://developers.podio.com/doc/subscriptions/get-subscription-by-id-22446
def find(id)
member Podio.connection.get("/subscription/#{id}").body
end
# @see https://developers.podio.com/doc/subscriptions/get-subscription-by-reference-22408
def find_by_reference(ref_type, ref_id)
member Podio.connection.get("/subscription/#{ref_type}/#{ref_id}").body
end
# @see https://developers.podio.com/doc/subscriptions/subscribe-22409
def create(ref_type, ref_id)
Podio.connection.post("/subscription/#{ref_type}/#{ref_id}").body['subscription_id']
end
# @see https://developers.podio.com/doc/subscriptions/unsubscribe-by-id-22445
def delete(id)
Podio.connection.delete("/subscription/#{id}")
end
# @see https://developers.podio.com/doc/subscriptions/unsubscribe-by-reference-22410
def delete_by_reference(ref_type, ref_id)
Podio.connection.delete("/subscription/#{ref_type}/#{ref_id}")
end
def find_subscribers_by_reference(ref_type, ref_id)
User.list Podio.connection.get("/subscription/#{ref_type}/#{ref_id}/user").body
end
end
end