lessonly-api 0.0.1 → 0.0.2
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/.gitignore +1 -0
- data/lessonly-api.gemspec +4 -1
- data/lib/lessonly_api.rb +18 -1
- data/lib/lessonly_api/assignments.rb +10 -0
- data/lib/lessonly_api/errors.rb +1 -1
- data/lib/lessonly_api/groups.rb +56 -31
- data/lib/lessonly_api/lessons.rb +88 -0
- data/lib/lessonly_api/paths.rb +10 -0
- data/lib/lessonly_api/request.rb +1 -1
- data/lib/lessonly_api/resource_type/assignment.rb +1 -0
- data/lib/lessonly_api/resource_type/assignments.rb +14 -0
- data/lib/lessonly_api/resource_type/base.rb +1 -2
- data/lib/lessonly_api/resource_type/group.rb +11 -2
- data/lib/lessonly_api/resource_type/group_assignment.rb +12 -0
- data/lib/lessonly_api/resource_type/groups.rb +2 -2
- data/lib/lessonly_api/resource_type/lesson.rb +15 -1
- data/lib/lessonly_api/resource_type/lesson_assignments_completed.rb +10 -0
- data/lib/lessonly_api/resource_type/lessons.rb +7 -0
- data/lib/lessonly_api/resource_type/links.rb +10 -0
- data/lib/lessonly_api/resource_type/path.rb +21 -0
- data/lib/lessonly_api/resource_type/paths.rb +7 -0
- data/lib/lessonly_api/resource_type/tag.rb +12 -0
- data/lib/lessonly_api/resource_type/tags.rb +7 -0
- data/lib/lessonly_api/resource_type/user.rb +63 -6
- data/lib/lessonly_api/tags.rb +24 -0
- data/lib/lessonly_api/users.rb +76 -13
- data/lib/lessonly_api/utils/client.rb +4 -4
- data/lib/lessonly_api/utils/custom_field_converter.rb +2 -1
- data/lib/lessonly_api/version.rb +1 -1
- metadata +69 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aad22b010e14c05c92e87774f6dc586f57c6de0a2e7caaf7381222f9d1bca7cb
|
4
|
+
data.tar.gz: dd8b9aa2986a1a049894a033c39693016c75edfb066afafc9bd5153c816ab3c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e6bb09474483a91ead312583078b7af92635944542253008f4f5b6a02093f7b03f229791ed43bc616b1dfb6f0be103ab6a8a74fac6f7a1887f293081753a220
|
7
|
+
data.tar.gz: 0c0499b7b5363f6772498c28ccbd80fd411f68c7061caa8919908d93bf3a78c00918385014bc3b3dea6a7237457bbe4cdf4b7e4b3fb2f7f2b900b31c404d49bb
|
data/.gitignore
CHANGED
data/lessonly-api.gemspec
CHANGED
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^spec\/})
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_runtime_dependency 'gem_config'
|
26
25
|
spec.add_runtime_dependency 'activemodel', '>= 3.2'
|
27
26
|
spec.add_runtime_dependency 'faraday', '>= 0.8'
|
27
|
+
spec.add_runtime_dependency 'gem_config'
|
28
28
|
spec.add_runtime_dependency 'httpclient', '~> 2.8'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '>= 2.1.2'
|
@@ -32,4 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'pry-byebug', '~> 3.7'
|
33
33
|
spec.add_development_dependency 'rake', '~> 12.3'
|
34
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
+
spec.add_development_dependency 'webmock', '~> 3.8'
|
36
|
+
spec.add_development_dependency 'sinatra'
|
37
|
+
spec.add_development_dependency 'yard'
|
35
38
|
end
|
data/lib/lessonly_api.rb
CHANGED
@@ -11,7 +11,7 @@ module LessonlyApi
|
|
11
11
|
|
12
12
|
has :root_url,
|
13
13
|
classes: String,
|
14
|
-
default: ENV['LESSONLY_ROOT_URL'] || 'https://api.
|
14
|
+
default: ENV['LESSONLY_ROOT_URL'] || 'https://api.lessonly.com/api/v1.1'
|
15
15
|
|
16
16
|
has :domain,
|
17
17
|
classes: String,
|
@@ -35,11 +35,28 @@ require 'lessonly_api/resource_type/base'
|
|
35
35
|
require 'lessonly_api/request'
|
36
36
|
|
37
37
|
require 'lessonly_api/users'
|
38
|
+
require 'lessonly_api/groups'
|
39
|
+
require 'lessonly_api/lessons'
|
40
|
+
require 'lessonly_api/paths'
|
41
|
+
require 'lessonly_api/assignments'
|
42
|
+
require 'lessonly_api/tags'
|
38
43
|
|
39
44
|
require 'lessonly_api/resource_type/users'
|
40
45
|
require 'lessonly_api/resource_type/user'
|
46
|
+
require 'lessonly_api/resource_type/groups'
|
47
|
+
require 'lessonly_api/resource_type/group'
|
41
48
|
require 'lessonly_api/resource_type/webhook'
|
49
|
+
require 'lessonly_api/resource_type/lessons'
|
42
50
|
require 'lessonly_api/resource_type/lesson'
|
51
|
+
require 'lessonly_api/resource_type/lesson_assignments_completed'
|
52
|
+
require 'lessonly_api/resource_type/links'
|
53
|
+
require 'lessonly_api/resource_type/paths'
|
54
|
+
require 'lessonly_api/resource_type/path'
|
55
|
+
require 'lessonly_api/resource_type/tags'
|
56
|
+
require 'lessonly_api/resource_type/tag'
|
57
|
+
require 'lessonly_api/resource_type/assignments'
|
58
|
+
require 'lessonly_api/resource_type/assignment'
|
59
|
+
require 'lessonly_api/resource_type/group_assignment'
|
43
60
|
require 'lessonly_api/resource_type/user_group'
|
44
61
|
require 'lessonly_api/resource_type/user_assignments'
|
45
62
|
require 'lessonly_api/resource_type/assignment'
|
data/lib/lessonly_api/errors.rb
CHANGED
data/lib/lessonly_api/groups.rb
CHANGED
@@ -1,59 +1,84 @@
|
|
1
1
|
module LessonlyApi
|
2
2
|
class Groups < Request
|
3
3
|
class << self
|
4
|
+
# Retrieve all groups
|
5
|
+
# https://docs.lessonly.com/#list-groups
|
6
|
+
#
|
7
|
+
# @return [ResourceType::Groups] the response converted to a resource object
|
4
8
|
def list
|
5
|
-
raw_result =
|
6
|
-
|
9
|
+
raw_result = send_get('/groups')
|
10
|
+
LessonlyApi::ResourceType::Groups.new(raw_result)
|
7
11
|
end
|
8
12
|
|
13
|
+
# Retrieve a listing of a groups members and managers.
|
14
|
+
# https://docs.lessonly.com/#show-group-details
|
15
|
+
#
|
16
|
+
# @param id [Integer] ID of the group
|
17
|
+
# @return [ResourceType::Group] the response converted to a resource object
|
9
18
|
def show(id)
|
10
|
-
raw_result =
|
19
|
+
raw_result = send_get("/groups/#{id}")
|
11
20
|
LessonlyApi::ResourceType::Group.new(raw_result)
|
12
21
|
end
|
13
22
|
|
23
|
+
# Create a group
|
24
|
+
# https://docs.lessonly.com/#create-group
|
25
|
+
#
|
26
|
+
# @param attributes [Hash] hash with group's attributes
|
27
|
+
# @return [ResourceType::Group] the response converted to a resource object
|
14
28
|
def create(attributes = {})
|
15
|
-
raw_result =
|
16
|
-
ResourceType::
|
29
|
+
raw_result = send_post('/groups', attributes)
|
30
|
+
ResourceType::Group.new(raw_result)
|
17
31
|
end
|
18
32
|
|
33
|
+
# Update a group
|
34
|
+
# https://docs.lessonly.com/#update-group
|
35
|
+
#
|
36
|
+
# @param id [Integer] ID of a group to update
|
37
|
+
# @param attributes [Hash] hash with group's attributes to update
|
38
|
+
# @return [ResourceType::Group] the response converted to a resource object
|
19
39
|
def update(id, attributes = {})
|
20
|
-
raw_result =
|
21
|
-
ResourceType::
|
40
|
+
raw_result = send_put("/groups/#{id}", attributes)
|
41
|
+
ResourceType::Group.new(raw_result)
|
22
42
|
end
|
23
43
|
|
44
|
+
# Archive a group
|
45
|
+
# https://docs.lessonly.com/#archive-group
|
46
|
+
#
|
47
|
+
# @param id [Integer] ID of a group to archive
|
48
|
+
# @return [ResourceType::Group] the response converted to a resource object
|
24
49
|
def archive(id)
|
25
|
-
raw_result =
|
26
|
-
ResourceType::
|
50
|
+
raw_result = send_put("/groups/#{id}/archive")
|
51
|
+
ResourceType::Group.new(raw_result)
|
27
52
|
end
|
28
53
|
|
54
|
+
# Restore an archived group
|
55
|
+
# https://docs.lessonly.com/#restore-group
|
56
|
+
#
|
57
|
+
# @param id [Integer] ID of a group to restore
|
58
|
+
# @return [ResourceType::Group] the response converted to a resource object
|
29
59
|
def restore(id)
|
30
|
-
raw_result =
|
31
|
-
ResourceType::
|
60
|
+
raw_result = send_put("/groups/#{id}/restore")
|
61
|
+
ResourceType::Group.new(raw_result)
|
32
62
|
end
|
33
63
|
|
64
|
+
# Delete a group
|
65
|
+
# https://docs.lessonly.com/#delete-group
|
66
|
+
#
|
67
|
+
# @param id [Integer] ID of a group to delete
|
68
|
+
# @return [ResourceType::Group] the response converted to a resource object
|
34
69
|
def delete(id)
|
35
|
-
raw_result =
|
36
|
-
ResourceType::
|
70
|
+
raw_result = send_delete("/groups/#{id}")
|
71
|
+
ResourceType::Group.new(raw_result)
|
37
72
|
end
|
38
73
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
def
|
45
|
-
raw_result =
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def user_assignments(id)
|
50
|
-
raw_result = get("/users/#{id}/assignments")
|
51
|
-
#
|
52
|
-
end
|
53
|
-
|
54
|
-
def create_user_assignments(id)
|
55
|
-
raw_result = get("/users/#{id}/assignments")
|
56
|
-
#
|
74
|
+
# Return a list of assignments for a given group
|
75
|
+
# https://docs.lessonly.com/#group-assignments
|
76
|
+
#
|
77
|
+
# @param id [Integer] ID of a group
|
78
|
+
# @return [ResourceType::GroupAssignments] the response converted to a resource object
|
79
|
+
def group_assignments(id)
|
80
|
+
raw_result = send_get("/groups/#{id}/assignments")
|
81
|
+
raw_result.map { |el| ResourceType::GroupAssignment.new(el) }
|
57
82
|
end
|
58
83
|
end
|
59
84
|
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module LessonlyApi
|
2
|
+
class Lessons < Request
|
3
|
+
class << self
|
4
|
+
# Retrieve all lessons
|
5
|
+
# https://docs.lessonly.com/#list-lessons
|
6
|
+
#
|
7
|
+
# @return [ResourceType::Lessons] the response converted to a resource object
|
8
|
+
def list
|
9
|
+
raw_result = send_get('/lessons')
|
10
|
+
ResourceType::Lessons.new(raw_result)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieve the lesson's information
|
14
|
+
# https://docs.lessonly.com/#show-lesson-details
|
15
|
+
#
|
16
|
+
# @param id [Integer] ID of the group
|
17
|
+
# @return [ResourceType::Lesson] the response converted to a resource object
|
18
|
+
def show(id)
|
19
|
+
raw_result = send_get("/lessons/#{id}")
|
20
|
+
ResourceType::Lesson.new(raw_result)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Update a lesson
|
24
|
+
# https://docs.lessonly.com/#update-lesson
|
25
|
+
#
|
26
|
+
# @param id [Integer] ID of a lesson to update
|
27
|
+
# @param attributes [Hash] hash with lesson's attributes to update
|
28
|
+
# @return [ResourceType::Lesson] the response converted to a resource object
|
29
|
+
def update(id, attributes = {})
|
30
|
+
raw_result = send_put("/lessons/#{id}", attributes)
|
31
|
+
ResourceType::Lesson.new(raw_result)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Archive a lesson
|
35
|
+
# https://docs.lessonly.com/#archive-lesson
|
36
|
+
#
|
37
|
+
# @param id [Integer] ID of a lesson to archive
|
38
|
+
# @return [ResourceType::Lesson] the response converted to a resource object
|
39
|
+
def archive(id)
|
40
|
+
raw_result = send_put("/lessons/#{id}/archive")
|
41
|
+
ResourceType::Lesson.new(raw_result)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Restore an archived lesson
|
45
|
+
# https://docs.lessonly.com/#restore-lesson
|
46
|
+
#
|
47
|
+
# @param id [Integer] ID of a lesson to restore
|
48
|
+
# @return [ResourceType::Lesson] the response converted to a resource object
|
49
|
+
def restore(id)
|
50
|
+
raw_result = send_put("/lessons/#{id}/restore")
|
51
|
+
ResourceType::Lesson.new(raw_result)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Retrieve all the assignments for a particular lesson
|
55
|
+
# https://docs.lessonly.com/#lesson-assignments
|
56
|
+
#
|
57
|
+
# @param id [Integer] ID of a lesson
|
58
|
+
# @param page [Integer] the number of the page
|
59
|
+
# @param per_page [Integer] the numer of records per page
|
60
|
+
# @return [ResourceType::LessonAssignment] the response converted to a resource object
|
61
|
+
def lesson_assignments(id, page: 1, per_page: 50)
|
62
|
+
raw_result = send_get("/lessons/#{id}/assignments", page: page, per_page: per_page)
|
63
|
+
ResourceType::Assignments.new(raw_result)
|
64
|
+
end
|
65
|
+
|
66
|
+
# Retrieves the number of completed assignments for a given lesson
|
67
|
+
# https://docs.lessonly.com/#lesson-completed-assignments-v1-1
|
68
|
+
#
|
69
|
+
# @param id [Integer] ID of a lesson
|
70
|
+
# @return [ResourceType::LessonAssignmentsCompleted] the response converted to a resource object
|
71
|
+
def lesson_completed_assignments(id)
|
72
|
+
raw_result = send_get("/lessons/#{id}/assignments/completed")
|
73
|
+
ResourceType::LessonAssignmentsCompleted.new(raw_result)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Allow to make assignments to a particular lesson in the API
|
77
|
+
# https://docs.lessonly.com/#assign-lesson
|
78
|
+
#
|
79
|
+
# @param id [Integer] ID of a lesson
|
80
|
+
# @param assignments [Array] array with assignments' attributes to create
|
81
|
+
# @return [ResourceType::Assignments] the response converted to a resource object
|
82
|
+
def assign_lesson(id, assignments = [])
|
83
|
+
raw_result = send_post("/lessons/#{id}/assignments", assignments: assignments)
|
84
|
+
ResourceType::Assignments.new(raw_result)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
data/lib/lessonly_api/request.rb
CHANGED
@@ -2,7 +2,7 @@ class LessonlyApi::Request < LessonlyApi::ResourceType::Base
|
|
2
2
|
delegate :get, :post, :client, to: :class
|
3
3
|
|
4
4
|
class << self
|
5
|
-
delegate :
|
5
|
+
delegate :send_get, :send_post, :send_put, :send_delete, to: :client
|
6
6
|
|
7
7
|
def client
|
8
8
|
LessonlyApi::Utils::Client.instance
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'active_model'
|
4
|
+
require 'active_support/core_ext/hash'
|
4
5
|
require 'json'
|
5
6
|
|
6
7
|
module LessonlyApi
|
7
8
|
module ResourceType
|
8
9
|
class Base
|
9
10
|
include ActiveModel::Model
|
10
|
-
include ActiveModel::Dirty
|
11
|
-
include ActiveModel::Serializers::JSON
|
12
11
|
|
13
12
|
class_attribute :fields_names
|
14
13
|
self.fields_names = []
|
@@ -1,7 +1,16 @@
|
|
1
1
|
module LessonlyApi
|
2
2
|
module ResourceType
|
3
|
-
class Group < LessonlyApi::
|
4
|
-
fields(
|
3
|
+
class Group < LessonlyApi::ResourceType::Base
|
4
|
+
fields(
|
5
|
+
:id,
|
6
|
+
:type,
|
7
|
+
:resource_type,
|
8
|
+
:name,
|
9
|
+
{members: [:user]},
|
10
|
+
{managers: [:user]},
|
11
|
+
{archived_at: :date_time},
|
12
|
+
:archived_by_user_id
|
13
|
+
)
|
5
14
|
end
|
6
15
|
end
|
7
16
|
end
|
@@ -1,7 +1,21 @@
|
|
1
1
|
module LessonlyApi
|
2
2
|
module ResourceType
|
3
3
|
class Lesson < LessonlyApi::ResourceType::Base
|
4
|
-
fields(
|
4
|
+
fields(
|
5
|
+
:id,
|
6
|
+
:type,
|
7
|
+
:description,
|
8
|
+
:resource_type,
|
9
|
+
:title,
|
10
|
+
{archived_at: :date_time},
|
11
|
+
:archived_by_user_id,
|
12
|
+
:retake_score,
|
13
|
+
:public,
|
14
|
+
{created_at: :date_time},
|
15
|
+
{last_updated_at: :date_time},
|
16
|
+
{links: :links},
|
17
|
+
tags: [:tag],
|
18
|
+
)
|
5
19
|
end
|
6
20
|
end
|
7
21
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module LessonlyApi
|
2
|
+
module ResourceType
|
3
|
+
class Path < LessonlyApi::ResourceType::Base
|
4
|
+
fields(
|
5
|
+
:resource_type,
|
6
|
+
:type,
|
7
|
+
:id,
|
8
|
+
:title,
|
9
|
+
:archived_at,
|
10
|
+
:archived_by_user_id,
|
11
|
+
:public,
|
12
|
+
:created_at,
|
13
|
+
:last_updated_at,
|
14
|
+
:published_at,
|
15
|
+
:publisher_id,
|
16
|
+
{tags: [:tag]},
|
17
|
+
{links: :links}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,6 +1,67 @@
|
|
1
1
|
module LessonlyApi
|
2
2
|
module ResourceType
|
3
|
+
# Class represents API response as a Ruby object.
|
3
4
|
class User < LessonlyApi::ResourceType::Base
|
5
|
+
# @!method id
|
6
|
+
# @return [Integer] ID of the user
|
7
|
+
|
8
|
+
# @!method resource_type
|
9
|
+
# @return [String] type of the resource
|
10
|
+
|
11
|
+
# @!method type
|
12
|
+
# @return [String] type of the resource
|
13
|
+
|
14
|
+
# @!method ext_uid
|
15
|
+
# @return [String] external ID of the user
|
16
|
+
|
17
|
+
# @!method email
|
18
|
+
# @return [String] an email of the user
|
19
|
+
|
20
|
+
# @!method name
|
21
|
+
# @return [String] a name of the user
|
22
|
+
|
23
|
+
# @!method role
|
24
|
+
# @return [String] a role of the user
|
25
|
+
|
26
|
+
# @!method role_id
|
27
|
+
# @return [Integer] ID of a user's role
|
28
|
+
|
29
|
+
# @!method archived_at
|
30
|
+
# @return [DateTime] timestamp of the user's archiving
|
31
|
+
|
32
|
+
# @!method archived_by_user_id
|
33
|
+
# @return [Inteher] ID of a user who archived the given user
|
34
|
+
|
35
|
+
# @!method job_title
|
36
|
+
# @return [String] title of the user's job
|
37
|
+
|
38
|
+
# @!method business_unit
|
39
|
+
# @return [String] business unit the user
|
40
|
+
|
41
|
+
# @!method department
|
42
|
+
# @return [String] name of the user's department
|
43
|
+
|
44
|
+
# @!method location
|
45
|
+
# @return [String] location of the user
|
46
|
+
|
47
|
+
# @!method locale
|
48
|
+
# @return [String] locale of the user
|
49
|
+
|
50
|
+
# @!method hire_date
|
51
|
+
# @return [Date] date of the user's hire
|
52
|
+
|
53
|
+
# @!method manager_name
|
54
|
+
# @return [String] name of the user's manager
|
55
|
+
|
56
|
+
# @!method mobile_phone_number
|
57
|
+
# @return [String] phone number of the user
|
58
|
+
|
59
|
+
# @!method custom_user_field_data
|
60
|
+
# @return [Array] array of hashes with custom fields
|
61
|
+
|
62
|
+
# @!method groups
|
63
|
+
# @return [ResourceType::UserGroup] the list of a user’s group memberships and groups the user is managing
|
64
|
+
|
4
65
|
fields(
|
5
66
|
:id,
|
6
67
|
:resource_type,
|
@@ -10,23 +71,19 @@ module LessonlyApi
|
|
10
71
|
:name,
|
11
72
|
:role,
|
12
73
|
:role_id,
|
13
|
-
:
|
74
|
+
{archived_at: :date_time},
|
14
75
|
:archived_by_user_id,
|
15
76
|
:job_title,
|
16
77
|
:business_unit,
|
17
78
|
:department,
|
18
79
|
:location,
|
19
80
|
:locale,
|
20
|
-
:
|
81
|
+
{hire_date: :date},
|
21
82
|
:manager_name,
|
22
83
|
:mobile_phone_number,
|
23
84
|
:custom_user_field_data,
|
24
85
|
{groups: :user_group}
|
25
86
|
)
|
26
|
-
|
27
|
-
def user_assignments
|
28
|
-
LessonlyApi::Users.user_assignments(self.id)
|
29
|
-
end
|
30
87
|
end
|
31
88
|
end
|
32
89
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module LessonlyApi
|
2
|
+
class Tags < Request
|
3
|
+
class << self
|
4
|
+
# Retrieve all tags
|
5
|
+
# https://docs.lessonly.com/#list-tags
|
6
|
+
#
|
7
|
+
# @return [ResourceType::Tags] the response converted to a resource object
|
8
|
+
def list
|
9
|
+
raw_result = send_get('/tags')
|
10
|
+
LessonlyApi::ResourceType::Tags.new(raw_result)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieve the tag's information
|
14
|
+
# https://docs.lessonly.com/#show-tag-details
|
15
|
+
#
|
16
|
+
# @param id [Integer] ID of the tag
|
17
|
+
# @return [ResourceType::Tag] the response converted to a resource object
|
18
|
+
def show(id)
|
19
|
+
raw_result = send_get("/tags/#{id}")
|
20
|
+
ResourceType::Tag.new(raw_result)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/lessonly_api/users.rb
CHANGED
@@ -1,59 +1,122 @@
|
|
1
1
|
module LessonlyApi
|
2
|
+
# The collection of methods to fetch users' data.
|
2
3
|
class Users < Request
|
3
4
|
class << self
|
5
|
+
# Retrieve all users
|
6
|
+
# https://docs.lessonly.com/#list-users
|
7
|
+
#
|
8
|
+
# @param page [Integer] the number of the page
|
9
|
+
# @param per_page [Integer] the numer of records per page
|
10
|
+
# @param filters [Hash] additional filters
|
11
|
+
# @return [ResourceType::Users] the response converted to a resource object
|
4
12
|
def list(page: 1, per_page: 50, **filters)
|
5
|
-
raw_result =
|
13
|
+
raw_result = send_get('/users', page: page, per_page: per_page, filter: filters)
|
6
14
|
ResourceType::Users.new(raw_result)
|
7
15
|
end
|
8
16
|
|
17
|
+
# Retrieve all the user's details including their custom field data
|
18
|
+
# https://docs.lessonly.com/#show-user-details
|
19
|
+
#
|
20
|
+
# @param id [Integer] ID of the user
|
21
|
+
# @return [ResourceType::User] the response converted to a resource object
|
9
22
|
def show(id)
|
10
|
-
raw_result =
|
23
|
+
raw_result = send_get("/users/#{id}")
|
11
24
|
LessonlyApi::ResourceType::User.new(raw_result)
|
12
25
|
end
|
13
26
|
|
27
|
+
# Create a user
|
28
|
+
# https://docs.lessonly.com/#create-user
|
29
|
+
#
|
30
|
+
# @param attributes [Hash] hash with user's attributes
|
31
|
+
# @return [ResourceType::User] the response converted to a resource object
|
14
32
|
def create(attributes = {})
|
15
|
-
raw_result =
|
33
|
+
raw_result = send_post('/users', attributes)
|
16
34
|
ResourceType::User.new(raw_result)
|
17
35
|
end
|
18
36
|
|
37
|
+
# Update a user
|
38
|
+
# https://docs.lessonly.com/#update-user
|
39
|
+
#
|
40
|
+
# @param id [Integer] ID of a user to update
|
41
|
+
# @param attributes [Hash] hash with user's attributes to update
|
42
|
+
# @return [ResourceType::User] the response converted to a resource object
|
19
43
|
def update(id, attributes = {})
|
20
|
-
raw_result =
|
44
|
+
raw_result = send_put("/users/#{id}", attributes)
|
21
45
|
ResourceType::User.new(raw_result)
|
22
46
|
end
|
23
47
|
|
48
|
+
# Archive a user
|
49
|
+
# https://docs.lessonly.com/#archive-user
|
50
|
+
#
|
51
|
+
# @param id [Integer] ID of a user to archive
|
52
|
+
# @return [ResourceType::User] the response converted to a resource object
|
24
53
|
def archive(id)
|
25
|
-
raw_result =
|
54
|
+
raw_result = send_put("/users/#{id}/archive")
|
26
55
|
ResourceType::User.new(raw_result)
|
27
56
|
end
|
28
57
|
|
58
|
+
# Restore an archived user
|
59
|
+
# https://docs.lessonly.com/#restore-user
|
60
|
+
#
|
61
|
+
# @param id [Integer] ID of a user to restore
|
62
|
+
# @return [ResourceType::User] the response converted to a resource object
|
29
63
|
def restore(id)
|
30
|
-
raw_result =
|
64
|
+
raw_result = send_put("/users/#{id}/restore")
|
31
65
|
ResourceType::User.new(raw_result)
|
32
66
|
end
|
33
67
|
|
34
|
-
#
|
35
|
-
|
36
|
-
|
68
|
+
# Delete a user
|
69
|
+
# https://docs.lessonly.com/#delete-user
|
70
|
+
#
|
71
|
+
# @param id [Integer] ID of a user to delete
|
72
|
+
# @return [ResourceType::User] the response converted to a resource object
|
73
|
+
def delete(id)
|
74
|
+
raw_result = send_delete("/users/#{id}")
|
75
|
+
# TODO: there should be other type, possibly
|
37
76
|
ResourceType::User.new(raw_result)
|
38
77
|
end
|
39
78
|
|
79
|
+
# Return the list of a user’s group memberships and groups they are managing
|
80
|
+
# https://docs.lessonly.com/#user-groups
|
81
|
+
#
|
82
|
+
# @param id [Integer] ID of a user
|
83
|
+
# @return [ResourceType::UserGroup] the response converted to a resource object
|
40
84
|
def user_groups(id)
|
41
|
-
raw_result =
|
85
|
+
raw_result = send_get("/users/#{id}/groups")
|
86
|
+
# TODO: there should be other type, possibly
|
42
87
|
ResourceType::UserGroup.new(raw_result)
|
43
88
|
end
|
44
89
|
|
90
|
+
# Update a user’s involvement in various groups
|
91
|
+
# https://docs.lessonly.com/#update-user-groups
|
92
|
+
#
|
93
|
+
# @param id [Integer] ID of a user
|
94
|
+
# @param attributes [Hash] hash with user's groups attributes to update
|
95
|
+
# @return [ResourceType::UserGroup] the response converted to a resource object
|
45
96
|
def update_user_groups(id, attributes = {})
|
46
|
-
raw_result =
|
97
|
+
raw_result = send_put("/users/#{id}/groups", attributes)
|
98
|
+
# TODO: there should be other type, possibly
|
47
99
|
ResourceType::UserGroup.new(raw_result)
|
48
100
|
end
|
49
101
|
|
102
|
+
# Return a list of assignments for a given user
|
103
|
+
# https://docs.lessonly.com/#user-assignments
|
104
|
+
#
|
105
|
+
# @param id [Integer] ID of a user
|
106
|
+
# @return [ResourceType::UserAssignments] the response converted to a resource object
|
50
107
|
def user_assignments(id)
|
51
|
-
raw_result =
|
108
|
+
raw_result = send_get("/users/#{id}/assignments")
|
52
109
|
ResourceType::UserAssignments.new(raw_result)
|
53
110
|
end
|
54
111
|
|
112
|
+
# Create assignments for a user
|
113
|
+
# https://docs.lessonly.com/#create-user-assignments
|
114
|
+
#
|
115
|
+
# @param id [Integer] ID of a user
|
116
|
+
# @param assignments [Array] array with assignments' attributes to create
|
117
|
+
# @return [ResourceType::UserAssignments] the response converted to a resource object
|
55
118
|
def create_user_assignments(id, assignments = [])
|
56
|
-
raw_result =
|
119
|
+
raw_result = send_post("/users/#{id}/assignments", assignments: assignments)
|
57
120
|
ResourceType::UserAssignments.new(raw_result)
|
58
121
|
end
|
59
122
|
end
|
@@ -34,19 +34,19 @@ module LessonlyApi
|
|
34
34
|
@instance ||= new(LessonlyApi.configuration)
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
37
|
+
def send_get(endpoint, params = {})
|
38
38
|
send_request(:get, endpoint, params)
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
41
|
+
def send_post(endpoint, params = {})
|
42
42
|
send_request(:post, endpoint, params)
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def send_put(endpoint, params = {})
|
46
46
|
send_request(:put, endpoint, params)
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def send_delete(endpoint, params = {})
|
50
50
|
send_request(:delete, endpoint, params)
|
51
51
|
end
|
52
52
|
|
@@ -7,7 +7,8 @@ module LessonlyApi
|
|
7
7
|
class CustomFieldConverter
|
8
8
|
CONVERSIONS = {
|
9
9
|
big_decimal: ->(val) { val.is_a?(BigDecimal) ? val : val && BigDecimal(val.to_s) },
|
10
|
-
date: ->(val) { val.is_a?(Date) ? val : val && Date.parse(val) }
|
10
|
+
date: ->(val) { val.is_a?(Date) ? val : val && Date.parse(val) },
|
11
|
+
date_time: ->(val) { val.is_a?(DateTime) ? val : val && DateTime.parse(val) }
|
11
12
|
}.freeze
|
12
13
|
|
13
14
|
def initialize(data_type)
|
data/lib/lessonly_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lessonly-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Kamenko
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activemodel
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0.8'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0.8'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: gem_config
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: httpclient
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,48 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '3.0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '3.8'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '3.8'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: sinatra
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
139
181
|
description: Ruby client for Lesson.ly API
|
140
182
|
email:
|
141
183
|
- ilya.kamenko@gmail.com
|
@@ -152,19 +194,32 @@ files:
|
|
152
194
|
- bin/setup
|
153
195
|
- lessonly-api.gemspec
|
154
196
|
- lib/lessonly_api.rb
|
197
|
+
- lib/lessonly_api/assignments.rb
|
155
198
|
- lib/lessonly_api/errors.rb
|
156
199
|
- lib/lessonly_api/groups.rb
|
200
|
+
- lib/lessonly_api/lessons.rb
|
201
|
+
- lib/lessonly_api/paths.rb
|
157
202
|
- lib/lessonly_api/request.rb
|
158
203
|
- lib/lessonly_api/resource_type/assignment.rb
|
204
|
+
- lib/lessonly_api/resource_type/assignments.rb
|
159
205
|
- lib/lessonly_api/resource_type/base.rb
|
160
206
|
- lib/lessonly_api/resource_type/group.rb
|
207
|
+
- lib/lessonly_api/resource_type/group_assignment.rb
|
161
208
|
- lib/lessonly_api/resource_type/groups.rb
|
162
209
|
- lib/lessonly_api/resource_type/lesson.rb
|
210
|
+
- lib/lessonly_api/resource_type/lesson_assignments_completed.rb
|
211
|
+
- lib/lessonly_api/resource_type/lessons.rb
|
212
|
+
- lib/lessonly_api/resource_type/links.rb
|
213
|
+
- lib/lessonly_api/resource_type/path.rb
|
214
|
+
- lib/lessonly_api/resource_type/paths.rb
|
215
|
+
- lib/lessonly_api/resource_type/tag.rb
|
216
|
+
- lib/lessonly_api/resource_type/tags.rb
|
163
217
|
- lib/lessonly_api/resource_type/user.rb
|
164
218
|
- lib/lessonly_api/resource_type/user_assignments.rb
|
165
219
|
- lib/lessonly_api/resource_type/user_group.rb
|
166
220
|
- lib/lessonly_api/resource_type/users.rb
|
167
221
|
- lib/lessonly_api/resource_type/webhook.rb
|
222
|
+
- lib/lessonly_api/tags.rb
|
168
223
|
- lib/lessonly_api/users.rb
|
169
224
|
- lib/lessonly_api/utils/client.rb
|
170
225
|
- lib/lessonly_api/utils/custom_field_converter.rb
|
@@ -174,7 +229,7 @@ homepage: https://github.com/toptal/lessonly-api
|
|
174
229
|
licenses:
|
175
230
|
- MIT
|
176
231
|
metadata: {}
|
177
|
-
post_install_message:
|
232
|
+
post_install_message:
|
178
233
|
rdoc_options: []
|
179
234
|
require_paths:
|
180
235
|
- lib
|
@@ -190,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
190
245
|
version: '0'
|
191
246
|
requirements: []
|
192
247
|
rubygems_version: 3.1.4
|
193
|
-
signing_key:
|
248
|
+
signing_key:
|
194
249
|
specification_version: 4
|
195
250
|
summary: Ruby client for Lesson.ly API
|
196
251
|
test_files: []
|