module Datacentred module Model class Project < OpenStruct def initialize(params) params.delete("links") if params params["created_at"] = Time.parse params["created_at"] params["updated_at"] = Time.parse params["updated_at"] super(params) end def self.all Request::Projects.list.map{ |project| new(project) } end def self.find(id) new Request::Projects.show(id) end def self.create(params) new Request::Projects.create(params) end def self.update(id, params) new Request::Projects.update(id, params) end def self.remove(id) Request::Projects.destroy(id) end def self.users(id) Request::Projects.list_users(id).map{ |user| new(user) } end def self.add_user(project_id, user_id) Request::Projects.add_user(project_id, user_id) end def self.remove_user(project_id, user_id) Request::Projects.remove_user(project_id, user_id) end end end end