cats_core 1.1.13 → 1.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7f1333a43773f878d178ee7f3daad6af88994875ac5fc4584e4b8ebf3fb0c87
4
- data.tar.gz: c37663a1516cbc7847360a10efa6dfbf64d2f743b59beebc0916d0ec4b0766fd
3
+ metadata.gz: 849c78b04184a39a42337994d2cf68e4be874dff4e0420e34a890ce0584658cd
4
+ data.tar.gz: 85b1a1ff55a91d353329eaebb38e5ff19bb2590bfa8ab2942dd5feb31a7b11c6
5
5
  SHA512:
6
- metadata.gz: 6b15f41ff65b916ae635fb575c95a24d6f7982fd79b517581f47f7cf09e50b9f90953df6b8d41e5776857807ee7cf480d9d7169365c57f5f4260ae73ea11620e
7
- data.tar.gz: 428f6deffeafecd95811843973aaae91567543b408955d556c35049f0cf94bc1b2addcd0a2e417728e7fd8cb5190ac8cdb930568570ae3ffa5f761189bf58732
6
+ metadata.gz: 18cb896b37d1c7449e8955e7209bcf663e02b0e43d42fe0c7137f9f8a0e4be5ed1f664d8bc2b2f4e777e15b6f8b6c8efb57114cdb283cdffbc8f51dff6c75d7a
7
+ data.tar.gz: e477156c701bee3b6dfb5c337fb344bcb1e86d16978e0208e8a9616a7721af364ff63862045f85db2ac825dd8fc876b0198ec87f857a4844064cdf7336a8a315
@@ -1,15 +1,20 @@
1
1
  module Cats
2
2
  module Core
3
3
  class UsersController < ApplicationController
4
- before_action :set_user, only: %i[stores warehouses]
4
+ before_action :set_user, only: %i[stores warehouse hub]
5
5
 
6
6
  def stores
7
7
  data = ActiveModelSerializers::SerializableResource.new(@user.stores)
8
8
  render json: { success: true, data: data }
9
9
  end
10
10
 
11
- def warehouses
12
- data = ActiveModelSerializers::SerializableResource.new(@user.warehouses)
11
+ def warehouse
12
+ data = ActiveModelSerializers::SerializableResource.new(@user.warehouse)
13
+ render json: { success: true, data: data }
14
+ end
15
+
16
+ def hub
17
+ data = ActiveModelSerializers::SerializableResource.new(@user.hub)
13
18
  render json: { success: true, data: data }
14
19
  end
15
20
 
@@ -13,10 +13,10 @@ module Cats
13
13
  validates :email, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
14
14
  validate :validate_phone_number
15
15
 
16
- def warehouses
17
- return unless details.key?('warehouses')
16
+ def warehouse
17
+ return unless details.key?('warehouse')
18
18
 
19
- Cats::Core::Location.where(id: details['warehouses'], location_type: Cats::Core::Location::WAREHOUSE)
19
+ Cats::Core::Location.find_by(id: details['warehouse'], location_type: Cats::Core::Location::WAREHOUSE)
20
20
  end
21
21
 
22
22
  def stores
@@ -25,6 +25,12 @@ module Cats
25
25
  Cats::Core::Store.where(id: details['stores'])
26
26
  end
27
27
 
28
+ def hub
29
+ return unless details.key?('hub')
30
+
31
+ Cats::Core::Location.find_by(id: details['hub'], location_type: Cats::Core::Location::HUB)
32
+ end
33
+
28
34
  def validate_phone_number
29
35
  return unless phone_number.present?
30
36
 
data/config/routes.rb CHANGED
@@ -20,7 +20,8 @@ Cats::Core::Engine.routes.draw do
20
20
  resources :users do
21
21
  member do
22
22
  get 'stores', controller: :users, action: :stores
23
- get 'warehouses', controller: :users, action: :warehouses
23
+ get 'warehouse', controller: :users, action: :warehouse
24
+ get 'hub', controller: :users, action: :hub
24
25
  end
25
26
  end
26
27
 
@@ -6,7 +6,7 @@ class CreateCatsCoreUsers < ActiveRecord::Migration[6.1]
6
6
  t.string :email, unique: true
7
7
  t.boolean :active, null: false, default: true
8
8
  t.string :password_digest
9
- t.jsonb :details
9
+ t.jsonb :details, null: false, default: {}
10
10
  t.string :phone_number
11
11
  t.references :application_module,
12
12
  null: false,
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.1.13'.freeze
3
+ VERSION = '1.1.14'.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.1.13
4
+ version: 1.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.