learnworlds 0.1.1 → 0.2.0

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: 326b7da781aae52fef008a7b6c28e38ac7df6bd5f7d3e7aaa63a2f49736e3422
4
- data.tar.gz: 0d9967da29d5c941b8470d3d0baf4e2c3d6ed287314cd0faaa02afcd6113b795
3
+ metadata.gz: bc096fa0ea3dfb07f2c9449360cb7053702bc3b85858464915b8acd644fb16e1
4
+ data.tar.gz: 192238d15c821879e34516748b82fa76dc03cb276b40a91ab98abc49e647cff5
5
5
  SHA512:
6
- metadata.gz: d4136813e98e0ab31e54a4abe278f66d6cc63c0eb887913be7cd2948589d4ae740bcc9091d149e49ee945f6655323de3a4560e1f45c1e326a342d7a3d43dc932
7
- data.tar.gz: af249f49f09b4c2d7d1dc476f9bc0dee42c55a795e6cac0ff0a5f8833106bdeb03c8f81ae5c15cdfe5c8ae8a24bd4d0b52ee87d28fdbdf5d6568796a7e0262f4
6
+ metadata.gz: f607da52aa8f1f5c5bb29993770ec61f3f8abcd7b1518508a58354999d0a8e74f3189624403855a715584a07aec0254dedb28e31bfb0982f24fef6d6d68856ec
7
+ data.tar.gz: 6b090dabfab1cd717a7c6f6dfbbc292ef627480f30027b365fc39cbedac9d3df864ebc74e68a4cc4ba149effec228e331cb0156b1cff4a968f674d2cb3668bc9
data/CHANGELOG.md CHANGED
@@ -1,6 +1,20 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.1] - 2022-06-29
3
+ ## [0.2.0] - 2022-07-11
4
+
5
+ - Adds single sign on fucntionality
6
+ - Default client secret to nil if not passed and not on env vars
7
+
8
+ ## [0.1.3] - 2022-07-08
9
+
10
+ - Rename User to UserObject in order to avoid conflicts (breaking change)
11
+
12
+ ## [0.1.2] - 2022-07-06
13
+
14
+ - Fix bug. Env var for client id was with double quotes
15
+ - Documentation updated
16
+
17
+ ## [0.1.1] - 2022-07-06
4
18
 
5
19
  - Add expires_in as parameter to persist_access_token_method
6
20
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- learnworlds (0.1.1)
4
+ learnworlds (0.2.0)
5
5
  faraday (~> 2.3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -61,7 +61,7 @@ LearnWorlds.configure do |config|
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
 
64
- config.persist_access_token_method = ->(access_token) { Rails.cache.write('learnworlds_access_token', access_token) } }
64
+ config.persist_access_token_method = ->(access_token, expires_in) { Rails.cache.write('learnworlds_access_token', access_token) } }
65
65
  end
66
66
  ```
67
67
 
@@ -84,6 +84,14 @@ client.user.find(user_id: 'user_id')
84
84
  client.user.enroll(user_id: 'user_id', product_id: 'course_id', product_type: 'course', price: 0)
85
85
  ```
86
86
 
87
+ ### SSO Resource
88
+
89
+ ```ruby
90
+
91
+ client.sso.redirect(email: 'test@test.com', redirect_to 'xyz.learnworlds.com/courses')
92
+
93
+ ```
94
+
87
95
 
88
96
  ## Development
89
97
 
@@ -9,8 +9,8 @@ module LearnWorlds
9
9
  attr_accessor :access_token, :expires_in
10
10
 
11
11
  def initialize(client_id: nil, client_secret: nil, base_url: nil, access_token: nil)
12
- @client_id = client_id || ENV.fetch('"LEARN_WORLDS_CLIENT_ID"')
13
- @client_secret = client_secret || ENV.fetch('LEARN_WORLDS_CLIENT_SECRET')
12
+ @client_id = client_id || ENV.fetch('LEARN_WORLDS_CLIENT_ID')
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
@@ -1,4 +1,4 @@
1
1
  module LearnWorlds
2
- class User < Object
2
+ class UserObject < Object
3
3
  end
4
4
  end
@@ -0,0 +1,9 @@
1
+ module LearnWorlds
2
+ class SingleSignOnResource < Resource
3
+ SSO_ENDPOINT = "/admin/api/sso".freeze
4
+
5
+ def redirect(email:, redirect_to:)
6
+ post_request(SSO_ENDPOINT, { email: email, redirectUrl: redirect_to }).body['url']
7
+ end
8
+ end
9
+ end
@@ -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: User)
7
+ Collection.from_response(response, key: "data", type: UserObject)
8
8
  end
9
9
 
10
10
  def create(**attributes)
11
- User.new(post_request(ENDPOINT, attributes).body)
11
+ UserObject.new(post_request(ENDPOINT, attributes).body)
12
12
  end
13
13
 
14
14
  def find(user_id:)
15
- User.new(get_request("#{ENDPOINT}/#{user_id}").body)
15
+ UserObject.new(get_request("#{ENDPOINT}/#{user_id}").body)
16
16
  end
17
17
 
18
18
  def update(user_id:, **params)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LearnWorlds
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
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 :User, "learn_worlds/objects/user"
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.1
4
+ version: 0.2.0
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-07-06 00:00:00.000000000 Z
11
+ date: 2022-07-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/user.rb
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