Class: Podio::Application

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

Overview

Instance Attribute Summary

Attributes inherited from ActivePodio::Base

#attributes

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ActivePodio::Base

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

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.activate(id) ⇒ Object



174
175
176
# File 'lib/podio/models/application.rb', line 174

def activate(id)
  Podio.connection.post("/app/#{id}/activate").body
end

.create(attributes) ⇒ Object



119
120
121
122
123
124
125
# File 'lib/podio/models/application.rb', line 119

def create(attributes)
  response = Podio.connection.post do |req|
    req.url "/app/"
    req.body = attributes
  end
  response.body['app_id']
end

.deactivate(id) ⇒ Object



169
170
171
# File 'lib/podio/models/application.rb', line 169

def deactivate(id)
  Podio.connection.post("/app/#{id}/deactivate").body
end

.delete(id) ⇒ Object



179
180
181
# File 'lib/podio/models/application.rb', line 179

def delete(id)
  Podio.connection.delete("/app/#{id}").body
end

.delete_field(app_id, field_id) ⇒ Object



164
165
166
# File 'lib/podio/models/application.rb', line 164

def delete_field(app_id, field_id)
  Podio.connection.delete("/app/#{app_id}/field/#{field_id}").status
end

.dependencies(id) ⇒ Object



195
196
197
# File 'lib/podio/models/application.rb', line 195

def dependencies(id)
  Podio.connection.get("/app/#{id}/dependencies/").body
end

.features(options) ⇒ Object



188
189
190
191
192
# File 'lib/podio/models/application.rb', line 188

def features(options)
  Podio.connection.get { |req|
    req.url("/app/features/", options)
  }.body
end

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



47
48
49
50
51
# File 'lib/podio/models/application.rb', line 47

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

.find_all(options = {}) ⇒ Object



67
68
69
70
71
# File 'lib/podio/models/application.rb', line 67

def find_all(options={})
  list Podio.connection.get { |req|
    req.url("/app/", options)
  }.body
end

.find_all_for_current_user(options = {}) ⇒ Object



74
75
76
77
78
# File 'lib/podio/models/application.rb', line 74

def find_all_for_current_user(options={})
  list Podio.connection.get { |req|
    req.url("/app/v2/", options)
  }.body
end

.find_all_for_space(space_id, options = {}) ⇒ Object



95
96
97
98
99
# File 'lib/podio/models/application.rb', line 95

def find_all_for_space(space_id, options = {})
  list Podio.connection.get { |req|
    req.url("/app/space/#{space_id}/", options)
  }.body
end

.find_by_org_space_and_app_labels(org_label, space_label, app_label, options = {}) ⇒ Object



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

def find_by_org_space_and_app_labels(org_label, space_label, app_label, options={})
  member Podio.connection.get { |req|
    req.url("/app/org/#{org_label}/space/#{space_label}/#{app_label}", options)
  }.body
end

.find_by_url_label(space_id, url_label, options = {}) ⇒ Object



54
55
56
57
58
# File 'lib/podio/models/application.rb', line 54

def find_by_url_label(space_id, url_label, options={})
  member Podio.connection.get { |req|
    req.url("/app/space/#{space_id}/#{url_label}", options)
  }.body
end

.find_top(options = {}) ⇒ Object



81
82
83
84
85
# File 'lib/podio/models/application.rb', line 81

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

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



88
89
90
91
92
# File 'lib/podio/models/application.rb', line 88

def find_top_for_org(org_id, options={})
  list Podio.connection.get { |req|
    req.url("/app/org/#{org_id}/top/", options)
  }.body
end

.get_calculations(app_id) ⇒ Object



102
103
104
105
106
# File 'lib/podio/models/application.rb', line 102

def get_calculations(app_id)
  list Podio.connection.get { |req|
    req.url("/app/#{app_id}/calculation/", {})
  }.body
end

.install(app_id, attributes) ⇒ Object



155
156
157
158
159
160
161
# File 'lib/podio/models/application.rb', line 155

def install(app_id, attributes)
  response = Podio.connection.post do |req|
    req.url "/app/#{app_id}/install"
    req.body = attributes
  end
  response.body['app_id']
end

.install_on_mobile(id) ⇒ Object



183
184
185
# File 'lib/podio/models/application.rb', line 183

def install_on_mobile(id)
  Podio.connection.post("/mobile/install_app/#{id}").body
end

.regenerate_apptoken(app_id) ⇒ Object



206
207
208
# File 'lib/podio/models/application.rb', line 206

def regenerate_apptoken(app_id)
  Podio.connection.post("/app/#{app_id}/token/regenerate").body
end

.search_icons(query) ⇒ Object



211
212
213
214
215
# File 'lib/podio/models/application.rb', line 211

def search_icons(query)
  Podio.connection.get { |req|
    req.url("/app/icon/search", {:query => query})
  }.body
end

.space_dependencies(space_id) ⇒ Object



200
201
202
203
204
# File 'lib/podio/models/application.rb', line 200

def space_dependencies(space_id)
  result = Podio.connection.get("/space/#{space_id}/dependencies/").body
  result['apps'] = result['apps'].collect { |app| Application.new(app) }
  result
end

.update(app_id, attributes) ⇒ Object



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

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

.update_description(app_id, description) ⇒ Object



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

def update_description(app_id, description)
  response = Podio.connection.put do |req|
    req.url "/app/#{app_id}/description"
    req.body = {:description => description}
  end
  response.status
end

.update_order(space_id, app_ids = []) ⇒ Object



109
110
111
112
113
114
115
116
# File 'lib/podio/models/application.rb', line 109

def update_order(space_id, app_ids = [])
  response = Podio.connection.put do |req|
    req.url "/app/space/#{space_id}/order"
    req.body = app_ids
  end

  response.body
end

.update_usage(app_id, usage) ⇒ Object



146
147
148
149
150
151
152
# File 'lib/podio/models/application.rb', line 146

def update_usage(app_id, usage)
  response = Podio.connection.put do |req|
    req.url "/app/#{app_id}/usage"
    req.body = {:usage => usage}
  end
  response.status
end

Instance Method Details

#item_nameObject



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

def item_name
  self[:item_name] || self.config['item_name']
end

#nameObject



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

def name
  self[:name] || self.config['name']
end