learnworlds 0.1.0 → 0.1.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: dec047b90f49e77a404d68f80a7622c5421d0183d3cc2d8e95fda932ca6c7690
4
- data.tar.gz: 1861ccc8603b47775f8aac4ff1d7b49ae2b0fa201867c06a6e760d75b50e5095
3
+ metadata.gz: cb7b97af5d7f11874865f675d8932b0ac841548d7c4fad5b097827ff2e80a43f
4
+ data.tar.gz: 13c3ec3e9c4811d1aa61895af37fdfef2c86d805061027ec8ddaa25604c4161e
5
5
  SHA512:
6
- metadata.gz: 04ee2d52a92ea6318e4eeb8c36ce25d340efe669f51fd54afb438ed833d6c90466689558a67a8241904fd4e70ff1689c67f34e7bcb76431392bfa9e86f9c35f1
7
- data.tar.gz: 875ab74e4416b3ab4e8304508eb70730e81f3456d4b178cda93d925966ffe513ba6c8a2381dc60e773c082641eb44e4ece45e84a7cc6c6226214358c9490bb3f
6
+ metadata.gz: 186dbe3be59265ae0c85c5dc91760f2b2017be38762f3def8c49938dcd24e1a8a23c92b234844a0bddbe44b60e4cd137b78d0053b267cd3c3ead5e8915665fae
7
+ data.tar.gz: 0617e02d710e75e1eb2a1d6bbe8438daf18f919fdddc1d721e18f6b60a43ede6ba2a239141bc44059dc43528633a1f7827d76e1860473f078ed2dcff55773664
data/.rubocop.yml CHANGED
@@ -26,3 +26,6 @@ Lint/SymbolConversion:
26
26
 
27
27
  Layout/LineLength:
28
28
  Max: 120
29
+
30
+ Metrics/MethodLength:
31
+ Max: 12
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2022-07-08
4
+
5
+ - Rename User to UserObject in order to avoid conflicts (breaking change)
6
+
7
+ ## [0.1.2] - 2022-07-06
8
+
9
+ - Fix bug. Env var for client id was with double quotes
10
+ - Documentation updated
11
+
12
+ ## [0.1.1] - 2022-07-06
13
+
14
+ - Add expires_in as parameter to persist_access_token_method
15
+
3
16
  ## [0.1.0] - 2022-06-29
4
17
 
5
18
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- learnworlds (0.1.0)
4
+ learnworlds (0.1.3)
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
 
@@ -6,10 +6,10 @@ require_relative "object"
6
6
  module LearnWorlds
7
7
  class Client
8
8
  attr_reader :base_url, :client_id, :client_secret
9
- attr_accessor :access_token
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"')
12
+ @client_id = client_id || ENV.fetch('LEARN_WORLDS_CLIENT_ID')
13
13
  @client_secret = client_secret || ENV.fetch('LEARN_WORLDS_CLIENT_SECRET')
14
14
  @base_url = base_url || ENV.fetch('LEARN_WORLDS_BASE_URL')
15
15
  @access_token = access_token
@@ -1,4 +1,4 @@
1
1
  module LearnWorlds
2
- class User < Object
2
+ class UserObject < Object
3
3
  end
4
4
  end
@@ -15,7 +15,7 @@ module LearnWorlds
15
15
  end
16
16
 
17
17
  # custom method to store the access token until it expires so we don't need to make uneccessary calls
18
- LearnWorlds.configuration.persist_access_token_method&.call(client.access_token)
18
+ LearnWorlds.configuration.persist_access_token_method&.call(client.access_token, client.expires_in)
19
19
  end
20
20
 
21
21
  # custom retrieve method can be used if you store the access token on your side until it expires for example
@@ -40,6 +40,7 @@ module LearnWorlds
40
40
  )
41
41
  response_body = Object.new(response.body)
42
42
  client.access_token = response_body.tokenData.access_token
43
+ client.expires_in = response_body.tokenData.expires_in
43
44
  end
44
45
  end
45
46
  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.0"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/learn_worlds.rb CHANGED
@@ -9,7 +9,7 @@ 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
15
  autoload :UserResource, "learn_worlds/resources/user_resource"
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.0
4
+ version: 0.1.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-07-01 00:00:00.000000000 Z
11
+ date: 2022-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -46,7 +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/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
52
  - lib/learn_worlds/resources/user_resource.rb