learnworlds 0.1.2 → 0.2.1
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 +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +1 -1
- data/README.md +15 -0
- data/lib/learn_worlds/client.rb +5 -1
- data/lib/learn_worlds/objects/{user.rb → user_object.rb} +1 -1
- data/lib/learn_worlds/resources/single_sign_on_resource.rb +9 -0
- data/lib/learn_worlds/resources/user_resource.rb +13 -3
- data/lib/learn_worlds/version.rb +1 -1
- data/lib/learn_worlds.rb +3 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad2a1e8a2ffd31771eaa98ad090a0c5fbc8e05dd25e0b991914f6a04234ca3d5
|
4
|
+
data.tar.gz: d0170a1aebada2099df0c45b26eb5cb4fc85c41bc8238bc98c552f3980762337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c13c5a27d196dfea26d5fcd7755ebae1a3bee336da05661315a6e757c02e62130aaed7cdc44cb84b4e5dc8e42e7156468d8f9fb858e58a98cbe861eb30f56da
|
7
|
+
data.tar.gz: ca6b5c91854da6342ec693430251a575ea5e806b4af851a23f55f5d7e96d0287dc0acf8c84a7f424c3aef7565f1c3fab8cd4902eb6125bde4b7e38e139635aad
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.2.1] - 2022-08-09
|
4
|
+
|
5
|
+
- Add attach and detach methods to the user resource
|
6
|
+
|
7
|
+
## [0.2.0] - 2022-07-11
|
8
|
+
|
9
|
+
- Adds single sign on functionality
|
10
|
+
- Default client secret to nil if not passed and not on env vars
|
11
|
+
|
12
|
+
## [0.1.3] - 2022-07-08
|
13
|
+
|
14
|
+
- Rename User to UserObject in order to avoid conflicts (breaking change)
|
15
|
+
|
3
16
|
## [0.1.2] - 2022-07-06
|
4
17
|
|
5
18
|
- Fix bug. Env var for client id was with double quotes
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -82,6 +82,21 @@ 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
|
+
|
92
|
+
```
|
93
|
+
|
94
|
+
### SSO Resource
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
|
98
|
+
client.sso.redirect(email: 'test@test.com', redirect_to 'xyz.learnworlds.com/courses')
|
99
|
+
|
85
100
|
```
|
86
101
|
|
87
102
|
|
data/lib/learn_worlds/client.rb
CHANGED
@@ -10,7 +10,7 @@ module LearnWorlds
|
|
10
10
|
|
11
11
|
def initialize(client_id: nil, client_secret: nil, base_url: nil, access_token: nil)
|
12
12
|
@client_id = client_id || ENV.fetch('LEARN_WORLDS_CLIENT_ID')
|
13
|
-
@client_secret = client_secret || ENV.fetch('LEARN_WORLDS_CLIENT_SECRET')
|
13
|
+
@client_secret = client_secret || ENV.fetch('LEARN_WORLDS_CLIENT_SECRET', nil)
|
14
14
|
@base_url = base_url || ENV.fetch('LEARN_WORLDS_BASE_URL')
|
15
15
|
@access_token = access_token
|
16
16
|
end
|
@@ -23,6 +23,10 @@ module LearnWorlds
|
|
23
23
|
AuthenticationResource.new(self)
|
24
24
|
end
|
25
25
|
|
26
|
+
def sso
|
27
|
+
SingleSignOnResource.new(self)
|
28
|
+
end
|
29
|
+
|
26
30
|
def connection
|
27
31
|
@connection ||= Faraday.new(base_url) do |conn|
|
28
32
|
conn.request :json
|
@@ -4,15 +4,15 @@ module LearnWorlds
|
|
4
4
|
|
5
5
|
def list(**params)
|
6
6
|
response = get_request(ENDPOINT, params)
|
7
|
-
Collection.from_response(response, key: "data", type:
|
7
|
+
Collection.from_response(response, key: "data", type: UserObject)
|
8
8
|
end
|
9
9
|
|
10
10
|
def create(**attributes)
|
11
|
-
|
11
|
+
UserObject.new(post_request(ENDPOINT, attributes).body)
|
12
12
|
end
|
13
13
|
|
14
14
|
def find(user_id:)
|
15
|
-
|
15
|
+
UserObject.new(get_request("#{ENDPOINT}/#{user_id}").body)
|
16
16
|
end
|
17
17
|
|
18
18
|
def update(user_id:, **params)
|
@@ -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
data/lib/learn_worlds.rb
CHANGED
@@ -9,11 +9,12 @@ module LearnWorlds
|
|
9
9
|
autoload :Collection, "learn_worlds/collection"
|
10
10
|
autoload :Configuration, "learn_worlds/configuration"
|
11
11
|
|
12
|
-
autoload :
|
12
|
+
autoload :UserObject, "learn_worlds/objects/user_object"
|
13
13
|
|
14
14
|
autoload :Resource, "learn_worlds/resource"
|
15
|
-
autoload :UserResource, "learn_worlds/resources/user_resource"
|
16
15
|
autoload :AuthenticationResource, "learn_worlds/resources/authentication_resource"
|
16
|
+
autoload :SingleSignOnResource, "learn_worlds/resources/single_sign_on_resource"
|
17
|
+
autoload :UserResource, "learn_worlds/resources/user_resource"
|
17
18
|
|
18
19
|
class << self
|
19
20
|
# Instantiate the Configuration singleton
|
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.1
|
4
|
+
version: 0.2.1
|
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-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -46,9 +46,10 @@ files:
|
|
46
46
|
- lib/learn_worlds/configuration.rb
|
47
47
|
- lib/learn_worlds/learn_worlds_error.rb
|
48
48
|
- lib/learn_worlds/object.rb
|
49
|
-
- lib/learn_worlds/objects/
|
49
|
+
- lib/learn_worlds/objects/user_object.rb
|
50
50
|
- lib/learn_worlds/resource.rb
|
51
51
|
- lib/learn_worlds/resources/authentication_resource.rb
|
52
|
+
- lib/learn_worlds/resources/single_sign_on_resource.rb
|
52
53
|
- lib/learn_worlds/resources/user_resource.rb
|
53
54
|
- lib/learn_worlds/version.rb
|
54
55
|
- sig/learnworlds.rbs
|