Class: Logistics::Core::CurrencyRatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/logistics/core/currency_rates_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/logistics/core/currency_rates_controller.rb', line 13

def create
  rate = CurrencyRate.new rate_params
  if rate.save
    response = Mks::Common::MethodResponse.new(true, 'Currency rate saved successfully!', nil, nil, nil)
    render json: response
  else
    errors = Mks::Common::Util.error_messages rate, 'Currency rate'
    response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
    render json: response
  end

end

#ratesObject



6
7
8
9
10
11
# File 'app/controllers/logistics/core/currency_rates_controller.rb', line 6

def rates
  currency = Currency.find(params[:id])
  rates = currency.currency_rates.order('rate_date DESC')
  response = Mks::Common::MethodResponse.new(true, nil, rates, nil, nil)
  render json: response
end

#updateObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/logistics/core/currency_rates_controller.rb', line 26

def update
  if @rate.update(rate_params)
    response = Mks::Common::MethodResponse.new(true, 'Currency rate updated successfully!', nil, nil, nil)
    render json: response
  else
    errors = Mks::Common::Util.error_messages @rate, 'Currency rate'
    response = Mks::Common::MethodResponse.new(false, nil, nil, errors, nil)
    render json: response
  end

end