ctws 0.1.10.alpha → 0.1.11.alpha

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
  SHA1:
3
- metadata.gz: 98cb9e3607fda4511231f9f9180d3f81e02b7f59
4
- data.tar.gz: a8e035c1836a421281662739e8dc8e48f8352bae
3
+ metadata.gz: ad946770043983270e71fbec6cb469fa8e295f5e
4
+ data.tar.gz: 442d2a1bf4e04fe406569151148943833c337655
5
5
  SHA512:
6
- metadata.gz: 40596c38fd421bc5419c029975e492d4990d0754d42ec753b277ada87af368120b4ac191129e50498acab82a2ee1933babcdbb44e30aae1c29ff36c72eebb6c4
7
- data.tar.gz: d6dc0f03e3991b1a71bb9f045ad9255e9f75bce98b472ad5357ee809b74894b45b7d8fb757eb56c523903869876a5574c63ac1d091895015fa2f92cfc21cb1b9
6
+ metadata.gz: 94ebbc73710ab85587738855253604f0ed5b176b52f21df80ef078d2d7d9b79678d5a4b68d1cbf4ad10e0e71ede77091495ea17a3ec79b68643ec85b1fee5739
7
+ data.tar.gz: 432cf50c15ab1fb6059d8b7558c34e0ad827ed081199355fae986bd187ee6029460fa8c6f047500ca2b32d3fdaa86afcd69519b9243d37fbaa132b28aa830d59
data/README.md CHANGED
@@ -56,9 +56,6 @@ By default the user model is `User` but you can change it by creating or editing
56
56
 
57
57
  ```ruby
58
58
  Ctws.user_class = "Account"
59
-
60
- Ctws.device_class = "DeviceApp" # TODO: documentation
61
- Ctws.profile_class = "Profile" # TODO: documentation
62
59
  ```
63
60
 
64
61
  The application `User` model **must have the `email` attribute**.
@@ -6,8 +6,10 @@ module Ctws
6
6
  # GET /min_app_version
7
7
  def min_app_version
8
8
  min_app_versions = []
9
- MinAppVersion.group(:platform).each do |platform|
10
- min_app_versions << platform.as_jsonapi
9
+ MinAppVersion.all.order(updated_at: :desc).group_by(&:platform).each do |platforms|
10
+ platforms[1].each_with_index do |platform, index|
11
+ min_app_versions << {platforms[0] => platform.as_jsonapi} if index == 0
12
+ end
11
13
  end
12
14
  json_response min_app_versions
13
15
  end
@@ -13,43 +13,14 @@ module Ctws
13
13
  elsif !Ctws.user_validate_with_password
14
14
  auth_token = Ctws::AuthenticateUser.new(ctws_user.email).call
15
15
  end
16
- # response = { message: Ctws::Message.account_created, auth_token: auth_token }
17
16
 
18
- json_response(user_as_jsonapi(ctws_user, auth_token), :created)
17
+ json_response(ctws_user.created_as_jsonapi({"#{ctws_user.model_name.singular}": ctws_user, token: auth_token}), :created)
19
18
  end
20
19
 
21
20
  private
22
21
 
23
- def user_as_jsonapi user, auth_token
24
- [{
25
- type: ActiveModel::Naming.param_key(Ctws.user_class),
26
- id: user.id,
27
- attributes: {
28
- message: Ctws::Message.account_created,
29
- auth_token: auth_token,
30
- created_at: user.created_at
31
- },
32
- relationships: {
33
- device_apps: {
34
- data: [{
35
- type: ActiveModel::Naming.param_key(Ctws.device_class),
36
- id: Ctws.device_class.where("#{Ctws.user_class.name.underscore}_id": user.id).last.id,
37
- attributes: Ctws.device_class.where("#{Ctws.user_class.name.underscore}_id": user.id).last
38
- }]
39
- },
40
- profile: {
41
- data: [{
42
- type: ActiveModel::Naming.param_key(Ctws.profile_class),
43
- id: Ctws.profile_class.where("#{Ctws.user_class.name.underscore}_id": user.id).last.id,
44
- attributes: Ctws.profile_class.where("#{Ctws.user_class.name.underscore}_id": user.id).last
45
- }]
46
- }
47
- }
48
- }]
49
- end
50
-
51
22
  def ctws_user_params
52
23
  params.permit(Ctws.user_class_strong_params)
53
24
  end
54
25
  end
55
- end
26
+ end
@@ -1,6 +1,4 @@
1
1
  Ctws.user_class = "User"
2
- Ctws.device_class = "DeviceApp"
3
- Ctws.profile_class = "Profile"
4
2
  Ctws.user_class_strong_params = [:email, :password, :password_confirmation]
5
3
  Ctws.user_validate_with_password = true
6
4
  Ctws.jwt_expiration_time = 24.hours.from_now
data/lib/ctws/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ctws
2
- VERSION = '0.1.10.alpha'
2
+ VERSION = '0.1.11.alpha'
3
3
  end
data/lib/ctws.rb CHANGED
@@ -2,8 +2,6 @@ require "ctws/engine"
2
2
 
3
3
  module Ctws
4
4
  mattr_accessor :user_class
5
- mattr_accessor :device_class
6
- mattr_accessor :profile_class
7
5
  mattr_accessor :user_class_strong_params
8
6
  mattr_accessor :user_validate_with_password
9
7
  mattr_accessor :jwt_expiration_time
@@ -12,12 +10,6 @@ module Ctws
12
10
  def self.user_class
13
11
  @@user_class.constantize
14
12
  end
15
- def self.device_class
16
- @@device_class.constantize
17
- end
18
- def self.profile_class
19
- @@profile_class.constantize
20
- end
21
13
 
22
14
  def self.jwt_auth_token_attrs
23
15
  # TODO: implement
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ctws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10.alpha
4
+ version: 0.1.11.alpha
5
5
  platform: ruby
6
6
  authors:
7
7
  - Agustí B.R.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-26 00:00:00.000000000 Z
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails