Class: Podio::AppStoreShare

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

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes, #error_code, #error_message, #error_parameters, #error_propagate

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActivePodio::Base

#==, #[], #[]=, #as_json, collection, delegate_to_hash, handle_api_errors_for, has_many, has_one, #hash, #initialize, #initialize_attributes, list, member, #new_record?, output_attribute_as_json, #persisted?, property, #to_param

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.create(attributes) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/podio/models/app_store_share.rb', line 52

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



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

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

.find(id) ⇒ Object



83
84
85
# File 'lib/podio/models/app_store_share.rb', line 83

def find(id)
  member Podio.connection.get("/app_store/#{id}/v2").body
end

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



130
131
132
133
134
# File 'lib/podio/models/app_store_share.rb', line 130

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

.find_all_by_reference(ref_type, ref_id) ⇒ Object



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

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(options = {}) ⇒ Object



136
137
138
139
140
# File 'lib/podio/models/app_store_share.rb', line 136

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

.find_all_own(options = {}) ⇒ Object



87
88
89
90
91
# File 'lib/podio/models/app_store_share.rb', line 87

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

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



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

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

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



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

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


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

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(options = {}) ⇒ Object



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

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

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



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

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


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

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



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

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



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

def api_friendly_ref_type
  'share'
end

#createObject



33
34
35
# File 'lib/podio/models/app_store_share.rb', line 33

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

#destroyObject



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

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

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



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

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