Class: CodasetAPI::Project
- Defined in:
- lib/codaset/codaset-api.rb
Overview
Find projects
CodasetAPI::Project.find(:all) # find all projects for the current account.
CodasetAPI::Project.find('my-project') # find individual project by slug
Creating a Project
project = CodasetAPI::Project.new(:name => 'Ninja Whammy Jammy')
project.save
# => true
Updating a Project
project = CodasetAPI::Project.find('my-project')
project.name = "Codaset Issues"
project.public = false
project.save
Finding tickets
project = CodasetAPI::Project.find('my-project')
project.tickets
Class Method Summary collapse
-
.element_path(id, prefix_options = {}, query_options = nil) ⇒ Object
begin monkey patches.
Instance Method Summary collapse
- #create ⇒ Object
- #element_path(options = nil) ⇒ Object
- #encode(options = {}) ⇒ Object
- #id ⇒ Object
-
#tickets(options = {}) ⇒ Object
end monkey patches.
- #update ⇒ Object
Methods inherited from Base
Class Method Details
.element_path(id, prefix_options = {}, query_options = nil) ⇒ Object
begin monkey patches
132 133 134 135 |
# File 'lib/codaset/codaset-api.rb', line 132 def self.element_path(id, = {}, = nil) , = () if .nil? "#{prefix()}#{URI.escape id.to_s}.#{format.extension}#{query_string()}" end |
Instance Method Details
#create ⇒ Object
155 156 157 158 159 160 |
# File 'lib/codaset/codaset-api.rb', line 155 def create connection.post(collection_path + '?' + encode, nil, self.class.headers).tap do |response| self.id = id_from_response(response) load_attributes_from_response(response) end end |
#element_path(options = nil) ⇒ Object
137 138 139 |
# File 'lib/codaset/codaset-api.rb', line 137 def element_path( = nil) self.class.element_path(self.slug, ) end |
#encode(options = {}) ⇒ Object
141 142 143 144 145 146 147 |
# File 'lib/codaset/codaset-api.rb', line 141 def encode(={}) val = [] attributes.each_pair do |key, value| val << "values[#{URI.escape key}]=#{URI.escape value}" rescue nil end val.join('&') end |
#id ⇒ Object
168 169 170 |
# File 'lib/codaset/codaset-api.rb', line 168 def id @attributes['slug'] end |
#tickets(options = {}) ⇒ Object
end monkey patches
164 165 166 |
# File 'lib/codaset/codaset-api.rb', line 164 def tickets( = {}) Ticket.find(:all, :params => .update(:slug => slug)) end |
#update ⇒ Object
149 150 151 152 153 |
# File 'lib/codaset/codaset-api.rb', line 149 def update connection.put(element_path() + '?' + encode, nil, self.class.headers).tap do |response| load_attributes_from_response(response) end end |