Class: Podio::Grant
Instance Attribute Summary
#attributes
Class Method Summary
collapse
-
.count_by_reference(ref_type, ref_id) ⇒ Object
-
.create(ref_type, ref_id, attributes = {}) ⇒ Object
-
.delete(ref_type, ref_id, user_id) ⇒ Object
-
.find_all(ref_type, ref_id, options = {}) ⇒ Object
-
.find_for_user_on_space(space_id, user_id, options = {}) ⇒ Object
-
.find_own(ref_type, ref_id, options = {}) ⇒ Object
-
.find_own_on_org(org_id, options = {}) ⇒ Object
Instance Method Summary
collapse
#==, #[], #[]=, #api_friendly_ref_type, #as_json, collection, delegate_to_hash, has_many, has_one, #hash, #initialize, #initialize_attributes, klass_from_string, list, member, #new_record?, output_attribute_as_json, #parent_model, #persisted?, property, #to_param
Class Method Details
.count_by_reference(ref_type, ref_id) ⇒ Object
55
56
57
|
# File 'lib/podio/models/grant.rb', line 55
def count_by_reference(ref_type, ref_id)
Podio.connection.get("/grant/#{ref_type}/#{ref_id}/count").body['count']
end
|
.create(ref_type, ref_id, attributes = {}) ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/podio/models/grant.rb', line 21
def create(ref_type, ref_id, attributes={})
response = Podio.connection.post do |req|
req.url "/grant/#{ref_type}/#{ref_id}"
req.body = attributes
end
response.body
end
|
.delete(ref_type, ref_id, user_id) ⇒ Object
50
51
52
|
# File 'lib/podio/models/grant.rb', line 50
def delete(ref_type, ref_id, user_id)
Podio.connection.delete("grant/#{ref_type}/#{ref_id}/#{user_id}").body
end
|
.find_all(ref_type, ref_id, options = {}) ⇒ Object
43
44
45
46
47
|
# File 'lib/podio/models/grant.rb', line 43
def find_all(ref_type, ref_id, options = {})
list Podio.connection.get { |req|
req.url("grant/#{ref_type}/#{ref_id}/", options)
}.body
end
|
.find_for_user_on_space(space_id, user_id, options = {}) ⇒ Object
60
61
62
63
64
|
# File 'lib/podio/models/grant.rb', line 60
def find_for_user_on_space(space_id, user_id, options = {})
list Podio.connection.get { |req|
req.url("/grant/space/#{space_id}/user/#{user_id}/", options)
}.body
end
|
.find_own(ref_type, ref_id, options = {}) ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/podio/models/grant.rb', line 31
def find_own(ref_type, ref_id, options = {})
response = Podio.connection.get { |req|
req.url("/grant/#{ref_type}/#{ref_id}/own", options)
}
if response.status == 200
member response.body
else
nil
end
end
|
.find_own_on_org(org_id, options = {}) ⇒ Object
67
68
69
70
71
|
# File 'lib/podio/models/grant.rb', line 67
def find_own_on_org(org_id, options = {})
list Podio.connection.get { |req|
req.url("/grant/org/#{org_id}/own/", options)
}.body
end
|
Instance Method Details
#save ⇒ Object
15
16
17
|
# File 'lib/podio/models/grant.rb', line 15
def save
self.class.create(self.ref_type, self.ref_id, self.attributes)
end
|