learnworlds 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -2
- data/Gemfile.lock +1 -1
- data/README.md +13 -5
- data/lib/learn_worlds/resources/single_sign_on_resource.rb +4 -0
- data/lib/learn_worlds/resources/user_resource.rb +10 -0
- data/lib/learn_worlds/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 350cb9098ffa9460535ace6d8c8c29988a5a924239c1ab654a682e6a9801f0e4
|
4
|
+
data.tar.gz: f5ba89153ac72c241790d9bab9691c5cb182ee3c92d03dccdb16c1062410192c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a724e288972dae917f0a1a2ce7e70fe2d83367d19a749a456f54a5a9991015f5ab307a50b26e9f225cfdc18a23ee54c9134573fa3cc1efd045592dbca100d8
|
7
|
+
data.tar.gz: 6f425e3d59b69b148479a2bc21e286000d83ea48d08bcb13a5fa5550b108ca58483367f4e2b484990c8f591a5e41f5da988a567df87ff3719c8004db9db6ef87
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.2] - 2022-08-09
|
4
|
+
|
5
|
+
- Add possibility to sso with user id instead of email
|
6
|
+
|
7
|
+
## [0.2.1] - 2022-08-09
|
8
|
+
|
9
|
+
- Add attach and detach methods to the user resource
|
10
|
+
|
3
11
|
## [0.2.0] - 2022-07-11
|
4
12
|
|
5
|
-
- Adds single sign on
|
13
|
+
- Adds single sign on functionality
|
6
14
|
- Default client secret to nil if not passed and not on env vars
|
7
15
|
|
8
16
|
## [0.1.3] - 2022-07-08
|
@@ -23,4 +31,3 @@
|
|
23
31
|
- Initial release
|
24
32
|
- Adds a basic structure to aid future developments
|
25
33
|
- Adds methods to interact with the user resource ( list, create, update, find and enroll )
|
26
|
-
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
18
18
|
|
19
19
|
### Authentication with Client Credentials grant
|
20
20
|
|
21
|
-
To authenticate with client credentials grant you need to
|
21
|
+
To authenticate with client credentials grant you need to
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
client = LearnWorlds::Client.new(
|
@@ -42,13 +42,13 @@ client = LearnWorlds::Client.new(
|
|
42
42
|
|
43
43
|
you can also save some lines of code if you set the folloing env vars `LEARN_WORLDS_CLIENT_ID`, `LEARN_WORLDS_CLIENT_SECRET`, `LEARN_WORLDS_BASE_URL`
|
44
44
|
|
45
|
-
Once that is done, you can initialize the client with
|
45
|
+
Once that is done, you can initialize the client with
|
46
46
|
|
47
47
|
```ruby
|
48
48
|
client = LearnWorlds::Client.new
|
49
49
|
```
|
50
50
|
|
51
|
-
Everytime you call `authenticate('client_credentials')` a new request will be made to Learn Worlds.
|
51
|
+
Everytime you call `authenticate('client_credentials')` a new request will be made to Learn Worlds.
|
52
52
|
If you want to avoid that you can define custom getters and setters for the access token via the configuration.
|
53
53
|
|
54
54
|
You can use that to add logic to persist or get the access token on your side and you can also add some logic to verify if the access token is still valid.
|
@@ -57,7 +57,7 @@ For example:
|
|
57
57
|
|
58
58
|
```ruby
|
59
59
|
LearnWorlds.configure do |config|
|
60
|
-
|
60
|
+
|
61
61
|
# return nil if access_token is invalid and you want to proceed with the authentication process
|
62
62
|
config.retrieve_access_token_method = ->() { Rails.cache.fetch("learnworlds_access_token") }
|
63
63
|
|
@@ -82,6 +82,13 @@ client.user.find(user_id: 'user_id')
|
|
82
82
|
|
83
83
|
# enrolls a user on a course
|
84
84
|
client.user.enroll(user_id: 'user_id', product_id: 'course_id', product_type: 'course', price: 0)
|
85
|
+
|
86
|
+
# attaches tags to an user
|
87
|
+
client.user.attach_tags(user_id: 'user_id', tags: ['tag1', 'tag2'])
|
88
|
+
|
89
|
+
# detaches tags from an user
|
90
|
+
client.user.detach_tags(user_id: 'user_id', tags: ['tag1', 'tag2'])
|
91
|
+
|
85
92
|
```
|
86
93
|
|
87
94
|
### SSO Resource
|
@@ -90,8 +97,9 @@ client.user.enroll(user_id: 'user_id', product_id: 'course_id', product_type: 'c
|
|
90
97
|
|
91
98
|
client.sso.redirect(email: 'test@test.com', redirect_to 'xyz.learnworlds.com/courses')
|
92
99
|
|
93
|
-
|
100
|
+
client.sso.redirect_with_id(user_id: 'learnworlds_user_id', redirect_to 'xyz.learnworlds.com/courses')
|
94
101
|
|
102
|
+
```
|
95
103
|
|
96
104
|
## Development
|
97
105
|
|
@@ -5,5 +5,9 @@ module LearnWorlds
|
|
5
5
|
def redirect(email:, redirect_to:)
|
6
6
|
post_request(SSO_ENDPOINT, { email: email, redirectUrl: redirect_to }).body['url']
|
7
7
|
end
|
8
|
+
|
9
|
+
def redirect_with_id(user_id:, redirect_to:)
|
10
|
+
post_request(SSO_ENDPOINT, { user_id: user_id, redirectUrl: redirect_to }).body['url']
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
@@ -24,5 +24,15 @@ module LearnWorlds
|
|
24
24
|
post_request("#{ENDPOINT}/#{user_id}/enrollment", attributes)
|
25
25
|
true
|
26
26
|
end
|
27
|
+
|
28
|
+
def attach_tags(user_id:, tags:)
|
29
|
+
put_request("#{ENDPOINT}/#{user_id}/tags", tags: tags, action: 'attach')
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def detach_tags(user_id:, tags:)
|
34
|
+
put_request("#{ENDPOINT}/#{user_id}/tags", tags: tags, action: 'detach')
|
35
|
+
true
|
36
|
+
end
|
27
37
|
end
|
28
38
|
end
|
data/lib/learn_worlds/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: learnworlds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nuno Correia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|