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 included from ActivePodio::Updatable

#remove_nil_values, #update_attributes

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

.create(attributes) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/podio/models/space.rb', line 42

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

  response.body
end

.delete(id) ⇒ Object



55
56
57
# File 'lib/podio/models/space.rb', line 55

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

.find(id) ⇒ Object



59
60
61
# File 'lib/podio/models/space.rb', line 59

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

.find_all_for_org(org_id) ⇒ Object



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

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

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



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

def find_all_spaces_for_org(org_id, options={})
  list Podio.connection.get("/org/#{org_id}/all_spaces/", options).body
end

.find_by_url(url) ⇒ Object



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

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

.find_open_for_org(org_id) ⇒ Object



79
80
81
# File 'lib/podio/models/space.rb', line 79

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

.join(space_id) ⇒ Object



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

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

.update(space_id, attributes) ⇒ Object



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

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

.validate_url_label(org_id, url_label) ⇒ Object



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

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



27
28
29
30
31
# File 'lib/podio/models/space.rb', line 27

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

#deleteObject



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

def delete
  self.class.delete(self.id)
end

#updateObject



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

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