learnworlds 0.2.1 → 0.2.3

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: ad2a1e8a2ffd31771eaa98ad090a0c5fbc8e05dd25e0b991914f6a04234ca3d5
4
- data.tar.gz: d0170a1aebada2099df0c45b26eb5cb4fc85c41bc8238bc98c552f3980762337
3
+ metadata.gz: c23afd4a12db0a2206b6c516528aef1af8aa0c5d58d04b9a827016a1830148ca
4
+ data.tar.gz: aa74366632f4ed85f0f3b82bcbacd1012ab2a979df3cab27f6a94933dba2f3a0
5
5
  SHA512:
6
- metadata.gz: 3c13c5a27d196dfea26d5fcd7755ebae1a3bee336da05661315a6e757c02e62130aaed7cdc44cb84b4e5dc8e42e7156468d8f9fb858e58a98cbe861eb30f56da
7
- data.tar.gz: ca6b5c91854da6342ec693430251a575ea5e806b4af851a23f55f5d7e96d0287dc0acf8c84a7f424c3aef7565f1c3fab8cd4902eb6125bde4b7e38e139635aad
6
+ metadata.gz: cb7fb5be2fe32e95ba31aeaa5557a05599b609f87c269387ad8c94c4a7d1ebe800481f408ac7c9663472c419cf943eaa35d502ef6ef81bf8f7a81885b3a918e4
7
+ data.tar.gz: b65f875304f0d2d2ff5616e4e3e22855fd88be69a91eda6be4e0ad7e3cdcd754d3f106643b186a72464477108943b382d67fd5fc46e680170db222245d5d22c6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.3] - 2022-08-09
4
+
5
+ - Add enrollments to user
6
+
7
+ ## [0.2.2] - 2022-08-09
8
+
9
+ - Add possibility to sso with user id instead of email
10
+
3
11
  ## [0.2.1] - 2022-08-09
4
12
 
5
13
  - Add attach and detach methods to the user resource
@@ -27,4 +35,3 @@
27
35
  - Initial release
28
36
  - Adds a basic structure to aid future developments
29
37
  - Adds methods to interact with the user resource ( list, create, update, find and enroll )
30
-
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- learnworlds (0.2.1)
4
+ learnworlds (0.2.3)
5
5
  faraday (~> 2.3)
6
6
 
7
7
  GEM
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
 
@@ -80,6 +80,9 @@ client.user.update(user_id: 'user_id', username: 'updated_username')
80
80
  # finds a user
81
81
  client.user.find(user_id: 'user_id')
82
82
 
83
+ # returns a list of enrollnments for a specific user
84
+ client.user.enrollments(user_id: 'user_id')
85
+
83
86
  # enrolls a user on a course
84
87
  client.user.enroll(user_id: 'user_id', product_id: 'course_id', product_type: 'course', price: 0)
85
88
 
@@ -97,8 +100,9 @@ client.user.detach_tags(user_id: 'user_id', tags: ['tag1', 'tag2'])
97
100
 
98
101
  client.sso.redirect(email: 'test@test.com', redirect_to 'xyz.learnworlds.com/courses')
99
102
 
100
- ```
103
+ client.sso.redirect_with_id(user_id: 'learnworlds_user_id', redirect_to 'xyz.learnworlds.com/courses')
101
104
 
105
+ ```
102
106
 
103
107
  ## Development
104
108
 
@@ -0,0 +1,4 @@
1
+ module LearnWorlds
2
+ class EnrollmentObject < Object
3
+ end
4
+ end
@@ -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
@@ -15,6 +15,11 @@ module LearnWorlds
15
15
  UserObject.new(get_request("#{ENDPOINT}/#{user_id}").body)
16
16
  end
17
17
 
18
+ def enrollments(user_id:)
19
+ response = get_request("#{ENDPOINT}/#{user_id}/courses")
20
+ Collection.from_response(response, key: "data", type: EnrollmentObject)
21
+ end
22
+
18
23
  def update(user_id:, **params)
19
24
  put_request("#{ENDPOINT}/#{user_id}", params)
20
25
  true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LearnWorlds
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.3"
5
5
  end
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.1
4
+ version: 0.2.3
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-08-11 00:00:00.000000000 Z
11
+ date: 2023-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -46,6 +46,7 @@ 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/enrollment_object.rb
49
50
  - lib/learn_worlds/objects/user_object.rb
50
51
  - lib/learn_worlds/resource.rb
51
52
  - lib/learn_worlds/resources/authentication_resource.rb