module Fakecrm::Accounts

Public Class Methods

included(base) click to toggle source
# File lib/fakecrm/server/accounts.rb, line 4
def self.included(base)
  base.class_eval do

    get '/crm/api/accounts.?:format?' do
      fetch_many(Account)
    end

    get '/crm/api/accounts/search.?:format?' do |format|
      search(Account, [:account_group], [:name], params[:sort_by], params[:sort_order])
    end

    get '/crm/api/accounts/:id.?:format?' do |id, format|
      fetch_one(Account, id.to_i)
    end

    put '/crm/api/accounts/:id.?:format?' do |id, format|
      update_one(Account, id.to_i, params["account"])
    end

    post '/crm/api/accounts.?:format?' do
      create_one(Account, params["account"])
    end

    delete '/crm/api/accounts/:id.?:format?' do |id, format|
      destroy_one(Account, id.to_i)
    end

  end
end