Module: Fakecrm::Accounts

Included in:
Server
Defined in:
lib/fakecrm/server/accounts.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fakecrm/server/accounts.rb', line 5

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