Class: Podio::Application

Inherits:
ActivePodio::Base show all
Defined in:
lib/podio/models/application.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

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

.activate(id) ⇒ Object



126
127
128
# File 'lib/podio/models/application.rb', line 126

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

.create(attributes) ⇒ Object



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

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

.deactivate(id) ⇒ Object



122
123
124
# File 'lib/podio/models/application.rb', line 122

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

.delete(id) ⇒ Object



130
131
132
# File 'lib/podio/models/application.rb', line 130

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

.delete_field(app_id, field_id) ⇒ Object



118
119
120
# File 'lib/podio/models/application.rb', line 118

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

.dependencies(id) ⇒ Object



144
145
146
# File 'lib/podio/models/application.rb', line 144

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

.features(options) ⇒ Object



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

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

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



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

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

.find_all(options = {}) ⇒ Object



50
51
52
53
54
# File 'lib/podio/models/application.rb', line 50

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

.find_all_for_current_user(options = {}) ⇒ Object



56
57
58
59
60
# File 'lib/podio/models/application.rb', line 56

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



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

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

.find_by_url_label(space_id, url_label) ⇒ Object



46
47
48
# File 'lib/podio/models/application.rb', line 46

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

.find_top(options = {}) ⇒ Object



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

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

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



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

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



79
80
81
82
83
# File 'lib/podio/models/application.rb', line 79

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

.install(app_id, attributes) ⇒ Object



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

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



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

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

.space_dependencies(space_id) ⇒ Object



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

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

.update(app_id, attributes) ⇒ Object



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

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

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



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

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

Instance Method Details

#item_nameObject



35
36
37
# File 'lib/podio/models/application.rb', line 35

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

#nameObject



31
32
33
# File 'lib/podio/models/application.rb', line 31

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