Class: Podio::Space

Inherits:
ActivePodio::Base show all
Includes:
ActivePodio::Updatable
Defined in:
lib/podio/models/space.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, list, member, #new_record?, #persisted?, property, #to_param

Constructor Details

This class inherits a constructor from ActivePodio::Base

Class Method Details

.create(attributes) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/podio/models/space.rb', line 36

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

  response.body
end

.delete(id) ⇒ Object



49
50
51
# File 'lib/podio/models/space.rb', line 49

def delete(id)
  Podio.connection.delete("/space/#{id}").status
end

.find(id) ⇒ Object



53
54
55
# File 'lib/podio/models/space.rb', line 53

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

.find_all_for_org(org_id) ⇒ Object



66
67
68
# File 'lib/podio/models/space.rb', line 66

def find_all_for_org(org_id)
  list Podio.connection.get("/org/#{org_id}/space/").body
end

.find_by_url(url, info = false) ⇒ Object



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

def find_by_url(url, info = false)
  info = info ? 1 : 0
  member Podio.connection.get("/space/url?url=#{ERB::Util.url_encode(url)}&info=#{info}").body
end

.find_open_for_org(org_id) ⇒ Object



70
71
72
# File 'lib/podio/models/space.rb', line 70

def find_open_for_org(org_id)
  list Podio.connection.get("/space/org/#{org_id}/available/").body
end

.join(space_id) ⇒ Object



57
58
59
# File 'lib/podio/models/space.rb', line 57

def join(space_id)
  Podio.connection.post("/space/#{space_id}/join").body
end

.update(space_id, attributes) ⇒ Object



45
46
47
# File 'lib/podio/models/space.rb', line 45

def update(space_id, attributes)
  Podio.connection.put("/space/#{space_id}", attributes).status
end

.validate_url_label(org_id, url_label) ⇒ Object



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

def validate_url_label(org_id, url_label)
  Podio.connection.post { |req|
    req.url "/space/org/#{org_id}/url/validate"
    req.body = {:url_label => url_label}
  }.body
end

Instance Method Details

#createObject



25
26
27
28
29
# File 'lib/podio/models/space.rb', line 25

def create
  response = Space.create(:org_id => org_id, :name => name, :privacy => self.privacy, :auto_join => self.auto_join)
  self.url = response['url']
  self.space_id = response['space_id']
end

#updateObject



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

def update
  self.class.update(self.space_id, :name => self.name, :post_on_new_app => self.post_on_new_app, :post_on_new_member => self.post_on_new_member, :url_label => self.url_label, :privacy => self.privacy, :auto_join => self.auto_join)
end