Class: Podio::AppStoreShare

Inherits:
ActivePodio::Base show all
Defined in:
lib/podio/models/app_store_share.rb

Overview

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActivePodio::Base

#==, #[], #[]=, #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

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.create(attributes) ⇒ Object



58
59
60
61
62
63
64
65
# File 'lib/podio/models/app_store_share.rb', line 58

def create(attributes)
  response = Podio.connection.post do |req|
    req.url "/app_store/"
    req.body = attributes
  end

  response.body['share_id']
end

.destroy(id) ⇒ Object



76
77
78
79
80
# File 'lib/podio/models/app_store_share.rb', line 76

def destroy(id)
  response = Podio.connection.delete do |req|
    req.url "/app_store/#{id}"
  end
end

.find(id, options = {}) ⇒ Object



92
93
94
95
96
# File 'lib/podio/models/app_store_share.rb', line 92

def find(id, options = {})
  member Podio.connection.get { |req|
    req.url "/app_store/#{id}/v2", options
  }.body
end

.find_all_by_category(share_type, category_id, options = {}) ⇒ Object



144
145
146
147
148
# File 'lib/podio/models/app_store_share.rb', line 144

def find_all_by_category(share_type, category_id, options = {})
  shares_collection Podio.connection.get { |req|
    req.url("/app_store/#{share_type}/category/#{category_id}/", options)
  }.body
end

.find_all_by_reference(ref_type, ref_id) ⇒ Object



134
135
136
# File 'lib/podio/models/app_store_share.rb', line 134

def find_all_by_reference(ref_type, ref_id)
  list Podio.connection.get("/app_store/#{ref_type}/#{ref_id}/").body
end

.find_all_by_search(share_type, options = {}) ⇒ Object



150
151
152
153
154
# File 'lib/podio/models/app_store_share.rb', line 150

def find_all_by_search(share_type, options = {})
  shares_collection Podio.connection.get { |req|
    req.url("/app_store/#{share_type}/search/", options)
  }.body
end

.find_all_own(share_type, options = {}) ⇒ Object



99
100
101
102
103
# File 'lib/podio/models/app_store_share.rb', line 99

def find_all_own(share_type, options = {})
  shares_collection Podio.connection.get { |req|
    req.url "/app_store/#{share_type}/own/", options
  }.body
end

.find_all_private_for_org(share_type, org_id, options = {}) ⇒ Object



105
106
107
108
109
# File 'lib/podio/models/app_store_share.rb', line 105

def find_all_private_for_org(share_type, org_id, options = {})
  shares_collection Podio.connection.get { |req|
    req.url "/app_store/#{share_type}/org/#{org_id}/", options
  }.body
end

.find_all_public_for_org(share_type, org_url, options = {}) ⇒ Object



111
112
113
114
115
# File 'lib/podio/models/app_store_share.rb', line 111

def find_all_public_for_org(share_type, org_url, options = {})
  shares_collection Podio.connection.get { |req|
    req.url "/app_store/#{share_type}/org/#{org_url}/", options
  }.body
end


118
119
120
121
122
# File 'lib/podio/models/app_store_share.rb', line 118

def find_all_recommended_for_area(area, options = {})
  list Podio.connection.get { |req|
    req.url("/app_store/recommended/#{area}/", options)
  }.body['shares']
end

.find_top(share_type, options = {}) ⇒ Object



138
139
140
141
142
# File 'lib/podio/models/app_store_share.rb', line 138

def find_top(share_type, options = {})
  shares_collection Podio.connection.get { |req|
    req.url("/app_store/#{share_type}/top/", options)
  }.body
end

.install(share_id, space_id, dependencies, social = true) ⇒ Object



83
84
85
86
87
88
89
90
# File 'lib/podio/models/app_store_share.rb', line 83

def install(share_id, space_id, dependencies, social = true)
  response = Podio.connection.post do |req|
    req.url "/app_store/#{share_id}/install/v2"
    req.body = {:space_id => space_id, :dependencies => dependencies, :social => social}
  end

  response.body
end


124
125
126
127
128
129
130
131
# File 'lib/podio/models/app_store_share.rb', line 124

def set_recommended_for_area(area, share_ids)
  response = Podio.connection.put do |req|
    req.url "/app_store/recommended/#{area}/"
    req.body = share_ids
  end

  response.status
end

.update(id, attributes) ⇒ Object



68
69
70
71
72
73
# File 'lib/podio/models/app_store_share.rb', line 68

def update(id, attributes)
  response = Podio.connection.put do |req|
    req.url "/app_store/#{id}"
    req.body = attributes
  end
end

Instance Method Details

#api_friendly_ref_typeObject



51
52
53
# File 'lib/podio/models/app_store_share.rb', line 51

def api_friendly_ref_type
  'share'
end

#createObject



37
38
39
# File 'lib/podio/models/app_store_share.rb', line 37

def create
  self.share_id = self.class.create(self.attributes)
end

#destroyObject



42
43
44
# File 'lib/podio/models/app_store_share.rb', line 42

def destroy
  self.class.destroy(self.share_id)
end

#install(space_id, dependencies, social = true) ⇒ Object



47
48
49
# File 'lib/podio/models/app_store_share.rb', line 47

def install(space_id, dependencies, social = true)
  self.class.install(self.share_id, space_id, dependencies, social)
end