cats_core 1.0.21 → 1.0.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc104d1c83591c9db1a70f89044e124322826738e56a7803c5ae0487421e3f17
4
- data.tar.gz: 4f80cded8f41799a6d77c87f8c920db0eb3ca86f8bad20a230a246ef35a667ca
3
+ metadata.gz: 7847bbf4c0a83ac387d2b9e7bc1f8f4b4ffe184d12f9611ee60c6f14d1fe3078
4
+ data.tar.gz: 319c387eeddbd6342b1b4fe14ea921e7c3e686243feded978cad60d96c9756ad
5
5
  SHA512:
6
- metadata.gz: 067a3510964611f5ab157eb661613082148bbd27b55ce0bd8cf89bea7a6d582099f0f17e44e7b31434acafcff2c68660da58e300c21d381a675a8d38be6c0dec
7
- data.tar.gz: b5068dda8fa207fbaa39282fa106c63a84e291777900c660e177b12ca5709059ef2d9c479ed239ea3a08b924b102846d6e5d944bdbe0a69c3d17a53a20c0f04b
6
+ metadata.gz: 5ec1c786270a96caa0097f2cd8c95d4a14e88b255d2def862f246770c36fd6956fc6b9e401ea931c4a306c0444c1ca9487fd64439769810249730c407b1e2ecb
7
+ data.tar.gz: eafd2a9293936dab8f7130c9428598fdc88fffb4b7a294e3f381fb08f985d9b379e5d268aa340ab5cfce4952da6c6b10b8b4b829cce8309268f48fb26de3b7ba
@@ -0,0 +1,46 @@
1
+ module Cats
2
+ module Core
3
+ class CurrenciesController < ApplicationController
4
+ before_action :set_currency, only: %i[show update]
5
+
6
+ def index
7
+ data = ActiveModelSerializers::SerializableResource.new(Cats::Core::Currency.all)
8
+ render json: { success: true, data: data }
9
+ end
10
+
11
+ def show
12
+ data = ActiveModelSerializers::SerializableResource.new(@currency)
13
+ render json: { success: true, data: data }
14
+ end
15
+
16
+ def create
17
+ obj = Cats::Core::Currency.new(model_params)
18
+ if obj.save
19
+ data = ActiveModelSerializers::SerializableResource.new(obj)
20
+ render json: { success: true, data: data }, status: :created
21
+ else
22
+ render json: { success: false, error: obj.errors.full_messages[0] }, status: :unprocessable_entity
23
+ end
24
+ end
25
+
26
+ def update
27
+ if @currency.update(model_params)
28
+ data = ActiveModelSerializers::SerializableResource.new(@currency)
29
+ render json: { success: true, data: data }
30
+ else
31
+ render json: { success: false, error: @currency.errors.full_messages[0] }, status: :unprocessable_entity
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def set_currency
38
+ @currency = Cats::Core::Currency.find(params[:id])
39
+ end
40
+
41
+ def model_params
42
+ params.require(:payload).permit(:code, :name)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -46,7 +46,7 @@ module Cats
46
46
  end
47
47
 
48
48
  def model_params
49
- params.require('payload').permit(:name, :location_type, :description, :parent_id)
49
+ params.require(:payload).permit(:name, :location_type, :description, :parent_id)
50
50
  end
51
51
  end
52
52
  end
@@ -0,0 +1,3 @@
1
+ class CurrencySerializer < ActiveModel::Serializer
2
+ attributes :id, :code, :name
3
+ end
data/config/routes.rb CHANGED
@@ -33,4 +33,5 @@ Cats::Core::Engine.routes.draw do
33
33
  get 'children'
34
34
  end
35
35
  end
36
+ resources :currencies, except: %i[destroy]
36
37
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.0.21'.freeze
3
+ VERSION = '1.0.22'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.21
4
+ version: 1.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
@@ -219,6 +219,7 @@ files:
219
219
  - app/controllers/cats/core/access_controller.rb
220
220
  - app/controllers/cats/core/application_controller.rb
221
221
  - app/controllers/cats/core/commodity_categories_controller.rb
222
+ - app/controllers/cats/core/currencies_controller.rb
222
223
  - app/controllers/cats/core/locations_controller.rb
223
224
  - app/controllers/cats/core/menus_controller.rb
224
225
  - app/controllers/cats/core/notifications_controller.rb
@@ -261,6 +262,7 @@ files:
261
262
  - app/models/cats/core/user.rb
262
263
  - app/notifications/cats/core/simple_notification.rb
263
264
  - app/serializers/cats/core/commodity_category_serializer.rb
265
+ - app/serializers/cats/core/currency_serializer.rb
264
266
  - app/serializers/cats/core/location_serializer.rb
265
267
  - app/serializers/cats/core/role_menu_serializer.rb
266
268
  - app/services/cats/core/menu_service.rb