Class: CodasetAPI::Ticket

Inherits:
Base
  • Object
show all
Defined in:
lib/codaset/codaset-api.rb

Overview

Find tickets

CodasetAPI::Ticket.find(:all, :params => { :project_id => 44 })
CodasetAPI::Ticket.find(:all, :params => { :project_id => 44, :q => "status:closed" })

project = CodasetAPI::Project.find(44)
project.tickets
project.tickets(:q => "status:closed")
project.tickets(:params => {:status => 'closed'})

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

inherited

Class Method Details

.element_path(id, prefix_options = {}, query_options = nil) ⇒ Object

begin monkey patches



191
192
193
194
# File 'lib/codaset/codaset-api.rb', line 191

def self.element_path(id, prefix_options = {}, query_options = nil)
   prefix_options, query_options = split_options(prefix_options) if query_options.nil?
   "#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}#{query_string(query_options)}"
end

Instance Method Details

#createObject



214
215
216
217
218
219
# File 'lib/codaset/codaset-api.rb', line 214

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



196
197
198
# File 'lib/codaset/codaset-api.rb', line 196

def element_path(options = nil)
  self.class.element_path(self.id, options)
end

#encode(options = {}) ⇒ Object



200
201
202
203
204
205
206
# File 'lib/codaset/codaset-api.rb', line 200

def encode(options={})
  val = []
  attributes.each_pair do |key, value|
    val << "values[#{URI.escape key}]=#{URI.escape value}" rescue nil
  end
  val.join('&')
end

#updateObject



208
209
210
211
212
# File 'lib/codaset/codaset-api.rb', line 208

def update
    connection.put(element_path(prefix_options) + '?' + encode, nil, self.class.headers).tap do |response|
       load_attributes_from_response(response)
    end
end