Class: Ishapi::InvoicesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ishapi/invoices_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home, #long_term_token, #test

Instance Method Details

#searchObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/ishapi/invoices_controller.rb', line 5

def search
  authorize! :open_permission, ::Ishapi
  begin
    i = Ish::Invoice.find_by( :number => params[:number] )
    if i.email == params[:email] && i.amount == params[:amount].to_f && i.payments.count == 0
      render :json => { :status => :ok }
    else
      render :status => 404, :json => {} # :json => { :status => 404, :code => 404, :message => 'Not Found1' }
    end
  rescue Mongoid::Errors::DocumentNotFound => e
    puts! e, 'e'
    render :status => 404, :json => {}  #  :json => { :status => 404, :code => 404, :message => 'Not Found1' }
  end
end