From 9d1733fa9d8c781e9dd2fd498ed3a2aed8edb135 Mon Sep 17 00:00:00 2001 From: Rocco Aliberti Date: Tue, 28 Feb 2023 16:54:31 +0100 Subject: [PATCH] Release v1.0.0-beta.26 [ci skip] --- .bin/cache-bust | 20 - .bin/httpsnippet-client-for-llms-node-api.js | 56 - .bin/snippets | 77 - .editorconfig | 35 - .github/CODEOWNERS | 4 - .github/SECURITY.md | 19 - .github/workflows/codeql-analysis.yml | 40 - .github/workflows/coding-standards.yml | 60 - .github/workflows/gh-pages.yml | 37 - .github/workflows/keep-alive.yml | 53 - .github/workflows/ossar-analysis.yml | 44 - .github/workflows/php-test-coverage.yml | 75 - .github/workflows/project-automation.yml | 94 - .github/workflows/shiftleft-analysis.yml | 30 - .github/workflows/sync-branches.yml | 35 - .github/workflows/test-phpunit.yml | 100 - .gitignore | 6 - .llmsdev.yml | 6 - CHANGELOG.md | 279 -- README.md | 97 - class-lifterlms-rest-api.php | 9 +- i18n/lifterlms-rest.pot | 42 +- .../class-llms-rest-api-keys-controller.php | 18 +- ...class-llms-rest-enrollments-controller.php | 28 +- .../class-llms-rest-students-controller.php | 5 +- ...llms-rest-students-progress-controller.php | 9 +- lifterlms-rest.php | 8 +- package-lock.json | 4417 ----------------- package.json | 31 - phpcs.xml | 23 - phpunit.xml.dist | 39 - spec/README.md | 24 - spec/code_samples/Node.js/access-plans/get.js | 13 - .../code_samples/Node.js/access-plans/post.js | 50 - .../Node.js/access-plans@{id}/delete.js | 13 - .../Node.js/access-plans@{id}/get.js | 13 - .../Node.js/access-plans@{id}/post.js | 50 - spec/code_samples/Node.js/api-keys/get.js | 13 - spec/code_samples/Node.js/api-keys/post.js | 19 - .../Node.js/api-keys@{id}/delete.js | 13 - .../code_samples/Node.js/api-keys@{id}/get.js | 13 - .../Node.js/api-keys@{id}/post.js | 19 - spec/code_samples/Node.js/courses/get.js | 13 - spec/code_samples/Node.js/courses/post.js | 74 - .../Node.js/courses@{id}/delete.js | 17 - spec/code_samples/Node.js/courses@{id}/get.js | 13 - .../code_samples/Node.js/courses@{id}/post.js | 74 - .../Node.js/courses@{id}@content/get.js | 13 - .../Node.js/courses@{id}@enrollments/get.js | 13 - spec/code_samples/Node.js/groups/get.js | 13 - spec/code_samples/Node.js/groups/post.js | 27 - .../Node.js/groups@{id}/delete.js | 17 - spec/code_samples/Node.js/groups@{id}/get.js | 13 - spec/code_samples/Node.js/groups@{id}/post.js | 27 - .../Node.js/groups@{id}@invitations/get.js | 13 - .../Node.js/groups@{id}@invitations/post.js | 18 - .../delete.js | 13 - .../get.js | 13 - .../Node.js/groups@{id}@members/get.js | 13 - .../groups@{id}@members@{member_id}/delete.js | 13 - .../groups@{id}@members@{member_id}/get.js | 13 - .../groups@{id}@members@{member_id}/post.js | 17 - .../Node.js/groups@{id}@seats/get.js | 13 - .../Node.js/groups@{id}@seats/put.js | 17 - spec/code_samples/Node.js/instructors/get.js | 13 - spec/code_samples/Node.js/instructors/post.js | 35 - .../Node.js/instructors@{id}/delete.js | 17 - .../Node.js/instructors@{id}/get.js | 13 - .../Node.js/instructors@{id}/post.js | 35 - .../Node.js/instructors@{id}@content/get.js | 13 - spec/code_samples/Node.js/lessons/get.js | 13 - spec/code_samples/Node.js/lessons/post.js | 50 - .../Node.js/lessons@{id}/delete.js | 17 - spec/code_samples/Node.js/lessons@{id}/get.js | 13 - .../code_samples/Node.js/lessons@{id}/post.js | 50 - spec/code_samples/Node.js/memberships/get.js | 13 - spec/code_samples/Node.js/memberships/post.js | 57 - .../Node.js/memberships@{id}/delete.js | 17 - .../Node.js/memberships@{id}/get.js | 13 - .../Node.js/memberships@{id}/post.js | 57 - .../memberships@{id}@enrollments/get.js | 13 - .../Node.js/quiz-questions/get.js | 13 - .../Node.js/quiz-questions/post.js | 40 - .../Node.js/quiz-questions@{id}/delete.js | 13 - .../Node.js/quiz-questions@{id}/get.js | 13 - .../Node.js/quiz-questions@{id}/post.js | 40 - spec/code_samples/Node.js/quizzes/get.js | 13 - spec/code_samples/Node.js/quizzes/post.js | 30 - .../Node.js/quizzes@{id}/delete.js | 13 - spec/code_samples/Node.js/quizzes@{id}/get.js | 13 - .../code_samples/Node.js/quizzes@{id}/post.js | 30 - spec/code_samples/Node.js/sections/get.js | 13 - spec/code_samples/Node.js/sections/post.js | 21 - .../Node.js/sections@{id}/delete.js | 13 - .../code_samples/Node.js/sections@{id}/get.js | 13 - .../Node.js/sections@{id}/post.js | 21 - .../Node.js/sections@{id}@content/get.js | 13 - spec/code_samples/Node.js/students/get.js | 13 - spec/code_samples/Node.js/students/post.js | 35 - .../Node.js/students@{id}/delete.js | 17 - .../code_samples/Node.js/students@{id}/get.js | 13 - .../Node.js/students@{id}/post.js | 35 - .../Node.js/students@{id}@enrollments/get.js | 13 - .../delete.js | 13 - .../get.js | 13 - .../patch.js | 18 - .../post.js | 13 - .../delete.js | 13 - .../students@{id}@progress@{post_id}/get.js | 13 - .../students@{id}@progress@{post_id}/post.js | 18 - spec/code_samples/Node.js/webhooks/get.js | 13 - spec/code_samples/Node.js/webhooks/post.js | 21 - .../Node.js/webhooks@{id}/delete.js | 13 - .../code_samples/Node.js/webhooks@{id}/get.js | 13 - .../Node.js/webhooks@{id}/post.js | 21 - spec/code_samples/cURL/access-plans/get.sh | 3 - spec/code_samples/cURL/access-plans/post.sh | 5 - .../cURL/access-plans@{id}/delete.sh | 3 - .../cURL/access-plans@{id}/get.sh | 3 - .../cURL/access-plans@{id}/post.sh | 5 - spec/code_samples/cURL/api-keys/get.sh | 3 - spec/code_samples/cURL/api-keys/post.sh | 5 - .../code_samples/cURL/api-keys@{id}/delete.sh | 3 - spec/code_samples/cURL/api-keys@{id}/get.sh | 3 - spec/code_samples/cURL/api-keys@{id}/post.sh | 5 - spec/code_samples/cURL/courses/get.sh | 3 - spec/code_samples/cURL/courses/post.sh | 5 - spec/code_samples/cURL/courses@{id}/delete.sh | 5 - spec/code_samples/cURL/courses@{id}/get.sh | 3 - spec/code_samples/cURL/courses@{id}/post.sh | 5 - .../cURL/courses@{id}@content/get.sh | 3 - .../cURL/courses@{id}@enrollments/get.sh | 3 - spec/code_samples/cURL/groups/get.sh | 3 - spec/code_samples/cURL/groups/post.sh | 5 - spec/code_samples/cURL/groups@{id}/delete.sh | 5 - spec/code_samples/cURL/groups@{id}/get.sh | 3 - spec/code_samples/cURL/groups@{id}/post.sh | 5 - .../cURL/groups@{id}@invitations/get.sh | 3 - .../cURL/groups@{id}@invitations/post.sh | 5 - .../delete.sh | 3 - .../get.sh | 3 - .../cURL/groups@{id}@members/get.sh | 3 - .../groups@{id}@members@{member_id}/delete.sh | 3 - .../groups@{id}@members@{member_id}/get.sh | 3 - .../groups@{id}@members@{member_id}/post.sh | 5 - .../cURL/groups@{id}@seats/get.sh | 3 - .../cURL/groups@{id}@seats/put.sh | 5 - spec/code_samples/cURL/instructors/get.sh | 3 - spec/code_samples/cURL/instructors/post.sh | 5 - .../cURL/instructors@{id}/delete.sh | 5 - .../code_samples/cURL/instructors@{id}/get.sh | 3 - .../cURL/instructors@{id}/post.sh | 5 - .../cURL/instructors@{id}@content/get.sh | 3 - spec/code_samples/cURL/lessons/get.sh | 3 - spec/code_samples/cURL/lessons/post.sh | 5 - spec/code_samples/cURL/lessons@{id}/delete.sh | 5 - spec/code_samples/cURL/lessons@{id}/get.sh | 3 - spec/code_samples/cURL/lessons@{id}/post.sh | 5 - spec/code_samples/cURL/memberships/get.sh | 3 - spec/code_samples/cURL/memberships/post.sh | 5 - .../cURL/memberships@{id}/delete.sh | 5 - .../code_samples/cURL/memberships@{id}/get.sh | 3 - .../cURL/memberships@{id}/post.sh | 5 - .../cURL/memberships@{id}@enrollments/get.sh | 3 - spec/code_samples/cURL/quiz-questions/get.sh | 3 - spec/code_samples/cURL/quiz-questions/post.sh | 5 - .../cURL/quiz-questions@{id}/delete.sh | 3 - .../cURL/quiz-questions@{id}/get.sh | 3 - .../cURL/quiz-questions@{id}/post.sh | 5 - spec/code_samples/cURL/quizzes/get.sh | 3 - spec/code_samples/cURL/quizzes/post.sh | 5 - spec/code_samples/cURL/quizzes@{id}/delete.sh | 3 - spec/code_samples/cURL/quizzes@{id}/get.sh | 3 - spec/code_samples/cURL/quizzes@{id}/post.sh | 5 - spec/code_samples/cURL/sections/get.sh | 3 - spec/code_samples/cURL/sections/post.sh | 5 - .../code_samples/cURL/sections@{id}/delete.sh | 3 - spec/code_samples/cURL/sections@{id}/get.sh | 3 - spec/code_samples/cURL/sections@{id}/post.sh | 5 - .../cURL/sections@{id}@content/get.sh | 3 - spec/code_samples/cURL/students/get.sh | 3 - spec/code_samples/cURL/students/post.sh | 5 - .../code_samples/cURL/students@{id}/delete.sh | 5 - spec/code_samples/cURL/students@{id}/get.sh | 3 - spec/code_samples/cURL/students@{id}/post.sh | 5 - .../cURL/students@{id}@enrollments/get.sh | 3 - .../delete.sh | 3 - .../get.sh | 3 - .../patch.sh | 5 - .../post.sh | 3 - .../delete.sh | 3 - .../students@{id}@progress@{post_id}/get.sh | 3 - .../students@{id}@progress@{post_id}/post.sh | 5 - spec/code_samples/cURL/webhooks/get.sh | 3 - spec/code_samples/cURL/webhooks/post.sh | 5 - .../code_samples/cURL/webhooks@{id}/delete.sh | 3 - spec/code_samples/cURL/webhooks@{id}/get.sh | 3 - spec/code_samples/cURL/webhooks@{id}/post.sh | 5 - spec/components/README.md | 14 - .../headers/PaginationTotalPages.yaml | 4 - .../headers/PaginationTotalResults.yaml | 4 - spec/components/parameters/Context.yaml | 11 - .../parameters/EnrollmentStatus.yaml | 6 - .../parameters/EnrollmentTrigger.yaml | 7 - spec/components/parameters/Exclude.yaml | 6 - spec/components/parameters/Include.yaml | 6 - spec/components/parameters/Order.yaml | 10 - spec/components/parameters/Page.yaml | 9 - spec/components/parameters/PerPage.yaml | 8 - spec/components/parameters/PostPassword.yaml | 7 - spec/components/parameters/PostStatus.yaml | 16 - spec/components/parameters/PostType.yaml | 14 - spec/components/parameters/Search.yaml | 7 - spec/components/parameters/SearchColumns.yaml | 18 - spec/components/parameters/SearchUsers.yaml | 7 - spec/components/responses/Error400.yaml | 6 - spec/components/responses/Error401.yaml | 6 - spec/components/responses/Error403.yaml | 6 - spec/components/responses/Error404.yaml | 6 - spec/components/schemas/APIKey.yaml | 65 - spec/components/schemas/AccessPlan.yaml | 199 - .../components/schemas/AccessPlanRequest.yaml | 12 - .../schemas/AccessPlanResponse.yaml | 71 - spec/components/schemas/Address.yaml | 26 - spec/components/schemas/Course.yaml | 108 - spec/components/schemas/CourseRequest.yaml | 33 - spec/components/schemas/CourseResponse.yaml | 216 - spec/components/schemas/Enrollment.yaml | 76 - spec/components/schemas/EnrollmentStatus.yaml | 6 - spec/components/schemas/Error.yaml | 14 - spec/components/schemas/Error400.yaml | 14 - spec/components/schemas/Error401.yaml | 14 - spec/components/schemas/Error403.yaml | 14 - spec/components/schemas/Error404.yaml | 14 - spec/components/schemas/Group.yaml | 40 - spec/components/schemas/GroupInvitation.yaml | 61 - spec/components/schemas/GroupMember.yaml | 96 - spec/components/schemas/GroupRequest.yaml | 15 - spec/components/schemas/GroupResponse.yaml | 110 - spec/components/schemas/GroupSeat.yaml | 51 - spec/components/schemas/Instructor.yaml | 55 - spec/components/schemas/Lesson.yaml | 137 - spec/components/schemas/LessonRequest.yaml | 3 - spec/components/schemas/LessonResponse.yaml | 115 - spec/components/schemas/Membership.yaml | 55 - .../components/schemas/MembershipRequest.yaml | 33 - .../schemas/MembershipResponse.yaml | 117 - spec/components/schemas/Post.yaml | 32 - .../schemas/PostContentRequest.yaml | 16 - .../schemas/PostContentResponse.yaml | 40 - spec/components/schemas/PostPublic.yaml | 40 - spec/components/schemas/PostStatus.yaml | 9 - spec/components/schemas/PostType.yaml | 3 - spec/components/schemas/Progress.yaml | 82 - spec/components/schemas/Quiz.yaml | 102 - spec/components/schemas/QuizQuestion.yaml | 56 - .../schemas/QuizQuestionRequest.yaml | 14 - .../schemas/QuizQuestionResponse.yaml | 38 - .../schemas/QuizQuestionTypeBlank.yaml | 19 - .../schemas/QuizQuestionTypeChoice.yaml | 60 - .../schemas/QuizQuestionTypeContent.yaml | 15 - .../schemas/QuizQuestionTypeLongAnswer.yaml | 20 - .../QuizQuestionTypePictureChoice.yaml | 75 - .../schemas/QuizQuestionTypeTrueFalse.yaml | 48 - .../QuizQuestionTypesResponseList.yaml | 25 - spec/components/schemas/QuizRequest.yaml | 12 - spec/components/schemas/QuizResponse.yaml | 72 - spec/components/schemas/ResourceId.yaml | 5 - spec/components/schemas/Section.yaml | 41 - spec/components/schemas/SectionRequest.yaml | 12 - spec/components/schemas/SectionResponse.yaml | 88 - .../schemas/SharedCourseMembership.yaml | 62 - spec/components/schemas/Student.yaml | 59 - spec/components/schemas/User.yaml | 127 - spec/components/schemas/UserName.yaml | 14 - spec/components/schemas/Webhook.yaml | 92 - .../securitySchemes/Basic-Authentication.yaml | 2 - spec/openapi.yaml | 450 -- spec/paths/README.md | 5 - spec/paths/access-plans.yaml | 92 - spec/paths/access-plans@{id}.yaml | 74 - spec/paths/api-keys.yaml | 117 - spec/paths/api-keys@{id}.yaml | 75 - spec/paths/courses.yaml | 86 - spec/paths/courses@{id}.yaml | 98 - spec/paths/courses@{id}@content.yaml | 63 - spec/paths/courses@{id}@enrollments.yaml | 71 - spec/paths/groups.yaml | 83 - spec/paths/groups@{id}.yaml | 96 - spec/paths/groups@{id}@invitations.yaml | 103 - ...oups@{id}@invitations@{invitation_id}.yaml | 51 - spec/paths/groups@{id}@members.yaml | 73 - .../groups@{id}@members@{member_id}.yaml | 81 - spec/paths/groups@{id}@seats.yaml | 56 - spec/paths/instructors.yaml | 115 - spec/paths/instructors@{id}.yaml | 94 - spec/paths/instructors@{id}@content.yaml | 74 - spec/paths/lessons.yaml | 95 - spec/paths/lessons@{id}.yaml | 97 - spec/paths/memberships.yaml | 86 - spec/paths/memberships@{id}.yaml | 97 - spec/paths/memberships@{id}@enrollments.yaml | 72 - spec/paths/quiz-questions.yaml | 141 - spec/paths/quiz-questions@{id}.yaml | 100 - spec/paths/quizzes.yaml | 106 - spec/paths/quizzes@{id}.yaml | 74 - spec/paths/sections.yaml | 88 - spec/paths/sections@{id}.yaml | 74 - spec/paths/sections@{id}@content.yaml | 69 - spec/paths/students.yaml | 116 - spec/paths/students@{id}.yaml | 94 - spec/paths/students@{id}@enrollments.yaml | 70 - .../students@{id}@enrollments@{post_id}.yaml | 105 - .../students@{id}@progress@{post_id}.yaml | 78 - spec/paths/webhooks.yaml | 89 - spec/paths/webhooks@{id}.yaml | 72 - tests/assets/lifterlms-rest-en_US.mo | Bin 679 -> 0 bytes tests/bootstrap.php | 78 - .../class-llms-rest-unit-test-case-base.php | 165 - .../class-llms-rest-unit-test-case-posts.php | 495 -- .../class-llms-rest-unit-test-case-server.php | 400 -- ...s-llms-rest-test-admin-form-controller.php | 531 -- ...ass-llms-rest-test-admin-settings-page.php | 106 - .../class-llms-rest-test-api-key.php | 114 - .../class-llms-rest-test-api-keys-query.php | 265 - .../class-llms-rest-test-api-keys.php | 322 -- .../class-llms-rest-test-authentication.php | 213 - .../class-llms-rest-test-capabilities.php | 61 - .../class-llms-rest-test-functions.php | 89 - .../class-llms-rest-test-install.php | 127 - .../unit-tests/class-llms-rest-test-main.php | 225 - .../class-llms-rest-test-webhook-delivery.php | 172 - .../class-llms-rest-test-webhook.php | 912 ---- .../class-llms-rest-test-webhooks-query.php | 227 - .../class-llms-rest-test-webhooks.php | 525 -- ...ms-rest-test-abstract-users-controller.php | 102 - .../class-llms-rest-test-access-plans.php | 1301 ----- ...ass-llms-rest-test-api-keys-controller.php | 426 -- .../server/class-llms-rest-test-courses.php | 1676 ------- .../class-llms-rest-test-enrollments.php | 744 --- ...llms-rest-test-instructors-controllers.php | 286 -- .../server/class-llms-rest-test-lessons.php | 831 ---- .../class-llms-rest-test-memberships.php | 1355 ----- .../server/class-llms-rest-test-sections.php | 448 -- .../class-llms-rest-test-server-functions.php | 449 -- ...ss-llms-rest-test-students-controllers.php | 1327 ----- ...rest-test-students-progress-controller.php | 404 -- ...ss-llms-rest-test-webhooks-controllers.php | 486 -- web/favicon.png | Bin 2138 -> 0 bytes web/index.html | 68 - web/redoc-config.yaml | 23 - 351 files changed, 67 insertions(+), 29665 deletions(-) delete mode 100755 .bin/cache-bust delete mode 100644 .bin/httpsnippet-client-for-llms-node-api.js delete mode 100755 .bin/snippets delete mode 100644 .editorconfig delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/SECURITY.md delete mode 100644 .github/workflows/codeql-analysis.yml delete mode 100644 .github/workflows/coding-standards.yml delete mode 100644 .github/workflows/gh-pages.yml delete mode 100644 .github/workflows/keep-alive.yml delete mode 100644 .github/workflows/ossar-analysis.yml delete mode 100644 .github/workflows/php-test-coverage.yml delete mode 100644 .github/workflows/project-automation.yml delete mode 100644 .github/workflows/shiftleft-analysis.yml delete mode 100644 .github/workflows/sync-branches.yml delete mode 100644 .github/workflows/test-phpunit.yml delete mode 100644 .gitignore delete mode 100644 .llmsdev.yml delete mode 100644 CHANGELOG.md delete mode 100644 README.md delete mode 100644 package-lock.json delete mode 100644 package.json delete mode 100644 phpcs.xml delete mode 100644 phpunit.xml.dist delete mode 100644 spec/README.md delete mode 100644 spec/code_samples/Node.js/access-plans/get.js delete mode 100644 spec/code_samples/Node.js/access-plans/post.js delete mode 100644 spec/code_samples/Node.js/access-plans@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/access-plans@{id}/get.js delete mode 100644 spec/code_samples/Node.js/access-plans@{id}/post.js delete mode 100644 spec/code_samples/Node.js/api-keys/get.js delete mode 100644 spec/code_samples/Node.js/api-keys/post.js delete mode 100644 spec/code_samples/Node.js/api-keys@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/api-keys@{id}/get.js delete mode 100644 spec/code_samples/Node.js/api-keys@{id}/post.js delete mode 100644 spec/code_samples/Node.js/courses/get.js delete mode 100644 spec/code_samples/Node.js/courses/post.js delete mode 100644 spec/code_samples/Node.js/courses@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/courses@{id}/get.js delete mode 100644 spec/code_samples/Node.js/courses@{id}/post.js delete mode 100644 spec/code_samples/Node.js/courses@{id}@content/get.js delete mode 100644 spec/code_samples/Node.js/courses@{id}@enrollments/get.js delete mode 100644 spec/code_samples/Node.js/groups/get.js delete mode 100644 spec/code_samples/Node.js/groups/post.js delete mode 100644 spec/code_samples/Node.js/groups@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/groups@{id}/get.js delete mode 100644 spec/code_samples/Node.js/groups@{id}/post.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@invitations/get.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@invitations/post.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/delete.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/get.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@members/get.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@members@{member_id}/delete.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@members@{member_id}/get.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@members@{member_id}/post.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@seats/get.js delete mode 100644 spec/code_samples/Node.js/groups@{id}@seats/put.js delete mode 100644 spec/code_samples/Node.js/instructors/get.js delete mode 100644 spec/code_samples/Node.js/instructors/post.js delete mode 100644 spec/code_samples/Node.js/instructors@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/instructors@{id}/get.js delete mode 100644 spec/code_samples/Node.js/instructors@{id}/post.js delete mode 100644 spec/code_samples/Node.js/instructors@{id}@content/get.js delete mode 100644 spec/code_samples/Node.js/lessons/get.js delete mode 100644 spec/code_samples/Node.js/lessons/post.js delete mode 100644 spec/code_samples/Node.js/lessons@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/lessons@{id}/get.js delete mode 100644 spec/code_samples/Node.js/lessons@{id}/post.js delete mode 100644 spec/code_samples/Node.js/memberships/get.js delete mode 100644 spec/code_samples/Node.js/memberships/post.js delete mode 100644 spec/code_samples/Node.js/memberships@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/memberships@{id}/get.js delete mode 100644 spec/code_samples/Node.js/memberships@{id}/post.js delete mode 100644 spec/code_samples/Node.js/memberships@{id}@enrollments/get.js delete mode 100644 spec/code_samples/Node.js/quiz-questions/get.js delete mode 100644 spec/code_samples/Node.js/quiz-questions/post.js delete mode 100644 spec/code_samples/Node.js/quiz-questions@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/quiz-questions@{id}/get.js delete mode 100644 spec/code_samples/Node.js/quiz-questions@{id}/post.js delete mode 100644 spec/code_samples/Node.js/quizzes/get.js delete mode 100644 spec/code_samples/Node.js/quizzes/post.js delete mode 100644 spec/code_samples/Node.js/quizzes@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/quizzes@{id}/get.js delete mode 100644 spec/code_samples/Node.js/quizzes@{id}/post.js delete mode 100644 spec/code_samples/Node.js/sections/get.js delete mode 100644 spec/code_samples/Node.js/sections/post.js delete mode 100644 spec/code_samples/Node.js/sections@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/sections@{id}/get.js delete mode 100644 spec/code_samples/Node.js/sections@{id}/post.js delete mode 100644 spec/code_samples/Node.js/sections@{id}@content/get.js delete mode 100644 spec/code_samples/Node.js/students/get.js delete mode 100644 spec/code_samples/Node.js/students/post.js delete mode 100644 spec/code_samples/Node.js/students@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/students@{id}/get.js delete mode 100644 spec/code_samples/Node.js/students@{id}/post.js delete mode 100644 spec/code_samples/Node.js/students@{id}@enrollments/get.js delete mode 100644 spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/delete.js delete mode 100644 spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/get.js delete mode 100644 spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/patch.js delete mode 100644 spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/post.js delete mode 100644 spec/code_samples/Node.js/students@{id}@progress@{post_id}/delete.js delete mode 100644 spec/code_samples/Node.js/students@{id}@progress@{post_id}/get.js delete mode 100644 spec/code_samples/Node.js/students@{id}@progress@{post_id}/post.js delete mode 100644 spec/code_samples/Node.js/webhooks/get.js delete mode 100644 spec/code_samples/Node.js/webhooks/post.js delete mode 100644 spec/code_samples/Node.js/webhooks@{id}/delete.js delete mode 100644 spec/code_samples/Node.js/webhooks@{id}/get.js delete mode 100644 spec/code_samples/Node.js/webhooks@{id}/post.js delete mode 100644 spec/code_samples/cURL/access-plans/get.sh delete mode 100644 spec/code_samples/cURL/access-plans/post.sh delete mode 100644 spec/code_samples/cURL/access-plans@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/access-plans@{id}/get.sh delete mode 100644 spec/code_samples/cURL/access-plans@{id}/post.sh delete mode 100644 spec/code_samples/cURL/api-keys/get.sh delete mode 100644 spec/code_samples/cURL/api-keys/post.sh delete mode 100644 spec/code_samples/cURL/api-keys@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/api-keys@{id}/get.sh delete mode 100644 spec/code_samples/cURL/api-keys@{id}/post.sh delete mode 100644 spec/code_samples/cURL/courses/get.sh delete mode 100644 spec/code_samples/cURL/courses/post.sh delete mode 100644 spec/code_samples/cURL/courses@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/courses@{id}/get.sh delete mode 100644 spec/code_samples/cURL/courses@{id}/post.sh delete mode 100644 spec/code_samples/cURL/courses@{id}@content/get.sh delete mode 100644 spec/code_samples/cURL/courses@{id}@enrollments/get.sh delete mode 100644 spec/code_samples/cURL/groups/get.sh delete mode 100644 spec/code_samples/cURL/groups/post.sh delete mode 100644 spec/code_samples/cURL/groups@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/groups@{id}/get.sh delete mode 100644 spec/code_samples/cURL/groups@{id}/post.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@invitations/get.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@invitations/post.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/delete.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/get.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@members/get.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@members@{member_id}/delete.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@members@{member_id}/get.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@members@{member_id}/post.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@seats/get.sh delete mode 100644 spec/code_samples/cURL/groups@{id}@seats/put.sh delete mode 100644 spec/code_samples/cURL/instructors/get.sh delete mode 100644 spec/code_samples/cURL/instructors/post.sh delete mode 100644 spec/code_samples/cURL/instructors@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/instructors@{id}/get.sh delete mode 100644 spec/code_samples/cURL/instructors@{id}/post.sh delete mode 100644 spec/code_samples/cURL/instructors@{id}@content/get.sh delete mode 100644 spec/code_samples/cURL/lessons/get.sh delete mode 100644 spec/code_samples/cURL/lessons/post.sh delete mode 100644 spec/code_samples/cURL/lessons@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/lessons@{id}/get.sh delete mode 100644 spec/code_samples/cURL/lessons@{id}/post.sh delete mode 100644 spec/code_samples/cURL/memberships/get.sh delete mode 100644 spec/code_samples/cURL/memberships/post.sh delete mode 100644 spec/code_samples/cURL/memberships@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/memberships@{id}/get.sh delete mode 100644 spec/code_samples/cURL/memberships@{id}/post.sh delete mode 100644 spec/code_samples/cURL/memberships@{id}@enrollments/get.sh delete mode 100644 spec/code_samples/cURL/quiz-questions/get.sh delete mode 100644 spec/code_samples/cURL/quiz-questions/post.sh delete mode 100644 spec/code_samples/cURL/quiz-questions@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/quiz-questions@{id}/get.sh delete mode 100644 spec/code_samples/cURL/quiz-questions@{id}/post.sh delete mode 100644 spec/code_samples/cURL/quizzes/get.sh delete mode 100644 spec/code_samples/cURL/quizzes/post.sh delete mode 100644 spec/code_samples/cURL/quizzes@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/quizzes@{id}/get.sh delete mode 100644 spec/code_samples/cURL/quizzes@{id}/post.sh delete mode 100644 spec/code_samples/cURL/sections/get.sh delete mode 100644 spec/code_samples/cURL/sections/post.sh delete mode 100644 spec/code_samples/cURL/sections@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/sections@{id}/get.sh delete mode 100644 spec/code_samples/cURL/sections@{id}/post.sh delete mode 100644 spec/code_samples/cURL/sections@{id}@content/get.sh delete mode 100644 spec/code_samples/cURL/students/get.sh delete mode 100644 spec/code_samples/cURL/students/post.sh delete mode 100644 spec/code_samples/cURL/students@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/students@{id}/get.sh delete mode 100644 spec/code_samples/cURL/students@{id}/post.sh delete mode 100644 spec/code_samples/cURL/students@{id}@enrollments/get.sh delete mode 100644 spec/code_samples/cURL/students@{id}@enrollments@{post_id}/delete.sh delete mode 100644 spec/code_samples/cURL/students@{id}@enrollments@{post_id}/get.sh delete mode 100644 spec/code_samples/cURL/students@{id}@enrollments@{post_id}/patch.sh delete mode 100644 spec/code_samples/cURL/students@{id}@enrollments@{post_id}/post.sh delete mode 100644 spec/code_samples/cURL/students@{id}@progress@{post_id}/delete.sh delete mode 100644 spec/code_samples/cURL/students@{id}@progress@{post_id}/get.sh delete mode 100644 spec/code_samples/cURL/students@{id}@progress@{post_id}/post.sh delete mode 100644 spec/code_samples/cURL/webhooks/get.sh delete mode 100644 spec/code_samples/cURL/webhooks/post.sh delete mode 100644 spec/code_samples/cURL/webhooks@{id}/delete.sh delete mode 100644 spec/code_samples/cURL/webhooks@{id}/get.sh delete mode 100644 spec/code_samples/cURL/webhooks@{id}/post.sh delete mode 100644 spec/components/README.md delete mode 100644 spec/components/headers/PaginationTotalPages.yaml delete mode 100644 spec/components/headers/PaginationTotalResults.yaml delete mode 100644 spec/components/parameters/Context.yaml delete mode 100644 spec/components/parameters/EnrollmentStatus.yaml delete mode 100644 spec/components/parameters/EnrollmentTrigger.yaml delete mode 100644 spec/components/parameters/Exclude.yaml delete mode 100644 spec/components/parameters/Include.yaml delete mode 100644 spec/components/parameters/Order.yaml delete mode 100644 spec/components/parameters/Page.yaml delete mode 100644 spec/components/parameters/PerPage.yaml delete mode 100644 spec/components/parameters/PostPassword.yaml delete mode 100644 spec/components/parameters/PostStatus.yaml delete mode 100644 spec/components/parameters/PostType.yaml delete mode 100644 spec/components/parameters/Search.yaml delete mode 100644 spec/components/parameters/SearchColumns.yaml delete mode 100644 spec/components/parameters/SearchUsers.yaml delete mode 100644 spec/components/responses/Error400.yaml delete mode 100644 spec/components/responses/Error401.yaml delete mode 100644 spec/components/responses/Error403.yaml delete mode 100644 spec/components/responses/Error404.yaml delete mode 100644 spec/components/schemas/APIKey.yaml delete mode 100644 spec/components/schemas/AccessPlan.yaml delete mode 100644 spec/components/schemas/AccessPlanRequest.yaml delete mode 100644 spec/components/schemas/AccessPlanResponse.yaml delete mode 100644 spec/components/schemas/Address.yaml delete mode 100644 spec/components/schemas/Course.yaml delete mode 100644 spec/components/schemas/CourseRequest.yaml delete mode 100644 spec/components/schemas/CourseResponse.yaml delete mode 100644 spec/components/schemas/Enrollment.yaml delete mode 100644 spec/components/schemas/EnrollmentStatus.yaml delete mode 100644 spec/components/schemas/Error.yaml delete mode 100644 spec/components/schemas/Error400.yaml delete mode 100644 spec/components/schemas/Error401.yaml delete mode 100644 spec/components/schemas/Error403.yaml delete mode 100644 spec/components/schemas/Error404.yaml delete mode 100644 spec/components/schemas/Group.yaml delete mode 100644 spec/components/schemas/GroupInvitation.yaml delete mode 100644 spec/components/schemas/GroupMember.yaml delete mode 100644 spec/components/schemas/GroupRequest.yaml delete mode 100644 spec/components/schemas/GroupResponse.yaml delete mode 100644 spec/components/schemas/GroupSeat.yaml delete mode 100644 spec/components/schemas/Instructor.yaml delete mode 100644 spec/components/schemas/Lesson.yaml delete mode 100644 spec/components/schemas/LessonRequest.yaml delete mode 100644 spec/components/schemas/LessonResponse.yaml delete mode 100644 spec/components/schemas/Membership.yaml delete mode 100644 spec/components/schemas/MembershipRequest.yaml delete mode 100644 spec/components/schemas/MembershipResponse.yaml delete mode 100644 spec/components/schemas/Post.yaml delete mode 100644 spec/components/schemas/PostContentRequest.yaml delete mode 100644 spec/components/schemas/PostContentResponse.yaml delete mode 100644 spec/components/schemas/PostPublic.yaml delete mode 100644 spec/components/schemas/PostStatus.yaml delete mode 100644 spec/components/schemas/PostType.yaml delete mode 100644 spec/components/schemas/Progress.yaml delete mode 100644 spec/components/schemas/Quiz.yaml delete mode 100644 spec/components/schemas/QuizQuestion.yaml delete mode 100644 spec/components/schemas/QuizQuestionRequest.yaml delete mode 100644 spec/components/schemas/QuizQuestionResponse.yaml delete mode 100644 spec/components/schemas/QuizQuestionTypeBlank.yaml delete mode 100644 spec/components/schemas/QuizQuestionTypeChoice.yaml delete mode 100644 spec/components/schemas/QuizQuestionTypeContent.yaml delete mode 100644 spec/components/schemas/QuizQuestionTypeLongAnswer.yaml delete mode 100644 spec/components/schemas/QuizQuestionTypePictureChoice.yaml delete mode 100644 spec/components/schemas/QuizQuestionTypeTrueFalse.yaml delete mode 100644 spec/components/schemas/QuizQuestionTypesResponseList.yaml delete mode 100644 spec/components/schemas/QuizRequest.yaml delete mode 100644 spec/components/schemas/QuizResponse.yaml delete mode 100644 spec/components/schemas/ResourceId.yaml delete mode 100644 spec/components/schemas/Section.yaml delete mode 100644 spec/components/schemas/SectionRequest.yaml delete mode 100644 spec/components/schemas/SectionResponse.yaml delete mode 100644 spec/components/schemas/SharedCourseMembership.yaml delete mode 100644 spec/components/schemas/Student.yaml delete mode 100644 spec/components/schemas/User.yaml delete mode 100644 spec/components/schemas/UserName.yaml delete mode 100644 spec/components/schemas/Webhook.yaml delete mode 100644 spec/components/securitySchemes/Basic-Authentication.yaml delete mode 100644 spec/openapi.yaml delete mode 100644 spec/paths/README.md delete mode 100644 spec/paths/access-plans.yaml delete mode 100644 spec/paths/access-plans@{id}.yaml delete mode 100644 spec/paths/api-keys.yaml delete mode 100644 spec/paths/api-keys@{id}.yaml delete mode 100644 spec/paths/courses.yaml delete mode 100644 spec/paths/courses@{id}.yaml delete mode 100644 spec/paths/courses@{id}@content.yaml delete mode 100644 spec/paths/courses@{id}@enrollments.yaml delete mode 100644 spec/paths/groups.yaml delete mode 100644 spec/paths/groups@{id}.yaml delete mode 100644 spec/paths/groups@{id}@invitations.yaml delete mode 100644 spec/paths/groups@{id}@invitations@{invitation_id}.yaml delete mode 100644 spec/paths/groups@{id}@members.yaml delete mode 100644 spec/paths/groups@{id}@members@{member_id}.yaml delete mode 100644 spec/paths/groups@{id}@seats.yaml delete mode 100644 spec/paths/instructors.yaml delete mode 100644 spec/paths/instructors@{id}.yaml delete mode 100644 spec/paths/instructors@{id}@content.yaml delete mode 100644 spec/paths/lessons.yaml delete mode 100644 spec/paths/lessons@{id}.yaml delete mode 100644 spec/paths/memberships.yaml delete mode 100644 spec/paths/memberships@{id}.yaml delete mode 100644 spec/paths/memberships@{id}@enrollments.yaml delete mode 100644 spec/paths/quiz-questions.yaml delete mode 100644 spec/paths/quiz-questions@{id}.yaml delete mode 100644 spec/paths/quizzes.yaml delete mode 100644 spec/paths/quizzes@{id}.yaml delete mode 100644 spec/paths/sections.yaml delete mode 100644 spec/paths/sections@{id}.yaml delete mode 100644 spec/paths/sections@{id}@content.yaml delete mode 100644 spec/paths/students.yaml delete mode 100644 spec/paths/students@{id}.yaml delete mode 100644 spec/paths/students@{id}@enrollments.yaml delete mode 100644 spec/paths/students@{id}@enrollments@{post_id}.yaml delete mode 100644 spec/paths/students@{id}@progress@{post_id}.yaml delete mode 100644 spec/paths/webhooks.yaml delete mode 100644 spec/paths/webhooks@{id}.yaml delete mode 100644 tests/assets/lifterlms-rest-en_US.mo delete mode 100644 tests/bootstrap.php delete mode 100644 tests/framework/class-llms-rest-unit-test-case-base.php delete mode 100644 tests/framework/class-llms-rest-unit-test-case-posts.php delete mode 100644 tests/framework/class-llms-rest-unit-test-case-server.php delete mode 100644 tests/unit-tests/admin/class-llms-rest-test-admin-form-controller.php delete mode 100644 tests/unit-tests/admin/class-llms-rest-test-admin-settings-page.php delete mode 100644 tests/unit-tests/class-llms-rest-test-api-key.php delete mode 100644 tests/unit-tests/class-llms-rest-test-api-keys-query.php delete mode 100644 tests/unit-tests/class-llms-rest-test-api-keys.php delete mode 100644 tests/unit-tests/class-llms-rest-test-authentication.php delete mode 100644 tests/unit-tests/class-llms-rest-test-capabilities.php delete mode 100644 tests/unit-tests/class-llms-rest-test-functions.php delete mode 100644 tests/unit-tests/class-llms-rest-test-install.php delete mode 100644 tests/unit-tests/class-llms-rest-test-main.php delete mode 100644 tests/unit-tests/class-llms-rest-test-webhook-delivery.php delete mode 100644 tests/unit-tests/class-llms-rest-test-webhook.php delete mode 100644 tests/unit-tests/class-llms-rest-test-webhooks-query.php delete mode 100644 tests/unit-tests/class-llms-rest-test-webhooks.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-abstract-users-controller.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-access-plans.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-api-keys-controller.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-courses.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-enrollments.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-instructors-controllers.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-lessons.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-memberships.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-sections.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-server-functions.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-students-controllers.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-students-progress-controller.php delete mode 100644 tests/unit-tests/server/class-llms-rest-test-webhooks-controllers.php delete mode 100644 web/favicon.png delete mode 100644 web/index.html delete mode 100644 web/redoc-config.yaml diff --git a/.bin/cache-bust b/.bin/cache-bust deleted file mode 100755 index 7b4e42c7..00000000 --- a/.bin/cache-bust +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env node - -/** - * Cachebust the openapi.json file powering the static html page - * - * Adds a version query string variable to the deployed static html index file - * and, in doing so, ensures that the latest version will be loaded (instead of a - * possibly outdated cached version). - * - * @since [version] - * @version [version] - */ - -const - fs = require( 'fs' ), - file = `${ process.cwd() }/web_deploy/index.html`, - html = fs.readFileSync( `${ process.cwd() }/web_deploy/index.html` ).toString(), - mtime = fs.statSync( `${ process.cwd() }/web_deploy/openapi.json`, { bigint: true } ).mtimeMs; - -fs.writeFileSync( file, html.replace( `'./openapi.json'`, `'./openapi.json?v=${ mtime }'` ) ); diff --git a/.bin/httpsnippet-client-for-llms-node-api.js b/.bin/httpsnippet-client-for-llms-node-api.js deleted file mode 100644 index e5dceff8..00000000 --- a/.bin/httpsnippet-client-for-llms-node-api.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * HTTP code snippet generator for llms-api-node. - * - * @package LifterLMS_Rest/Bin - * - * @since [version] - * @version [version] - */ - -'use strict' - -const CodeBuilder = require( 'httpsnippet/src/helpers/code-builder' ); - -module.exports = function( source, options ) { - - const - opts = Object.assign( { - indent: ' ' - }, options ), - code = new CodeBuilder( opts.indent ), - apiOpts = { - url: `${ source.uriObj.protocol }//${ source.uriObj.host }`, - consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXX', - consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', - }; - - code.push( 'const llmsAPI = require( "llms-api-node" );' ); - code.push( 'const llms = new llmsAPI( %s );', JSON.stringify( apiOpts, null, opts.indent ) ); - - code.blank(); - - let opener = `llms.${ source.method.toLowerCase() }( '${ source.uriObj.path.replace( '/wp-json/llms/v1', '' ) }',`; - if ( source.postData.jsonObj ) { - code.push( 'const postData = %s;', JSON.stringify( source.postData.jsonObj, null, opts.indent ) ); - code.blank(); - opener += ` postData,`; - } - opener += ` function( err, data, res ) {`; - - code.push( opener ); - code.push( 1, `if ( err ) {` ); - code.push( 2, `throw new Error( 'Error!' );` ); - code.push( 1, `}`) - code.push( 1, 'console.log( data );' ); - code.push( '} );'); - - return code.join(); - -}; - -module.exports.info = { - key: 'llms', - title: 'llms-api-node', - link: 'http://nodejs.org/api/http.html#http_http_request_options_callback', - description: 'LifterLMS Node API Interface', -}; diff --git a/.bin/snippets b/.bin/snippets deleted file mode 100755 index 9ca15b5c..00000000 --- a/.bin/snippets +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env node - -const - fs = require( 'fs' ), - path = require( 'path' ), - OpenAPISnippet = require( 'openapi-snippet' ), - HTTPSnippet = require('httpsnippet'), - openAPI = require( '../web_deploy/openapi.json' ), - targets = [ 'shell_curl', 'node_llms' ]; - -// Add a target for the llms-api-node lib. -HTTPSnippet.addTargetClient( 'node', require( './httpsnippet-client-for-llms-node-api' ) ); - -function getFilepath( obj, target ) { - - const - resource = obj.url.replace( 'https://example.tld/wp-json/llms/v1/', '' ).split( '/' ).join( '@' ); - - switch ( target ) { - case 'shell_curl': - lang = 'cURL'; - ext = 'sh'; - break; - - case 'node_llms': - lang = 'Node.js'; - ext = 'js'; - break; - } - - return `spec/code_samples/${ lang }/${ resource }/${ obj.method.toLowerCase() }.${ ext }`; - -} - -function getSnippet( obj, target ) { - return modSnippet( obj.snippets.filter( snip => snip.id === target )[0].content, target ); -} - -function modSnippet( snip, target ) { - - if ( 'shell_curl' === target ) { - snip = snip.replace( "--header 'authorization: Basic REPLACE_BASIC_AUTH'", '--user ck_XXXXXX:cs_XXXXXX' ); - } - - return snip; - -} - -function writeSnippetForTarget( obj, target ) { - - const filePath = getFilepath( obj, target ); - - fs.mkdirSync( path.dirname( filePath ), { recursive: true } ); - fs.writeFileSync( filePath, getSnippet( obj, target ) ); - -} - -try { - - const results = OpenAPISnippet.getSnippets( openAPI, targets ); - - results.forEach( snip => { - - if ( 'PARAMETERS' === snip.method ) { - return; - } - - writeSnippetForTarget( snip, 'shell_curl' ); - writeSnippetForTarget( snip, 'node_llms' ); - - } ); - -} catch ( err ) { - - console.error( err ); - -} diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 56734c34..00000000 --- a/.editorconfig +++ /dev/null @@ -1,35 +0,0 @@ -### -# -# This file is deployed into this repository via the "Sync Organization Files" workflow. -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/.editorconfig} -# -### - -# This file is for unifying the coding style for different editors and IDEs -# editorconfig.org - -# WordPress Coding Standards -# https://developer.wordpress.org/coding-standards/wordpress-coding-standards/ - -root = true - -[*] -charset = utf-8 -end_of_line = lf -indent_size = 4 -tab_width = 4 -indent_style = tab -insert_final_newline = true -trim_trailing_whitespace = true - -[*.txt] -trim_trailing_whitespace = false - -[*.{md,json,yml,yml.template}] -indent_style = space -indent_size = 2 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index a0317657..00000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,4 +0,0 @@ -* @eri-trabiccolo - -# Workflows & etc... -.github @thomasplevy diff --git a/.github/SECURITY.md b/.github/SECURITY.md deleted file mode 100644 index 382b377c..00000000 --- a/.github/SECURITY.md +++ /dev/null @@ -1,19 +0,0 @@ -Security Policy ---------------- - -## Supported Versions - -LifterLMS 3.x is the only supported branch of LifterLMS. If you're using an unsupported version of LifterLMS we strongly recommend you upgrade to the latest version as soon as possible. - -| Version | Supported | -| ------- | ------------------ | -| 3.x | :white_check_mark: | -| 2.x | :x: | -| 1.x | :x: | - - -## Reporting a Vulnerability - -The LifterLMS team takes security issues and vulnerabilities very seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions. - -To report a vulnerability, please see our guidelines at https://lifterlms.com/security/ diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 719d869e..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: "CodeQL" - -on: - pull_request: - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: ['javascript'] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml deleted file mode 100644 index f3302244..00000000 --- a/.github/workflows/coding-standards.yml +++ /dev/null @@ -1,60 +0,0 @@ -### -# -# This workflow file is deployed into this repository via the "Sync Organization Files" workflow -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/coding-standards.yml} -# -### -name: Coding Standards - -on: - workflow_dispatch: - pull_request: - # Once daily at 00:00 UTC. - schedule: - - cron: '0 0 * * *' - -concurrency: - group: ${{ github.workflow }}-${{ 'pull_request' == github.event_name && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - phpcs: - name: Check Coding Standards - - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.0' - coverage: none - tools: composer, cs2pr - - # Composer Install. - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - name: Install Composer dependencies - run: composer update - - # Check Coding Standards. - - name: Run PHPCS - run: composer run check-cs-errors -- --report-full --report-checkstyle=./phpcs-report.xml - - - name: Show PHPCS results in PR - run: cs2pr ./phpcs-report.xml diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml deleted file mode 100644 index eb645d80..00000000 --- a/.github/workflows/gh-pages.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: GitHub Pages - -on: - push: - branches: - - trunk - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ 'pull_request' == github.event_name && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - deploy: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Node - uses: actions/setup-node@v1 - with: - node-version: '16' - cache: 'npm' - - - name: Install npm dependencies - run: npm ci - - - name: Build - run: npm run build:docs - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./web_deploy diff --git a/.github/workflows/keep-alive.yml b/.github/workflows/keep-alive.yml deleted file mode 100644 index ad192995..00000000 --- a/.github/workflows/keep-alive.yml +++ /dev/null @@ -1,53 +0,0 @@ -### -# -# This workflow file is deployed into this repository via the "Sync Organization Files" workflow. -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/keep-alive.yml} -# -# Keep Repo Alive -# -# This workflow ensures that cronjob workflows are not automatically disabled after 60 days of repo inactivity. -# The workflow will automatically add an empty commit if the repo's latest commitwas made more than 50 days ago. This empty commit will prevent GitHub from automatically disabling this (and other) -# cronjob actions in the repo. -# -### -name: Keep Repo Alive - -on: - # Once daily at 00:00 UTC. - schedule: - - cron: '0 0 * * *' - -jobs: - - keep-alive: - name: Keep Repo Alive - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - token: ${{ secrets.ORG_WORKFLOWS }} - fetch-depth: 0 - - name: Add keep-alive commit - run: | - LAST_COMMIT_TIME=$( git --no-pager log -1 --format=%ct ) - NOW=$( date +%s ) - DIFF_IN_DAYS=$(( ( NOW - LAST_COMMIT_TIME ) / 86400 )) - - echo "Days since last commit: $DIFF_IN_DAYS" - - if (( $DIFF_IN_DAYS > 50 )); then - echo "Adding a keep-alive commit." - - git config --global user.name "keepalive[bot]" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - - git commit --allow-empty -m "Automated commit from the Keep Repo Alive workflow" - git push origin HEAD - else - echo "No keep-alive commit required." - fi \ No newline at end of file diff --git a/.github/workflows/ossar-analysis.yml b/.github/workflows/ossar-analysis.yml deleted file mode 100644 index 3676b8d6..00000000 --- a/.github/workflows/ossar-analysis.yml +++ /dev/null @@ -1,44 +0,0 @@ -# This workflow integrates a collection of open source static analysis tools -# with GitHub code scanning. For documentation, or to provide feedback, visit -# https://github.com/github/ossar-action -name: OSSAR - -on: - pull_request: - -jobs: - OSSAR-Scan: - # OSSAR runs on windows-latest. - # ubuntu-latest and macos-latest support coming soon - runs-on: windows-latest - - steps: - # Checkout your code repository to scan - - name: Checkout repository - uses: actions/checkout@v2 - with: - # We must fetch at least the immediate parents so that if this is - # a pull request then we can checkout the head. - fetch-depth: 2 - - # If this run was triggered by a pull request event, then checkout - # the head of the pull request instead of the merge commit. - - run: git checkout HEAD^2 - if: ${{ github.event_name == 'pull_request' }} - - # Install dotnet, used by OSSAR - - name: Install .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '3.1.201' - - # Run open source static analysis tools - - name: Run OSSAR - uses: github/ossar-action@v1 - id: ossar - - # Upload results to the Security tab - - name: Upload OSSAR results - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: ${{ steps.ossar.outputs.sarifFile }} diff --git a/.github/workflows/php-test-coverage.yml b/.github/workflows/php-test-coverage.yml deleted file mode 100644 index d0012007..00000000 --- a/.github/workflows/php-test-coverage.yml +++ /dev/null @@ -1,75 +0,0 @@ -### -# -# This workflow file is deployed into this repository via the "Sync Organization Files" workflow -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/php-test-coverage.yml} -# -### -name: PHP Code Coverage Report - -on: - workflow_dispatch: - inputs: - cache-suffix: - description: Cache suffix - type: string - pull_request: - # Once daily at 00:00 UTC. - schedule: - - cron: '0 0 * * *' - -concurrency: - group: ${{ github.workflow }}-${{ 'pull_request' == github.event_name && github.head_ref || github.sha }} - cancel-in-progress: true - - -jobs: - - check-secret: - name: "Check for required secret" - runs-on: ubuntu-latest - outputs: - has-secret: ${{ steps.check-secret.outputs.has-secret }} - steps: - - name: Test secret - id: check-secret - run: | - if [ ! -z "${{ secrets.CC_TEST_REPORTER_ID }}" ]; then - echo "::set-output name=has-secret::true" - fi - - test: - name: "PHP Test Coverage" - runs-on: ubuntu-latest - - needs: check-secret - - if: ${{ 'true' == needs.check-secret.outputs.has-secret }} - - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Environment - uses: gocodebox/.github/.github/actions/setup-phpunit@trunk - with: - php-version: "8.0" - wp-version: "5.8" - coverage: "xdebug" - env-file: ".github/.env.php-test-coverage" - deploy-key: ${{ secrets.LLMS_DEPLOY_KEY }} - secrets: ${{ toJSON( secrets ) }} - cache-suffix: ${{ inputs.cache-suffix }} - - - name: Run Tests with Coverage & Upload Coverage Report - uses: paambaati/codeclimate-action@v2.7.5 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - RUN_CODE_COVERAGE: "1" - with: - coverageCommand: composer run tests -- --coverage-clover clover.xml diff --git a/.github/workflows/project-automation.yml b/.github/workflows/project-automation.yml deleted file mode 100644 index 35667960..00000000 --- a/.github/workflows/project-automation.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: Issue & PR Automation - -on: - issues: - types: - - opened - - reopened - pull_request_target: - types: - - opened - - reopened - - review_requested - -env: - PRIMARY_CODEOWNER: '@thomasplevy' - PROJECT_ORG: gocodebox - PROJECT_ID: 18 - -jobs: - - ####################################### - # Add issue to the Development project. - ####################################### - issue-to-project: - name: Move Issue to Project Board - runs-on: ubuntu-latest - if: ( 'issues' == github.event_name && ( 'opened' == github.event.action || 'reopened' == github.event.action ) ) - steps: - - name: Add Issue to Project - uses: leonsteinhaeuser/project-beta-automations@v1.2.0 - with: - gh_token: ${{ secrets.ORG_WORKFLOWS }} - organization: ${{ env.PROJECT_ORG }} - project_id: ${{ env.PROJECT_ID }} - resource_node_id: ${{ github.event.issue.node_id }} - status_value: "Awaiting Triage" - - # - uses: hmarr/debug-action@v2 - - #################################### - # Assign to the project's CODEOWNER. - #################################### - issue-assig: - name: Assign Issue to the Primary CODEOWNER - runs-on: ubuntu-latest - if: ( 'issues' == github.event_name && ( 'opened' == github.event.action || 'reopened' == github.event.action ) && ( null == github.event.issue.assignee ) ) - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Check CODEOWNERS file existence - id: codeowners_file_exists - uses: andstor/file-existence-action@v2 - with: - files: .github/CODEOWNERS - - - name: Parse CODEOWNERS file - id: codeowner - if: steps.codeowners_file_exists.outputs.files_exists == 'true' - uses: SvanBoxel/codeowners-action@v1 - with: - path: .github/CODEOWNERS - - - name: Update PRIMARY_CODEOWNER env var - if: steps.codeowners_file_exists.outputs.files_exists == 'true' - run: | - echo PRIMARY_CODEOWNER=$( echo '${{ steps.codeowner.outputs.codeowners }}' | jq -r '."*"[0]' ) >> $GITHUB_ENV - - - name: Strip @ from username - run: | - echo "PRIMARY_CODEOWNER=${PRIMARY_CODEOWNER#?}" >> $GITHUB_ENV - - - name: Assign issue - uses: pozil/auto-assign-issue@v1 - with: - repo-token: ${{ secrets.ORG_WORKFLOWS }} - assignees: ${{ env.PRIMARY_CODEOWNER }} - - ##################################### - # Add PRs to the Development project. - ##################################### - pr-to-board: - name: Move Pull Request to the Project Board - runs-on: ubuntu-latest - if: ( 'pull_request_target' == github.event_name && ( 'opened' == github.event.action || 'reopened' == github.event.action || 'review_requested' == github.event.action ) ) - steps: - - name: Mark PR as Awaiting Review - uses: leonsteinhaeuser/project-beta-automations@v1.2.0 - with: - gh_token: ${{ secrets.ORG_WORKFLOWS }} - organization: ${{ env.PROJECT_ORG }} - project_id: ${{ env.PROJECT_ID }} - resource_node_id: ${{ github.event.pull_request.node_id }} - status_value: "Awaiting Review" diff --git a/.github/workflows/shiftleft-analysis.yml b/.github/workflows/shiftleft-analysis.yml deleted file mode 100644 index dbfb7241..00000000 --- a/.github/workflows/shiftleft-analysis.yml +++ /dev/null @@ -1,30 +0,0 @@ -# This workflow integrates ShiftLeft Scan with GitHub's code scanning feature -# ShiftLeft Scan is a free open-source security tool for modern DevOps teams -# Visit https://slscan.io/en/latest/integrations/code-scan for help -name: ShiftLeft Scan - -on: - pull_request: - -jobs: - Scan-Build: - # Scan runs on ubuntu, mac and windows - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Perform ShiftLeft Scan - uses: ShiftLeftSecurity/scan-action@master - env: - WORKSPACE: "" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SCAN_AUTO_BUILD: true - with: - output: reports - # Scan auto-detects the languages in your project. To override uncomment the below variable and set the type - # type: credscan,java - # type: python - - - name: Upload report - uses: github/codeql-action/upload-sarif@v1 - with: - sarif_file: reports diff --git a/.github/workflows/sync-branches.yml b/.github/workflows/sync-branches.yml deleted file mode 100644 index 2a7ad7be..00000000 --- a/.github/workflows/sync-branches.yml +++ /dev/null @@ -1,35 +0,0 @@ -### -# -# This workflow file is deployed into this repository via the "Sync Organization Files" workflow -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/sync-branches.yml} -# -### -name: Sync Branches -on: - push: - branches: - - trunk - workflow_dispatch: - -jobs: - sync: - name: trunk -> dev - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - token: ${{ secrets.ORG_WORKFLOWS }} - fetch-depth: 0 - - name: Perform sync - run: | - git config --global user.name "branch-sync[bot]" - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git checkout dev - git pull origin trunk --no-ff - git status - git push origin dev diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml deleted file mode 100644 index 720b332c..00000000 --- a/.github/workflows/test-phpunit.yml +++ /dev/null @@ -1,100 +0,0 @@ -### -# -# This workflow file is deployed into this repository via the "Sync Organization Files" workflow -# -# Direct edits to this file are at risk of being overwritten by the next sync. All edits should be made -# to the source file. -# -# @see Sync workflow {@link https://github.com/gocodebox/.github/actions/workflows/workflow-sync.yml} -# @see Workflow template {@link https://github.com/gocodebox/.github/blob/trunk/.github/workflow-templates/test-phpunit.yml} -# -### -name: Test PHPUnit - -on: - workflow_dispatch: - inputs: - cache-suffix: - description: Cache suffix - type: string - pull_request: - # Once daily at 00:00 UTC. - schedule: - - cron: '0 0 * * *' - -concurrency: - group: ${{ github.workflow }}-${{ 'pull_request' == github.event_name && github.head_ref || github.sha }} - cancel-in-progress: true - -jobs: - - ### - # - # Setup the test matrix. - # - ### - set-matrix: - name: Setup Matrix - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.setup.outputs.matrix }} - steps: - - uses: actions/checkout@v2 - - id: setup - uses: gocodebox/.github/.github/actions/setup-matrix@trunk - - ### - # - # Run tests. - # - ### - test: - name: WP ${{ matrix.WP }} on PHP ${{ matrix.PHP }}${{ matrix.name-append }} - - needs: set-matrix - runs-on: ubuntu-latest - continue-on-error: ${{ matrix.allow-failure }} - - strategy: - fail-fast: false - matrix: ${{ fromJSON( needs.set-matrix.outputs.matrix ) }} - - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Environment - uses: gocodebox/.github/.github/actions/setup-phpunit@trunk - with: - php-version: ${{ matrix.PHP }} - wp-version: ${{ matrix.WP }} - llms-branch: ${{ matrix.LLMS }} - env-file: ".github/.env.test-phpunit" - deploy-key: ${{ secrets.LLMS_DEPLOY_KEY }} - secrets: ${{ toJSON( secrets ) }} - cache-suffix: ${{ inputs.cache-suffix }} - - - name: Run Tests - run: composer run tests - - ### - # - # Check the status of the entire test matrix. - # - # This will succeed if all jobs from the `test` job's matrix succeed. It allows jobs marked with `allow-failure` - # to fail. - # - # This job can be used as a single status check for branch protection rules. Without this - # we would need to require every job in the above build matrix. - # - ### - status: - name: Test PHPUnit Status - runs-on: ubuntu-latest - if: ${{ always() }} - needs: test - steps: - - name: Check overall matrix status - if: ${{ 'success' != needs.test.result }} - run: exit 1 diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 7121d15c..00000000 --- a/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -vendor/ -node_modules/ -dist/ -tmp/ -web_deploy/ -composer.lock diff --git a/.llmsdev.yml b/.llmsdev.yml deleted file mode 100644 index 47723330..00000000 --- a/.llmsdev.yml +++ /dev/null @@ -1,6 +0,0 @@ -update-version: - extra-replacements: - - [ - "./spec/openapi.yaml", - "(?<= version: )(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?" - ] diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 213ea90f..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,279 +0,0 @@ -LifterLMS REST API Changelog -============================ - -v1.0.0-beta.25 - 2022-05-11 ---------------------------- - -##### Updates and Enhancements - -+ Stop returning an error when updating resource properties with a value equal to the saved one. [#222](https://github.com/gocodebox/lifterlms-rest#222), [#289](https://github.com/gocodebox/lifterlms-rest#289) - -##### Bug Fixes - -+ Allow deletion of an unenrolled student's progress. [#173](https://github.com/gocodebox/lifterlms-rest#173) -+ Delete API Keys when user is deleted. [#90](https://github.com/gocodebox/lifterlms-rest#90) - - -v1.0.0-beta-24 - 2022-03-17 ---------------------------- - -##### Bug Fixes - -+ Fixed reference to a non-existent schema property, visibiliy in place of visibility, when updating/adding an access plan. -+ Fixed issue when updating a free access plan. [#267](https://github.com/gocodebox/lifterlms-rest#267) -+ Fixed issue causing the access plan `availability_restrictions` property to always return an empty array. [#269](https://github.com/gocodebox/lifterlms-rest#269) -+ Fixed issue that prevented updating the access plan `redirect_forced` property. [#271](https://github.com/gocodebox/lifterlms-rest#271) -+ Fixed issue updating access plans when there are 6 (max) plans associated with a course/membership. [#272](https://github.com/gocodebox/lifterlms-rest#272) - - -v1.0.0-beta.23 - 2022-02-23 ---------------------------- - -##### Updates and Enhancements - -+ Replaced call to deprecated `LLMS_Section::get_parent_course()` with `LLMS_Section::get( 'parent_course' )`. -+ Replaced the calls to the deprecated `LLMS_Lesson::get_parent_course()` method with `LLMS_Lesson::get( 'parent_course' )`. -+ Replaced deprecated `llms_user_removed_from_membership_level` action hook with `llms_user_removed_from_membership`. - - -v1.0.0-beta.22 - 2021-12-15 ---------------------------- - -##### Developer Notes - -+ The LifterLMS Core minimum required version has been raised to version 6.0.0-alpha.1. -+ Renamed `LLMS_REST_API_Keys_Query` and `LLMS_REST_Webhooks_Query` `preprare_query()` methods to `prepare_query`. [gocodebox/lifterlms#859](https://github.com/gocodebox/lifterlms#859) - - -v1.0.0-beta.21 - 2021-12-07 ---------------------------- - -##### New Features - -+ Post based resources like couress, memberships, section, lessons... are now searchable. - - -v1.0.0-beta.20 - 2021-10-11 ---------------------------- - -+ Fixed an issue that generated a PHP Fatal when retrieving the list of access plans if logged in as administrator. -+ Fixed the access plan's `access_expires` property format not respecting the specs (Y-m-d H:i:s). -+ Fixed an issue that made the access plan's properties `sale_date_start` and `sale_date_end` to be returned as empty. - - -v1.0.0-beta.19 - 2021-04-13 ---------------------------- - -+ Added collection filtering by post status for courses, lessons, and memberships. - - -v1.0.0-beta.18 - 2021-02-09 ---------------------------- - -##### Updates - -+ Added Access Plan resource and endpoint. -+ Provide a more significant error message when trying to delete an item without permissions. -+ Use `WP_Http` constants in favor of integers when referencing HTTP status codes. - -##### Bug fixes - -+ Fixes localization issues where a singular name was used in favor of the expected plural form. -+ Fixed issues where an error object was not properly returned when expected -+ Fixed call to undefined function `llms_bad_request_error()`, must be `llms_rest_bad_request_error()`. -+ Fixed access plans resource link. -+ Fixed wrong trigger retrieved when multiple trigger were present for the same user/post pair on Student Enrollment resources. - - -v1.0.0-beta.17 - 2020-11-24 ---------------------------- - -+ Bugfix: Fixed an issue with webhooks causing a failed webhook to cause other webhooks to stop triggering. -+ Update: Added improved localization methods when running as a standalone plugin. - -##### Breaking Change - -+ Method `LLMS_REST_Webhook::is_pending()` has been removed. -+ Database column `pending_delivery` on the `lifterlms_rest_webhooks` table (and related model properties) have been deprecated and scheduled for removal. - - -v1.0.0-beta.16 - 2020-11-05 ---------------------------- - -+ Improved performance of various database queries. - - -v1.0.0-beta.15 - 2020-09-21 ---------------------------- - -+ Bugfix: Created lessons will now have the derivative `course_id` property set according to the ID of the lesson's parent section. -+ Bugfix: The `course_id` property of lessons is now properly marked as read-only. - - -v1.0.0-beta.14 - 2020-07-01 ---------------------------- - -##### Breaking Change - -+ `LLMS_REST_Controller::prepare_links()` now requires a second parameter, the `WP_REST_Request` for the current request. Any classes extending and overwriting this method must adjust their method signature to accommodate this change. - -##### Bug Fixes - -+ Fix issue causing response objects to unintentionally include keys of remapped fields. This error occurs only when extending core controllers and attempting to exclude core fields. - - -v1.0.0-beta.13 - 2020-06-22 ---------------------------- - -+ Bugfix: Fixed error response messages on the instructors endpoint. -+ Bugfix: Fixed student progress deletion endpoint issues preventing progress from being fully removed. - - -v1.0.0-beta.12 - 2020-05-27 ---------------------------- - -+ Fix: Prevent infinite loops encountered when invalid API keys are utilized. -+ Fix: Add an action used to fire LifterLMS core engagement and notification emails -+ Feature: Added the ability to filter student and instructor collection list requests by various user information fields. - - -v1.0.0-beta.11 - 2020-03-30 ---------------------------- - -+ Bugfix: Correctly store user `billing_postcode` meta data. -+ Bugfix: Fixed issue preventing course.created (and other post.created) webhooks from firing. - - -v1.0.0-beta.10 - 2020-02-28 ---------------------------- - -+ Added text domain to i18n functions that were missing the domain. -+ Fixed setting roles instead of appending them when updating user, thanks [@pondermatic](https://github.com/pondermatic)! -+ Added a "trigger" parameter to enrollment-related endpoints. -+ Added `llms_rest_enrollments_item_schema`, `llms_rest_prepare_enrollment_object_response`, `llms_rest_enrollment_links` filter hooks. -+ Fixed return when the enrollment to be deleted doesn't exist, returns `204` instead of `404`. -+ Fixed 'context' query parameter schema, thanks [@pondermatic](https://github.com/pondermatic)! - - -v1.0.0-beta.9 - 2019-11-11 --------------------------- - -##### Updates - -+ Added memberships controller, huge thanks to [@pondermatic](https://github.com/pondermatic)! -+ Added new filters: - - + `llms_rest_lesson_filters_removed_for_response` - + `llms_rest_course_item_schema` - + `llms_rest_pre_insert_course` - + `llms_rest_prepare_course_object_response` - + `llms_rest_course_links` - -+ Improved validation when defining instructors for courses. -+ Improved performance on post collection listing functions. - -##### Bug fixes - -+ Ensure that a course instructor is always set for courses. -+ Fixed `sales_page_url` not returned in `edit` context. -+ In `update_additional_object_fields()` method, use `WP_Error::$errors` in place of `WP_Error::has_errors()` to support WordPress version prior to 5.1. - - -v1.0.0-beta.8 - 2019-10-24 --------------------------- - -+ Return links to those taxonomies which have an accessible rest route. -+ Initialize `$prepared_item` array before adding values to it. Thanks [@pondermatic](https://github.com/pondermatic)! -+ Fixed `sales_page_type` not returned as `none` if course's `sales_page_content_type` property is empty. -+ Load webhook actions a little bit later, to avoid PHP warnings on first plugin activation. -+ Renamed `sales_page_page_type` and `sales_page_page_url` properties, respectively to `sales_page_type` and `sales_page_url` according to the specs. -+ Add missing quotes in enrollment/access default messages shortcodes. -+ Call `set_bulk()` llms post method passing `true` as second parameter, so to instruct it to return a WP_Error on failure. -+ Add missing quotes in enrollment/access default messages shortcodes. -+ `sales_page_page_id` and `sales_page_url` always returned in edit context. -+ Call `set_bulk()` llms post method passing `true` as second parameter, so to instruct it to return a WP_Error on failure. - - -v1.0.0-beta.7 - 2019-09-27 --------------------------- - -##### Updates - -+ Added the following properties to the lesson schema and response object: `drip_date`, `drip_days`, `drip_method`, `public`, `quiz`. -+ Added the following links to lesson objects: `prerequisite` and `quiz`. -+ Use `WP_Error::$errors` in place of `WP_Error::has_errors()` to support WordPress version prior to 5.1. -+ Added `llms_rest_lesson_item_schema`, `llms_rest_pre_insert_lesson`, `llms_rest_prepare_lesson_object_response`, `llms_rest_lesson_links` filter hooks. -+ Course properties `access_opens_date`, `access_closes_date`, `enrollment_opens_date`, `enrollment_closes_date` are now nullable. -+ Course properties `prerequisite` and `prerequisite_track` can be be cleared (set to `0` to signify no prerequisite exists). -+ Added prerequisite validation for courses, if `prerequisite` is not a valid course the course `prerequisite` will be set to `0` and if `prerequisite_track` is not a valid course track, the course `prerequisite_track` will be set to `0`. - -##### Bug Fixes - -+ Fixed lesson `siblings` link that was using the parent course's id instead of the parent section's id. -+ Fixed lesson `parent` link href, replacing 'section' with 'sections'. -+ Fixed lesson progression callback name when defining the filters to be removed while preparing the item for response. -+ Fixed description of the `post_id` path parameter for student enrollments resources. Thanks [@pondermatic](https://github.com/pondermatic). -+ Fixed section parent course object retrieval method when building the resource links. - - -v1.0.0-beta.6 - 2019-08-27 --------------------------- - -+ Fix issue causing certain webhooks to not trigger as a result of action load order. -+ Change "access_plans" to "Access Plans" for better human reading. - - -v1.0.0-beta.5 - 2019-08-22 --------------------------- - -+ Load all required files and functions when authentication is triggered. -+ Access `$_SERVER` variables via `filter_var` instead of `llms_filter_input` to work around PHP bug https://bugs.php.net/bug.php?id=49184. - - -v1.0.0-beta.4 - 2019-08-21 --------------------------- - -+ Load authentication handlers as early as possible. Fixes conflicts with numerous plugins which load user information earlier than expected by the WordPress core. -+ Harden permissions associated with viewing student enrollment information. -+ Returns a 400 Bad Request when invalid dates are supplied. -+ Student Enrollment objects return student and post id's as integers instead of strings. -+ Fixed references to an undefined function. - - -v1.0.0-beta.3 - 2019-08-19 --------------------------- - -##### Interface and Experience improvements during API Key creation - -+ Better expose that API Keys are never shown again after the initial creation. -+ Allow downloading of API Credentials as a `.txt` file. -+ Add `required` properties to required fields. - -##### Updates - -+ Added the ability to CRUD webhooks via the REST API. -+ Conditionally throw `_doing_it_wrong` on server controller stubs. -+ Improve performance by returning early when errors are encountered for various methods. -+ Utilizes a new custom property `show_in_llms_rest` to determine if taxonomies should be displayed in the LifterLMS REST API. -+ On the webhooks table the "Delivery URL" is trimmed to 40 characters to improve table readability. - -##### Bug fixes - -+ Fixed a formatting error when creating webhooks with the default auto-generated webhook name. -+ On the webhooks table a translatable string is output for the status instead of the database value. -+ Fix an issue causing the "Last" page pagination link to display for lists with 0 possible results. -+ Don't output the "Last" page pagination link on the last page. - - -v1.0.0-beta.2 - 2019-08-15 --------------------------- - -+ Filter course taxonomies by the `public` property instead of the `show_in_rest` property. -+ Fixed bug preventing async webhooks from being delivered properly. -+ Only load the main plugin function when loading the main plugin file. Fixes issue when running plugin alongside LifterLMS core with bundled API. - - -v1.0.0-beta.1 - 2019-08-15 --------------------------- - -+ Initial public beta release. diff --git a/README.md b/README.md deleted file mode 100644 index 04485a0a..00000000 --- a/README.md +++ /dev/null @@ -1,97 +0,0 @@ -LifterLMS REST API -================== - -[![Test PHPUnit][img-phpunit-tests]][link-phpunit-tests] -[![PHP Tests Coverage][img-gh-tests-coverage]][link-gh-tests-coverage] -[![PHPCS Coding Standards][img-phpcs-checks]][link-phpcs-checks] -[![Code Climate maintainability][img-cc-maintainability]][link-cc] -[![Code Climate test coverage][img-cc-coverage]][link-cc-coverage] - -[![PHP Supported Version][img-php]][link-php] - -[![Contributions Welcome][img-contributions-welcome]][link-contributing] -[![Slack community][img-slack]][link-slack] - ---- - -A REST API feature plugin for [LifterLMS](https://github.com/gocodebox/lifterlms). - ---- - -**This specification (and repository) is in beta. It is not yet a fully-functional API. API changes will be continue to be made without deprecation until 1.0.0 is released as a "stable" API.** - - -## Contributing [![Contributions Welcome][img-contributions-welcome]][link-contributing] - -We are looking for both API specification designers and developers interested in contributing. Read our contribution guidelines [here][link-contributing]. - - -## Specification & Documentation - -The LifterLMS REST API follows the [OpenAPI Specification (Version 3.0.0)][link-openapi-spec]. - -REST API documentation is available at [gocodebox.github.io/lifterlms-rest/](https://gocodebox.github.io/lifterlms-rest/). - -The full OpenAPI spec can be downloaded in [json](https://gocodebox.github.io/lifterlms-rest/openapi.json) or [yaml](https://gocodebox.github.io/lifterlms-rest/openapi.yaml) formats. - - -## Building & Developing REST API Doc spec - -This repo uses [ReDoc](https://github.com/Rebilly/ReDoc). - -To build the docs locally for development: - -+ `npm start`: Starts the development server. -+ `npm run build`: Bundles the spec and prepares web_deploy folder with static assets. -+ `npm test`: Validates the spec. -+ `npm run gh-pages`: Deploys docs to GitHub Pages. You don't need to run it manually if you have Travis CI configured. - - -## Tests and Coding Standards - -The LifterLMS REST API adheres to the [documentation](links-cs-docs) and [coding standards][link-cs-code] defined for the LifterLMS Core codebase. - -+ `composer run check-cs`: Check coding and documentation standards, showing warnings and errors. -+ `composer run check-cs-errors`: Check coding and documentation standards, showing errors only. - -To run the phpunit test suite: - -+ `composer run tests-install`: Install the test suite. -+ `composer run tests-run`: Run the test suite. - - -## Building and Publishing Releases - -+ `llms-dev log:write`: Write changelog. -+ `llms-dev ver:update`: Update version numbers. -+ `npm run build`: Build a release: spec, doc code snippets, and included language files. -+ `llms-dev archive`: Build distributable zip file. -+ `llms-dev publish:gh`: Publish release. -+ Open a Pull Request in the LifterLMS Core to upgrade the library. - -These steps require `write` access to the repository as well as access to the internal development CLI `llms-dev`. Developers and maintainers are provided with required permissions as needed. - - - -[link-cc]: https://codeclimate.com/github/gocodebox/lifterlms-rest/maintainability "LifterLMS REST on Code Climate" -[link-cc-coverage]: https://codeclimate.com/github/gocodebox/lifterlms-rest/test_coverage "Code coverage reports on Code Climate" -[link-cs-code]: https://github.com/gocodebox/lifterlms/blob/master/docs/coding-standards.md "LifterLMS Coding Standards" -[link-cs-docs]: https://github.com/gocodebox/lifterlms/blob/master/docs/documentation-standards.md "LifterLMS Documentation Standards" -[link-contributing]: https://github.com/gocodebox/lifterlms/blob/master/.github/CONTRIBUTING.md "Contribute to LifterLMS REST" -[link-openapi-spec]: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md "OpenAPI Specification (Version 3.0.0)" -[link-php]: https://www.php.net/supported-versions "PHP Supported Versions" -[link-slack]: https://lifterlms.com/slack "Chat with the community on Slack" -[link-support]: https://lifterlms.com/my-account/my-tickets "LifterLMS customer support" -[link-support-forums]: https://wordpress.org/support/plugin/lifterlms "LifterLMS user support forums" -[link-phpunit-tests]: https://github.com/gocodebox/lifterlms-rest/actions/workflows/test-phpunit.yml "PHPUnit Tests Status" -[link-gh-tests-coverage]: https://github.com/gocodebox/lifterlms-rest/actions/workflows/php-test-coverage.yml "PHP Tests Coverage" -[link-phpcs-checks]: https://github.com/gocodebox/lifterlms-rest/actions/workflows/coding-standards.yml "PHPCS Coding Standards Checks" - -[img-cc-coverage]:https://img.shields.io/codeclimate/coverage/gocodebox/lifterlms-rest?style=for-the-badge&logo=code-climate -[img-cc-maintainability]:https://img.shields.io/codeclimate/maintainability/gocodebox/lifterlms-rest?logo=code-climate&style=for-the-badge -[img-contributions-welcome]: https://img.shields.io/badge/contributions-welcome-blue.svg?style=for-the-badge&logo=data:image/svg%2bxml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik02NzIgMTQ3MnEwLTQwLTI4LTY4dC02OC0yOC02OCAyOC0yOCA2OCAyOCA2OCA2OCAyOCA2OC0yOCAyOC02OHptMC0xMTUycTAtNDAtMjgtNjh0LTY4LTI4LTY4IDI4LTI4IDY4IDI4IDY4IDY4IDI4IDY4LTI4IDI4LTY4em02NDAgMTI4cTAtNDAtMjgtNjh0LTY4LTI4LTY4IDI4LTI4IDY4IDI4IDY4IDY4IDI4IDY4LTI4IDI4LTY4em05NiAwcTAgNTItMjYgOTYuNXQtNzAgNjkuNXEtMiAyODctMjI2IDQxNC02NyAzOC0yMDMgODEtMTI4IDQwLTE2OS41IDcxdC00MS41IDEwMHYyNnE0NCAyNSA3MCA2OS41dDI2IDk2LjVxMCA4MC01NiAxMzZ0LTEzNiA1Ni0xMzYtNTYtNTYtMTM2cTAtNTIgMjYtOTYuNXQ3MC02OS41di04MjBxLTQ0LTI1LTcwLTY5LjV0LTI2LTk2LjVxMC04MCA1Ni0xMzZ0MTM2LTU2IDEzNiA1NiA1NiAxMzZxMCA1Mi0yNiA5Ni41dC03MCA2OS41djQ5N3E1NC0yNiAxNTQtNTcgNTUtMTcgODcuNS0yOS41dDcwLjUtMzEgNTktMzkuNSA0MC41LTUxIDI4LTY5LjUgOC41LTkxLjVxLTQ0LTI1LTcwLTY5LjV0LTI2LTk2LjVxMC04MCA1Ni0xMzZ0MTM2LTU2IDEzNiA1NiA1NiAxMzZ6IiBmaWxsPSIjZmZmIi8+PC9zdmc+ -[img-php]: https://img.shields.io/badge/PHP-7.2%2B-brightgreen?style=for-the-badge&logoColor=white&logo=php -[img-slack]: https://img.shields.io/badge/chat-on%20slack-blueviolet?style=for-the-badge&logo=slack -[img-phpunit-tests]: https://img.shields.io/github/workflow/status/gocodebox/lifterlms-rest/Test%20PHPUnit?label=PHPUnit&logo=github&style=for-the-badge -[img-gh-tests-coverage]: https://img.shields.io/github/workflow/status/gocodebox/lifterlms-rest/PHP%20Code%20Coverage%20Report?label=PHP%20Tests%20Coverage&logo=github&style=for-the-badge -[img-phpcs-checks]: https://img.shields.io/github/workflow/status/gocodebox/lifterlms-rest/Coding%20Standards?label=PHPCS&logo=github&style=for-the-badge diff --git a/class-lifterlms-rest-api.php b/class-lifterlms-rest-api.php index 77398f2b..9e7abb25 100644 --- a/class-lifterlms-rest-api.php +++ b/class-lifterlms-rest-api.php @@ -1,11 +1,11 @@ version, '>' ) ) { + if ( ! function_exists( 'llms' ) || version_compare( '7.0.2', llms()->version, '>' ) ) { return; } diff --git a/i18n/lifterlms-rest.pot b/i18n/lifterlms-rest.pot index 3df1819f..0c775cf4 100644 --- a/i18n/lifterlms-rest.pot +++ b/i18n/lifterlms-rest.pot @@ -1,15 +1,15 @@ -# Copyright (C) 2019-2022 LifterLMS +# Copyright (C) 2019-2023 LifterLMS # This file is distributed under the GPLv3. msgid "" msgstr "" -"Project-Id-Version: LifterLMS REST API 1.0.0-beta.25\n" +"Project-Id-Version: LifterLMS REST API 1.0.0-beta.26\n" "Report-Msgid-Bugs-To: https://lifterlms.com/my-account/my-tickets\n" "Last-Translator: Team LifterLMS \n" "Language-Team: Team LifterLMS \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2022-05-11T06:55:12+00:00\n" +"POT-Creation-Date: 2023-02-28T15:32:26+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: llms/dev 0.0.2\n" "X-Domain: lifterlms\n" @@ -1108,63 +1108,63 @@ msgstr "" msgid "Sorry, you are not allowed to create an enrollment as this user." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:331 +#: includes/server/class-llms-rest-enrollments-controller.php:332 msgid "The enrollment could not be created" msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:367 +#: includes/server/class-llms-rest-enrollments-controller.php:368 msgid "Sorry, you are not allowed to update an enrollment as this user." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:417 +#: includes/server/class-llms-rest-enrollments-controller.php:419 msgid "The enrollment status could not be updated" msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:431 +#: includes/server/class-llms-rest-enrollments-controller.php:433 msgid "The enrollment creation date could not be updated" msgstr "" #. Translators: %s = The post type name. -#: includes/server/class-llms-rest-enrollments-controller.php:471 +#: includes/server/class-llms-rest-enrollments-controller.php:473 msgid "Sorry, you are not allowed to delete enrollments as this user." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:511 +#: includes/server/class-llms-rest-enrollments-controller.php:513 msgid "The enrollment cannot be deleted." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:643 +#: includes/server/class-llms-rest-enrollments-controller.php:646 msgid "Filter results to records matching the specified status." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:650 +#: includes/server/class-llms-rest-enrollments-controller.php:653 msgid "Limit results to a specific course or membership or a list of courses and/or memberships. Accepts a single post id or a comma separated list of post ids." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:675 +#: includes/server/class-llms-rest-enrollments-controller.php:678 #: includes/server/class-llms-rest-students-progress-controller.php:223 msgid "The ID of the course/membership." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:681 +#: includes/server/class-llms-rest-enrollments-controller.php:684 #: includes/server/class-llms-rest-students-progress-controller.php:217 msgid "The ID of the student." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:687 +#: includes/server/class-llms-rest-enrollments-controller.php:690 msgid "Creation date. Format: `Y-m-d H:i:s`" msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:692 +#: includes/server/class-llms-rest-enrollments-controller.php:695 msgid "Date last modified. Format: `Y-m-d H:i:s`" msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:698 +#: includes/server/class-llms-rest-enrollments-controller.php:701 #: includes/server/class-llms-rest-students-progress-controller.php:245 msgid "The status of the enrollment." msgstr "" -#: includes/server/class-llms-rest-enrollments-controller.php:704 +#: includes/server/class-llms-rest-enrollments-controller.php:707 msgid "The enrollment trigger. Default is `any`." msgstr "" @@ -1387,7 +1387,7 @@ msgstr "" msgid "You are not allowed to list students." msgstr "" -#: includes/server/class-llms-rest-students-controller.php:386 +#: includes/server/class-llms-rest-students-controller.php:387 msgid "You are not allowed to edit this student." msgstr "" @@ -1395,15 +1395,15 @@ msgstr "" msgid "Student's progress as a percentage." msgstr "" -#: includes/server/class-llms-rest-students-progress-controller.php:413 +#: includes/server/class-llms-rest-students-progress-controller.php:418 msgid "Unique identifier for the student. The WP User ID." msgstr "" -#: includes/server/class-llms-rest-students-progress-controller.php:417 +#: includes/server/class-llms-rest-students-progress-controller.php:422 msgid "Unique course, lesson, or section Identifer. The WordPress Post ID." msgstr "" -#: includes/server/class-llms-rest-students-progress-controller.php:511 +#: includes/server/class-llms-rest-students-progress-controller.php:516 msgid "Created date cannot be in the future." msgstr "" diff --git a/includes/server/class-llms-rest-api-keys-controller.php b/includes/server/class-llms-rest-api-keys-controller.php index 433a0dc0..5cf9f009 100644 --- a/includes/server/class-llms-rest-api-keys-controller.php +++ b/includes/server/class-llms-rest-api-keys-controller.php @@ -1,11 +1,11 @@ get_fields_for_response( $request ) as $field ) { - $data[ $field ] = $item->get( $field ); + $fields_for_response = $this->get_fields_for_response( $request ); + foreach ( $this->map_schema_to_database() as $schema_field => $db_field ) { + if ( in_array( $schema_field, $fields_for_response, true ) ) { + $data[ $schema_field ] = $item->get( $db_field ); + } } // Is a creation request, return consumer key & secret. diff --git a/includes/server/class-llms-rest-enrollments-controller.php b/includes/server/class-llms-rest-enrollments-controller.php index 5260f416..cfa6b730 100644 --- a/includes/server/class-llms-rest-enrollments-controller.php +++ b/includes/server/class-llms-rest-enrollments-controller.php @@ -5,7 +5,7 @@ * @package LLMS_REST * * @since 1.0.0-beta.1 - * @version 1.0.0-beta.18 + * @version 1.0.0-beta.26 */ defined( 'ABSPATH' ) || exit; @@ -109,7 +109,7 @@ public function get_endpoint_args_for_item_schema( $method = WP_REST_Server::CRE * @since 1.0.0-beta.1 * @since 1.0.0-beta.7 Fixed description of the `post_id` path parameter. * @since 1.0.0-beta.10 Add `trigger` param for create/update/delete endpoints. - * Use backticks in args descriptions. + * Use backticks in args descriptions. * * @return void */ @@ -294,6 +294,7 @@ public function create_item_permissions_check( $request ) { * * @since 1.0.0-beta.1 * @since 1.0.0-beta.10 Handle the `trigger` param. + * @since 1.0.0-beta.26 By default don't load the current user if a falsy student ID is supplied. * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. @@ -306,14 +307,14 @@ public function create_item( $request ) { // The default trigger for the `LLMS_Student::enroll()` method is 'unspecified'. $trigger = $request['trigger'] && 'any' !== $request['trigger'] ? $request['trigger'] : 'unspecified'; - // check both students and product exist. - $student = new LLMS_Student( $user_id ); + // Check both students and product exist. + $student = new LLMS_Student( $user_id, false ); if ( ! $student->exists() ) { return llms_rest_not_found_error(); } - // can only be enrolled in the following post types. + // Can only be enrolled in the following post types. $product_type = get_post_type( $post_id ); if ( ! $product_type ) { return llms_rest_not_found_error(); @@ -377,6 +378,7 @@ public function update_item_permissions_check( $request ) { * @since 1.0.0-beta.1 * @since 1.0.0-beta.4 Return a bad request error when supplying an invalid date_created param. * @since 1.0.0-beta.10 Handle `trigger` param. + * @since 1.0.0-beta.26 By default don't load the current user if a falsy student ID is supplied. * * @param WP_REST_Request $request Request object. * @return WP_REST_Response|WP_Error Response object or WP_Error on failure. @@ -386,14 +388,14 @@ public function update_item( $request ) { $student_id = (int) $request['id']; $post_id = (int) $request['post_id']; - // check both students and product exist. - $student = new LLMS_Student( $student_id ); + // Check both students and product exist. + $student = new LLMS_Student( $student_id, false ); if ( ! $student->exists() ) { return llms_rest_not_found_error(); } - // can only be enrolled in the following post types. + // Can only be enrolled in the following post types. $product_type = get_post_type( $post_id ); if ( ! $product_type ) { return llms_rest_not_found_error(); @@ -446,7 +448,7 @@ public function update_item( $request ) { * Check if a given request has access to delete an item. * * @since 1.0.0-beta.1 - * @since The`trigger` param is now taken into account. + * @since 1.0.0-beta.10 The`trigger` param is now taken into account. * @since 1.0.0-beta.18 Provide a more significant error message when trying to delete an item without permissions. * * @param WP_REST_Request $request Full details about the request. @@ -520,6 +522,7 @@ public function delete_item( $request ) { * * @since 1.0.0-beta.1 * @since 1.0.0-beta.10 Added the `trigger` param. + * @since 1.0.0-beta.26 By default don't load the current user if a falsy student ID is supplied. * * @param int $student_id Student ID. * @param int $post_id The course/membership ID. @@ -529,7 +532,7 @@ public function delete_item( $request ) { */ protected function enrollment_exists( $student_id, $post_id, $trigger = 'any', $wp_error = true ) { - $student = llms_get_student( $student_id ); + $student = llms_get_student( $student_id, false ); if ( empty( $student ) ) { return $wp_error ? llms_rest_not_found_error() : false; @@ -1011,7 +1014,7 @@ protected function get_objects_query( $query_args, $request = null ) { * * @since 1.0.0-beta.1 * @since 1.0.0-beta.10 Filter enrollment to include only fields available for response. - * Added `llms_rest_prepare_enrollment_object_response` filter hook. + * Added `llms_rest_prepare_enrollment_object_response` filter hook. * * @param stdClass $enrollment Enrollment object. * @param WP_REST_Request $request Full details about the request. @@ -1111,6 +1114,7 @@ public function prepare_links( $enrollment, $request ) { * * @since 1.0.0-beta.1 * @since 1.0.0-beta.10 Added the `trigger` paramater. + * @since 1.0.0-beta.26 Fixed passing a 3rd parameter to `LLMS_Student::enroll()` method. * * @param LLMS_Student $student Student. * @param integer $post_id The post id. @@ -1125,7 +1129,7 @@ protected function handle_status_update( $student, $post_id, $status, $trigger ) case 'enrolled': // The default trigger for the `LLMS_Student::enroll()` method is 'unspecified'. $trigger = $trigger && 'any' !== $trigger ? $trigger : 'unspecified'; - $updated = $student->enroll( $post_id, 'admin_' . get_current_user_id(), $trigger ); + $updated = $student->enroll( $post_id, $trigger ); break; default: $updated = $student->unenroll( $post_id, $trigger, $status ); diff --git a/includes/server/class-llms-rest-students-controller.php b/includes/server/class-llms-rest-students-controller.php index 73831f41..8fab3988 100644 --- a/includes/server/class-llms-rest-students-controller.php +++ b/includes/server/class-llms-rest-students-controller.php @@ -5,7 +5,7 @@ * @package LifterLMS_REST/Classes/Controllers * * @since 1.0.0-beta.1 - * @version 1.0.0-beta.14 + * @version 1.0.0-beta.26 */ defined( 'ABSPATH' ) || exit; @@ -198,13 +198,14 @@ public function get_items_permissions_check( $request ) { * Get object. * * @since 1.0.0-beta.1 + * @since 1.0.0-beta.26 Don't autoload current user if a falsy user id is supplied. * * @param int $id Object ID. * @return LLMS_Student|WP_Error */ protected function get_object( $id ) { - $student = llms_get_student( $id ); + $student = llms_get_student( $id, false ); return $student ? $student : llms_rest_not_found_error(); } diff --git a/includes/server/class-llms-rest-students-progress-controller.php b/includes/server/class-llms-rest-students-progress-controller.php index 03df3b3a..3f0c9002 100644 --- a/includes/server/class-llms-rest-students-progress-controller.php +++ b/includes/server/class-llms-rest-students-progress-controller.php @@ -5,7 +5,7 @@ * @package LifterLMS_REST/Classes * * @since 1.0.0-beta.1 - * @version 1.0.0-beta.25 + * @version 1.0.0-beta.26 */ defined( 'ABSPATH' ) || exit; @@ -264,6 +264,7 @@ public function get_item_schema() { * Get object. * * @since 1.0.0-beta.1 + * @since 1.0.0-beta.26 Don't autoload current user if a falsy user id is supplied. * * @param int[] $ids { * Numeric array of ids. @@ -285,7 +286,11 @@ protected function get_object( $ids ) { $post = llms_get_post( $post_id ); - $student = llms_get_student( $student_id ); + $student = llms_get_student( $student_id, false ); + + if ( ! $student ) { + return llms_rest_not_found_error(); + } $obj->student_id = $student_id; $obj->post_id = $post_id; diff --git a/lifterlms-rest.php b/lifterlms-rest.php index 68cd8e73..9d3e2bd0 100644 --- a/lifterlms-rest.php +++ b/lifterlms-rest.php @@ -5,19 +5,19 @@ * @package LifterLMS_REST_API/Main * * @since 1.0.0-beta.1 - * @version 1.0.0-beta.1 + * @version 1.0.0-beta.26 * * Plugin Name: LifterLMS REST API * Plugin URI: https://lifterlms.com/ * Description: REST API feature plugin for the LifterLMS Core. - * Version: 1.0.0-beta.25 + * Version: 1.0.0-beta.26 * Author: LifterLMS * Author URI: https://lifterlms.com/ * Text Domain: lifterlms * Domain Path: /i18n * License: GPLv3 * License URI: https://www.gnu.org/licenses/gpl-3.0.html - * Requires LifterLMS: 6.5.0 + * Requires LifterLMS: 7.0.2 */ defined( 'ABSPATH' ) || exit; @@ -38,7 +38,7 @@ } if ( ! defined( 'LLMS_REST_API_PLUGIN_DIR' ) ) { - define( 'LLMS_REST_API_PLUGIN_DIR', dirname( __FILE__ ) . '/' ); + define( 'LLMS_REST_API_PLUGIN_DIR', __DIR__ . '/' ); } if ( ! defined( 'LLMS_REST_API_PLUGIN_URL' ) ) { diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index e5ffabfb..00000000 --- a/package-lock.json +++ /dev/null @@ -1,4417 +0,0 @@ -{ - "name": "lifterlms-rest", - "version": "1.0.0-beta.25", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "@babel/code-frame": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.3.tgz", - "integrity": "sha512-fDx9eNW0qz0WkUeqL6tXEXzVlPh6Y5aCDEZesl0xBGA8ndRukX91Uk44ZqnkECp01NAZUdCAl+aiQNGi0k88Eg==", - "dev": true, - "requires": { - "@babel/highlight": "^7.10.3" - } - }, - "@babel/helper-validator-identifier": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.3.tgz", - "integrity": "sha512-bU8JvtlYpJSBPuj1VUmKpFGaDZuLxASky3LhaKj3bmpSTY6VWooSM8msk+Z0CZoErFye2tlABF6yDkT3FOPAXw==", - "dev": true - }, - "@babel/highlight": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.3.tgz", - "integrity": "sha512-Ih9B/u7AtgEnySE2L2F0Xm0GaM729XqqLfHkalTsbjXGyqmf/6M0Cu0WpvqueUlW+xk88BHw9Nkpj49naU+vWw==", - "dev": true, - "requires": { - "@babel/helper-validator-identifier": "^7.10.3", - "chalk": "^2.0.0", - "js-tokens": "^4.0.0" - } - }, - "@babel/runtime": { - "version": "7.10.3", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.10.3.tgz", - "integrity": "sha512-RzGO0RLSdokm9Ipe/YD+7ww8X2Ro79qiXZF3HU9ljrM+qnJmH1Vqth+hbiQZy761LnMJTMitHDuKVYTk3k4dLw==", - "dev": true, - "requires": { - "regenerator-runtime": "^0.13.4" - } - }, - "@lifterlms/dev": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/@lifterlms/dev/-/dev-0.0.2.tgz", - "integrity": "sha512-srpnOE1ui3tytMORf4/+U+zfJcQ2LUMUqCpwKetXf6gZFjhCLHe4GeeKls/Dkw9pXPUKBTA90lrZSWm/fLsqCQ==", - "dev": true, - "requires": { - "chalk": "^4.1.2", - "columnify": "^1.5.4", - "commander": "^8.2.0", - "inquirer": "^8.2.0", - "replace-in-file": "^6.3.1", - "semver": "^7.3.5", - "yaml": "^1.10.2" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "commander": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", - "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", - "dev": true, - "requires": { - "lru-cache": "^6.0.0" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "accepts": { - "version": "1.3.7", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", - "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", - "dev": true, - "requires": { - "mime-types": "~2.1.24", - "negotiator": "0.6.2" - } - }, - "ajv": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", - "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", - "dev": true, - "requires": { - "co": "^4.6.0", - "fast-deep-equal": "^1.0.0", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.3.0" - } - }, - "ansi-escapes": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", - "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", - "dev": true, - "requires": { - "type-fest": "^0.21.3" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==", - "dev": true - }, - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "requires": { - "micromatch": "^3.1.4", - "normalize-path": "^2.1.1" - }, - "dependencies": { - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "^1.0.1" - } - } - } - }, - "argparse": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", - "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, - "requires": { - "sprintf-js": "~1.0.2" - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "arr-flatten": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", - "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true - }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=", - "dev": true - }, - "array-union": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", - "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", - "dev": true, - "requires": { - "array-uniq": "^1.0.1" - } - }, - "array-uniq": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", - "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true - }, - "async": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", - "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", - "dev": true, - "requires": { - "lodash": "^4.17.14" - } - }, - "async-each": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", - "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", - "dev": true - }, - "async-limiter": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz", - "integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==", - "dev": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true - }, - "atob": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", - "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "requires": { - "cache-base": "^1.0.1", - "class-utils": "^0.3.5", - "component-emitter": "^1.2.1", - "define-property": "^1.0.0", - "isobject": "^3.0.1", - "mixin-deep": "^1.2.0", - "pascalcase": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "base64-js": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", - "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true - }, - "better-ajv-errors": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/better-ajv-errors/-/better-ajv-errors-0.5.7.tgz", - "integrity": "sha512-O7tpXektKWVwYCH5g6Vs3lKD+sJs7JHh5guapmGJd+RTwxhFZEf4FwvbHBURUnoXsTeFaMvGuhTTmEGiHpNi6w==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/runtime": "^7.0.0", - "chalk": "^2.4.1", - "core-js": "^2.5.7", - "json-to-ast": "^2.0.3", - "jsonpointer": "^4.0.1", - "leven": "^2.1.0" - } - }, - "binary-extensions": { - "version": "1.13.1", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", - "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", - "dev": true - }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dev": true, - "optional": true, - "requires": { - "file-uri-to-path": "1.0.0" - } - }, - "bl": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", - "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "dev": true, - "requires": { - "buffer": "^5.5.0", - "inherits": "^2.0.4", - "readable-stream": "^3.4.0" - }, - "dependencies": { - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true - }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - } - } - } - }, - "body-parser": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", - "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", - "dev": true, - "requires": { - "bytes": "3.1.0", - "content-type": "~1.0.4", - "debug": "2.6.9", - "depd": "~1.1.2", - "http-errors": "1.7.2", - "iconv-lite": "0.4.24", - "on-finished": "~2.3.0", - "qs": "6.7.0", - "raw-body": "2.4.0", - "type-is": "~1.6.17" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "^1.1.0", - "array-unique": "^0.3.2", - "extend-shallow": "^2.0.1", - "fill-range": "^4.0.0", - "isobject": "^3.0.1", - "repeat-element": "^1.1.2", - "snapdragon": "^0.8.1", - "snapdragon-node": "^2.0.1", - "split-string": "^3.0.2", - "to-regex": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "buffer": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", - "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.1.13" - } - }, - "bytes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", - "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", - "dev": true - }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "requires": { - "collection-visit": "^1.0.0", - "component-emitter": "^1.2.1", - "get-value": "^2.0.6", - "has-value": "^1.0.0", - "isobject": "^3.0.1", - "set-value": "^2.0.0", - "to-object-path": "^0.3.0", - "union-value": "^1.0.0", - "unset-value": "^1.0.0" - } - }, - "call-me-maybe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.1.tgz", - "integrity": "sha1-JtII6onje1y95gJQoV8DHBak1ms=", - "dev": true - }, - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true - }, - "chalk": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", - "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", - "dev": true, - "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" - } - }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true - }, - "chokidar": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", - "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", - "dev": true, - "requires": { - "anymatch": "^2.0.0", - "async-each": "^1.0.1", - "braces": "^2.3.2", - "fsevents": "^1.2.7", - "glob-parent": "^3.1.0", - "inherits": "^2.0.3", - "is-binary-path": "^1.0.0", - "is-glob": "^4.0.0", - "normalize-path": "^3.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.2.1", - "upath": "^1.1.1" - } - }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "define-property": "^0.2.5", - "isobject": "^3.0.0", - "static-extend": "^0.1.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "dev": true, - "requires": { - "restore-cursor": "^3.1.0" - } - }, - "cli-spinners": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.6.1.tgz", - "integrity": "sha512-x/5fWmGMnbKQAaNwN+UZlV79qBLM9JFnJuJ03gIi5whrob0xV0ofNVHy9DhwGdsMJQc2OKv0oGmLzvaqvAVv+g==", - "dev": true - }, - "cli-width": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", - "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", - "dev": true - }, - "cliui": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", - "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", - "dev": true, - "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" - } - }, - "clone": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", - "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", - "dev": true - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true - }, - "code-error-fragment": { - "version": "0.0.230", - "resolved": "https://registry.npmjs.org/code-error-fragment/-/code-error-fragment-0.0.230.tgz", - "integrity": "sha512-cadkfKp6932H8UkhzE/gcUqhRMNf8jHzkAN7+5Myabswaghu4xABTgPHDCjW+dBAJxj/SpkTYokpzDqY4pCzQw==", - "dev": true - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", - "dev": true, - "requires": { - "map-visit": "^1.0.0", - "object-visit": "^1.0.0" - } - }, - "color-convert": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", - "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", - "dev": true, - "requires": { - "color-name": "1.1.3" - } - }, - "color-name": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", - "dev": true - }, - "columnify": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/columnify/-/columnify-1.5.4.tgz", - "integrity": "sha1-Rzfd8ce2mop8NAVweC6UfuyOeLs=", - "dev": true, - "requires": { - "strip-ansi": "^3.0.0", - "wcwidth": "^1.0.0" - }, - "dependencies": { - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, - "component-emitter": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", - "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "content-disposition": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", - "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", - "dev": true, - "requires": { - "safe-buffer": "5.1.2" - } - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", - "dev": true - }, - "cookie": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", - "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==", - "dev": true - }, - "cookie-signature": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", - "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=", - "dev": true - }, - "cookiejar": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz", - "integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA==", - "dev": true - }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true - }, - "core-js": { - "version": "2.6.11", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz", - "integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg==", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "cors": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "dev": true, - "requires": { - "object-assign": "^4", - "vary": "^1" - } - }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "^1.0.4", - "path-key": "^2.0.1", - "semver": "^5.5.0", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", - "dev": true - }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true - }, - "deep-is": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", - "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", - "dev": true - }, - "defaults": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", - "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", - "dev": true, - "requires": { - "clone": "^1.0.2" - } - }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "requires": { - "is-descriptor": "^1.0.2", - "isobject": "^3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "depd": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", - "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=", - "dev": true - }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=", - "dev": true - }, - "drange": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/drange/-/drange-1.1.1.tgz", - "integrity": "sha512-pYxfDYpued//QpnLIm4Avk7rsNtAtQkUES2cwAYSvD/wd2pKD71gN2Ebj3e7klzXwjocvE8c5vx/1fxwpqmSxA==", - "dev": true - }, - "duplexer": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.2.tgz", - "integrity": "sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==", - "dev": true - }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", - "dev": true - }, - "email-addresses": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/email-addresses/-/email-addresses-3.1.0.tgz", - "integrity": "sha512-k0/r7GrWVL32kZlGwfPNgB2Y/mMXVTq/decgLczm/j34whdaspNrZO8CnXPf1laaHxI6ptUlsnAxN+UAPw+fzg==", - "dev": true - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=", - "dev": true - }, - "end-of-stream": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", - "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, - "requires": { - "once": "^1.4.0" - } - }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=", - "dev": true - }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", - "dev": true - }, - "escodegen": { - "version": "1.14.2", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.2.tgz", - "integrity": "sha512-InuOIiKk8wwuOFg6x9BQXbzjrQhtyXh46K9bqVTPzSo2FnyMBaYGBMC6PhQy7yxxil9vIedFBweQBMK74/7o8A==", - "dev": true, - "requires": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - } - }, - "esprima": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "dev": true - }, - "estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true - }, - "esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "dev": true - }, - "etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", - "dev": true - }, - "event-stream": { - "version": "3.3.4", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", - "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", - "dev": true, - "requires": { - "duplexer": "~0.1.1", - "from": "~0", - "map-stream": "~0.1.0", - "pause-stream": "0.0.11", - "split": "0.3", - "stream-combiner": "~0.0.4", - "through": "~2.3.1" - } - }, - "execa": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-1.0.0.tgz", - "integrity": "sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA==", - "dev": true, - "requires": { - "cross-spawn": "^6.0.0", - "get-stream": "^4.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "^2.3.3", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "posix-character-classes": "^0.1.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "express": { - "version": "4.17.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", - "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", - "dev": true, - "requires": { - "accepts": "~1.3.7", - "array-flatten": "1.1.1", - "body-parser": "1.19.0", - "content-disposition": "0.5.3", - "content-type": "~1.0.4", - "cookie": "0.4.0", - "cookie-signature": "1.0.6", - "debug": "2.6.9", - "depd": "~1.1.2", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "~1.1.2", - "fresh": "0.5.2", - "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.5", - "qs": "6.7.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.1.2", - "send": "0.17.1", - "serve-static": "1.14.1", - "setprototypeof": "1.1.1", - "statuses": "~1.5.0", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - } - }, - "extend": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", - "dev": true - }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", - "dev": true, - "requires": { - "assign-symbols": "^1.0.0", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "external-editor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", - "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "dev": true, - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "^0.3.2", - "define-property": "^1.0.0", - "expand-brackets": "^2.1.4", - "extend-shallow": "^2.0.1", - "fragment-cache": "^0.2.1", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "faker": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/faker/-/faker-4.1.0.tgz", - "integrity": "sha1-HkW7vsxndLPBlfrSg1EJxtdIzD8=", - "dev": true - }, - "fast-deep-equal": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz", - "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=", - "dev": true - }, - "fast-json-stable-stringify": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true - }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", - "dev": true - }, - "fast-safe-stringify": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", - "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", - "dev": true - }, - "figures": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", - "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true, - "optional": true - }, - "filename-reserved-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/filename-reserved-regex/-/filename-reserved-regex-1.0.0.tgz", - "integrity": "sha1-5hz4BfDeHJhFZ9A4bcXfUO5a9+Q=", - "dev": true - }, - "filenamify": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/filenamify/-/filenamify-1.2.1.tgz", - "integrity": "sha1-qfL/0RxQO+0wABUCknI3jx8TZaU=", - "dev": true, - "requires": { - "filename-reserved-regex": "^1.0.0", - "strip-outer": "^1.0.0", - "trim-repeated": "^1.0.0" - } - }, - "filenamify-url": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/filenamify-url/-/filenamify-url-1.0.0.tgz", - "integrity": "sha1-syvYExnvWGO3MHi+1Q9GpPeXX1A=", - "dev": true, - "requires": { - "filenamify": "^1.0.0", - "humanize-url": "^1.0.0" - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-number": "^3.0.0", - "repeat-string": "^1.6.1", - "to-regex-range": "^2.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "finalhandler": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", - "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", - "dev": true, - "requires": { - "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.3", - "statuses": "~1.5.0", - "unpipe": "~1.0.0" - } - }, - "find-up": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", - "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", - "dev": true, - "requires": { - "locate-path": "^3.0.0" - } - }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true - }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", - "dev": true - }, - "form-data": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", - "mime-types": "^2.1.12" - } - }, - "format-util": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/format-util/-/format-util-1.0.5.tgz", - "integrity": "sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==", - "dev": true - }, - "formidable": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.2.tgz", - "integrity": "sha512-V8gLm+41I/8kguQ4/o1D3RIHRmhYFG4pnNyonvua+40rqcEmT4+V71yaZ3B457xbbgCsCfjSPi65u/W6vK1U5Q==", - "dev": true - }, - "forwarded": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", - "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=", - "dev": true - }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", - "dev": true, - "requires": { - "map-cache": "^0.2.2" - } - }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", - "dev": true - }, - "from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", - "dev": true - }, - "fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - }, - "fs-readfile-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fs-readfile-promise/-/fs-readfile-promise-2.0.1.tgz", - "integrity": "sha1-gAI4I5gfn//+AWCei+Zo9prknnA=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2" - } - }, - "fs-writefile-promise": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/fs-writefile-promise/-/fs-writefile-promise-1.0.3.tgz", - "integrity": "sha1-4C+bWP/CVe2CKtx6ARFPRF1I0GM=", - "dev": true, - "requires": { - "mkdirp-promise": "^1.0.0", - "pinkie-promise": "^1.0.0" - }, - "dependencies": { - "pinkie": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-1.0.0.tgz", - "integrity": "sha1-Wkfyi6EBXQIBvae/DzWOR77Ix+Q=", - "dev": true - }, - "pinkie-promise": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-1.0.0.tgz", - "integrity": "sha1-0dpn9UglY7t89X8oauKCLs+/NnA=", - "dev": true, - "requires": { - "pinkie": "^1.0.0" - } - } - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fsevents": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.13.tgz", - "integrity": "sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==", - "dev": true, - "optional": true, - "requires": { - "bindings": "^1.5.0", - "nan": "^2.12.1" - } - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", - "dev": true - }, - "get-own-enumerable-property-symbols": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz", - "integrity": "sha512-I0UBV/XOz1XkIJHEUDMZAbzCThU/H8DxmSfmdGcKPnVhu2VfFqr34jr9777IyaTYvxjedWhqVIilEDsCdP5G6g==", - "dev": true - }, - "get-stream": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", - "integrity": "sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w==", - "dev": true, - "requires": { - "pump": "^3.0.0" - } - }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, - "gh-pages": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/gh-pages/-/gh-pages-2.2.0.tgz", - "integrity": "sha512-c+yPkNOPMFGNisYg9r4qvsMIjVYikJv7ImFOhPIVPt0+AcRUamZ7zkGRLHz7FKB0xrlZ+ddSOJsZv9XAFVXLmA==", - "dev": true, - "requires": { - "async": "^2.6.1", - "commander": "^2.18.0", - "email-addresses": "^3.0.1", - "filenamify-url": "^1.0.0", - "fs-extra": "^8.1.0", - "globby": "^6.1.0" - }, - "dependencies": { - "fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "dev": true, - "requires": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - } - } - } - }, - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "requires": { - "is-glob": "^3.1.0", - "path-dirname": "^1.0.0" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "^2.1.0" - } - } - } - }, - "globby": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", - "integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=", - "dev": true, - "requires": { - "array-union": "^1.0.1", - "glob": "^7.0.3", - "object-assign": "^4.0.1", - "pify": "^2.0.0", - "pinkie-promise": "^2.0.0" - } - }, - "graceful-fs": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", - "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", - "dev": true - }, - "grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", - "dev": true - }, - "graphlib": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/graphlib/-/graphlib-2.1.8.tgz", - "integrity": "sha512-jcLLfkpoVGmH7/InMC/1hIvOPSUh38oJtGhvrOFGzioE1DZ+0YW16RgmOJhHiuWTvGiJQ9Z1Ik43JvkRPRvE+A==", - "dev": true, - "requires": { - "lodash": "^4.17.15" - } - }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", - "dev": true - }, - "har-validator": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", - "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", - "dev": true, - "requires": { - "ajv": "^6.12.3", - "har-schema": "^2.0.0" - }, - "dependencies": { - "ajv": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.4.tgz", - "integrity": "sha512-eienB2c9qVQs2KWexhkrdMLVDoIQCz5KSeLxwg9Lzk4DOfBtIK9PQwwufcsn1jjGuf9WZmqPMbGxOzfcuphJCQ==", - "dev": true, - "requires": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - } - }, - "fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - } - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "^2.0.6", - "has-values": "^1.0.0", - "isobject": "^3.0.0" - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "kind-of": "^4.0.0" - }, - "dependencies": { - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "http-errors": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", - "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", - "dev": true, - "requires": { - "depd": "~1.1.2", - "inherits": "2.0.3", - "setprototypeof": "1.1.1", - "statuses": ">= 1.5.0 < 2", - "toidentifier": "1.0.0" - } - }, - "http2-client": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/http2-client/-/http2-client-1.3.3.tgz", - "integrity": "sha512-nUxLymWQ9pzkzTmir24p2RtsgruLmhje7lH3hLX1IpwvyTg77fW+1brenPPP3USAR+rQ36p5sTA/x7sjCJVkAA==", - "dev": true - }, - "httpsnippet": { - "version": "1.22.0", - "resolved": "https://registry.npmjs.org/httpsnippet/-/httpsnippet-1.22.0.tgz", - "integrity": "sha512-umtG+usjz5JCtevTX2EgmSfwNnJOhMKF9HzF4rHecUY+CLoLZzZwOwyxUsvcAtB4l+VWjTbWMCIVZkprUBkPMw==", - "dev": true, - "requires": { - "chalk": "^1.1.1", - "commander": "^2.9.0", - "debug": "^2.2.0", - "event-stream": "3.3.4", - "form-data": "3.0.0", - "fs-readfile-promise": "^2.0.1", - "fs-writefile-promise": "^1.0.3", - "har-validator": "^5.0.0", - "pinkie-promise": "^2.0.0", - "stringify-object": "^3.3.0" - }, - "dependencies": { - "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", - "dev": true - }, - "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", - "dev": true, - "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" - } - }, - "form-data": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.0.tgz", - "integrity": "sha512-CKMFDglpbMi6PyN+brwB9Q/GOw0eAnsrEZDgcsH5Krhz5Od/haKHAX0NmQfha2zPPz0JpWzA7GJHGSnvCRLWsg==", - "dev": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, - "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", - "dev": true - } - } - }, - "humanize-url": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/humanize-url/-/humanize-url-1.0.1.tgz", - "integrity": "sha1-9KuZ4NKIF0yk4eUEB8VfuuRk7/8=", - "dev": true, - "requires": { - "normalize-url": "^1.0.0", - "strip-url-auth": "^1.0.0" - } - }, - "iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "dev": true, - "requires": { - "safer-buffer": ">= 2.1.2 < 3" - } - }, - "ieee754": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", - "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "inquirer": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.0.tgz", - "integrity": "sha512-0crLweprevJ02tTuA6ThpoAERAGyVILC4sS74uib58Xf/zSr1/ZWtmm7D5CI+bSQEaA04f0K7idaHpQbSWgiVQ==", - "dev": true, - "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^4.1.1", - "cli-cursor": "^3.1.0", - "cli-width": "^3.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.21", - "mute-stream": "0.0.8", - "ora": "^5.4.1", - "run-async": "^2.4.0", - "rxjs": "^7.2.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "invert-kv": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-2.0.0.tgz", - "integrity": "sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA==", - "dev": true - }, - "ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "dev": true - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "requires": { - "binary-extensions": "^1.0.0" - } - }, - "is-buffer": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", - "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", - "dev": true - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", - "dev": true, - "requires": { - "is-extglob": "^2.1.1" - } - }, - "is-interactive": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", - "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", - "dev": true - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "is-obj": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-obj/-/is-obj-1.0.1.tgz", - "integrity": "sha1-PkcprB9f3gJc19g6iW2rn09n2w8=", - "dev": true - }, - "is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=", - "dev": true - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "is-regexp": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-regexp/-/is-regexp-1.0.0.tgz", - "integrity": "sha1-/S2INUXEa6xaYz57mgnof6LLUGk=", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, - "is-unicode-supported": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", - "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "js-base64": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.1.tgz", - "integrity": "sha512-G5x2saUTupU9D/xBY9snJs3TxvwX8EkpLFiYlPpDt/VmMHOXprnSU1nxiTmFbijCX4BLF/cMRIfAcC5BiMYgFQ==", - "dev": true - }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", - "dev": true - }, - "js-yaml": { - "version": "3.14.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", - "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", - "dev": true, - "requires": { - "argparse": "^1.0.7", - "esprima": "^4.0.0" - } - }, - "json-pointer": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/json-pointer/-/json-pointer-0.6.2.tgz", - "integrity": "sha512-vLWcKbOaXlO+jvRy4qNd+TI1QUPZzfJj1tpJ3vAXDych5XJf93ftpUKe5pKCrzyIIwgBJcOcCVRUfqQP25afBw==", - "dev": true, - "requires": { - "foreach": "^2.0.4" - } - }, - "json-refs": { - "version": "3.0.15", - "resolved": "https://registry.npmjs.org/json-refs/-/json-refs-3.0.15.tgz", - "integrity": "sha512-0vOQd9eLNBL18EGl5yYaO44GhixmImes2wiYn9Z3sag3QnehWrYWlB9AFtMxCL2Bj3fyxgDYkxGFEU/chlYssw==", - "dev": true, - "requires": { - "commander": "~4.1.1", - "graphlib": "^2.1.8", - "js-yaml": "^3.13.1", - "lodash": "^4.17.15", - "native-promise-only": "^0.8.1", - "path-loader": "^1.0.10", - "slash": "^3.0.0", - "uri-js": "^4.2.2" - }, - "dependencies": { - "commander": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", - "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", - "dev": true - } - } - }, - "json-schema-faker": { - "version": "0.5.0-rcv.24", - "resolved": "https://registry.npmjs.org/json-schema-faker/-/json-schema-faker-0.5.0-rcv.24.tgz", - "integrity": "sha512-qwuRwv7dnUdqdwuifb6kJAVUKm0mzi4h/mzvMwDKxyWUzjxFCdVH/g9IfKxvc4M7rvAavr8pcx9uO1PNIIWE0g==", - "dev": true, - "requires": { - "json-schema-ref-parser": "^6.1.0", - "jsonpath-plus": "^2.0.0", - "randexp": "^0.5.3" - } - }, - "json-schema-ref-parser": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/json-schema-ref-parser/-/json-schema-ref-parser-6.1.0.tgz", - "integrity": "sha512-pXe9H1m6IgIpXmE5JSb8epilNTGsmTb2iPohAXpOdhqGFbQjNeHHsZxU+C8w6T81GZxSPFLeUoqDJmzxx5IGuw==", - "dev": true, - "requires": { - "call-me-maybe": "^1.0.1", - "js-yaml": "^3.12.1", - "ono": "^4.0.11" - } - }, - "json-schema-traverse": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", - "dev": true - }, - "json-to-ast": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/json-to-ast/-/json-to-ast-2.1.0.tgz", - "integrity": "sha512-W9Lq347r8tA1DfMvAGn9QNcgYm4Wm7Yc+k8e6vezpMnRT+NHbtlxgNBXRVjXe9YM6eTn6+p/MKOlV/aABJcSnQ==", - "dev": true, - "requires": { - "code-error-fragment": "0.0.230", - "grapheme-splitter": "^1.0.4" - } - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "jsonpath": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/jsonpath/-/jsonpath-1.1.1.tgz", - "integrity": "sha512-l6Cg7jRpixfbgoWgkrl77dgEj8RPvND0wMH6TwQmi9Qs4TFfS9u5cUFnbeKTwj5ga5Y3BTGGNI28k117LJ009w==", - "dev": true, - "requires": { - "esprima": "1.2.2", - "static-eval": "2.0.2", - "underscore": "1.12.1" - }, - "dependencies": { - "esprima": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.2.2.tgz", - "integrity": "sha512-+JpPZam9w5DuJ3Q67SqsMGtiHKENSMRVoxvArfJZK01/BfLEObtZ6orJa/MtoGNR/rfMgp5837T41PAmTwAv/A==", - "dev": true - }, - "underscore": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.12.1.tgz", - "integrity": "sha512-hEQt0+ZLDVUMhebKxL4x1BTtDY7bavVofhZ9KZ4aI26X9SRaE+Y3m83XUL1UP2jn8ynjndwCCpEHdUG+9pP1Tw==", - "dev": true - } - } - }, - "jsonpath-plus": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/jsonpath-plus/-/jsonpath-plus-2.0.0.tgz", - "integrity": "sha512-ksXaz9+3SIZ5BMxgr7MQueYcR515VRZPuoDhIymUd1JcF6BnVaYJS7k4NJni4EHhvJaOIGGiPqT8+ifsGp6mBw==", - "dev": true - }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true - }, - "kind-of": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", - "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", - "dev": true - }, - "lcid": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", - "integrity": "sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA==", - "dev": true, - "requires": { - "invert-kv": "^2.0.0" - } - }, - "leven": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", - "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", - "dev": true - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, - "livereload": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/livereload/-/livereload-0.8.2.tgz", - "integrity": "sha512-8wCvhiCL4cGVoT3U5xoe+UjpiiVZLrlOvr6dbhb1VlyC5QarhrlyRRt4z7EMGO4KSgXj+tKF/dr284F28/wI+g==", - "dev": true, - "requires": { - "chokidar": "^2.1.5", - "opts": ">= 1.2.0", - "ws": "^6.2.1" - } - }, - "locate-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", - "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", - "dev": true, - "requires": { - "p-locate": "^3.0.0", - "path-exists": "^3.0.0" - } - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true - }, - "lodash.get": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", - "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", - "dev": true - }, - "lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", - "dev": true - }, - "log-symbols": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", - "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", - "dev": true, - "requires": { - "chalk": "^4.1.0", - "is-unicode-supported": "^0.1.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "requires": { - "yallist": "^4.0.0" - } - }, - "map-age-cleaner": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz", - "integrity": "sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w==", - "dev": true, - "requires": { - "p-defer": "^1.0.0" - } - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-stream": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", - "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "^1.0.0" - } - }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=", - "dev": true - }, - "mem": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-4.3.0.tgz", - "integrity": "sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w==", - "dev": true, - "requires": { - "map-age-cleaner": "^0.1.1", - "mimic-fn": "^2.0.0", - "p-is-promise": "^2.0.0" - } - }, - "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=", - "dev": true - }, - "methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "braces": "^2.3.1", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "extglob": "^2.0.4", - "fragment-cache": "^0.2.1", - "kind-of": "^6.0.2", - "nanomatch": "^1.2.9", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.2" - } - }, - "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "dev": true - }, - "mime-db": { - "version": "1.44.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", - "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", - "dev": true - }, - "mime-types": { - "version": "2.1.27", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", - "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", - "dev": true, - "requires": { - "mime-db": "1.44.0" - } - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "minimist": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz", - "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==", - "dev": true - }, - "mixin-deep": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", - "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", - "dev": true, - "requires": { - "for-in": "^1.0.2", - "is-extendable": "^1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "^2.0.4" - } - } - } - }, - "mkdirp": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz", - "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==", - "dev": true, - "requires": { - "minimist": "^1.2.5" - } - }, - "mkdirp-promise": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mkdirp-promise/-/mkdirp-promise-1.1.0.tgz", - "integrity": "sha1-LISJPtZ24NmPsY+5piEv0bK5qBk=", - "dev": true - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "mute-stream": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", - "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", - "dev": true - }, - "nan": { - "version": "2.14.1", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", - "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==", - "dev": true, - "optional": true - }, - "nanomatch": { - "version": "1.2.13", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", - "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", - "dev": true, - "requires": { - "arr-diff": "^4.0.0", - "array-unique": "^0.3.2", - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "fragment-cache": "^0.2.1", - "is-windows": "^1.0.2", - "kind-of": "^6.0.2", - "object.pick": "^1.3.0", - "regex-not": "^1.0.0", - "snapdragon": "^0.8.1", - "to-regex": "^3.0.1" - } - }, - "native-promise-only": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", - "integrity": "sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE=", - "dev": true - }, - "negotiator": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", - "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", - "dev": true - }, - "nice-try": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", - "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", - "dev": true - }, - "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "dev": true, - "requires": { - "whatwg-url": "^5.0.0" - } - }, - "node-fetch-h2": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/node-fetch-h2/-/node-fetch-h2-2.3.0.tgz", - "integrity": "sha512-ofRW94Ab0T4AOh5Fk8t0h8OBWrmjb0SSB20xh1H8YnPV9EJ+f5AMoYSUQ2zgJ4Iq2HAK0I2l5/Nequ8YzFS3Hg==", - "dev": true, - "requires": { - "http2-client": "^1.2.5" - } - }, - "normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true - }, - "normalize-url": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-1.9.1.tgz", - "integrity": "sha1-LMDWazHqIwNkWENuNiDYWVTGbDw=", - "dev": true, - "requires": { - "object-assign": "^4.0.1", - "prepend-http": "^1.0.0", - "query-string": "^4.1.0", - "sort-keys": "^1.0.0" - } - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "^2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "oas-kit-common": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/oas-kit-common/-/oas-kit-common-1.0.8.tgz", - "integrity": "sha512-pJTS2+T0oGIwgjGpw7sIRU8RQMcUoKCDWFLdBqKB2BNmGpbBMH2sdqAaOXUg8OzonZHU0L7vfJu1mJFEiYDWOQ==", - "dev": true, - "requires": { - "fast-safe-stringify": "^2.0.7" - } - }, - "oas-linter": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/oas-linter/-/oas-linter-1.0.8.tgz", - "integrity": "sha512-d60OArJNBalU5q9utXgsWUdxNS2EWenLp/fSrCQXFHoZhFOLQDTCh2CeqddifM0q1Q0Z9noTiFnwuyqSi2Pa6A==", - "dev": true, - "requires": { - "js-yaml": "^3.12.0", - "should": "^13.2.1" - } - }, - "oas-resolver": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/oas-resolver/-/oas-resolver-1.1.1.tgz", - "integrity": "sha512-r7jWfhtW/eQ42/eqnUXMUS46jB+XoNlIOSkjN6ZQH+3tqPQHMwAqRUQTqdh+0Qw7IAipftb6zFVwyfE6kVCmGQ==", - "dev": true, - "requires": { - "js-yaml": "^3.12.0", - "node-fetch-h2": "^2.3.0", - "oas-kit-common": "^1.0.6", - "reftools": "^1.0.4", - "yargs": "^12.0.2" - } - }, - "oas-schema-walker": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/oas-schema-walker/-/oas-schema-walker-1.1.4.tgz", - "integrity": "sha512-foVDDS0RJYMfhQEDh/WdBuCzydTcsCnGo9EeD8SpWq1uW10JXiz+8SfYVDA7LO87kjmlnTRZle/2gr5qxabaEA==", - "dev": true - }, - "oas-validator": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/oas-validator/-/oas-validator-1.1.13.tgz", - "integrity": "sha512-sEWaUq5/b5+iOUEtnu/Ioi3bN1SwIvexSpeFdg3H0v4ASPmK1l/70vpYXfupVElFzjx4unc2odFp9oJR+L5f7w==", - "dev": true, - "requires": { - "ajv": "^5.5.2", - "better-ajv-errors": "^0.5.2", - "js-yaml": "^3.12.0", - "oas-kit-common": "^1.0.4", - "oas-linter": "^1.0.8", - "oas-resolver": "^1.0.12", - "oas-schema-walker": "^1.1.0", - "reftools": "^1.0.3", - "should": "^13.2.1" - } - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true - }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "^0.1.0", - "define-property": "^0.2.5", - "kind-of": "^3.0.3" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "^3.0.0" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "^3.0.1" - } - }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "dev": true, - "requires": { - "ee-first": "1.1.1" - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1" - } - }, - "onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "dev": true, - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "ono": { - "version": "4.0.11", - "resolved": "https://registry.npmjs.org/ono/-/ono-4.0.11.tgz", - "integrity": "sha512-jQ31cORBFE6td25deYeD80wxKBMj+zBmHTrVxnc6CKhx8gho6ipmWM5zj/oeoqioZ99yqBls9Z/9Nss7J26G2g==", - "dev": true, - "requires": { - "format-util": "^1.0.3" - } - }, - "openapi-sampler": { - "version": "1.0.0-beta.16", - "resolved": "https://registry.npmjs.org/openapi-sampler/-/openapi-sampler-1.0.0-beta.16.tgz", - "integrity": "sha512-05+GvwMagTY7GxoDQoWJfmAUFlxfebciiEzqKmu4iq6+MqBEn62AMUkn0CTxyKhnUGIaR2KXjTeslxIeJwVIOw==", - "dev": true, - "requires": { - "json-pointer": "^0.6.0" - } - }, - "openapi-snippet": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/openapi-snippet/-/openapi-snippet-0.9.1.tgz", - "integrity": "sha512-PL7dInP/+AcpZ1QdfkU5ELSQzXhdLe8zC3Z8i8fSg+q8fcU5VF9NdRg1KIlvfGuCrMLVPvP63HhAxCUF/lpUZQ==", - "dev": true, - "requires": { - "httpsnippet": "^1.16.7", - "openapi-sampler": "^1.0.0-beta.14" - } - }, - "optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "dev": true, - "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - } - }, - "opts": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/opts/-/opts-1.2.7.tgz", - "integrity": "sha512-hwZhzGGG/GQ7igxAVFOEun2N4fWul31qE9nfBdCnZGQCB5+L7tN9xZ+94B4aUpLOJx/of3zZs5XsuubayQYQjA==", - "dev": true - }, - "ora": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", - "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", - "dev": true, - "requires": { - "bl": "^4.1.0", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-spinners": "^2.5.0", - "is-interactive": "^1.0.0", - "is-unicode-supported": "^0.1.0", - "log-symbols": "^4.1.0", - "strip-ansi": "^6.0.0", - "wcwidth": "^1.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, - "os-locale": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz", - "integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==", - "dev": true, - "requires": { - "execa": "^1.0.0", - "lcid": "^2.0.0", - "mem": "^4.0.0" - } - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, - "p-defer": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-defer/-/p-defer-1.0.0.tgz", - "integrity": "sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=", - "dev": true - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, - "p-is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/p-is-promise/-/p-is-promise-2.1.0.tgz", - "integrity": "sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg==", - "dev": true - }, - "p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "requires": { - "p-try": "^2.0.0" - } - }, - "p-locate": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", - "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", - "dev": true, - "requires": { - "p-limit": "^2.0.0" - } - }, - "p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true - }, - "parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "dev": true - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true - }, - "path-loader": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/path-loader/-/path-loader-1.0.10.tgz", - "integrity": "sha512-CMP0v6S6z8PHeJ6NFVyVJm6WyJjIwFvyz2b0n2/4bKdS/0uZa/9sKUlYZzubrn3zuDRU0zIuEDX9DZYQ2ZI8TA==", - "dev": true, - "requires": { - "native-promise-only": "^0.8.1", - "superagent": "^3.8.3" - } - }, - "path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=", - "dev": true - }, - "pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "dev": true, - "requires": { - "through": "~2.3" - } - }, - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "pinkie": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", - "dev": true - }, - "pinkie-promise": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", - "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", - "dev": true, - "requires": { - "pinkie": "^2.0.0" - } - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, - "prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", - "dev": true - }, - "prepend-http": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/prepend-http/-/prepend-http-1.0.4.tgz", - "integrity": "sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=", - "dev": true - }, - "process-nextick-args": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", - "dev": true - }, - "proxy-addr": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz", - "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==", - "dev": true, - "requires": { - "forwarded": "~0.1.2", - "ipaddr.js": "1.9.1" - } - }, - "pump": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", - "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, - "requires": { - "end-of-stream": "^1.1.0", - "once": "^1.3.1" - } - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "qs": { - "version": "6.7.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", - "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", - "dev": true - }, - "query-string": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-4.3.4.tgz", - "integrity": "sha1-u7aTucqRXCMlFbIosaArYJBD2+s=", - "dev": true, - "requires": { - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" - } - }, - "randexp": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.5.3.tgz", - "integrity": "sha512-U+5l2KrcMNOUPYvazA3h5ekF80FHTUG+87SEAmHZmolh1M+i/WyTCxVzmi+tidIa1tM4BSe8g2Y/D3loWDjj+w==", - "dev": true, - "requires": { - "drange": "^1.0.2", - "ret": "^0.2.0" - }, - "dependencies": { - "ret": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.2.2.tgz", - "integrity": "sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ==", - "dev": true - } - } - }, - "range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "dev": true - }, - "raw-body": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", - "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", - "dev": true, - "requires": { - "bytes": "3.1.0", - "http-errors": "1.7.2", - "iconv-lite": "0.4.24", - "unpipe": "1.0.0" - } - }, - "readable-stream": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", - "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "readdirp": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", - "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", - "dev": true, - "requires": { - "graceful-fs": "^4.1.11", - "micromatch": "^3.1.10", - "readable-stream": "^2.0.2" - } - }, - "reftools": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/reftools/-/reftools-1.1.1.tgz", - "integrity": "sha512-7ySkzK7YpUeJP16rzJqEXTZ7IrAq/AL/p+wWejD9wdKQOe+mYYVAOB3w5ZTs2eoHfmAidwr/6PcC+q+LzPF/DQ==", - "dev": true - }, - "regenerator-runtime": { - "version": "0.13.5", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz", - "integrity": "sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==", - "dev": true - }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.2", - "safe-regex": "^1.1.0" - } - }, - "remove-trailing-separator": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", - "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", - "dev": true - }, - "repeat-element": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", - "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "replace-in-file": { - "version": "6.3.2", - "resolved": "https://registry.npmjs.org/replace-in-file/-/replace-in-file-6.3.2.tgz", - "integrity": "sha512-Dbt5pXKvFVPL3WAaEB3ZX+95yP0CeAtIPJDwYzHbPP5EAHn+0UoegH/Wg3HKflU9dYBH8UnBC2NvY3P+9EZtTg==", - "dev": true, - "requires": { - "chalk": "^4.1.2", - "glob": "^7.2.0", - "yargs": "^17.2.1" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "glob": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", - "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yargs": { - "version": "17.3.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.3.0.tgz", - "integrity": "sha512-GQl1pWyDoGptFPJx9b9L6kmR33TGusZvXIZUT+BOz9f7X2L94oeAskFYLEg/FkhV06zZPBYLvLZRWeYId29lew==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" - } - }, - "yargs-parser": { - "version": "21.0.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.0.tgz", - "integrity": "sha512-z9kApYUOCwoeZ78rfRYYWdiU/iNL6mwwYlkkZfJoyMR1xps+NEBX5X7XmRpxkZHhXJ6+Ey00IwKxBBSW9FIjyA==", - "dev": true - } - } - }, - "require-dir": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/require-dir/-/require-dir-1.2.0.tgz", - "integrity": "sha512-LY85DTSu+heYgDqq/mK+7zFHWkttVNRXC9NKcKGyuGLdlsfbjEPrIEYdCVrx6hqnJb+xSu3Lzaoo8VnmOhhjNA==", - "dev": true - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", - "dev": true - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "dev": true, - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - } - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true - }, - "run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", - "dev": true - }, - "rxjs": { - "version": "7.4.0", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz", - "integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==", - "dev": true, - "requires": { - "tslib": "~2.1.0" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true - }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "~0.1.10" - } - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", - "dev": true - }, - "send": { - "version": "0.17.1", - "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", - "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", - "dev": true, - "requires": { - "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "0.5.2", - "http-errors": "~1.7.2", - "mime": "1.6.0", - "ms": "2.1.1", - "on-finished": "~2.3.0", - "range-parser": "~1.2.1", - "statuses": "~1.5.0" - }, - "dependencies": { - "ms": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", - "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", - "dev": true - } - } - }, - "serve-static": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", - "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", - "dev": true, - "requires": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "0.17.1" - } - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, - "set-value": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", - "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", - "dev": true, - "requires": { - "extend-shallow": "^2.0.1", - "is-extendable": "^0.1.1", - "is-plain-object": "^2.0.3", - "split-string": "^3.0.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - } - } - }, - "setprototypeof": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", - "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", - "dev": true - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, - "should": { - "version": "13.2.3", - "resolved": "https://registry.npmjs.org/should/-/should-13.2.3.tgz", - "integrity": "sha512-ggLesLtu2xp+ZxI+ysJTmNjh2U0TsC+rQ/pfED9bUZZ4DKefP27D+7YJVVTvKsmjLpIi9jAa7itwDGkDDmt1GQ==", - "dev": true, - "requires": { - "should-equal": "^2.0.0", - "should-format": "^3.0.3", - "should-type": "^1.4.0", - "should-type-adaptors": "^1.0.1", - "should-util": "^1.0.0" - } - }, - "should-equal": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/should-equal/-/should-equal-2.0.0.tgz", - "integrity": "sha512-ZP36TMrK9euEuWQYBig9W55WPC7uo37qzAEmbjHz4gfyuXrEUgF8cUvQVO+w+d3OMfPvSRQJ22lSm8MQJ43LTA==", - "dev": true, - "requires": { - "should-type": "^1.4.0" - } - }, - "should-format": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/should-format/-/should-format-3.0.3.tgz", - "integrity": "sha1-m/yPdPo5IFxT04w01xcwPidxJPE=", - "dev": true, - "requires": { - "should-type": "^1.3.0", - "should-type-adaptors": "^1.0.1" - } - }, - "should-type": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/should-type/-/should-type-1.4.0.tgz", - "integrity": "sha1-B1bYzoRt/QmEOmlHcZ36DUz/XPM=", - "dev": true - }, - "should-type-adaptors": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/should-type-adaptors/-/should-type-adaptors-1.1.0.tgz", - "integrity": "sha512-JA4hdoLnN+kebEp2Vs8eBe9g7uy0zbRo+RMcU0EsNy+R+k049Ki+N5tT5Jagst2g7EAja+euFuoXFCa8vIklfA==", - "dev": true, - "requires": { - "should-type": "^1.3.0", - "should-util": "^1.0.0" - } - }, - "should-util": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/should-util/-/should-util-1.0.1.tgz", - "integrity": "sha512-oXF8tfxx5cDk8r2kYqlkUJzZpDBqVY/II2WhvU0n9Y3XYvAYRmeaf1PvvIvTgPnv4KJ+ES5M0PyDq5Jp+Ygy2g==", - "dev": true - }, - "signal-exit": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", - "integrity": "sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA==", - "dev": true - }, - "slash": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", - "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", - "dev": true - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "requires": { - "base": "^0.11.1", - "debug": "^2.2.0", - "define-property": "^0.2.5", - "extend-shallow": "^2.0.1", - "map-cache": "^0.2.2", - "source-map": "^0.5.6", - "source-map-resolve": "^0.5.0", - "use": "^3.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "^0.1.0" - } - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "requires": { - "define-property": "^1.0.0", - "isobject": "^3.0.0", - "snapdragon-util": "^3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "^1.0.0" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "^6.0.0" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "^1.0.0", - "is-data-descriptor": "^1.0.0", - "kind-of": "^6.0.2" - } - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "requires": { - "kind-of": "^3.2.0" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "sort-keys": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-1.1.2.tgz", - "integrity": "sha1-RBttTTRnmPG05J6JIK37oOVD+a0=", - "dev": true, - "requires": { - "is-plain-obj": "^1.0.0" - } - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - }, - "source-map-resolve": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", - "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", - "dev": true, - "requires": { - "atob": "^2.1.2", - "decode-uri-component": "^0.2.0", - "resolve-url": "^0.2.1", - "source-map-url": "^0.4.0", - "urix": "^0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, - "split": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", - "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", - "dev": true, - "requires": { - "through": "2" - } - }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "requires": { - "extend-shallow": "^3.0.0" - } - }, - "sprintf-js": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true - }, - "static-eval": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/static-eval/-/static-eval-2.0.2.tgz", - "integrity": "sha512-N/D219Hcr2bPjLxPiV+TQE++Tsmrady7TqAJugLy7Xk1EumfDWS/f5dtBbkRCGE7wKKXuYockQoj8Rm2/pVKyg==", - "dev": true, - "requires": { - "escodegen": "^1.8.1" - } - }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "^0.2.5", - "object-copy": "^0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "^0.1.0" - } - } - } - }, - "statuses": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", - "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=", - "dev": true - }, - "stream-combiner": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", - "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", - "dev": true, - "requires": { - "duplexer": "~0.1.1" - } - }, - "strict-uri-encode": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", - "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - }, - "stringify-object": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/stringify-object/-/stringify-object-3.3.0.tgz", - "integrity": "sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==", - "dev": true, - "requires": { - "get-own-enumerable-property-symbols": "^3.0.0", - "is-obj": "^1.0.1", - "is-regexp": "^1.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "^3.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz", - "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==", - "dev": true - } - } - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true - }, - "strip-outer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", - "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.2" - } - }, - "strip-url-auth": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/strip-url-auth/-/strip-url-auth-1.0.1.tgz", - "integrity": "sha1-IrD6OkE4WzO+PzMVUbu4N/oM164=", - "dev": true - }, - "superagent": { - "version": "3.8.3", - "resolved": "https://registry.npmjs.org/superagent/-/superagent-3.8.3.tgz", - "integrity": "sha512-GLQtLMCoEIK4eDv6OGtkOoSMt3D+oq0y3dsxMuYuDvaNUvuT8eFBuLmfR0iYYzHC1e8hpzC6ZsxbuP6DIalMFA==", - "dev": true, - "requires": { - "component-emitter": "^1.2.0", - "cookiejar": "^2.1.0", - "debug": "^3.1.0", - "extend": "^3.0.0", - "form-data": "^2.3.1", - "formidable": "^1.2.0", - "methods": "^1.1.1", - "mime": "^1.4.1", - "qs": "^6.5.1", - "readable-stream": "^2.3.5" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - } - } - }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "requires": { - "has-flag": "^3.0.0" - } - }, - "swagger-editor-dist": { - "version": "3.11.5", - "resolved": "https://registry.npmjs.org/swagger-editor-dist/-/swagger-editor-dist-3.11.5.tgz", - "integrity": "sha512-GAPEsedT0F/te5AkMfq8Q3W2xUcyc2F0XZqdp7DrBvJkybuOsKSah0P3UhlSVMaNV51n+6wOyV1SFvlJI6E+zQ==", - "dev": true - }, - "swagger-methods": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/swagger-methods/-/swagger-methods-1.0.8.tgz", - "integrity": "sha512-G6baCwuHA+C5jf4FNOrosE4XlmGsdjbOjdBK4yuiDDj/ro9uR4Srj3OR84oQMT8F3qKp00tYNv0YN730oTHPZA==", - "dev": true - }, - "swagger-repo": { - "version": "2.0.0-rc.15", - "resolved": "https://registry.npmjs.org/swagger-repo/-/swagger-repo-2.0.0-rc.15.tgz", - "integrity": "sha512-bXzw8oByP8RabdNHTZlCMZ3YEz3t1IKz+JbzP43JSd7N+oRe7Ms9Li46R6rqx6nF2MWClvjBSs1q949O/rqjAA==", - "dev": true, - "requires": { - "body-parser": "^1.15.2", - "chalk": "^2.4.1", - "commander": "^2.9.0", - "cors": "^2.7.1", - "express": "^4.13.4", - "fs-extra": "^7.0.1", - "gh-pages": "^2.0.1", - "glob": "^7.0.0", - "js-yaml": "^3.13.1", - "json-pointer": "^0.6.0", - "jsonpath": "^1.0.2", - "livereload": "^0.8.0", - "lodash": "^4.17.15", - "mkdirp": "^0.5.1", - "node-fetch": "^2.3.0", - "oas-validator": "^1.1.13", - "require-dir": "^1.0.0", - "swagger-editor-dist": "^3.6.16", - "swagger-ui-dist": "^3.20.1", - "sway": "^2.0.6" - } - }, - "swagger-schema-official": { - "version": "2.0.0-bab6bed", - "resolved": "https://registry.npmjs.org/swagger-schema-official/-/swagger-schema-official-2.0.0-bab6bed.tgz", - "integrity": "sha1-cAcEaNbSl3ylI3suUZyn0Gouo/0=", - "dev": true - }, - "swagger-ui-dist": { - "version": "3.27.0", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.27.0.tgz", - "integrity": "sha512-dlbH4L8+UslXVeYvCulicmJP2cnHLoabQGfeav5lx74fM+tMQW53M8iqpH5wbBqBbFkZwza+IIWoPrenqO/F2g==", - "dev": true - }, - "sway": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/sway/-/sway-2.0.6.tgz", - "integrity": "sha512-0HRT2WuU44XIdq+eCiMx67Bl/kiEKORP+4j+Wt89rFjoR5Dwx2hmU4PkMA6hnd48XLfS50olIac3pQGrV/wv7w==", - "dev": true, - "requires": { - "debug": "^3.1.0", - "faker": "^4.1.0", - "js-base64": "^2.4.5", - "js-yaml": "^3.13.1", - "json-refs": "^3.0.13", - "json-schema-faker": "^0.5.0-rc16", - "lodash": "^4.17.10", - "native-promise-only": "^0.8.1", - "path-to-regexp": "^1.7.0", - "swagger-methods": "^1.0.0", - "swagger-schema-official": "2.0.0-bab6bed", - "z-schema": "^3.22.0" - }, - "dependencies": { - "debug": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", - "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", - "dev": true, - "requires": { - "ms": "^2.1.1" - } - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, - "path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "dev": true, - "requires": { - "isarray": "0.0.1" - } - } - } - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "~1.0.2" - } - }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "requires": { - "define-property": "^2.0.2", - "extend-shallow": "^3.0.2", - "regex-not": "^1.0.2", - "safe-regex": "^1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "^3.0.0", - "repeat-string": "^1.6.1" - } - }, - "toidentifier": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", - "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", - "dev": true - }, - "tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=", - "dev": true - }, - "trim-repeated": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-1.0.0.tgz", - "integrity": "sha1-42RqLqTokTEr9+rObPsFOAvAHCE=", - "dev": true, - "requires": { - "escape-string-regexp": "^1.0.2" - } - }, - "tslib": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz", - "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", - "dev": true - }, - "type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2" - } - }, - "type-fest": { - "version": "0.21.3", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", - "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", - "dev": true - }, - "type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "dev": true, - "requires": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - } - }, - "union-value": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", - "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", - "dev": true, - "requires": { - "arr-union": "^3.1.0", - "get-value": "^2.0.6", - "is-extendable": "^0.1.1", - "set-value": "^2.0.1" - } - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true - }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=", - "dev": true - }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "^0.3.1", - "isobject": "^3.0.0" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "^2.0.3", - "has-values": "^0.1.4", - "isobject": "^2.0.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - } - } - }, - "upath": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", - "integrity": "sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg==", - "dev": true - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "dev": true, - "requires": { - "punycode": "^2.1.0" - } - }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "use": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", - "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", - "dev": true - }, - "validator": { - "version": "10.11.0", - "resolved": "https://registry.npmjs.org/validator/-/validator-10.11.0.tgz", - "integrity": "sha512-X/p3UZerAIsbBfN/IwahhYaBbY68EN/UQBWHtsbXGT5bfrH/p4NQzUCG1kF/rtKaNpnJ7jAu6NGTdSNtyNIXMw==", - "dev": true - }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", - "dev": true - }, - "wcwidth": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", - "integrity": "sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=", - "dev": true, - "requires": { - "defaults": "^1.0.3" - } - }, - "webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=", - "dev": true - }, - "whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", - "dev": true, - "requires": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true - }, - "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "dev": true - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "dev": true, - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - }, - "ws": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.2.tgz", - "integrity": "sha512-zmhltoSR8u1cnDsD43TX59mzoMZsLKqUweyYBAIvTngR3shc0W6aOZylZmq/7hqyVxPdi+5Ud2QInblgyE72fw==", - "dev": true, - "requires": { - "async-limiter": "~1.0.0" - } - }, - "y18n": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.1.tgz", - "integrity": "sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==", - "dev": true - }, - "yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, - "yaml": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz", - "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==", - "dev": true - }, - "yargs": { - "version": "12.0.5", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-12.0.5.tgz", - "integrity": "sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==", - "dev": true, - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.2.0", - "find-up": "^3.0.0", - "get-caller-file": "^1.0.1", - "os-locale": "^3.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1 || ^4.0.0", - "yargs-parser": "^11.1.1" - } - }, - "yargs-parser": { - "version": "11.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-11.1.1.tgz", - "integrity": "sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==", - "dev": true, - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - } - }, - "z-schema": { - "version": "3.25.1", - "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.25.1.tgz", - "integrity": "sha512-7tDlwhrBG+oYFdXNOjILSurpfQyuVgkRe3hB2q8TEssamDHB7BbLWYkYO98nTn0FibfdFroFKDjndbgufAgS/Q==", - "dev": true, - "requires": { - "commander": "^2.7.1", - "core-js": "^2.5.7", - "lodash.get": "^4.0.0", - "lodash.isequal": "^4.0.0", - "validator": "^10.0.0" - } - } - } -} diff --git a/package.json b/package.json deleted file mode 100644 index 98df7cc2..00000000 --- a/package.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "lifterlms-rest", - "version": "1.0.0-beta.25", - "description": "REST API feature plugin for the LifterLMS Core.", - "author": "LifterLMS", - "homepage": "https://lifterlms.com/", - "main": "gulpfile.js", - "repository": { - "type": "git", - "url": "https://github.com/gocodebox/lifterlms-rest.git" - }, - "license": "GPL-3.0", - "bugs": { - "url": "https://github.com/gocodebox/lifterlms-rest/issues" - }, - "devDependencies": { - "@lifterlms/dev": "^0.0.2", - "openapi-snippet": "^0.9.1", - "swagger-repo": "^2.0.0-rc.15" - }, - "scripts": { - "dev": "llms-dev", - "start": "swagger-repo serve -p 8888", - "build": "npm run build:docs && llms-dev pot", - "build:docs": "npm run build:spec && npm run build:snippets && npm run build:spec", - "build:snippets": "./.bin/snippets", - "build:spec": "swagger-repo build -o web_deploy && ./.bin/cache-bust", - "test": "swagger-repo validate", - "gh-pages": "swagger-repo gh-pages" - } -} diff --git a/phpcs.xml b/phpcs.xml deleted file mode 100644 index aa81d32c..00000000 --- a/phpcs.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - LifterLMS REST API rules for PHP_CodeSniffer - - . - - - - - - - - - - - - - spec/code_samples/ - - - .bin/ - - diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index 13e9e53d..00000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - tests/unit-tests - - ./tests/unit-tests/class-llms-rest-test-webhook-delivery.php - - - - - - . - - ./tests/ - ./tmp/ - ./dist/ - ./node_modules/ - ./vendor/ - ./**/index.php - - - - - diff --git a/spec/README.md b/spec/README.md deleted file mode 100644 index cb92eacf..00000000 --- a/spec/README.md +++ /dev/null @@ -1,24 +0,0 @@ -## Global headers (only for OpenAPI 2) - -When using OpenAPI 2 you can minimize headers duplications by using `headers` global object (similar to `definitions`, `responses`). -During build process all references to global `headers` will be inlined and `headers` will be removed from the resulting spec so spec will be valid (global `headers` are not allowed by OpenAPI 2 spec): - -Example: -```yaml -... -headers: - Rate-Limit-Limit: - description: The number of allowed requests in the current period - type: integer -... -paths: - /api-keys: - get: - summary: Retrieve a list of api keys - responses: - 200: - description: A list of api keys was retrieved successfully - headers: - Rate-Limit-Limit: - $ref: "#/headers/Rate-Limit-Limit" -``` diff --git a/spec/code_samples/Node.js/access-plans/get.js b/spec/code_samples/Node.js/access-plans/get.js deleted file mode 100644 index 1b5ae066..00000000 --- a/spec/code_samples/Node.js/access-plans/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/access-plans?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&post_id=123%2C456', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/access-plans/post.js b/spec/code_samples/Node.js/access-plans/post.js deleted file mode 100644 index 8b0de04f..00000000 --- a/spec/code_samples/Node.js/access-plans/post.js +++ /dev/null @@ -1,50 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "price": 199.97, - "sku": "LIFETIME-999-001", - "frequency": 0, - "length": 0, - "period": "year", - "enroll_text": "Buy Now", - "sale_enabled": false, - "sale_price": 99.97, - "sale_date_start": "2019-01-23 00:00:00", - "sale_date_end": "2019-03-23 23:59:59", - "availability_restrictions": [ - 123, - 456, - 789 - ], - "access_expiration": "lifetime", - "access_expires": "2019-03-23 23:59:59", - "access_length": 1, - "access_period": "year", - "trial_enabled": false, - "trial_length": 1, - "trial_period": "week", - "trial_price": 1.99, - "post_id": 789, - "redirect_type": "self", - "redirect_page": 1, - "redirect_url": "https://example.tld/my/redirect", - "redirect_forced": false, - "visibility": "visible", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "title": "Liftetime Access", - "content": "\\n
  • Expectoque quid ad id
  • quod quaerebam, respondeas
\\n" -}; - -llms.post( '/access-plans', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/access-plans@{id}/delete.js b/spec/code_samples/Node.js/access-plans@{id}/delete.js deleted file mode 100644 index ab1a78d6..00000000 --- a/spec/code_samples/Node.js/access-plans@{id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/access-plans/%7Bid%7D', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/access-plans@{id}/get.js b/spec/code_samples/Node.js/access-plans@{id}/get.js deleted file mode 100644 index 81d8dcc3..00000000 --- a/spec/code_samples/Node.js/access-plans@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/access-plans/%7Bid%7D?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/access-plans@{id}/post.js b/spec/code_samples/Node.js/access-plans@{id}/post.js deleted file mode 100644 index f6d2334c..00000000 --- a/spec/code_samples/Node.js/access-plans@{id}/post.js +++ /dev/null @@ -1,50 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "price": 199.97, - "sku": "LIFETIME-999-001", - "frequency": 0, - "length": 0, - "period": "year", - "enroll_text": "Buy Now", - "sale_enabled": false, - "sale_price": 99.97, - "sale_date_start": "2019-01-23 00:00:00", - "sale_date_end": "2019-03-23 23:59:59", - "availability_restrictions": [ - 123, - 456, - 789 - ], - "access_expiration": "lifetime", - "access_expires": "2019-03-23 23:59:59", - "access_length": 1, - "access_period": "year", - "trial_enabled": false, - "trial_length": 1, - "trial_period": "week", - "trial_price": 1.99, - "post_id": 789, - "redirect_type": "self", - "redirect_page": 1, - "redirect_url": "https://example.tld/my/redirect", - "redirect_forced": false, - "visibility": "visible", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "title": "Liftetime Access", - "content": "\\n
  • Expectoque quid ad id
  • quod quaerebam, respondeas
\\n" -}; - -llms.post( '/access-plans/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/api-keys/get.js b/spec/code_samples/Node.js/api-keys/get.js deleted file mode 100644 index 96241385..00000000 --- a/spec/code_samples/Node.js/api-keys/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/api-keys?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&user=123%2C456&user_not_in=123%2C456&permissions=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/api-keys/post.js b/spec/code_samples/Node.js/api-keys/post.js deleted file mode 100644 index 14af549b..00000000 --- a/spec/code_samples/Node.js/api-keys/post.js +++ /dev/null @@ -1,19 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "user_id": 456, - "description": "My API Key", - "permissions": "read" -}; - -llms.post( '/api-keys', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/api-keys@{id}/delete.js b/spec/code_samples/Node.js/api-keys@{id}/delete.js deleted file mode 100644 index 233ffd38..00000000 --- a/spec/code_samples/Node.js/api-keys@{id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/api-keys/987', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/api-keys@{id}/get.js b/spec/code_samples/Node.js/api-keys@{id}/get.js deleted file mode 100644 index 5925734c..00000000 --- a/spec/code_samples/Node.js/api-keys@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/api-keys/987?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/api-keys@{id}/post.js b/spec/code_samples/Node.js/api-keys@{id}/post.js deleted file mode 100644 index 53113b13..00000000 --- a/spec/code_samples/Node.js/api-keys@{id}/post.js +++ /dev/null @@ -1,19 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "user_id": 456, - "description": "My API Key", - "permissions": "read" -}; - -llms.post( '/api-keys/987', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/courses/get.js b/spec/code_samples/Node.js/courses/get.js deleted file mode 100644 index 6f42d3c2..00000000 --- a/spec/code_samples/Node.js/courses/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/courses?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=draft', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/courses/post.js b/spec/code_samples/Node.js/courses/post.js deleted file mode 100644 index 86c740dc..00000000 --- a/spec/code_samples/Node.js/courses/post.js +++ /dev/null @@ -1,74 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "access_opens_message": "This course opens on [lifterlms_course_info key=\"start_date\"].", - "access_closes_message": "This course closed on [lifterlms_course_info key=\"end_date\"].", - "enrollment_opens_message": "Enrollment in this course opens on [lifterlms_course_info key=\"enrollment_start_date\"].", - "enrollment_closes_message": "Enrollment in this course closed on [lifterlms_course_info key=\"enrollment_end_date\"].", - "capacity_message": "Enrollment has closed because the maximum number of allowed students has been reached.", - "length": "7 days", - "restricted_message": "You must enroll in this course to access course content.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "getting-started-with-lifterlms", - "status": "publish", - "password": "p4$sW0rd", - "featured_media": 987, - "comment_status": "open", - "ping_status": "open", - "permalink": "https://example.com/course/getting-started-with-lifterlms", - "post_type": "course", - "catalog_visibility": "catalog_search", - "categories": [ - 1, - 2, - 3 - ], - "tags": [ - 4, - 5, - 6 - ], - "difficulties": [ - 7 - ], - "tracks": [ - 8, - 9 - ], - "audio_embed": "https://open.spotify.com/track/trackid", - "video_embed": "https://www.youtube.com/watch?v=videoid", - "capacity_enabled": false, - "capacity_limit": 25, - "prerequisite": 456, - "prerequisite_track": 789, - "access_opens_date": "2019-05-20 17:22:05", - "access_closes_date": "2019-06-05 17:22:05", - "enrollment_opens_date": "2019-05-15 12:15:00", - "enrollment_closes_date": "2019-10-01 23:59:59", - "video_tile": false, - "instructors": [ - 1, - 2, - 3 - ], - "sales_page_type": "none", - "sales_page_page_id": 543, - "sales_page_url": "https://example.tld/custom-sales-page" -}; - -llms.post( '/courses', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/courses@{id}/delete.js b/spec/code_samples/Node.js/courses@{id}/delete.js deleted file mode 100644 index 57155d98..00000000 --- a/spec/code_samples/Node.js/courses@{id}/delete.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "force": false -}; - -llms.delete( '/courses/123', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/courses@{id}/get.js b/spec/code_samples/Node.js/courses@{id}/get.js deleted file mode 100644 index 416fa6d0..00000000 --- a/spec/code_samples/Node.js/courses@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/courses/123?context=edit&password=p4%24sW0rd', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/courses@{id}/post.js b/spec/code_samples/Node.js/courses@{id}/post.js deleted file mode 100644 index de2fd9a1..00000000 --- a/spec/code_samples/Node.js/courses@{id}/post.js +++ /dev/null @@ -1,74 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "access_opens_message": "This course opens on [lifterlms_course_info key=\"start_date\"].", - "access_closes_message": "This course closed on [lifterlms_course_info key=\"end_date\"].", - "enrollment_opens_message": "Enrollment in this course opens on [lifterlms_course_info key=\"enrollment_start_date\"].", - "enrollment_closes_message": "Enrollment in this course closed on [lifterlms_course_info key=\"enrollment_end_date\"].", - "capacity_message": "Enrollment has closed because the maximum number of allowed students has been reached.", - "length": "7 days", - "restricted_message": "You must enroll in this course to access course content.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "getting-started-with-lifterlms", - "status": "publish", - "password": "p4$sW0rd", - "featured_media": 987, - "comment_status": "open", - "ping_status": "open", - "permalink": "https://example.com/course/getting-started-with-lifterlms", - "post_type": "course", - "catalog_visibility": "catalog_search", - "categories": [ - 1, - 2, - 3 - ], - "tags": [ - 4, - 5, - 6 - ], - "difficulties": [ - 7 - ], - "tracks": [ - 8, - 9 - ], - "audio_embed": "https://open.spotify.com/track/trackid", - "video_embed": "https://www.youtube.com/watch?v=videoid", - "capacity_enabled": false, - "capacity_limit": 25, - "prerequisite": 456, - "prerequisite_track": 789, - "access_opens_date": "2019-05-20 17:22:05", - "access_closes_date": "2019-06-05 17:22:05", - "enrollment_opens_date": "2019-05-15 12:15:00", - "enrollment_closes_date": "2019-10-01 23:59:59", - "video_tile": false, - "instructors": [ - 1, - 2, - 3 - ], - "sales_page_type": "none", - "sales_page_page_id": 543, - "sales_page_url": "https://example.tld/custom-sales-page" -}; - -llms.post( '/courses/123', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/courses@{id}@content/get.js b/spec/code_samples/Node.js/courses@{id}@content/get.js deleted file mode 100644 index 402b5152..00000000 --- a/spec/code_samples/Node.js/courses@{id}@content/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/courses/%7Bid%7D/content?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/courses@{id}@enrollments/get.js b/spec/code_samples/Node.js/courses@{id}@enrollments/get.js deleted file mode 100644 index d5123f8d..00000000 --- a/spec/code_samples/Node.js/courses@{id}@enrollments/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/courses/%7Bid%7D/enrollments?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&status=SOME_STRING_VALUE&student=1%2C2%2C3', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups/get.js b/spec/code_samples/Node.js/groups/get.js deleted file mode 100644 index 34a0ed4e..00000000 --- a/spec/code_samples/Node.js/groups/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/groups?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups/post.js b/spec/code_samples/Node.js/groups/post.js deleted file mode 100644 index dd13d4fe..00000000 --- a/spec/code_samples/Node.js/groups/post.js +++ /dev/null @@ -1,27 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "team-codebox", - "post": 1234, - "visibility": "open", - "logo": 1987, - "banner": 1897 -}; - -llms.post( '/groups', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}/delete.js b/spec/code_samples/Node.js/groups@{id}/delete.js deleted file mode 100644 index b9447e83..00000000 --- a/spec/code_samples/Node.js/groups@{id}/delete.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "force": false -}; - -llms.delete( '/groups/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}/get.js b/spec/code_samples/Node.js/groups@{id}/get.js deleted file mode 100644 index 29948923..00000000 --- a/spec/code_samples/Node.js/groups@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/groups/%7Bid%7D?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}/post.js b/spec/code_samples/Node.js/groups@{id}/post.js deleted file mode 100644 index 7d5cf95d..00000000 --- a/spec/code_samples/Node.js/groups@{id}/post.js +++ /dev/null @@ -1,27 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "team-codebox", - "post": 1234, - "visibility": "open", - "logo": 1987, - "banner": 1897 -}; - -llms.post( '/groups/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@invitations/get.js b/spec/code_samples/Node.js/groups@{id}@invitations/get.js deleted file mode 100644 index e4569086..00000000 --- a/spec/code_samples/Node.js/groups@{id}@invitations/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/groups/%7Bid%7D/invitations?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&email=jeffrey%40fakewebsite.tld&role=leader%2Cadmin', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@invitations/post.js b/spec/code_samples/Node.js/groups@{id}@invitations/post.js deleted file mode 100644 index 30a9269b..00000000 --- a/spec/code_samples/Node.js/groups@{id}@invitations/post.js +++ /dev/null @@ -1,18 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "email": "stephen@example.net", - "role": "member" -}; - -llms.post( '/groups/%7Bid%7D/invitations', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/delete.js b/spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/delete.js deleted file mode 100644 index 844dd648..00000000 --- a/spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/groups/%7Bid%7D/invitations/%7Binvitation_id%7D', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/get.js b/spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/get.js deleted file mode 100644 index fdd45ec0..00000000 --- a/spec/code_samples/Node.js/groups@{id}@invitations@{invitation_id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/groups/%7Bid%7D/invitations/%7Binvitation_id%7D?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@members/get.js b/spec/code_samples/Node.js/groups@{id}@members/get.js deleted file mode 100644 index e3cf19f5..00000000 --- a/spec/code_samples/Node.js/groups@{id}@members/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/groups/%7Bid%7D/members?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&group_roles=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@members@{member_id}/delete.js b/spec/code_samples/Node.js/groups@{id}@members@{member_id}/delete.js deleted file mode 100644 index 5d3f3a00..00000000 --- a/spec/code_samples/Node.js/groups@{id}@members@{member_id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/groups/%7Bid%7D/members/%7Bmember_id%7D?trigger=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@members@{member_id}/get.js b/spec/code_samples/Node.js/groups@{id}@members@{member_id}/get.js deleted file mode 100644 index 7d5ac958..00000000 --- a/spec/code_samples/Node.js/groups@{id}@members@{member_id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/groups/%7Bid%7D/members/%7Bmember_id%7D?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@members@{member_id}/post.js b/spec/code_samples/Node.js/groups@{id}@members@{member_id}/post.js deleted file mode 100644 index e9aabd7c..00000000 --- a/spec/code_samples/Node.js/groups@{id}@members@{member_id}/post.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "group_role": "member" -}; - -llms.post( '/groups/%7Bid%7D/members/%7Bmember_id%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@seats/get.js b/spec/code_samples/Node.js/groups@{id}@seats/get.js deleted file mode 100644 index acdcdc90..00000000 --- a/spec/code_samples/Node.js/groups@{id}@seats/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/groups/123/seats', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/groups@{id}@seats/put.js b/spec/code_samples/Node.js/groups@{id}@seats/put.js deleted file mode 100644 index 92de50de..00000000 --- a/spec/code_samples/Node.js/groups@{id}@seats/put.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "total": 20 -}; - -llms.put( '/groups/123/seats', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/instructors/get.js b/spec/code_samples/Node.js/instructors/get.js deleted file mode 100644 index 2ded4554..00000000 --- a/spec/code_samples/Node.js/instructors/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/instructors?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=jamie%40lifterlms.com&search_columns=email%2Cusername&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&post_in=1%2C2%2C3&post_not_in=4%2C5%2C6&roles=instructor%2Clms_manager', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/instructors/post.js b/spec/code_samples/Node.js/instructors/post.js deleted file mode 100644 index f4ab507a..00000000 --- a/spec/code_samples/Node.js/instructors/post.js +++ /dev/null @@ -1,35 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "email": "jamie@lifterlms.com", - "username": "jamie2019", - "password": "my_l337-p@$5w0rd!", - "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - "registered_date": "2019-05-03 19:25:01", - "url": "https://myawesomewebsite.tld", - "first_name": "Jamie", - "last_name": "Cook", - "nickname": "JamieC", - "name": "Jamie Cook", - "billing_address_1": "1234 Somewhere Place", - "billing_address_2": "Suite ABC", - "billing_city": "Anywhere", - "billing_state": "CA", - "billing_postcode": "12345-678", - "billing_country": "US", - "roles": [ - "instructor" - ] -}; - -llms.post( '/instructors', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/instructors@{id}/delete.js b/spec/code_samples/Node.js/instructors@{id}/delete.js deleted file mode 100644 index bef61b11..00000000 --- a/spec/code_samples/Node.js/instructors@{id}/delete.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "reassign": 456 -}; - -llms.delete( '/instructors/123', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/instructors@{id}/get.js b/spec/code_samples/Node.js/instructors@{id}/get.js deleted file mode 100644 index 71897160..00000000 --- a/spec/code_samples/Node.js/instructors@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/instructors/123?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/instructors@{id}/post.js b/spec/code_samples/Node.js/instructors@{id}/post.js deleted file mode 100644 index ed267486..00000000 --- a/spec/code_samples/Node.js/instructors@{id}/post.js +++ /dev/null @@ -1,35 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "email": "jamie@lifterlms.com", - "username": "jamie2019", - "password": "my_l337-p@$5w0rd!", - "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - "registered_date": "2019-05-03 19:25:01", - "url": "https://myawesomewebsite.tld", - "first_name": "Jamie", - "last_name": "Cook", - "nickname": "JamieC", - "name": "Jamie Cook", - "billing_address_1": "1234 Somewhere Place", - "billing_address_2": "Suite ABC", - "billing_city": "Anywhere", - "billing_state": "CA", - "billing_postcode": "12345-678", - "billing_country": "US", - "roles": [ - "instructor" - ] -}; - -llms.post( '/instructors/123', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/instructors@{id}@content/get.js b/spec/code_samples/Node.js/instructors@{id}@content/get.js deleted file mode 100644 index 0d8bb850..00000000 --- a/spec/code_samples/Node.js/instructors@{id}@content/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/instructors/123/content?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&post=123%2C456&post_exclude=789%2C324&post_type=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/lessons/get.js b/spec/code_samples/Node.js/lessons/get.js deleted file mode 100644 index 105beb81..00000000 --- a/spec/code_samples/Node.js/lessons/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/lessons?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=draft&parent=987', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/lessons/post.js b/spec/code_samples/Node.js/lessons/post.js deleted file mode 100644 index 1a3e4f24..00000000 --- a/spec/code_samples/Node.js/lessons/post.js +++ /dev/null @@ -1,50 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "getting-started-with-lifterlms", - "status": "publish", - "password": "p4$sW0rd", - "featured_media": 987, - "comment_status": "open", - "ping_status": "open", - "permalink": "https://example.com/lesson/getting-started-with-lifterlms", - "post_type": "lesson", - "audio_embed": "https://open.spotify.com/track/trackid", - "video_embed": "https://www.youtube.com/watch?v=videoid", - "prerequisite": 321, - "public": false, - "parent_id": 987, - "points": 1, - "order": 1, - "drip_method": "none", - "drip_days": 1, - "drip_date": "2019-12-12 23:23:59", - "quiz": { - "enabled": true, - "id": 432, - "progression": "complete" - }, - "assignment": { - "enabled": true, - "id": 876, - "progression": "complete" - } -}; - -llms.post( '/lessons', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/lessons@{id}/delete.js b/spec/code_samples/Node.js/lessons@{id}/delete.js deleted file mode 100644 index b2779e57..00000000 --- a/spec/code_samples/Node.js/lessons@{id}/delete.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "force": false -}; - -llms.delete( '/lessons/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/lessons@{id}/get.js b/spec/code_samples/Node.js/lessons@{id}/get.js deleted file mode 100644 index 8bc584ab..00000000 --- a/spec/code_samples/Node.js/lessons@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/lessons/%7Bid%7D?context=edit&password=p4%24sW0rd', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/lessons@{id}/post.js b/spec/code_samples/Node.js/lessons@{id}/post.js deleted file mode 100644 index a44045c7..00000000 --- a/spec/code_samples/Node.js/lessons@{id}/post.js +++ /dev/null @@ -1,50 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "getting-started-with-lifterlms", - "status": "publish", - "password": "p4$sW0rd", - "featured_media": 987, - "comment_status": "open", - "ping_status": "open", - "permalink": "https://example.com/lesson/getting-started-with-lifterlms", - "post_type": "lesson", - "audio_embed": "https://open.spotify.com/track/trackid", - "video_embed": "https://www.youtube.com/watch?v=videoid", - "prerequisite": 321, - "public": false, - "parent_id": 987, - "points": 1, - "order": 1, - "drip_method": "none", - "drip_days": 1, - "drip_date": "2019-12-12 23:23:59", - "quiz": { - "enabled": true, - "id": 432, - "progression": "complete" - }, - "assignment": { - "enabled": true, - "id": 876, - "progression": "complete" - } -}; - -llms.post( '/lessons/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/memberships/get.js b/spec/code_samples/Node.js/memberships/get.js deleted file mode 100644 index b53607e5..00000000 --- a/spec/code_samples/Node.js/memberships/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/memberships?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=draft', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/memberships/post.js b/spec/code_samples/Node.js/memberships/post.js deleted file mode 100644 index d6c9f712..00000000 --- a/spec/code_samples/Node.js/memberships/post.js +++ /dev/null @@ -1,57 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "restriction_message": "You must belong to the [lifterlms_membership_link id=\"1234\"] membership to access this content.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "getting-started-with-lifterlms", - "status": "publish", - "password": "p4$sW0rd", - "featured_media": 987, - "comment_status": "open", - "ping_status": "open", - "permalink": "https://example.com/membership/getting-started-with-lifterlms", - "post_type": "llms_membership", - "categories": [ - 1, - 2, - 3 - ], - "tags": [ - 4, - 5, - 6 - ], - "restriction_action": "none", - "restriction_page_id": 456, - "restriction_url": "https://example.tld/my-custom-url", - "auto_enroll": [ - 456, - 789 - ], - "catalog_visibility": "catalog_search", - "instructors": [ - 1, - 2, - 3 - ], - "sales_page_type": "none", - "sales_page_page_id": 543, - "sales_page_url": "https://example.tld/custom-sales-page" -}; - -llms.post( '/memberships', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/memberships@{id}/delete.js b/spec/code_samples/Node.js/memberships@{id}/delete.js deleted file mode 100644 index c46e2a94..00000000 --- a/spec/code_samples/Node.js/memberships@{id}/delete.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "force": false -}; - -llms.delete( '/memberships/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/memberships@{id}/get.js b/spec/code_samples/Node.js/memberships@{id}/get.js deleted file mode 100644 index 063c4336..00000000 --- a/spec/code_samples/Node.js/memberships@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/memberships/%7Bid%7D?context=edit&password=p4%24sW0rd', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/memberships@{id}/post.js b/spec/code_samples/Node.js/memberships@{id}/post.js deleted file mode 100644 index 5e2d7be9..00000000 --- a/spec/code_samples/Node.js/memberships@{id}/post.js +++ /dev/null @@ -1,57 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "content": "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - "excerpt": "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.", - "restriction_message": "You must belong to the [lifterlms_membership_link id=\"1234\"] membership to access this content.", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "menu_order": 0, - "slug": "getting-started-with-lifterlms", - "status": "publish", - "password": "p4$sW0rd", - "featured_media": 987, - "comment_status": "open", - "ping_status": "open", - "permalink": "https://example.com/membership/getting-started-with-lifterlms", - "post_type": "llms_membership", - "categories": [ - 1, - 2, - 3 - ], - "tags": [ - 4, - 5, - 6 - ], - "restriction_action": "none", - "restriction_page_id": 456, - "restriction_url": "https://example.tld/my-custom-url", - "auto_enroll": [ - 456, - 789 - ], - "catalog_visibility": "catalog_search", - "instructors": [ - 1, - 2, - 3 - ], - "sales_page_type": "none", - "sales_page_page_id": 543, - "sales_page_url": "https://example.tld/custom-sales-page" -}; - -llms.post( '/memberships/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/memberships@{id}@enrollments/get.js b/spec/code_samples/Node.js/memberships@{id}@enrollments/get.js deleted file mode 100644 index a527db86..00000000 --- a/spec/code_samples/Node.js/memberships@{id}@enrollments/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/memberships/%7Bid%7D/enrollments?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&status=SOME_STRING_VALUE&student=1%2C2%2C3', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quiz-questions/get.js b/spec/code_samples/Node.js/quiz-questions/get.js deleted file mode 100644 index e1f037a9..00000000 --- a/spec/code_samples/Node.js/quiz-questions/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/quiz-questions?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&quiz=789', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quiz-questions/post.js b/spec/code_samples/Node.js/quiz-questions/post.js deleted file mode 100644 index c2941a2e..00000000 --- a/spec/code_samples/Node.js/quiz-questions/post.js +++ /dev/null @@ -1,40 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "order": 1, - "parent_id": 234, - "points": 10, - "video_embed": "https://www.youtube.com/watch?v=videoid", - "featured_media": 205, - "question_type": "choice", - "choices": [ - { - "marker": "A", - "choice": "Red", - "correct": false - }, - { - "marker": "B", - "choice": "Green", - "correct": true - } - ], - "multi_choices": false, - "title": "What is your favorite color?", - "content": "

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

", - "answer_clarification": "

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

" -}; - -llms.post( '/quiz-questions', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quiz-questions@{id}/delete.js b/spec/code_samples/Node.js/quiz-questions@{id}/delete.js deleted file mode 100644 index bb832d0d..00000000 --- a/spec/code_samples/Node.js/quiz-questions@{id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/quiz-questions/%7Bid%7D', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quiz-questions@{id}/get.js b/spec/code_samples/Node.js/quiz-questions@{id}/get.js deleted file mode 100644 index aa0b9a19..00000000 --- a/spec/code_samples/Node.js/quiz-questions@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/quiz-questions/%7Bid%7D?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quiz-questions@{id}/post.js b/spec/code_samples/Node.js/quiz-questions@{id}/post.js deleted file mode 100644 index 821d38aa..00000000 --- a/spec/code_samples/Node.js/quiz-questions@{id}/post.js +++ /dev/null @@ -1,40 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "order": 1, - "parent_id": 234, - "points": 10, - "video_embed": "https://www.youtube.com/watch?v=videoid", - "featured_media": 205, - "question_type": "choice", - "choices": [ - { - "marker": "A", - "choice": "Red", - "correct": false - }, - { - "marker": "B", - "choice": "Green", - "correct": true - } - ], - "multi_choices": false, - "title": "What is your favorite color?", - "content": "

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

", - "answer_clarification": "

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

" -}; - -llms.post( '/quiz-questions/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quizzes/get.js b/spec/code_samples/Node.js/quizzes/get.js deleted file mode 100644 index 2fda3d62..00000000 --- a/spec/code_samples/Node.js/quizzes/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/quizzes?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&parent=789&course=1234&status=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quizzes/post.js b/spec/code_samples/Node.js/quizzes/post.js deleted file mode 100644 index 519ded7f..00000000 --- a/spec/code_samples/Node.js/quizzes/post.js +++ /dev/null @@ -1,30 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "slug": "final-exam", - "status": "draft", - "attempt_limiting": true, - "attempts_allowed": 1, - "time_limiting": true, - "time_limit": 90, - "passing_percentage": 65, - "show_correct_answer": false, - "randomize_questions": false, - "parent_id": 789, - "title": "Final Exam", - "content": "

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

" -}; - -llms.post( '/quizzes', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quizzes@{id}/delete.js b/spec/code_samples/Node.js/quizzes@{id}/delete.js deleted file mode 100644 index 89416949..00000000 --- a/spec/code_samples/Node.js/quizzes@{id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/quizzes/%7Bid%7D', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quizzes@{id}/get.js b/spec/code_samples/Node.js/quizzes@{id}/get.js deleted file mode 100644 index 3abf7a2a..00000000 --- a/spec/code_samples/Node.js/quizzes@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/quizzes/%7Bid%7D?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/quizzes@{id}/post.js b/spec/code_samples/Node.js/quizzes@{id}/post.js deleted file mode 100644 index f308a07a..00000000 --- a/spec/code_samples/Node.js/quizzes@{id}/post.js +++ /dev/null @@ -1,30 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "slug": "final-exam", - "status": "draft", - "attempt_limiting": true, - "attempts_allowed": 1, - "time_limiting": true, - "time_limit": 90, - "passing_percentage": 65, - "show_correct_answer": false, - "randomize_questions": false, - "parent_id": 789, - "title": "Final Exam", - "content": "

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

" -}; - -llms.post( '/quizzes/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/sections/get.js b/spec/code_samples/Node.js/sections/get.js deleted file mode 100644 index ea960afc..00000000 --- a/spec/code_samples/Node.js/sections/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/sections?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&parent=1234', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/sections/post.js b/spec/code_samples/Node.js/sections/post.js deleted file mode 100644 index f5112dd0..00000000 --- a/spec/code_samples/Node.js/sections/post.js +++ /dev/null @@ -1,21 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "order": 1, - "parent_id": 1234 -}; - -llms.post( '/sections', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/sections@{id}/delete.js b/spec/code_samples/Node.js/sections@{id}/delete.js deleted file mode 100644 index 508cf9fb..00000000 --- a/spec/code_samples/Node.js/sections@{id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/sections/%7Bid%7D', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/sections@{id}/get.js b/spec/code_samples/Node.js/sections@{id}/get.js deleted file mode 100644 index dffb588b..00000000 --- a/spec/code_samples/Node.js/sections@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/sections/%7Bid%7D?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/sections@{id}/post.js b/spec/code_samples/Node.js/sections@{id}/post.js deleted file mode 100644 index 4d188830..00000000 --- a/spec/code_samples/Node.js/sections@{id}/post.js +++ /dev/null @@ -1,21 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "title": "Getting Started with LifterLMS", - "date_created": "2019-05-20 17:22:05", - "date_created_gmt": "2019-05-20 13:22:05", - "order": 1, - "parent_id": 1234 -}; - -llms.post( '/sections/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/sections@{id}@content/get.js b/spec/code_samples/Node.js/sections@{id}@content/get.js deleted file mode 100644 index e93a9f27..00000000 --- a/spec/code_samples/Node.js/sections@{id}@content/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/sections/%7Bid%7D/content?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&parent=987', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students/get.js b/spec/code_samples/Node.js/students/get.js deleted file mode 100644 index 45cac97e..00000000 --- a/spec/code_samples/Node.js/students/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/students?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=jamie%40lifterlms.com&search_columns=email%2Cusername&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&enrolled_in=1%2C2%2C3&enrolled_not_in=4%2C5%2C6&roles=student%2Ccustomer', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students/post.js b/spec/code_samples/Node.js/students/post.js deleted file mode 100644 index 0d981eaf..00000000 --- a/spec/code_samples/Node.js/students/post.js +++ /dev/null @@ -1,35 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "email": "jamie@lifterlms.com", - "username": "jamie2019", - "password": "my_l337-p@$5w0rd!", - "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - "registered_date": "2019-05-03 19:25:01", - "url": "https://myawesomewebsite.tld", - "first_name": "Jamie", - "last_name": "Cook", - "nickname": "JamieC", - "name": "Jamie Cook", - "billing_address_1": "1234 Somewhere Place", - "billing_address_2": "Suite ABC", - "billing_city": "Anywhere", - "billing_state": "CA", - "billing_postcode": "12345-678", - "billing_country": "US", - "roles": [ - "student" - ] -}; - -llms.post( '/students', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}/delete.js b/spec/code_samples/Node.js/students@{id}/delete.js deleted file mode 100644 index 89e114e5..00000000 --- a/spec/code_samples/Node.js/students@{id}/delete.js +++ /dev/null @@ -1,17 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "reassign": 456 -}; - -llms.delete( '/students/123', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}/get.js b/spec/code_samples/Node.js/students@{id}/get.js deleted file mode 100644 index c87e60f1..00000000 --- a/spec/code_samples/Node.js/students@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/students/123?context=edit', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}/post.js b/spec/code_samples/Node.js/students@{id}/post.js deleted file mode 100644 index 0782491b..00000000 --- a/spec/code_samples/Node.js/students@{id}/post.js +++ /dev/null @@ -1,35 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "email": "jamie@lifterlms.com", - "username": "jamie2019", - "password": "my_l337-p@$5w0rd!", - "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", - "registered_date": "2019-05-03 19:25:01", - "url": "https://myawesomewebsite.tld", - "first_name": "Jamie", - "last_name": "Cook", - "nickname": "JamieC", - "name": "Jamie Cook", - "billing_address_1": "1234 Somewhere Place", - "billing_address_2": "Suite ABC", - "billing_city": "Anywhere", - "billing_state": "CA", - "billing_postcode": "12345-678", - "billing_country": "US", - "roles": [ - "student" - ] -}; - -llms.post( '/students/123', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@enrollments/get.js b/spec/code_samples/Node.js/students@{id}@enrollments/get.js deleted file mode 100644 index 75f12a26..00000000 --- a/spec/code_samples/Node.js/students@{id}@enrollments/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/students/123/enrollments?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&status=SOME_STRING_VALUE&post=1%2C2%2C3', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/delete.js b/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/delete.js deleted file mode 100644 index 785455ec..00000000 --- a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/students/123/enrollments/456?trigger=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/get.js b/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/get.js deleted file mode 100644 index 7acc84b2..00000000 --- a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/students/123/enrollments/456', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/patch.js b/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/patch.js deleted file mode 100644 index 5c68a194..00000000 --- a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/patch.js +++ /dev/null @@ -1,18 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "date_created": "2019-05-21 14:22:05", - "status": "enrolled" -}; - -llms.patch( '/students/123/enrollments/456?trigger=SOME_STRING_VALUE', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/post.js b/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/post.js deleted file mode 100644 index ee7a5b0c..00000000 --- a/spec/code_samples/Node.js/students@{id}@enrollments@{post_id}/post.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.post( '/students/123/enrollments/456?trigger=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@progress@{post_id}/delete.js b/spec/code_samples/Node.js/students@{id}@progress@{post_id}/delete.js deleted file mode 100644 index 9d609a4a..00000000 --- a/spec/code_samples/Node.js/students@{id}@progress@{post_id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/students/123/progress/456', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@progress@{post_id}/get.js b/spec/code_samples/Node.js/students@{id}@progress@{post_id}/get.js deleted file mode 100644 index 310cbe2a..00000000 --- a/spec/code_samples/Node.js/students@{id}@progress@{post_id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/students/123/progress/456', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/students@{id}@progress@{post_id}/post.js b/spec/code_samples/Node.js/students@{id}@progress@{post_id}/post.js deleted file mode 100644 index f633974e..00000000 --- a/spec/code_samples/Node.js/students@{id}@progress@{post_id}/post.js +++ /dev/null @@ -1,18 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "date_created": "2019-05-21T14:22:05", - "status": "incomplete" -}; - -llms.post( '/students/123/progress/456', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/webhooks/get.js b/spec/code_samples/Node.js/webhooks/get.js deleted file mode 100644 index dc3c03b0..00000000 --- a/spec/code_samples/Node.js/webhooks/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/webhooks?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=SOME_STRING_VALUE', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/webhooks/post.js b/spec/code_samples/Node.js/webhooks/post.js deleted file mode 100644 index abb0da0c..00000000 --- a/spec/code_samples/Node.js/webhooks/post.js +++ /dev/null @@ -1,21 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "name": "A Student Enrolled in a Course", - "status": "disabled", - "topic": "student.created", - "delivery_url": "https://example.tld/webhook-receipt/endpoint", - "secret": "$P3CI41-$3CR37!" -}; - -llms.post( '/webhooks', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/webhooks@{id}/delete.js b/spec/code_samples/Node.js/webhooks@{id}/delete.js deleted file mode 100644 index 1c968b31..00000000 --- a/spec/code_samples/Node.js/webhooks@{id}/delete.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.delete( '/webhooks/%7Bid%7D', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/webhooks@{id}/get.js b/spec/code_samples/Node.js/webhooks@{id}/get.js deleted file mode 100644 index 085ad93c..00000000 --- a/spec/code_samples/Node.js/webhooks@{id}/get.js +++ /dev/null @@ -1,13 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -llms.get( '/webhooks/%7Bid%7D', function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/Node.js/webhooks@{id}/post.js b/spec/code_samples/Node.js/webhooks@{id}/post.js deleted file mode 100644 index 751389dd..00000000 --- a/spec/code_samples/Node.js/webhooks@{id}/post.js +++ /dev/null @@ -1,21 +0,0 @@ -const llmsAPI = require( "llms-api-node" ); -const llms = new llmsAPI( { - "url": "https://example.tld", - "consumerKey": "ck_XXXXXXXXXXXXXXXXXXXXXX", - "consumerSecret": "cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" -} ); - -const postData = { - "name": "A Student Enrolled in a Course", - "status": "disabled", - "topic": "student.created", - "delivery_url": "https://example.tld/webhook-receipt/endpoint", - "secret": "$P3CI41-$3CR37!" -}; - -llms.post( '/webhooks/%7Bid%7D', postData, function( err, data, res ) { - if ( err ) { - throw new Error( 'Error!' ); - } - console.log( data ); -} ); \ No newline at end of file diff --git a/spec/code_samples/cURL/access-plans/get.sh b/spec/code_samples/cURL/access-plans/get.sh deleted file mode 100644 index d8c2173e..00000000 --- a/spec/code_samples/cURL/access-plans/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/access-plans?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&post_id=123%2C456' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/access-plans/post.sh b/spec/code_samples/cURL/access-plans/post.sh deleted file mode 100644 index fbbdf44b..00000000 --- a/spec/code_samples/cURL/access-plans/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/access-plans \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"price":199.97,"sku":"LIFETIME-999-001","frequency":0,"length":0,"period":"year","enroll_text":"Buy Now","sale_enabled":false,"sale_price":99.97,"sale_date_start":"2019-01-23 00:00:00","sale_date_end":"2019-03-23 23:59:59","availability_restrictions":[123,456,789],"access_expiration":"lifetime","access_expires":"2019-03-23 23:59:59","access_length":1,"access_period":"year","trial_enabled":false,"trial_length":1,"trial_period":"week","trial_price":1.99,"post_id":789,"redirect_type":"self","redirect_page":1,"redirect_url":"https://example.tld/my/redirect","redirect_forced":false,"visibility":"visible","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"title":"Liftetime Access","content":"\\n
  • Expectoque quid ad id
  • quod quaerebam, respondeas
\\n"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/access-plans@{id}/delete.sh b/spec/code_samples/cURL/access-plans@{id}/delete.sh deleted file mode 100644 index ee961e48..00000000 --- a/spec/code_samples/cURL/access-plans@{id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/access-plans/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/access-plans@{id}/get.sh b/spec/code_samples/cURL/access-plans@{id}/get.sh deleted file mode 100644 index 25f54394..00000000 --- a/spec/code_samples/cURL/access-plans@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/access-plans/%7Bid%7D?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/access-plans@{id}/post.sh b/spec/code_samples/cURL/access-plans@{id}/post.sh deleted file mode 100644 index 4f37b86f..00000000 --- a/spec/code_samples/cURL/access-plans@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/access-plans/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"price":199.97,"sku":"LIFETIME-999-001","frequency":0,"length":0,"period":"year","enroll_text":"Buy Now","sale_enabled":false,"sale_price":99.97,"sale_date_start":"2019-01-23 00:00:00","sale_date_end":"2019-03-23 23:59:59","availability_restrictions":[123,456,789],"access_expiration":"lifetime","access_expires":"2019-03-23 23:59:59","access_length":1,"access_period":"year","trial_enabled":false,"trial_length":1,"trial_period":"week","trial_price":1.99,"post_id":789,"redirect_type":"self","redirect_page":1,"redirect_url":"https://example.tld/my/redirect","redirect_forced":false,"visibility":"visible","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"title":"Liftetime Access","content":"\\n
  • Expectoque quid ad id
  • quod quaerebam, respondeas
\\n"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/api-keys/get.sh b/spec/code_samples/cURL/api-keys/get.sh deleted file mode 100644 index 5d3de34d..00000000 --- a/spec/code_samples/cURL/api-keys/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/api-keys?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&user=123%2C456&user_not_in=123%2C456&permissions=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/api-keys/post.sh b/spec/code_samples/cURL/api-keys/post.sh deleted file mode 100644 index db5dbf31..00000000 --- a/spec/code_samples/cURL/api-keys/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/api-keys \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"user_id":456,"description":"My API Key","permissions":"read"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/api-keys@{id}/delete.sh b/spec/code_samples/cURL/api-keys@{id}/delete.sh deleted file mode 100644 index 892e197a..00000000 --- a/spec/code_samples/cURL/api-keys@{id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/api-keys/987 \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/api-keys@{id}/get.sh b/spec/code_samples/cURL/api-keys@{id}/get.sh deleted file mode 100644 index 0d15a680..00000000 --- a/spec/code_samples/cURL/api-keys@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/api-keys/987?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/api-keys@{id}/post.sh b/spec/code_samples/cURL/api-keys@{id}/post.sh deleted file mode 100644 index 0cef4163..00000000 --- a/spec/code_samples/cURL/api-keys@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/api-keys/987 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"user_id":456,"description":"My API Key","permissions":"read"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/courses/get.sh b/spec/code_samples/cURL/courses/get.sh deleted file mode 100644 index f594dde1..00000000 --- a/spec/code_samples/cURL/courses/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/courses?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=draft' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/courses/post.sh b/spec/code_samples/cURL/courses/post.sh deleted file mode 100644 index 06852f25..00000000 --- a/spec/code_samples/cURL/courses/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/courses \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","access_opens_message":"This course opens on [lifterlms_course_info key=\"start_date\"].","access_closes_message":"This course closed on [lifterlms_course_info key=\"end_date\"].","enrollment_opens_message":"Enrollment in this course opens on [lifterlms_course_info key=\"enrollment_start_date\"].","enrollment_closes_message":"Enrollment in this course closed on [lifterlms_course_info key=\"enrollment_end_date\"].","capacity_message":"Enrollment has closed because the maximum number of allowed students has been reached.","length":"7 days","restricted_message":"You must enroll in this course to access course content.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"getting-started-with-lifterlms","status":"publish","password":"p4$sW0rd","featured_media":987,"comment_status":"open","ping_status":"open","permalink":"https://example.com/course/getting-started-with-lifterlms","post_type":"course","catalog_visibility":"catalog_search","categories":[1,2,3],"tags":[4,5,6],"difficulties":[7],"tracks":[8,9],"audio_embed":"https://open.spotify.com/track/trackid","video_embed":"https://www.youtube.com/watch?v=videoid","capacity_enabled":false,"capacity_limit":25,"prerequisite":456,"prerequisite_track":789,"access_opens_date":"2019-05-20 17:22:05","access_closes_date":"2019-06-05 17:22:05","enrollment_opens_date":"2019-05-15 12:15:00","enrollment_closes_date":"2019-10-01 23:59:59","video_tile":false,"instructors":[1,2,3],"sales_page_type":"none","sales_page_page_id":543,"sales_page_url":"https://example.tld/custom-sales-page"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/courses@{id}/delete.sh b/spec/code_samples/cURL/courses@{id}/delete.sh deleted file mode 100644 index a367262f..00000000 --- a/spec/code_samples/cURL/courses@{id}/delete.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/courses/123 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"force":false}' \ No newline at end of file diff --git a/spec/code_samples/cURL/courses@{id}/get.sh b/spec/code_samples/cURL/courses@{id}/get.sh deleted file mode 100644 index 3544c230..00000000 --- a/spec/code_samples/cURL/courses@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/courses/123?context=edit&password=p4%24sW0rd' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/courses@{id}/post.sh b/spec/code_samples/cURL/courses@{id}/post.sh deleted file mode 100644 index 08537fdb..00000000 --- a/spec/code_samples/cURL/courses@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/courses/123 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","access_opens_message":"This course opens on [lifterlms_course_info key=\"start_date\"].","access_closes_message":"This course closed on [lifterlms_course_info key=\"end_date\"].","enrollment_opens_message":"Enrollment in this course opens on [lifterlms_course_info key=\"enrollment_start_date\"].","enrollment_closes_message":"Enrollment in this course closed on [lifterlms_course_info key=\"enrollment_end_date\"].","capacity_message":"Enrollment has closed because the maximum number of allowed students has been reached.","length":"7 days","restricted_message":"You must enroll in this course to access course content.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"getting-started-with-lifterlms","status":"publish","password":"p4$sW0rd","featured_media":987,"comment_status":"open","ping_status":"open","permalink":"https://example.com/course/getting-started-with-lifterlms","post_type":"course","catalog_visibility":"catalog_search","categories":[1,2,3],"tags":[4,5,6],"difficulties":[7],"tracks":[8,9],"audio_embed":"https://open.spotify.com/track/trackid","video_embed":"https://www.youtube.com/watch?v=videoid","capacity_enabled":false,"capacity_limit":25,"prerequisite":456,"prerequisite_track":789,"access_opens_date":"2019-05-20 17:22:05","access_closes_date":"2019-06-05 17:22:05","enrollment_opens_date":"2019-05-15 12:15:00","enrollment_closes_date":"2019-10-01 23:59:59","video_tile":false,"instructors":[1,2,3],"sales_page_type":"none","sales_page_page_id":543,"sales_page_url":"https://example.tld/custom-sales-page"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/courses@{id}@content/get.sh b/spec/code_samples/cURL/courses@{id}@content/get.sh deleted file mode 100644 index 24e98f99..00000000 --- a/spec/code_samples/cURL/courses@{id}@content/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/courses/%7Bid%7D/content?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/courses@{id}@enrollments/get.sh b/spec/code_samples/cURL/courses@{id}@enrollments/get.sh deleted file mode 100644 index 2d118095..00000000 --- a/spec/code_samples/cURL/courses@{id}@enrollments/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/courses/%7Bid%7D/enrollments?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&status=SOME_STRING_VALUE&student=1%2C2%2C3' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups/get.sh b/spec/code_samples/cURL/groups/get.sh deleted file mode 100644 index 49b1ed60..00000000 --- a/spec/code_samples/cURL/groups/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/groups?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups/post.sh b/spec/code_samples/cURL/groups/post.sh deleted file mode 100644 index c2a330c5..00000000 --- a/spec/code_samples/cURL/groups/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/groups \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"team-codebox","post":1234,"visibility":"open","logo":1987,"banner":1897}' \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}/delete.sh b/spec/code_samples/cURL/groups@{id}/delete.sh deleted file mode 100644 index f613c83c..00000000 --- a/spec/code_samples/cURL/groups@{id}/delete.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/groups/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"force":false}' \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}/get.sh b/spec/code_samples/cURL/groups@{id}/get.sh deleted file mode 100644 index b4184214..00000000 --- a/spec/code_samples/cURL/groups@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/groups/%7Bid%7D?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}/post.sh b/spec/code_samples/cURL/groups@{id}/post.sh deleted file mode 100644 index 705e26f4..00000000 --- a/spec/code_samples/cURL/groups@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/groups/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"team-codebox","post":1234,"visibility":"open","logo":1987,"banner":1897}' \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@invitations/get.sh b/spec/code_samples/cURL/groups@{id}@invitations/get.sh deleted file mode 100644 index 2b5e1cff..00000000 --- a/spec/code_samples/cURL/groups@{id}@invitations/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/invitations?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&email=jeffrey%40fakewebsite.tld&role=leader%2Cadmin' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@invitations/post.sh b/spec/code_samples/cURL/groups@{id}@invitations/post.sh deleted file mode 100644 index e0d15157..00000000 --- a/spec/code_samples/cURL/groups@{id}@invitations/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/invitations \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"email":"stephen@example.net","role":"member"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/delete.sh b/spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/delete.sh deleted file mode 100644 index 41ac6ea4..00000000 --- a/spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/invitations/%7Binvitation_id%7D \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/get.sh b/spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/get.sh deleted file mode 100644 index 97f7a0d2..00000000 --- a/spec/code_samples/cURL/groups@{id}@invitations@{invitation_id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/invitations/%7Binvitation_id%7D?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@members/get.sh b/spec/code_samples/cURL/groups@{id}@members/get.sh deleted file mode 100644 index b491573f..00000000 --- a/spec/code_samples/cURL/groups@{id}@members/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/members?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&group_roles=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@members@{member_id}/delete.sh b/spec/code_samples/cURL/groups@{id}@members@{member_id}/delete.sh deleted file mode 100644 index 8266ed6d..00000000 --- a/spec/code_samples/cURL/groups@{id}@members@{member_id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url 'https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/members/%7Bmember_id%7D?trigger=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@members@{member_id}/get.sh b/spec/code_samples/cURL/groups@{id}@members@{member_id}/get.sh deleted file mode 100644 index 70e14e29..00000000 --- a/spec/code_samples/cURL/groups@{id}@members@{member_id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/members/%7Bmember_id%7D?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@members@{member_id}/post.sh b/spec/code_samples/cURL/groups@{id}@members@{member_id}/post.sh deleted file mode 100644 index 65a47d5f..00000000 --- a/spec/code_samples/cURL/groups@{id}@members@{member_id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/groups/%7Bid%7D/members/%7Bmember_id%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"group_role":"member"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@seats/get.sh b/spec/code_samples/cURL/groups@{id}@seats/get.sh deleted file mode 100644 index 98afd006..00000000 --- a/spec/code_samples/cURL/groups@{id}@seats/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url https://example.tld/wp-json/llms/v1/groups/123/seats \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/groups@{id}@seats/put.sh b/spec/code_samples/cURL/groups@{id}@seats/put.sh deleted file mode 100644 index e201e7d1..00000000 --- a/spec/code_samples/cURL/groups@{id}@seats/put.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request PUT \ - --url https://example.tld/wp-json/llms/v1/groups/123/seats \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"total":20}' \ No newline at end of file diff --git a/spec/code_samples/cURL/instructors/get.sh b/spec/code_samples/cURL/instructors/get.sh deleted file mode 100644 index b84fc6ac..00000000 --- a/spec/code_samples/cURL/instructors/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/instructors?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=jamie%40lifterlms.com&search_columns=email%2Cusername&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&post_in=1%2C2%2C3&post_not_in=4%2C5%2C6&roles=instructor%2Clms_manager' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/instructors/post.sh b/spec/code_samples/cURL/instructors/post.sh deleted file mode 100644 index 582990fe..00000000 --- a/spec/code_samples/cURL/instructors/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/instructors \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"email":"jamie@lifterlms.com","username":"jamie2019","password":"my_l337-p@$5w0rd!","description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.","registered_date":"2019-05-03 19:25:01","url":"https://myawesomewebsite.tld","first_name":"Jamie","last_name":"Cook","nickname":"JamieC","name":"Jamie Cook","billing_address_1":"1234 Somewhere Place","billing_address_2":"Suite ABC","billing_city":"Anywhere","billing_state":"CA","billing_postcode":"12345-678","billing_country":"US","roles":["instructor"]}' \ No newline at end of file diff --git a/spec/code_samples/cURL/instructors@{id}/delete.sh b/spec/code_samples/cURL/instructors@{id}/delete.sh deleted file mode 100644 index 9e75cfcc..00000000 --- a/spec/code_samples/cURL/instructors@{id}/delete.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/instructors/123 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"reassign":456}' \ No newline at end of file diff --git a/spec/code_samples/cURL/instructors@{id}/get.sh b/spec/code_samples/cURL/instructors@{id}/get.sh deleted file mode 100644 index 7036c3ad..00000000 --- a/spec/code_samples/cURL/instructors@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/instructors/123?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/instructors@{id}/post.sh b/spec/code_samples/cURL/instructors@{id}/post.sh deleted file mode 100644 index 0362af71..00000000 --- a/spec/code_samples/cURL/instructors@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/instructors/123 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"email":"jamie@lifterlms.com","username":"jamie2019","password":"my_l337-p@$5w0rd!","description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.","registered_date":"2019-05-03 19:25:01","url":"https://myawesomewebsite.tld","first_name":"Jamie","last_name":"Cook","nickname":"JamieC","name":"Jamie Cook","billing_address_1":"1234 Somewhere Place","billing_address_2":"Suite ABC","billing_city":"Anywhere","billing_state":"CA","billing_postcode":"12345-678","billing_country":"US","roles":["instructor"]}' \ No newline at end of file diff --git a/spec/code_samples/cURL/instructors@{id}@content/get.sh b/spec/code_samples/cURL/instructors@{id}@content/get.sh deleted file mode 100644 index ba126d8e..00000000 --- a/spec/code_samples/cURL/instructors@{id}@content/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/instructors/123/content?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&post=123%2C456&post_exclude=789%2C324&post_type=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/lessons/get.sh b/spec/code_samples/cURL/lessons/get.sh deleted file mode 100644 index 392b2f95..00000000 --- a/spec/code_samples/cURL/lessons/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/lessons?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=draft&parent=987' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/lessons/post.sh b/spec/code_samples/cURL/lessons/post.sh deleted file mode 100644 index a8b6d673..00000000 --- a/spec/code_samples/cURL/lessons/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/lessons \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"getting-started-with-lifterlms","status":"publish","password":"p4$sW0rd","featured_media":987,"comment_status":"open","ping_status":"open","permalink":"https://example.com/lesson/getting-started-with-lifterlms","post_type":"lesson","audio_embed":"https://open.spotify.com/track/trackid","video_embed":"https://www.youtube.com/watch?v=videoid","prerequisite":321,"public":false,"parent_id":987,"points":1,"order":1,"drip_method":"none","drip_days":1,"drip_date":"2019-12-12 23:23:59","quiz":{"enabled":true,"id":432,"progression":"complete"},"assignment":{"enabled":true,"id":876,"progression":"complete"}}' \ No newline at end of file diff --git a/spec/code_samples/cURL/lessons@{id}/delete.sh b/spec/code_samples/cURL/lessons@{id}/delete.sh deleted file mode 100644 index f1158691..00000000 --- a/spec/code_samples/cURL/lessons@{id}/delete.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/lessons/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"force":false}' \ No newline at end of file diff --git a/spec/code_samples/cURL/lessons@{id}/get.sh b/spec/code_samples/cURL/lessons@{id}/get.sh deleted file mode 100644 index 9e6b68a8..00000000 --- a/spec/code_samples/cURL/lessons@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/lessons/%7Bid%7D?context=edit&password=p4%24sW0rd' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/lessons@{id}/post.sh b/spec/code_samples/cURL/lessons@{id}/post.sh deleted file mode 100644 index 28fc09cf..00000000 --- a/spec/code_samples/cURL/lessons@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/lessons/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"getting-started-with-lifterlms","status":"publish","password":"p4$sW0rd","featured_media":987,"comment_status":"open","ping_status":"open","permalink":"https://example.com/lesson/getting-started-with-lifterlms","post_type":"lesson","audio_embed":"https://open.spotify.com/track/trackid","video_embed":"https://www.youtube.com/watch?v=videoid","prerequisite":321,"public":false,"parent_id":987,"points":1,"order":1,"drip_method":"none","drip_days":1,"drip_date":"2019-12-12 23:23:59","quiz":{"enabled":true,"id":432,"progression":"complete"},"assignment":{"enabled":true,"id":876,"progression":"complete"}}' \ No newline at end of file diff --git a/spec/code_samples/cURL/memberships/get.sh b/spec/code_samples/cURL/memberships/get.sh deleted file mode 100644 index 0ef1f55d..00000000 --- a/spec/code_samples/cURL/memberships/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/memberships?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=draft' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/memberships/post.sh b/spec/code_samples/cURL/memberships/post.sh deleted file mode 100644 index 6a93b75c..00000000 --- a/spec/code_samples/cURL/memberships/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/memberships \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","restriction_message":"You must belong to the [lifterlms_membership_link id=\"1234\"] membership to access this content.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"getting-started-with-lifterlms","status":"publish","password":"p4$sW0rd","featured_media":987,"comment_status":"open","ping_status":"open","permalink":"https://example.com/membership/getting-started-with-lifterlms","post_type":"llms_membership","categories":[1,2,3],"tags":[4,5,6],"restriction_action":"none","restriction_page_id":456,"restriction_url":"https://example.tld/my-custom-url","auto_enroll":[456,789],"catalog_visibility":"catalog_search","instructors":[1,2,3],"sales_page_type":"none","sales_page_page_id":543,"sales_page_url":"https://example.tld/custom-sales-page"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/memberships@{id}/delete.sh b/spec/code_samples/cURL/memberships@{id}/delete.sh deleted file mode 100644 index 013c0845..00000000 --- a/spec/code_samples/cURL/memberships@{id}/delete.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/memberships/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"force":false}' \ No newline at end of file diff --git a/spec/code_samples/cURL/memberships@{id}/get.sh b/spec/code_samples/cURL/memberships@{id}/get.sh deleted file mode 100644 index 58715b2b..00000000 --- a/spec/code_samples/cURL/memberships@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/memberships/%7Bid%7D?context=edit&password=p4%24sW0rd' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/memberships@{id}/post.sh b/spec/code_samples/cURL/memberships@{id}/post.sh deleted file mode 100644 index 94428cf4..00000000 --- a/spec/code_samples/cURL/memberships@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/memberships/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","content":"\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n","excerpt":"Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.","restriction_message":"You must belong to the [lifterlms_membership_link id=\"1234\"] membership to access this content.","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","menu_order":0,"slug":"getting-started-with-lifterlms","status":"publish","password":"p4$sW0rd","featured_media":987,"comment_status":"open","ping_status":"open","permalink":"https://example.com/membership/getting-started-with-lifterlms","post_type":"llms_membership","categories":[1,2,3],"tags":[4,5,6],"restriction_action":"none","restriction_page_id":456,"restriction_url":"https://example.tld/my-custom-url","auto_enroll":[456,789],"catalog_visibility":"catalog_search","instructors":[1,2,3],"sales_page_type":"none","sales_page_page_id":543,"sales_page_url":"https://example.tld/custom-sales-page"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/memberships@{id}@enrollments/get.sh b/spec/code_samples/cURL/memberships@{id}@enrollments/get.sh deleted file mode 100644 index fa1c4d81..00000000 --- a/spec/code_samples/cURL/memberships@{id}@enrollments/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/memberships/%7Bid%7D/enrollments?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&status=SOME_STRING_VALUE&student=1%2C2%2C3' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/quiz-questions/get.sh b/spec/code_samples/cURL/quiz-questions/get.sh deleted file mode 100644 index 421ce202..00000000 --- a/spec/code_samples/cURL/quiz-questions/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/quiz-questions?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&quiz=789' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/quiz-questions/post.sh b/spec/code_samples/cURL/quiz-questions/post.sh deleted file mode 100644 index d22b01dc..00000000 --- a/spec/code_samples/cURL/quiz-questions/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/quiz-questions \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","order":1,"parent_id":234,"points":10,"video_embed":"https://www.youtube.com/watch?v=videoid","featured_media":205,"question_type":"choice","choices":[{"marker":"A","choice":"Red","correct":false},{"marker":"B","choice":"Green","correct":true}],"multi_choices":false,"title":"What is your favorite color?","content":"

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

","answer_clarification":"

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/quiz-questions@{id}/delete.sh b/spec/code_samples/cURL/quiz-questions@{id}/delete.sh deleted file mode 100644 index df183dd2..00000000 --- a/spec/code_samples/cURL/quiz-questions@{id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/quiz-questions/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/quiz-questions@{id}/get.sh b/spec/code_samples/cURL/quiz-questions@{id}/get.sh deleted file mode 100644 index 3dd58127..00000000 --- a/spec/code_samples/cURL/quiz-questions@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/quiz-questions/%7Bid%7D?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/quiz-questions@{id}/post.sh b/spec/code_samples/cURL/quiz-questions@{id}/post.sh deleted file mode 100644 index 8de2993a..00000000 --- a/spec/code_samples/cURL/quiz-questions@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/quiz-questions/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","order":1,"parent_id":234,"points":10,"video_embed":"https://www.youtube.com/watch?v=videoid","featured_media":205,"question_type":"choice","choices":[{"marker":"A","choice":"Red","correct":false},{"marker":"B","choice":"Green","correct":true}],"multi_choices":false,"title":"What is your favorite color?","content":"

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

","answer_clarification":"

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/quizzes/get.sh b/spec/code_samples/cURL/quizzes/get.sh deleted file mode 100644 index 7842ea8d..00000000 --- a/spec/code_samples/cURL/quizzes/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/quizzes?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=term&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&parent=789&course=1234&status=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/quizzes/post.sh b/spec/code_samples/cURL/quizzes/post.sh deleted file mode 100644 index 8f643a53..00000000 --- a/spec/code_samples/cURL/quizzes/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/quizzes \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","slug":"final-exam","status":"draft","attempt_limiting":true,"attempts_allowed":1,"time_limiting":true,"time_limit":90,"passing_percentage":65,"show_correct_answer":false,"randomize_questions":false,"parent_id":789,"title":"Final Exam","content":"

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/quizzes@{id}/delete.sh b/spec/code_samples/cURL/quizzes@{id}/delete.sh deleted file mode 100644 index 479d1ad3..00000000 --- a/spec/code_samples/cURL/quizzes@{id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/quizzes/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/quizzes@{id}/get.sh b/spec/code_samples/cURL/quizzes@{id}/get.sh deleted file mode 100644 index 0483169f..00000000 --- a/spec/code_samples/cURL/quizzes@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/quizzes/%7Bid%7D?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/quizzes@{id}/post.sh b/spec/code_samples/cURL/quizzes@{id}/post.sh deleted file mode 100644 index 952058f2..00000000 --- a/spec/code_samples/cURL/quizzes@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/quizzes/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","slug":"final-exam","status":"draft","attempt_limiting":true,"attempts_allowed":1,"time_limiting":true,"time_limit":90,"passing_percentage":65,"show_correct_answer":false,"randomize_questions":false,"parent_id":789,"title":"Final Exam","content":"

Lorem ipsum dolor sit amet.

\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/sections/get.sh b/spec/code_samples/cURL/sections/get.sh deleted file mode 100644 index 2fb30338..00000000 --- a/spec/code_samples/cURL/sections/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/sections?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&parent=1234' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/sections/post.sh b/spec/code_samples/cURL/sections/post.sh deleted file mode 100644 index 0b1dd505..00000000 --- a/spec/code_samples/cURL/sections/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/sections \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","order":1,"parent_id":1234}' \ No newline at end of file diff --git a/spec/code_samples/cURL/sections@{id}/delete.sh b/spec/code_samples/cURL/sections@{id}/delete.sh deleted file mode 100644 index 435e79ca..00000000 --- a/spec/code_samples/cURL/sections@{id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/sections/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/sections@{id}/get.sh b/spec/code_samples/cURL/sections@{id}/get.sh deleted file mode 100644 index c296f358..00000000 --- a/spec/code_samples/cURL/sections@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/sections/%7Bid%7D?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/sections@{id}/post.sh b/spec/code_samples/cURL/sections@{id}/post.sh deleted file mode 100644 index bc07b44a..00000000 --- a/spec/code_samples/cURL/sections@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/sections/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"title":"Getting Started with LifterLMS","date_created":"2019-05-20 17:22:05","date_created_gmt":"2019-05-20 13:22:05","order":1,"parent_id":1234}' \ No newline at end of file diff --git a/spec/code_samples/cURL/sections@{id}@content/get.sh b/spec/code_samples/cURL/sections@{id}@content/get.sh deleted file mode 100644 index edab06a8..00000000 --- a/spec/code_samples/cURL/sections@{id}@content/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/sections/%7Bid%7D/content?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&parent=987' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students/get.sh b/spec/code_samples/cURL/students/get.sh deleted file mode 100644 index b6cf5d80..00000000 --- a/spec/code_samples/cURL/students/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/students?context=edit&page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&search=jamie%40lifterlms.com&search_columns=email%2Cusername&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&enrolled_in=1%2C2%2C3&enrolled_not_in=4%2C5%2C6&roles=student%2Ccustomer' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students/post.sh b/spec/code_samples/cURL/students/post.sh deleted file mode 100644 index c773011c..00000000 --- a/spec/code_samples/cURL/students/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/students \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"email":"jamie@lifterlms.com","username":"jamie2019","password":"my_l337-p@$5w0rd!","description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.","registered_date":"2019-05-03 19:25:01","url":"https://myawesomewebsite.tld","first_name":"Jamie","last_name":"Cook","nickname":"JamieC","name":"Jamie Cook","billing_address_1":"1234 Somewhere Place","billing_address_2":"Suite ABC","billing_city":"Anywhere","billing_state":"CA","billing_postcode":"12345-678","billing_country":"US","roles":["student"]}' \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}/delete.sh b/spec/code_samples/cURL/students@{id}/delete.sh deleted file mode 100644 index 70d2d2b7..00000000 --- a/spec/code_samples/cURL/students@{id}/delete.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/students/123 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"reassign":456}' \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}/get.sh b/spec/code_samples/cURL/students@{id}/get.sh deleted file mode 100644 index e84a1851..00000000 --- a/spec/code_samples/cURL/students@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/students/123?context=edit' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}/post.sh b/spec/code_samples/cURL/students@{id}/post.sh deleted file mode 100644 index 25eadc27..00000000 --- a/spec/code_samples/cURL/students@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/students/123 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"email":"jamie@lifterlms.com","username":"jamie2019","password":"my_l337-p@$5w0rd!","description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit.","registered_date":"2019-05-03 19:25:01","url":"https://myawesomewebsite.tld","first_name":"Jamie","last_name":"Cook","nickname":"JamieC","name":"Jamie Cook","billing_address_1":"1234 Somewhere Place","billing_address_2":"Suite ABC","billing_city":"Anywhere","billing_state":"CA","billing_postcode":"12345-678","billing_country":"US","roles":["student"]}' \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@enrollments/get.sh b/spec/code_samples/cURL/students@{id}@enrollments/get.sh deleted file mode 100644 index a4c0436e..00000000 --- a/spec/code_samples/cURL/students@{id}@enrollments/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/students/123/enrollments?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&status=SOME_STRING_VALUE&post=1%2C2%2C3' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/delete.sh b/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/delete.sh deleted file mode 100644 index d43530c1..00000000 --- a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url 'https://example.tld/wp-json/llms/v1/students/123/enrollments/456?trigger=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/get.sh b/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/get.sh deleted file mode 100644 index 2560565c..00000000 --- a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url https://example.tld/wp-json/llms/v1/students/123/enrollments/456 \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/patch.sh b/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/patch.sh deleted file mode 100644 index 905b3e25..00000000 --- a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/patch.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request PATCH \ - --url 'https://example.tld/wp-json/llms/v1/students/123/enrollments/456?trigger=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"date_created":"2019-05-21 14:22:05","status":"enrolled"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/post.sh b/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/post.sh deleted file mode 100644 index 323ec169..00000000 --- a/spec/code_samples/cURL/students@{id}@enrollments@{post_id}/post.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request POST \ - --url 'https://example.tld/wp-json/llms/v1/students/123/enrollments/456?trigger=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@progress@{post_id}/delete.sh b/spec/code_samples/cURL/students@{id}@progress@{post_id}/delete.sh deleted file mode 100644 index c76563ec..00000000 --- a/spec/code_samples/cURL/students@{id}@progress@{post_id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/students/123/progress/456 \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@progress@{post_id}/get.sh b/spec/code_samples/cURL/students@{id}@progress@{post_id}/get.sh deleted file mode 100644 index b75f9c78..00000000 --- a/spec/code_samples/cURL/students@{id}@progress@{post_id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url https://example.tld/wp-json/llms/v1/students/123/progress/456 \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/students@{id}@progress@{post_id}/post.sh b/spec/code_samples/cURL/students@{id}@progress@{post_id}/post.sh deleted file mode 100644 index c05dcd6e..00000000 --- a/spec/code_samples/cURL/students@{id}@progress@{post_id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/students/123/progress/456 \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"date_created":"2019-05-21T14:22:05","status":"incomplete"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/webhooks/get.sh b/spec/code_samples/cURL/webhooks/get.sh deleted file mode 100644 index acca278d..00000000 --- a/spec/code_samples/cURL/webhooks/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url 'https://example.tld/wp-json/llms/v1/webhooks?page=1&per_page=SOME_INTEGER_VALUE&order=SOME_STRING_VALUE&orderby=SOME_STRING_VALUE&include=1%2C2%2C3&exclude=10%2C11%2C12&status=SOME_STRING_VALUE' \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/webhooks/post.sh b/spec/code_samples/cURL/webhooks/post.sh deleted file mode 100644 index 1a6135a7..00000000 --- a/spec/code_samples/cURL/webhooks/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/webhooks \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"name":"A Student Enrolled in a Course","status":"disabled","topic":"student.created","delivery_url":"https://example.tld/webhook-receipt/endpoint","secret":"$P3CI41-$3CR37!"}' \ No newline at end of file diff --git a/spec/code_samples/cURL/webhooks@{id}/delete.sh b/spec/code_samples/cURL/webhooks@{id}/delete.sh deleted file mode 100644 index 27d8a7d4..00000000 --- a/spec/code_samples/cURL/webhooks@{id}/delete.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request DELETE \ - --url https://example.tld/wp-json/llms/v1/webhooks/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/webhooks@{id}/get.sh b/spec/code_samples/cURL/webhooks@{id}/get.sh deleted file mode 100644 index 9ecfcd4c..00000000 --- a/spec/code_samples/cURL/webhooks@{id}/get.sh +++ /dev/null @@ -1,3 +0,0 @@ -curl --request GET \ - --url https://example.tld/wp-json/llms/v1/webhooks/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ No newline at end of file diff --git a/spec/code_samples/cURL/webhooks@{id}/post.sh b/spec/code_samples/cURL/webhooks@{id}/post.sh deleted file mode 100644 index 1eca74f9..00000000 --- a/spec/code_samples/cURL/webhooks@{id}/post.sh +++ /dev/null @@ -1,5 +0,0 @@ -curl --request POST \ - --url https://example.tld/wp-json/llms/v1/webhooks/%7Bid%7D \ - --user ck_XXXXXX:cs_XXXXXX \ - --header 'content-type: application/json' \ - --data '{"name":"A Student Enrolled in a Course","status":"disabled","topic":"student.created","delivery_url":"https://example.tld/webhook-receipt/endpoint","secret":"$P3CI41-$3CR37!"}' \ No newline at end of file diff --git a/spec/components/README.md b/spec/components/README.md deleted file mode 100644 index 7a2c6f8d..00000000 --- a/spec/components/README.md +++ /dev/null @@ -1,14 +0,0 @@ -Reusable components -=========== - -* You can create the following folders here: - - `schemas` - reusable [Schema Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject) - - `responses` - reusable [Response Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#responseObject) - - `parameters` - reusable [Parameter Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#parameterObject) - - `examples` - reusable [Example Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#exampleObject) - - `headers` - reusable [Header Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#headerObject) - - `requestBodies` - reusable [Request Body Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#requestBodyObject) - - `links` - reusable [Link Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#linkObject) - - `callbacks` - reusable [Callback Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#callbackObject) - - `securitySchemes` - reusable [Security Scheme Objects](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#securitySchemeObject) -* Filename of files inside the folders represent component name, i.e. `Customer.yaml` diff --git a/spec/components/headers/PaginationTotalPages.yaml b/spec/components/headers/PaginationTotalPages.yaml deleted file mode 100644 index ff6de2ce..00000000 --- a/spec/components/headers/PaginationTotalPages.yaml +++ /dev/null @@ -1,4 +0,0 @@ -description: Total number of pages available in the collection. -schema: - type: integer - example: 28 diff --git a/spec/components/headers/PaginationTotalResults.yaml b/spec/components/headers/PaginationTotalResults.yaml deleted file mode 100644 index e55c4368..00000000 --- a/spec/components/headers/PaginationTotalResults.yaml +++ /dev/null @@ -1,4 +0,0 @@ -description: Total number of results found in the collection. -schema: - type: integer - example: 275 diff --git a/spec/components/parameters/Context.yaml b/spec/components/parameters/Context.yaml deleted file mode 100644 index 6bf8d903..00000000 --- a/spec/components/parameters/Context.yaml +++ /dev/null @@ -1,11 +0,0 @@ -name: context -in: query -description: Specify the scope under which the request is made. `edit` should be used when requesting content to be modified; `view` should be used when requesting content to be displayed. -required: false -schema: - type: string - enum: - - view - - edit - default: view - example: edit diff --git a/spec/components/parameters/EnrollmentStatus.yaml b/spec/components/parameters/EnrollmentStatus.yaml deleted file mode 100644 index c5dbf064..00000000 --- a/spec/components/parameters/EnrollmentStatus.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: enrollment_status -in: query -description: Limit results by enrollment status. -required: false -schema: - $ref: '#/components/schemas/EnrollmentStatus' diff --git a/spec/components/parameters/EnrollmentTrigger.yaml b/spec/components/parameters/EnrollmentTrigger.yaml deleted file mode 100644 index bef5d189..00000000 --- a/spec/components/parameters/EnrollmentTrigger.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: trigger -in: query -description: The trigger of the enrollment to act on. -required: false -schema: - type: string - default: any diff --git a/spec/components/parameters/Exclude.yaml b/spec/components/parameters/Exclude.yaml deleted file mode 100644 index b93b2720..00000000 --- a/spec/components/parameters/Exclude.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: exclude -in: query -description: Exclude a list of `id`s from results. Accepts a single `id` or a comma separated list of `id`s. -schema: - type: string - example: [10,11,12] diff --git a/spec/components/parameters/Include.yaml b/spec/components/parameters/Include.yaml deleted file mode 100644 index 3804ae70..00000000 --- a/spec/components/parameters/Include.yaml +++ /dev/null @@ -1,6 +0,0 @@ -name: include -in: query -description: Limit results to a list of `id`s. Accepts a single `id` or a comma separated list of `id`s. -schema: - type: string - example: [1,2,3] diff --git a/spec/components/parameters/Order.yaml b/spec/components/parameters/Order.yaml deleted file mode 100644 index 106d770e..00000000 --- a/spec/components/parameters/Order.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: order -in: query -description: Specifcy the sort order for a collection of results. -required: false -schema: - type: string - enum: - - asc - - desc - default: asc diff --git a/spec/components/parameters/Page.yaml b/spec/components/parameters/Page.yaml deleted file mode 100644 index 03068748..00000000 --- a/spec/components/parameters/Page.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: page -in: query -description: Specify the page number for a paginated collection. -required: false -schema: - type: integer - minimum: 1 - default: 1 - example: 1 diff --git a/spec/components/parameters/PerPage.yaml b/spec/components/parameters/PerPage.yaml deleted file mode 100644 index 3719e512..00000000 --- a/spec/components/parameters/PerPage.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: per_page -in: query -description: Specify the number of results per paginated collection page. -required: false -schema: - type: integer - minimum: 1 - default: 10 diff --git a/spec/components/parameters/PostPassword.yaml b/spec/components/parameters/PostPassword.yaml deleted file mode 100644 index 39fd62ad..00000000 --- a/spec/components/parameters/PostPassword.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: password -in: query -description: Post password. Required if the post is password protected. -required: false -schema: - type: string - example: p4$sW0rd diff --git a/spec/components/parameters/PostStatus.yaml b/spec/components/parameters/PostStatus.yaml deleted file mode 100644 index ebca97bd..00000000 --- a/spec/components/parameters/PostStatus.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: status -in: query -description: Limit result set to posts assigned one or more statuses. -required: false -schema: - type: string - enum: - - publish - - pending - - draft - - auto-draft - - future - - private - - trash - default: publish - example: draft diff --git a/spec/components/parameters/PostType.yaml b/spec/components/parameters/PostType.yaml deleted file mode 100644 index 17380a8d..00000000 --- a/spec/components/parameters/PostType.yaml +++ /dev/null @@ -1,14 +0,0 @@ -name: post_type -in: query -description: Filter results to those of a specific `post_type`. -required: false -schema: - type: string - enum: - - course - - lesson - - llms_membership - - llms_question - - llms_quiz - - section - default: course diff --git a/spec/components/parameters/Search.yaml b/spec/components/parameters/Search.yaml deleted file mode 100644 index 68a9d874..00000000 --- a/spec/components/parameters/Search.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: search -in: query -description: Filter results to those matching the specified search string. -required: false -schema: - type: string - example: term diff --git a/spec/components/parameters/SearchColumns.yaml b/spec/components/parameters/SearchColumns.yaml deleted file mode 100644 index 300a43b9..00000000 --- a/spec/components/parameters/SearchColumns.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: search_columns -description: | - Column names to be searched. Accepts a single column name or a comma separated list of column names. - - All columns can be searched when `context=edit`, when `context=view` only `id` and `name` may be specified. - - When the `search` parameter is specified, the default `search_columns` defaults to all of the columns available for the given `context`. -in: query -required: false -schema: - type: string - example: [email,username] - enum: - - id - - email - - name - - url - - username diff --git a/spec/components/parameters/SearchUsers.yaml b/spec/components/parameters/SearchUsers.yaml deleted file mode 100644 index fe9944e1..00000000 --- a/spec/components/parameters/SearchUsers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: search -in: query -description: Filter results to those matching the specified search string. -required: false -schema: - type: string - example: jamie@lifterlms.com diff --git a/spec/components/responses/Error400.yaml b/spec/components/responses/Error400.yaml deleted file mode 100644 index ab711c5d..00000000 --- a/spec/components/responses/Error400.yaml +++ /dev/null @@ -1,6 +0,0 @@ -x-summary: Bad request. -description: Invalid or malformed request syntax. -content: - application/json: - schema: - $ref: '#/components/schemas/Error400' diff --git a/spec/components/responses/Error401.yaml b/spec/components/responses/Error401.yaml deleted file mode 100644 index 8ed29fba..00000000 --- a/spec/components/responses/Error401.yaml +++ /dev/null @@ -1,6 +0,0 @@ -x-summary: Unauthorized. -description: Invalid API Credentials. -content: - application/json: - schema: - $ref: '#/components/schemas/Error401' diff --git a/spec/components/responses/Error403.yaml b/spec/components/responses/Error403.yaml deleted file mode 100644 index 62facc84..00000000 --- a/spec/components/responses/Error403.yaml +++ /dev/null @@ -1,6 +0,0 @@ -x-summary: Forbidden. -description: The client does not have access to perform the requested action. -content: - application/json: - schema: - $ref: '#/components/schemas/Error403' diff --git a/spec/components/responses/Error404.yaml b/spec/components/responses/Error404.yaml deleted file mode 100644 index 3e9d4822..00000000 --- a/spec/components/responses/Error404.yaml +++ /dev/null @@ -1,6 +0,0 @@ -x-summary: Not Found. -description: The requested resource could not be located. -content: - application/json: - schema: - $ref: '#/components/schemas/Error404' diff --git a/spec/components/schemas/APIKey.yaml b/spec/components/schemas/APIKey.yaml deleted file mode 100644 index 8cb0f51f..00000000 --- a/spec/components/schemas/APIKey.yaml +++ /dev/null @@ -1,65 +0,0 @@ -type: object -properties: - id: - allOf: - - description: Unique API Key Identifier. - - $ref: '#/components/schemas/ResourceId' - user_id: - description: The WordPress User ID of the API Key's owner. - type: integer - minimum: 1 - example: 456 - description: - description: A friendly, human-readable name description of the key. - type: string - example: My API Key - permissions: - description: Determines the key's permissions and capabilities. - type: string - enum: - - read - - write - - read_write - truncated_key: - description: The last 7 characters of the Consumer Key. - type: string - example: 61913f3 - readOnly: true - last_access: - description: 'The date the key was last used. Format: `Y-m-d H:i:s`' - type: string - example: '2019-05-21 19:22:05' - readOnly: true - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the API key. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/api-keys/123 - collection: - description: REST URI to the API key collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/api-keys - user: - description: REST URI to the API key's owner. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/wp/v2/users/456 - diff --git a/spec/components/schemas/AccessPlan.yaml b/spec/components/schemas/AccessPlan.yaml deleted file mode 100644 index 69158852..00000000 --- a/spec/components/schemas/AccessPlan.yaml +++ /dev/null @@ -1,199 +0,0 @@ -allOf: - - type: object - properties: - id: - readOnly: true - description: Unique Access Plan Identifier. The WordPress Post `ID`. - price: - description: Access plan price. - type: number - format: float - minimum: 0 - example: 199.97 - sku: - description: External identifier. - type: string - example: LIFETIME-999-001 - frequency: - description: >- - Billing frequency.
- `0` denotes a one-time payment.
- `>= 1` denotes a recurring plan. - type: integer - minimum: 0 - maximum: 6 - default: 0 - length: - description: >- - For recurring plans only.
- Determines the number of intervals a plan should run for.
- `0` denotes the plan should run until cancelled. - type: integer - minimum: 0 - default: 0 - period: - description: >- - For recurring plans only.
- Determines the interval of recurring payments. - type: string - enum: - - year - - month - - week - - day - default: year - enroll_text: - description: Text of the "Purchase" button - type: string - default: Buy Now - sale_enabled: - description: Mark the plan as "On Sale" allowing for temporary price adjustments. - type: boolean - default: false - sale_price: - description: Sale price.
- Only applies when `sale_enabled` is `true`. - type: number - format: float - minimum: 0 - example: 99.97 - sale_date_start: - description: >- - Used to automatically start a scheduled sale. If empty, the plan is on sale immediately.
- Only applies when `sale_enabled` is `true`. - Format: `Y-m-d H:i:s`. - type: string - example: '2019-01-23 00:00:00' - sale_date_end: - description: >- - Used to automatically end a scheduled sale. If empty, the plan remains on sale indefinitely.
- Only applies when `sale_enabled` is `true`. - Format: `Y-m-d H:i:s`. - type: string - example: '2019-03-23 23:59:59' - availability_restrictions: - description: >- - Restrict usage of this access plan to students enrolled in at least one of the specified memberships.
- Applicable only when `post_id` refers to a Course. - type: array - minimum: 1 - example: [ 123, 456, 789 ] - items: - type: integer - access_expiration: - description: >- - Access expiration type.
- `lifetime` provides access until cancelled or until a recurring payment fails.
- `limited-period` provides access for a limited period as specified by `access_length` and `access_period`
- `limited-date` provides access until the date specified by `access_expires_date` - type: string - enum: - - lifetime - - limited-period - - limited-date - default: lifetime - access_expires: - description: >- - Date when access expires.
- Only applicable when `access_expiration` is `limited-date`. - Format: `Y-m-d H:i:s`. - type: string - example: '2019-03-23 23:59:59' - access_length: - description: >- - Determine the length of access from time of purchase.
- Only applicable when `access_expiration` is `limited-period`. - type: integer - minimum: 1 - default: 1 - access_period: - description: >- - Determine the length of access from time of purchase.
- Only applicable when `access_expiration` is `limited-period`. - type: string - enum: - - year - - month - - week - - day - default: year - trial_enabled: - description: Enable a trial period for a recurring access plan. - type: boolean - default: false - trial_length: - description: >- - Determines the length of trial access.
- Only applicable when `trial_enabled` is `true`. - type: integer - minimum: 1 - default: 1 - trial_period: - description: >- - Determines the length of trial access.
- Only applicable when `trial_enabled` is `true`. - type: string - enum: - - year - - month - - week - - day - default: week - trial_price: - description: >- - Determines the price of the trial period.
- Only applicable when `trial_enabled` is `true`. - type: number - format: float - minimum: 0 - default: 0 - example: 1.99 - permalink: - description: Access Plan URL. - type: string - example: https://example.com/checkout/?plan=123 - readOnly: true - post_id: - description: Determines the course or membership which can be accessed through the plan. - type: integer - minimum: 1 - example: 789 - post_type: - $ref: '#/components/schemas/PostType' - default: llms_access_plan - type: string - redirect_type: - description: >- - Determines the redirection behavior of the user's browser upon successful checkout or registration through the plan.
- `self`: Redirect to the permalink of the specified `post_id`. - `page`: Redirect to the permalink of the WordPress page specified by `redirect_page_id`. - `url`: Redirect to the URL specified by `redirect_url`. - type: string - enum: - - self - - page - - url - default: self - redirect_page: - description: WordPress page ID to use for checkout success redirection.
Applicable only when `redirect_type` is `page`. - type: integer - minimum: 1 - redirect_url: - description: URL to use for checkout success redirection.
Applicable only when `redirect_type` is `url`. - type: string - example: https://example.tld/my/redirect - redirect_forced: - description: >- - Use this plans's redirect settings when purchasing a Membership this plan is restricted to.
- Applicable only when `availability_restrictions` exist for the plan. - type: boolean - default: false - visibility: - description: Access plan visibility. - type: string - enum: - - visible - - hidden - - featured - default: visible - - $ref: '#/components/schemas/Post' diff --git a/spec/components/schemas/AccessPlanRequest.yaml b/spec/components/schemas/AccessPlanRequest.yaml deleted file mode 100644 index c79ea76a..00000000 --- a/spec/components/schemas/AccessPlanRequest.yaml +++ /dev/null @@ -1,12 +0,0 @@ -allOf: - - $ref: '#/components/schemas/AccessPlan' - - type: object - properties: - title: - type: string - description: Access plan name. - example: Liftetime Access - content: - type: string - description: Access plan short description. - example: \n
  • Expectoque quid ad id
  • quod quaerebam, respondeas
\n diff --git a/spec/components/schemas/AccessPlanResponse.yaml b/spec/components/schemas/AccessPlanResponse.yaml deleted file mode 100644 index 1bf89f90..00000000 --- a/spec/components/schemas/AccessPlanResponse.yaml +++ /dev/null @@ -1,71 +0,0 @@ -required: - - price -allOf: - - $ref: '#/components/schemas/AccessPlan' - - type: object - properties: - title: - description: Access plan name. - type: object - properties: - rendered: - type: string - description: Rendered title. - example: Liftetime Access - raw: - type: string - description: Raw title. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example: Liftetime Access - content: - description: Access plan short description. - type: object - properties: - rendered: - type: string - description: Rendered description. - example: \n
  • Expectoque quid ad id
  • quod quaerebam, respondeas
\n - raw: - type: string - description: Raw description. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example: \n
  • Expectoque quid ad id
  • quod quaerebam, respondeas
\n - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the access plan. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/access-plans/123 - collection: - description: REST URI to the access plan collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/access-plans - post: - description: REST URI to the access plan's related course or membership. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses/789 - restrictions: - description: REST URIs to the memberships required to use the access plan. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/memberships?include=123,456,789 diff --git a/spec/components/schemas/Address.yaml b/spec/components/schemas/Address.yaml deleted file mode 100644 index ba794bfe..00000000 --- a/spec/components/schemas/Address.yaml +++ /dev/null @@ -1,26 +0,0 @@ -type: object -properties: - address_1: - description: Address line 1. - type: string - example: 1234 Somewhere Place - address_2: - description: Address line 2. - type: string - example: Suite ABC - city: - description: City name. - type: string - example: Anywhere - state: - description: 'ISO code or state, province, or district name.' - type: string - example: CA - postcode: - description: Postal code. - type: string - example: 12345-678 - country: - description: ISO country code. - type: string - example: US diff --git a/spec/components/schemas/Course.yaml b/spec/components/schemas/Course.yaml deleted file mode 100644 index 19e16d3a..00000000 --- a/spec/components/schemas/Course.yaml +++ /dev/null @@ -1,108 +0,0 @@ -allOf: - - type: object - properties: - id: - readOnly: true - description: Unique Course Identifier. The WordPress Post `ID`. - - $ref: '#/components/schemas/PostPublic' - - type: object - properties: - permalink: - example: https://example.com/course/getting-started-with-lifterlms - post_type: - default: course - type: string - catalog_visibility: - description: Visibility of the course in catalogs and search results. - type: string - categories: - description: List of course categories. - type: array - items: - type: integer - tags: - description: List of course tags. - type: array - items: - type: integer - difficulties: - description: List of course difficulties. - type: array - default: [] - example: [ 7 ] - items: - type: integer - tracks: - description: List of course tracks. - type: array - default: [] - example: [ 8, 9 ] - items: - type: integer - audio_embed: - description: URL to an oEmbed enable audio URL. - type: string - example: https://open.spotify.com/track/trackid - video_embed: - description: URL to an oEmbed enable video URL. - type: string - example: https://www.youtube.com/watch?v=videoid - capacity_enabled: - description: Determines if an enrollment capacity limit is enabled. - type: boolean - default: false - capacity_limit: - description: Number of students who can be enrolled in the course before enrollment closes. - minimum: 0 - type: integer - example: 25 - prerequisite: - description: Course ID of the prerequisite course. - type: integer - example: 456 - prerequisite_track: - description: Term ID of a the prerequisite track. - type: integer - example: 789 - access_opens_date: - description: >- - Date when the course opens, allowing enrolled students to begin to view and interact with the restricted course content.
- If blank the course is open until after the `access_closes_date` has passed.
- Does not affect course enrollment, see `enrollment_opens_date` to control the course enrollment start date.
- Format: `Y-m-d H:i:s`. - type: string - nullable: true - example: '2019-05-20 17:22:05' - access_closes_date: - description: >- - Date when the course closes. After this date enrolled students may no longer view and interact with the restricted course content.
- If blank the course is open indefinitely after the the `access_opens_date` has passed.
- Does not affect course enrollment, see `enrollment_opens_date` to control the course enrollment close date.
- Format: `Y-m-d H:i:s`. - type: string - nullable: true - example: '2019-06-05 17:22:05' - enrollment_opens_date: - description: >- - Date when the course enrollment opens.
- If blank course enrollment is open until after the `enrollment_closes_date` has passed.
- Does not affect course content access, see `access_opens_date` to control course access start date.
- Format: `Y-m-d H:i:s`. - type: string - nullable: true - example: '2019-05-15 12:15:00' - enrollment_closes_date: - description: >- - Date when the course enrollment closes.
- If blank course enrollment is open indefinitely after the the `enrollment_opens_date` has passed.
- Does not affect course content access, see `access_opens_date` to control course access close date.
- Format: `Y-m-d H:i:s`. - type: string - nullable: true - example: '2019-10-01 23:59:59' - video_tile: - description: When `true` the `video_embed` will be used on the course tiles (on the catalog, for example) instead of the featured image. - type: boolean - default: false - - - $ref: '#/components/schemas/SharedCourseMembership' diff --git a/spec/components/schemas/CourseRequest.yaml b/spec/components/schemas/CourseRequest.yaml deleted file mode 100644 index 6c9a01ed..00000000 --- a/spec/components/schemas/CourseRequest.yaml +++ /dev/null @@ -1,33 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentRequest' - - type: object - properties: - access_opens_message: - description: Message displayed to enrolled students when the course is accessed before the `access_opens_date` has passed. - type: string - default: This course opens on [lifterlms_course_info key="start_date"]. - access_closes_message: - description: Message displayed to enrolled students when the course is accessed after the `access_closes_date` has passed. - type: string - default: This course closed on [lifterlms_course_info key="end_date"]. - enrollment_opens_message: - description: Message displayed to visitors when attempting to enroll into a course before the `enrollment_opens_date` has passed. - type: string - default: Enrollment in this course opens on [lifterlms_course_info key="enrollment_start_date"]. - enrollment_closes_message: - description: Message displayed to visitors when attempting to enroll into a course after the `enrollment_closes_date` has passed. - type: string - default: Enrollment in this course closed on [lifterlms_course_info key="enrollment_end_date"]. - capacity_message: - description: Message displayed when enrollment capacity has been reached. - type: string - default: Enrollment has closed because the maximum number of allowed students has been reached. - length: - description: User defined course length. - type: string - example: 7 days - restricted_message: - description: Message displayed when non-enrolled visitors try to access restricted course content (lessons, quizzes, etc..) directly. - type: string - default: You must enroll in this course to access course content. - - $ref: '#/components/schemas/Course' diff --git a/spec/components/schemas/CourseResponse.yaml b/spec/components/schemas/CourseResponse.yaml deleted file mode 100644 index 61ca9343..00000000 --- a/spec/components/schemas/CourseResponse.yaml +++ /dev/null @@ -1,216 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentResponse' - - type: object - properties: - access_opens_message: - description: Message displayed to enrolled students when the course is accessed before the `access_opens_date` has passed. - type: object - properties: - rendered: - description: Rendered message content. - type: string - default: This course opens on January, 28, 2019. - raw: - description: Raw message content. - type: string - default: This course opens on [lifterlms_course_info key="start_date"]. - access_closes_message: - description: Message displayed to enrolled students when the course is accessed after the `access_closes_date` has passed. - type: object - properties: - rendered: - description: Rendered message content. - type: string - default: This course closed on March 5, 2018. - raw: - description: Raw message content. - type: string - default: This course closed on [lifterlms_course_info key="end_date"]. - enrollment_opens_message: - description: Message displayed to visitors when attempting to enroll into a course before the `enrollment_opens_date` has passed. - type: object - properties: - rendered: - description: Rendered message content. - type: string - default: Enrollment in this course opens on opens on January, 28, 2019. - raw: - description: Raw message content. - type: string - default: Enrollment in this course opens on [lifterlms_course_info key="enrollment_start_date"]. - enrollment_closes_message: - description: Message displayed to visitors when attempting to enroll into a course after the `enrollment_closes_date` has passed. - type: object - properties: - rendered: - description: Rendered message content. - type: string - default: Enrollment in this course closed on March 5, 2018. - raw: - description: Raw message content. - type: string - default: Enrollment in this course closed on [lifterlms_course_info key="enrollment_end_date"]. - capacity_message: - description: Message displayed when enrollment capacity has been reached. - type: object - properties: - rendered: - description: Rendered message content. - type: string - example: Enrollment has closed because the maximum number of allowed students has been reached. - raw: - description: Raw message content. - type: string - example: Enrollment has closed because the maximum number of allowed students has been reached. - length: - description: User defined course length. - type: object - properties: - rendered: - description: Rendered length description. - type: string - example: 7 days - raw: - description: Raw length description. - type: string - example: 7 days - restricted_message: - description: Message displayed when non-enrolled visitors try to access restricted course content (lessons, quizzes, etc..) directly. - type: object - properties: - rendered: - description: Rendered message content. - type: string - default: You must enroll in this course to access course content. - raw: - description: Raw message content. - type: string - default: You must enroll in this course to access course content. - - $ref: '#/components/schemas/Course' - - type: object - properties: - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the course. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses/1234 - collection: - description: REST URI to the course collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses - access_plans: - description: REST URI to the collection of access plans for the course. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/access-plans?post_id=1234 - content: - description: REST URI to the course's content collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses/1234/content - enrollments: - description: REST URI to the collection of the courses's enrollments. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses/1234/enrollments - instructors: - description: REST URI to the collection of the course's instructors. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/instructors?post=1234 - prerequisites: - description: REST URIs to course prerequisite resources. - type: array - example: [ - { - "type": "course", - "href": "/wp-json/llms/v1/courses/456" - }, - { - "type": "track", - "href": "/wp-json/wp/v2/course_track/789" - } - ] - items: - type: object - properties: - type: - type: string - href: - type: string - students: - description: REST URI to the collection of the course's enrolled students. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students?enrolled_in=1234 - wp:featured_media: - description: REST URI to the WordPress attachement image. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/wp/v2/media/987 - wp:term: - description: Collection of REST URIs to the course's taxonomy term information. - type: array - example: [ - { - "taxonomy": "course_cat", - "href": "/wp-json/wp/v2/course_cat?post=1234" - }, - { - "taxonomy": "course_tag", - "href": "/wp-json/wp/v2/course_tag?post=1234" - }, - { - "taxonomy": "course_difficulty", - "href": "/wp-json/wp/v2/course_difficulty?post=1234" - }, - { - "taxonomy": "course_track", - "href": "/wp-json/wp/v2/course_track?post=1234" - } - ] - items: - type: object - properties: - taxonomy: - type: string - href: - type: string diff --git a/spec/components/schemas/Enrollment.yaml b/spec/components/schemas/Enrollment.yaml deleted file mode 100644 index 632bd4e2..00000000 --- a/spec/components/schemas/Enrollment.yaml +++ /dev/null @@ -1,76 +0,0 @@ -type: object -properties: - student_id: - description: The ID of the student. - type: integer - minimum: 1 - example: 123 - readOnly: true - post_id: - description: The ID of the course/membership. - type: integer - minimum: 1 - example: 456 - readOnly: true - date_created: - description: 'The enrollment creation date. Format: `Y-m-d H:i:s`' - type: string - example: '2019-05-21 14:22:05' - date_updated: - description: 'The date of the last enrollment update. Format: `Y-m-d H:i:s`' - type: string - example: '2019-05-21 19:22:05' - readOnly: true - status: - $ref: '#/components/schemas/EnrollmentStatus' - trigger: - description: 'The enrollment trigger.' - type: string - readOnly: true - _links: - description: A map of links to other related API resources. - readOnly: true - type: object - properties: - self: - description: REST URI to the enrollment. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/123/enrollments/456 - collection: - description: REST URI to the enrollments collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/123/enrollments - post: - description: Rest URI to the post resource. - type: array - items: - type: object - properties: - type: - type: string - enum: - - course - - membership - example: course - href: - type: string - example: /wp-json/llms/v1/courses/456 - student: - description: Rest URI to the student resource. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/123 diff --git a/spec/components/schemas/EnrollmentStatus.yaml b/spec/components/schemas/EnrollmentStatus.yaml deleted file mode 100644 index b15505f4..00000000 --- a/spec/components/schemas/EnrollmentStatus.yaml +++ /dev/null @@ -1,6 +0,0 @@ -description: The status of the enrollment. -type: string -enum: - - enrolled - - expired - - cancelled diff --git a/spec/components/schemas/Error.yaml b/spec/components/schemas/Error.yaml deleted file mode 100644 index e2ed46d3..00000000 --- a/spec/components/schemas/Error.yaml +++ /dev/null @@ -1,14 +0,0 @@ -type: object -properties: - code: - description: The API error code. - message: - description: The API error message. - data: - description: Additional response data. - type: object - properties: - status: - minimum: 100 - maximum: 600 - description: The HTTP status code. diff --git a/spec/components/schemas/Error400.yaml b/spec/components/schemas/Error400.yaml deleted file mode 100644 index 1ccf8eb4..00000000 --- a/spec/components/schemas/Error400.yaml +++ /dev/null @@ -1,14 +0,0 @@ -allOf: - - $ref: '#/components/schemas/Error' - - properties: - code: - default: llms_rest_bad_request - type: string - message: - default: Invalid or malformed request syntax. - type: string - data: - properties: - status: - default: 400 - type: integer diff --git a/spec/components/schemas/Error401.yaml b/spec/components/schemas/Error401.yaml deleted file mode 100644 index cc687914..00000000 --- a/spec/components/schemas/Error401.yaml +++ /dev/null @@ -1,14 +0,0 @@ -allOf: - - $ref: '#/components/schemas/Error' - - properties: - code: - default: llms_rest_unauthorized_request - type: string - message: - default: The API credentials were invalid. - type: string - data: - properties: - status: - default: 401 - type: integer diff --git a/spec/components/schemas/Error403.yaml b/spec/components/schemas/Error403.yaml deleted file mode 100644 index d2cfcb98..00000000 --- a/spec/components/schemas/Error403.yaml +++ /dev/null @@ -1,14 +0,0 @@ -allOf: - - $ref: '#/components/schemas/Error' - - properties: - code: - default: llms_rest_forbidden_request - type: string - message: - default: You are not authorized to perform this request. - type: string - data: - properties: - status: - default: 403 - type: integer diff --git a/spec/components/schemas/Error404.yaml b/spec/components/schemas/Error404.yaml deleted file mode 100644 index 257d4644..00000000 --- a/spec/components/schemas/Error404.yaml +++ /dev/null @@ -1,14 +0,0 @@ -allOf: - - $ref: '#/components/schemas/Error' - - properties: - code: - default: llms_rest_not_found - type: string - message: - default: The requested resource could not be found. - type: string - data: - properties: - status: - default: 404 - type: integer diff --git a/spec/components/schemas/Group.yaml b/spec/components/schemas/Group.yaml deleted file mode 100644 index b40813e3..00000000 --- a/spec/components/schemas/Group.yaml +++ /dev/null @@ -1,40 +0,0 @@ -allOf: - - type: object - properties: - id: - description: Unique group identifier. The WordPress Post `ID`. - readOnly: true - - $ref: '#/components/schemas/Post' - - type: object - properties: - id: - readOnly: true - example: 1987 - slug: - description: Group URL slug. - type: string - example: team-codebox - permalink: - description: Post URL. - type: string - example: https://example.com/group/team-codebox - readOnly: true - post_type: - default: llms_group - type: string - readOnly: true - post: - description: WordPress post ID of the course or membership accessible by the group. - type: integer - minimum: 1 - example: 1234 - visibility: - description: | - Visibility of the group profile. - - The available options and the default value are dependent of the site's global settings. For example, if the site's group visibility option is "closed" than no groups on the site can be set to anything other than "closed". The default value will always equal the site's global setting. - type: string - enum: - - open - - private - - closed diff --git a/spec/components/schemas/GroupInvitation.yaml b/spec/components/schemas/GroupInvitation.yaml deleted file mode 100644 index 8840891d..00000000 --- a/spec/components/schemas/GroupInvitation.yaml +++ /dev/null @@ -1,61 +0,0 @@ -type: object -properties: - id: - allOf: - - description: Unique Invitation Identifier. - - $ref: '#/components/schemas/ResourceId' - accept_link: - description: URL used to accept the invitation. - type: string - readOnly: true - example: https://example.com/dashboard?invite=eb5d96fa7cfa7eb0469511c142c6de2f - email: - description: | - Email address of the invited group member. - - If no email address is supplied, an open invitation link will be created. Only one such record - may exist for the group. An attempt to create a new one when one already exists will result in - a `400 Bad Request` Error response. - type: string - example: stephen@example.net - default: "" - role: - description: Group member role. - type: string - default: member - enum: - - member - - leader - - admin - _links: - description: A map of links to other related API resources. - readOnly: true - type: object - properties: - self: - description: REST URI to the group invitation. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123/invitations/456 - collection: - description: REST URI to the collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123/invitations - group: - description: Rest URI to the group resource. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123 diff --git a/spec/components/schemas/GroupMember.yaml b/spec/components/schemas/GroupMember.yaml deleted file mode 100644 index 055f95fa..00000000 --- a/spec/components/schemas/GroupMember.yaml +++ /dev/null @@ -1,96 +0,0 @@ -description: Group Member User Object -type: object -properties: - id: - allOf: - - $ref: '#/components/schemas/ResourceId' - - description: Unique Member Identifer. The WordPress User `ID`. - example: 789 - email: - description: | - The user's email address. - - Only returned when `context=edit`. - type: string - example: jamie@lifterlms.com - readOnly: true - avatar_urls: - description: | - A list of the Gravatars available for the user. - - The object key is the size (in pixels) of the avatar and the value is the Gravatar's URL. - type: object - readOnly: true - properties: - 24: - type: string - example: https://secure.gravatar.com/avatar/30eab7b16342fe5f772ed30a36da2763?s=24&d=mm&r=g - 48: - type: string - example: https://secure.gravatar.com/avatar/30eab7b16342fe5f772ed30a36da2763?s=48&d=mm&r=g - 96: - type: string - example: https://secure.gravatar.com/avatar/30eab7b16342fe5f772ed30a36da2763?s=48&d=mm&r=g - nickname: - description: | - The user's chosen nickname. - - Only returned when `context=edit`. - type: string - example: JamieC - readOnly: true - name: - description: The user's public display name. - type: string - example: Jamie Cook - readOnly: true - group_role: - description: The user's role within the group. - type: string - enum: - - member - - leader - - admin - - primary_admin - default: member - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the member. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123/members/789 - collection: - description: REST URI to the group members collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123/members - group: - description: Rest URI to the group resource. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123 - student: - description: REST URI to the student. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/789 diff --git a/spec/components/schemas/GroupRequest.yaml b/spec/components/schemas/GroupRequest.yaml deleted file mode 100644 index 30ddde94..00000000 --- a/spec/components/schemas/GroupRequest.yaml +++ /dev/null @@ -1,15 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentRequest' - - $ref: '#/components/schemas/Group' - - type: object - properties: - logo: - description: WordPress post ID of the attachment post for the group's logo image. - type: integer - example: 1987 - minimum: 0 - banner: - description: WordPress post ID of the attachment post for the group's banner image. - type: integer - example: 1897 - minimum: 0 diff --git a/spec/components/schemas/GroupResponse.yaml b/spec/components/schemas/GroupResponse.yaml deleted file mode 100644 index b8764fe2..00000000 --- a/spec/components/schemas/GroupResponse.yaml +++ /dev/null @@ -1,110 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentResponse' - - $ref: '#/components/schemas/Group' - - type: object - properties: - logo: - description: Group logo image. - type: object - properties: - id: - description: WordPress post ID of the attachment post. - example: 1987 - minimum: 0 - source_url: - description: Full URL to the attachment file. If no `logo.id` is set, `logo.source_url` will default to the sitewide group logo image url. - example: https://example.com/wp-content/uploads/2020/01/team-codebox-logo.jpg - banner: - description: Group banner image. - type: object - properties: - id: - description: WordPress post ID of the attachment post. - example: 1897 - minimum: 0 - source_url: - description: Full URL to the attachment file. If no `banner.id` is set, `banner.source_url` will default to the sitewide group banner image url. - example: https://example.com/wp-content/uploads/2020/01/team-codebox-banner.jpg - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the course. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/1234 - collection: - description: REST URI to the course collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups - post: - description: Rest URI to the post resource. - type: array - items: - type: object - properties: - type: - type: string - enum: - - course - - membership - example: course - href: - type: string - example: /wp-json/llms/v1/courses/456 - enrollments: - description: REST URI to the collection of the groups's enrollments. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/1234/enrollments - instructors: - description: REST URI to the collection of the course's instructors. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/instructors?post=1234 - students: - description: REST URI to the collection of the course's enrolled students. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students?enrolled_in=1234 - logo: - description: REST URI to the WordPress attachement. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/wp/v2/media/1987 - banner: - description: REST URI to the WordPress attachement. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/wp/v2/media/1897 diff --git a/spec/components/schemas/GroupSeat.yaml b/spec/components/schemas/GroupSeat.yaml deleted file mode 100644 index fe85697d..00000000 --- a/spec/components/schemas/GroupSeat.yaml +++ /dev/null @@ -1,51 +0,0 @@ -type: object -properties: - total: - description: | - Number of available seats. - - During a `PUT` request, must be >= `used`. - type: integer - minimum: 1 - example: 20 - used: - description: | - Number of used seats. - - This value is calculated by adding the number of group current members to the number of open invitations. - type: integer - minimum: 1 - example: 5 - readOnly: true - open: - description: | - Number of remaining seats. - - This value is calculated by subtracting the `used` property from the `total` property. - type: integer - minimum: 0 - example: 15 - readOnly: true - _links: - description: A map of links to other related API resources. - readOnly: true - type: object - properties: - self: - description: REST URI to the group seats resource. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123/seats - group: - description: Rest URI to the group resource. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/groups/123 diff --git a/spec/components/schemas/Instructor.yaml b/spec/components/schemas/Instructor.yaml deleted file mode 100644 index 6e708217..00000000 --- a/spec/components/schemas/Instructor.yaml +++ /dev/null @@ -1,55 +0,0 @@ -allOf: - - type: object - properties: - id: - description: Unique Instructor Identifer. The WordPress User `ID`. - readOnly: true - - $ref: '#/components/schemas/User' - - type: object - properties: - roles: - description: | - The user's WordPress user role. - - Only returned when `context=edit`. - type: array - default: [ instructor ] - items: - type: string - enum: - - administrator - - lms_manager - - instructor - - instructors_assistant - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the instructor. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/instructors/1234 - collection: - description: REST URI to the instructor collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/instructors - content: - description: REST URI to a collection of the instructor's content. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/instructors/1234/contents diff --git a/spec/components/schemas/Lesson.yaml b/spec/components/schemas/Lesson.yaml deleted file mode 100644 index ffec7664..00000000 --- a/spec/components/schemas/Lesson.yaml +++ /dev/null @@ -1,137 +0,0 @@ -allOf: - - type: object - properties: - id: - description: Unique lesson identifier. The WordPress Post `ID`. - readOnly: true - - $ref: '#/components/schemas/PostPublic' - - type: object - properties: - id: - readOnly: true - example: 789 - permalink: - example: https://example.com/lesson/getting-started-with-lifterlms - post_type: - default: lesson - type: string - audio_embed: - description: URL to an oEmbed enable audio URL. - type: string - example: https://open.spotify.com/track/trackid - video_embed: - description: URL to an oEmbed enable video URL. - type: string - example: https://www.youtube.com/watch?v=videoid - prerequisite: - description: Lesson ID of the prerequisite lesson. - type: integer - example: 321 - public: - description: Denotes a lesson that's publicly accessible regardless of course enrollment. - type: boolean - default: false - course_id: - description: WordPress post ID of the lesson's parent course. - type: integer - minimum: 1 - example: 1234 - readOnly: true - parent_id: - description: WordPress post ID of the parent item.
Must be a Section ID. `0` indicates an "orphaned" lesson which can be edited and viewed by instructors and admins but cannot be read by students. - type: integer - minimum: 0 - example: 987 - points: - description: Determines the weight of the lesson when grading the course. - type: integer - minimum: 0 - default: 1 - order: - description: Order of the lesson within its immediate parent. - type: integer - default: 1 - minimum: 1 - drip_method: - description: | - Determine the method with which to make the lesson content available. - - - `none`: Drip is disabled; the lesson is immediately available. - - `date`: Lesson is made available at a specific date and time. - - `enrollment`: Lesson is made available a specific number of days after enrollment into the course. - - `start`: Lesson is made available a specific number of days after the course's start date. Only available on courses with a `access_opens_date`. - - `prerequisite`: Lesson is made available a specific number of days after the `prerequisite` lesson is completed. - type: string - enum: - - none - - date - - enrollment - - start - - prerequisite - default: none - drip_days: - description: Number of days to wait before allowing access to the lesson. Applicable only when `drip_method` is `enrollment`, `start`, or `prerequisite`. - type: integer - minimum: 1 - default: 1 - drip_date: - description: 'The date and time when the lesson becomes available. Applicable only when `drip_method` is `date`. Format: `Y-m-d H:i:s`.' - type: string - nullable: true - example: '2019-12-12 23:23:59' - quiz: - description: Associate a quiz with this lesson. - type: object - properties: - enabled: - description: Determines if a quiz is enabled for the lesson. - type: boolean - default: false - example: true - id: - description: The post ID of the associated quiz. - type: integer - minimum: 0 - default: 0 - example: 432 - progression: - description: | - Determines lesson progression requirements related to the quiz. - - - `complete`: The quiz must be completed (with any grade) to progress the lesson. - - `pass`: A passing grade must be earned to progress the lesson. - type: string - enum: - - complete - - pass - default: complete - assignment: - description: | - Associate an assignment with this lesson. - - _While assignment functionality is included with the LifterLMS Core REST API, the assignments themselves are implemented by the LifterLMS Assignments add-on._ - type: object - properties: - enabled: - description: Determines if an assignment is enabled for the lesson. - type: boolean - default: false - example: true - id: - description: The post ID of the associated assingment. - type: integer - minimum: 0 - default: 0 - example: 876 - progression: - description: | - Determines lesson progression requirements related to the assignment. - - - `complete`: The assignment must be completed (with any grade) to progress the lesson. - - `pass`: A passing grade must be earned to progress the lesson. - type: string - enum: - - complete - - pass - default: complete - diff --git a/spec/components/schemas/LessonRequest.yaml b/spec/components/schemas/LessonRequest.yaml deleted file mode 100644 index d2cc5328..00000000 --- a/spec/components/schemas/LessonRequest.yaml +++ /dev/null @@ -1,3 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentRequest' - - $ref: '#/components/schemas/Lesson' diff --git a/spec/components/schemas/LessonResponse.yaml b/spec/components/schemas/LessonResponse.yaml deleted file mode 100644 index f185ac3d..00000000 --- a/spec/components/schemas/LessonResponse.yaml +++ /dev/null @@ -1,115 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentResponse' - - $ref: '#/components/schemas/Lesson' - - type: object - properties: - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the lesson. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/lessons/1234 - collection: - description: REST URI to the lesson collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/lessons - assignment: - description: REST URI to the lesson's assignment. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/assignments/876 - course: - description: REST URI to the lesson's parent course. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses/1234 - next: - description: REST URI to the next sibling lesson in the section. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/lessons/4567 - prerequisite: - description: REST URIs to lesson prerequisite resources. - type: array - items: - type: object - properties: - type: - type: string - example: lesson - href: - type: string - example: /wp-json/llms/v1/lessons/321 - previous: - description: REST URI to the previous sibling lesson in the section. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/lessons/8910 - parent: - description: REST URI to the lessons's parent. - type: array - items: - type: object - properties: - type: - type: string - example: section - href: - type: string - example: /wp-json/llms/v1/sections/987 - quiz: - description: REST URI to the lesson's quiz. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/quizzes/432 - siblings: - description: REST URI to the collection of the lessons's siblings within its parent. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/lessons?parent=987 - wp:featured_media: - description: REST URI to the WordPress attachement image. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/wp/v2/media/987 diff --git a/spec/components/schemas/Membership.yaml b/spec/components/schemas/Membership.yaml deleted file mode 100644 index 0825b849..00000000 --- a/spec/components/schemas/Membership.yaml +++ /dev/null @@ -1,55 +0,0 @@ -allOf: - - type: object - properties: - id: - readOnly: true - description: Unique membership identifier. The WordPress Post `ID`. - - $ref: '#/components/schemas/PostPublic' - - type: object - properties: - permalink: - example: https://example.com/membership/getting-started-with-lifterlms - post_type: - default: llms_membership - type: string - categories: - description: List of membership categories. - type: array - items: - type: integer - tags: - description: List of membership tags. - type: array - items: - type: integer - restriction_action: - description: | - Determines the action to take when content restricted by the membership is accessed by a non-member.
- `none`: Remain on page and display the message `restriction_message`. - `membership`: Redirect to the membership's permalink. - `page`: Redirect to the permalink of the page identified by `restriction_page_id`. - `custom`: Redirect to the URL identified by `restriction_url`. - type: string - enum: - - none - - membership - - page - - custom - default: none - restriction_page_id: - description: WordPress page ID used for redirecting non-members when `restriction_action` is `page`. - type: integer - minimum: 1 - example: 456 - restriction_url: - description: URL used for redirecting non-members when `restriction_action` is `custom`. - type: string - example: https://example.tld/my-custom-url - auto_enroll: - description: List of courses to automatically enroll students into when they're enrolled into the membership. - type: array - default: [] - example: [ 456, 789 ] - items: - type: integer - - $ref: '#/components/schemas/SharedCourseMembership' diff --git a/spec/components/schemas/MembershipRequest.yaml b/spec/components/schemas/MembershipRequest.yaml deleted file mode 100644 index 4c5b6224..00000000 --- a/spec/components/schemas/MembershipRequest.yaml +++ /dev/null @@ -1,33 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentRequest' - - type: object - properties: - restriction_message: - description: Message to display to non-members after a `restriction_action` redirect. When `restriction_action` is `none` replaces the page content with this message. - type: string - default: You must belong to the [lifterlms_membership_link id="1234"] membership to access this content. - # access_closes_message: - # description: Message displayed to enrolled students when the course is accessed after the `access_closes_date` has passed. - # type: string - # default: This course closed on [lifterlms_course_info key="end_date"]. - # enrollment_opens_message: - # description: Message displayed to visitors when attempting to enroll into a course before the `enrollment_opens_date` has passed. - # type: string - # default: Enrollment in this course opens on [lifterlms_course_info key="enrollment_start_date"]. - # enrollment_closes_message: - # description: Message displayed to visitors when attempting to enroll into a course after the `enrollment_closes_date` has passed. - # type: string - # default: Enrollment in this course closed on [lifterlms_course_info key="enrollment_end_date"]. - # capacity_message: - # description: Message displayed when enrollment capacity has been reached. - # type: string - # default: Enrollment has closed because the maximum number of allowed students has been reached. - # length: - # description: User defined course length. - # type: string - # example: 7 days - # restricted_message: - # description: Message displayed when non-enrolled visitors try to access restricted course content (lessons, quizzes, etc..) directly. - # type: string - # default: You must enroll in this course to access course content. - - $ref: '#/components/schemas/Membership' diff --git a/spec/components/schemas/MembershipResponse.yaml b/spec/components/schemas/MembershipResponse.yaml deleted file mode 100644 index 13f575eb..00000000 --- a/spec/components/schemas/MembershipResponse.yaml +++ /dev/null @@ -1,117 +0,0 @@ -allOf: - - $ref: '#/components/schemas/PostContentResponse' - - $ref: '#/components/schemas/Membership' - - type: object - properties: - restriction_message: - description: Message to display to non-members after a `restriction_action` redirect. When `restriction_action` is `none` replaces the page content with this message. - type: object - properties: - rendered: - description: Rendered message content. - type: string - default: You must belong to the Gold membership to access this content. - raw: - description: Raw message content. - type: string - default: You must belong to the [lifterlms_membership_link id="1234"] membership to access this content. - - type: object - properties: - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the membership. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/memberships/1234 - collection: - description: REST URI to the membership collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/memberships - access_plans: - description: REST URI to the collection of access plans for the membership. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/access-plans?post_id=1234 - auto_enrollment_courses: - description: REST URI to the collection of automatic enrollment courses for the membership. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses?include=456,789 - enrollments: - description: REST URI to the collection of the memberships's enrollments. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/enrollments?post=1234 - instructors: - description: REST URI to the collection of the membership's instructors. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/instructors?post=1234 - students: - description: REST URI to the collection of the membership's enrolled students. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students?enrolled_in=1234 - wp:featured_media: - description: REST URI to the WordPress attachement image. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/wp/v2/media/987 - wp:term: - description: Collection of REST URIs to the membership's taxonomy term information. - type: array - example: [ - { - "taxonomy": "membership_cat", - "href": "/wp-json/wp/v2/membership_cat?post=1234" - }, - { - "taxonomy": "membership_tag", - "href": "/wp-json/wp/v2/membership_tag?post=1234" - } - ] - items: - type: object - properties: - taxonomy: - type: string - href: - type: string - diff --git a/spec/components/schemas/Post.yaml b/spec/components/schemas/Post.yaml deleted file mode 100644 index 720a3b37..00000000 --- a/spec/components/schemas/Post.yaml +++ /dev/null @@ -1,32 +0,0 @@ -description: Reduced WordPress Post object properties shared by LifterLMS custom post types -type: object -required: - - id -properties: - id: - allOf: - - description: Unique Post Identifier. The WordPress Post `ID`. - - $ref: '#/components/schemas/ResourceId' - date_created: - description: 'Creation date. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:22:05' - date_created_gmt: - description: 'Creation date (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:22:05' - date_updated: - description: 'Date last modified. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:25:05' - readOnly: true - date_updated_gmt: - description: 'Date last modified (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:25:05' - readOnly: true - menu_order: - description: Custom post sort order. - type: integer - default: 0 - minimum: 0 diff --git a/spec/components/schemas/PostContentRequest.yaml b/spec/components/schemas/PostContentRequest.yaml deleted file mode 100644 index eaac5bc6..00000000 --- a/spec/components/schemas/PostContentRequest.yaml +++ /dev/null @@ -1,16 +0,0 @@ -description: Post content request fields. -type: object -properties: - title: - type: string - description: Raw title. - example: Getting Started with LifterLMS - content: - type: string - description: Raw post content. - example: \n

Lorem ipsum dolor sit amet.

\n\n\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\n - excerpt: - type: string - description: Raw excerpt content. - example: Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus. - diff --git a/spec/components/schemas/PostContentResponse.yaml b/spec/components/schemas/PostContentResponse.yaml deleted file mode 100644 index 1c892062..00000000 --- a/spec/components/schemas/PostContentResponse.yaml +++ /dev/null @@ -1,40 +0,0 @@ -description: Post content fields. -type: object -properties: - title: - description: Post title. - type: object - properties: - rendered: - type: string - description: Rendered title. - example: Getting Started with LifterLMS - raw: - type: string - description: Raw title. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example: Getting Started with LifterLMS - content: - description: Post content. - type: object - properties: - rendered: - type: string - description: Rendered post content. - example: \n

Lorem ipsum dolor sit amet.

\n\n\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\n - raw: - type: string - description: Raw post content. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example: \n

Lorem ipsum dolor sit amet.

\n\n\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\n - excerpt: - description: Post excerpt. - type: object - properties: - rendered: - type: string - description: Rendered HTML content. - example:

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

- raw: - type: string - description: Raw HTML content. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example: Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus. - diff --git a/spec/components/schemas/PostPublic.yaml b/spec/components/schemas/PostPublic.yaml deleted file mode 100644 index 8cd20767..00000000 --- a/spec/components/schemas/PostPublic.yaml +++ /dev/null @@ -1,40 +0,0 @@ -description: Reduced WordPress Post object properties shared by LifterLMS custom post types -allOf: - - $ref: '#/components/schemas/Post' - - type: object - properties: - slug: - description: Post URL slug. - type: string - example: getting-started-with-lifterlms - permalink: - description: Post URL. - type: string - example: https://example.com/post/getting-started-with-lifterlms - readOnly: true - post_type: - $ref: '#/components/schemas/PostType' - status: - $ref: '#/components/schemas/PostStatus' - password: - description: Password used to protect access to the content.
Readable only in `edit` context. - type: string - example: p4$sW0rd - featured_media: - description: Featured image ID. - type: integer - example: 987 - comment_status: - description: Post comment status. Default comment status dependent upon general WordPress post discussion settings. - type: string - enum: - - open - - closed - default: open - ping_status: - description: Post ping status. Default ping status dependent upon general WordPress post discussion settings. - type: string - enum: - - open - - closed - default: open diff --git a/spec/components/schemas/PostStatus.yaml b/spec/components/schemas/PostStatus.yaml deleted file mode 100644 index 9f1bc007..00000000 --- a/spec/components/schemas/PostStatus.yaml +++ /dev/null @@ -1,9 +0,0 @@ -description: The publication status of the course. -type: string -enum: - - publish - - pending - - draft - - future - - private -default: publish diff --git a/spec/components/schemas/PostType.yaml b/spec/components/schemas/PostType.yaml deleted file mode 100644 index 269a1f9f..00000000 --- a/spec/components/schemas/PostType.yaml +++ /dev/null @@ -1,3 +0,0 @@ -description: LifterLMS custom post type. -type: string -readOnly: true diff --git a/spec/components/schemas/Progress.yaml b/spec/components/schemas/Progress.yaml deleted file mode 100644 index 918abd71..00000000 --- a/spec/components/schemas/Progress.yaml +++ /dev/null @@ -1,82 +0,0 @@ -type: object -required: - - status -properties: - student_id: - description: The ID of the student. - type: integer - minimum: 1 - example: 123 - readOnly: true - post_id: - description: The ID of the course, section, or lesson. - type: integer - minimum: 1 - example: 456 - readOnly: true - date_created: - description: The progress creation date. Cannot be in the future. - type: string - format: date-time - example: '2019-05-21T14:22:05' - date_updated: - description: The date of the last progress update. - type: string - format: date-time - example: '2019-05-21T19:22:05' - readOnly: true - progress: - description: Student's progress as a percentage. - type: number - format: float - minimum: 0 - maximum: 100 - default: 0 - example: 89.83 - readOnly: true - status: - description: Student progress status. - type: string - enum: - - incomplete - - complete - default: incomplete - _links: - description: A map of links to other related API resources. - readOnly: true - type: object - properties: - self: - description: REST URI to the progress. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/123/progress/456 - post: - description: Rest URI to the post resource. - type: array - items: - type: object - properties: - type: - type: string - enum: - - course - - section - - lesson - example: course - href: - type: string - example: /wp-json/llms/v1/courses/456 - student: - description: Rest URI to the student resource. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/123 diff --git a/spec/components/schemas/Quiz.yaml b/spec/components/schemas/Quiz.yaml deleted file mode 100644 index 14f8d1a6..00000000 --- a/spec/components/schemas/Quiz.yaml +++ /dev/null @@ -1,102 +0,0 @@ -description: Base quiz post object. -type: object -properties: - id: - description: Unique quiz identifer. The WordPress Post `ID`. - type: integer - minimum: 234 - readOnly: true - date_created: - description: 'Creation date. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:22:05' - date_created_gmt: - description: 'Creation date (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:22:05' - date_updated: - description: 'Date last modified. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:25:05' - readOnly: true - date_updated_gmt: - description: 'Date last modified (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:25:05' - readOnly: true - slug: - description: Quiz URL slug. - type: string - example: final-exam - permalink: - description: Quiz URL. - type: string - example: https://example.tld/quiz/final-exam - readOnly: true - post_type: - allOf: - - $ref: '#/components/schemas/PostType' - type: string - default: llms_quiz - status: - description: The publication status of the quiz. - type: string - enum: - - publish - - draft - default: draft - attempt_limiting: - description: | - Determine if attempt limiting is enabled. - - When enabled, students are locked out after the number of attempts specified by `allowed_attempts`. - type: boolean - default: false - example: true - attempts_allowed: - description: Limit the number of times a student can attempt the quiz before the quiz is locked. Only used when `attempt_limiting` is `true`. - type: integer - minimum: 1 - time_limiting: - description: | - Determine if a time limit is enforced for each attempt. - - When enabled, a quiz attempt is automatically ended after the time period specified by `time_limit` has passed. - type: boolean - default: false - example: true - time_limit: - description: Determines the number of minutes allowed for each quiz attempt. Only used when `time_limiting` is `true`. - type: integer - minimum: 1 - example: 90 - passing_percentage: - description: Determines the grade required to consider an attempt "passing". - type: number - minimum: 0 - default: 65 - total_points: - description: The total points of all questions within the quiz. - type: integer - minimum: 0 - example: 10 - readOnly: true - show_correct_answer: - description: When enabled, students will be shown the correct answers to questions they answered incorrectly during quiz reviews. - type: boolean - default: false - randomize_questions: - description: When enabled, questions will be shuffled into a random order for each new quiz attempt. - type: boolean - default: false - course_id: - description: WordPress post ID of the quizzes's parent course. - type: integer - minimum: 1 - example: 1234 - readOnly: true - parent_id: - description: WordPress post ID of the parent item.
Must be a Lesson ID. `0` indicates an "orphaned" quiz which can be edited and viewed by instructors and admins but cannot be taken by students. - type: integer - minimum: 0 - example: 789 diff --git a/spec/components/schemas/QuizQuestion.yaml b/spec/components/schemas/QuizQuestion.yaml deleted file mode 100644 index d38fb576..00000000 --- a/spec/components/schemas/QuizQuestion.yaml +++ /dev/null @@ -1,56 +0,0 @@ -description: Base quiz question post object. -type: object -properties: - id: - description: Unique question identifer. The WordPress Post `ID`. - type: integer - minimum: 234 - readOnly: true - date_created: - description: 'Creation date. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:22:05' - date_created_gmt: - description: 'Creation date (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:22:05' - date_updated: - description: 'Date last modified. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:25:05' - readOnly: true - date_updated_gmt: - description: 'Date last modified (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:25:05' - readOnly: true - post_type: - allOf: - - $ref: '#/components/schemas/PostType' - type: string - default: llms_question - order: - description: Order of the question within its immediate parent. - type: integer - default: 1 - minimum: 1 - parent_id: - description: Resource ID of the question's parent (quiz). - type: integer - minimum: 1 - example: 234 - points: - description: Number of points awarded for correctly answering the question. - type: integer - minimum: 0 - default: 1 - example: 10 - video_embed: - description: URL to an oEmbed enable video URL. - type: string - example: https://www.youtube.com/watch?v=videoid - featured_media: - description: Featured image ID. - type: integer - example: 205 - diff --git a/spec/components/schemas/QuizQuestionRequest.yaml b/spec/components/schemas/QuizQuestionRequest.yaml deleted file mode 100644 index 5a32c721..00000000 --- a/spec/components/schemas/QuizQuestionRequest.yaml +++ /dev/null @@ -1,14 +0,0 @@ -type: object -properties: - title: - description: Raw quiz title. Most likely in the form of a question. - type: string - example: What is your favorite color? - content: - description: Raw quiz content. Useful for providing additional information or context to the question. - type: string - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

- answer_clarification: - description: Raw additional clarifying information displayed on the quiz attempt review screen when the question was answered incorrectly. - type: string - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

diff --git a/spec/components/schemas/QuizQuestionResponse.yaml b/spec/components/schemas/QuizQuestionResponse.yaml deleted file mode 100644 index 016590ca..00000000 --- a/spec/components/schemas/QuizQuestionResponse.yaml +++ /dev/null @@ -1,38 +0,0 @@ -type: object -properties: - title: - description: Quiz title. Most likely in the form of a question. - type: object - properties: - rendered: - type: string - description: Rendered title. - example: What is your favorite color? - raw: - type: string - description: Raw title. Useful when displaying title in the WP Editor. Only returned in `edit` context. - example: What is your favorite color? - content: - description: Quiz content. Useful for providing additional information or context to the question. - type: object - properties: - rendered: - type: string - description: Rendered content. - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

- raw: - type: string - description: Raw content. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

- answer_clarification: - description: Additional clarifying information displayed on the quiz attempt review screen when the question was answered incorrectly. - type: object - properties: - rendered: - type: string - description: Rendered content. - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

- raw: - type: string - description: Raw content. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

diff --git a/spec/components/schemas/QuizQuestionTypeBlank.yaml b/spec/components/schemas/QuizQuestionTypeBlank.yaml deleted file mode 100644 index 172b1841..00000000 --- a/spec/components/schemas/QuizQuestionTypeBlank.yaml +++ /dev/null @@ -1,19 +0,0 @@ -title: Fill in the Blank -description: Fill in the Blank quiz question type -allOf: - - $ref: '#/components/schemas/QuizQuestion' - - type: object - properties: - question_type: - description: The type of question. - type: string - default: blank - correct_value: - description: | - Specify the correct value(s) for each blank in the `title` property and enable automatic grading of the question. - - For questions with multiple blanks, separate each blank by with a pipe (`|`) character. The correct values should be supplied in the same order as the blanks. - type: string - example: 'foo|bar' - - diff --git a/spec/components/schemas/QuizQuestionTypeChoice.yaml b/spec/components/schemas/QuizQuestionTypeChoice.yaml deleted file mode 100644 index d0a07ac7..00000000 --- a/spec/components/schemas/QuizQuestionTypeChoice.yaml +++ /dev/null @@ -1,60 +0,0 @@ -title: Multiple Choice -description: Choice quiz question type -allOf: - - $ref: '#/components/schemas/QuizQuestion' - - type: object - properties: - question_type: - description: The type of question. - type: string - default: choice - choices: - description: A collection of choices available for the question. - type: array - minItems: 2 - maxItems: 26 - example: [ - { - "marker": "A", - "choice": "Red", - "correct": false - }, - { - "marker": "B", - "choice": "Green", - "correct": true - } - ] - items: - type: object - properties: - id: - description: Unique resource identifier for the choice. - type: string - readOnly: true - marker: - description: | - The marker used to visually identify and order the choices. - - Valid markers: `A` through `Z`. - - If no marker is supplied, the next available marker in the range will be used. - type: string - default: A - choice: - description: Raw choice text. - type: string - correct: - description: | - Determines if the choice is correct. - - When `multi_choices` is disabled, only one choice may be marked as `correct`. - type: boolean - default: false - multi_choices: - description: | - Enable multiple correct answers. - - When disabled only a single correct choice is available, when enabled, one or more correct choices are available. - type: boolean - default: false diff --git a/spec/components/schemas/QuizQuestionTypeContent.yaml b/spec/components/schemas/QuizQuestionTypeContent.yaml deleted file mode 100644 index abb668e0..00000000 --- a/spec/components/schemas/QuizQuestionTypeContent.yaml +++ /dev/null @@ -1,15 +0,0 @@ -title: Content -description: Content quiz question type -allOf: - - type: object - properties: - question_type: - description: The type of question. - type: string - default: content - points: - type: integer - readOnly: true - example: 0 - default: 0 - - $ref: '#/components/schemas/QuizQuestion' diff --git a/spec/components/schemas/QuizQuestionTypeLongAnswer.yaml b/spec/components/schemas/QuizQuestionTypeLongAnswer.yaml deleted file mode 100644 index 4b2463dc..00000000 --- a/spec/components/schemas/QuizQuestionTypeLongAnswer.yaml +++ /dev/null @@ -1,20 +0,0 @@ -title: Long Answer -description: Long answer quiz question type -allOf: - - $ref: '#/components/schemas/QuizQuestion' - - type: object - properties: - question_type: - description: The type of question. - type: string - default: long_answer - words_min: - description: Minimum word count for the answer. Setting the minimum at `0` disables the minimum word count. - type: integer - minimum: 0 - example: 500 - words_max: - description: Maximum word count for the answer. Setting the maximum at `0` disables the maximum word count. - type: integer - minimum: 0 - example: 10000 diff --git a/spec/components/schemas/QuizQuestionTypePictureChoice.yaml b/spec/components/schemas/QuizQuestionTypePictureChoice.yaml deleted file mode 100644 index 2d5ef7b7..00000000 --- a/spec/components/schemas/QuizQuestionTypePictureChoice.yaml +++ /dev/null @@ -1,75 +0,0 @@ -title: Picture Choice -description: Picuter choice quiz question type -allOf: - - $ref: '#/components/schemas/QuizQuestion' - - type: object - properties: - question_type: - description: The type of question. - type: string - default: picture_choice - choices: - description: A collection of choices available for the question. - type: array - minItems: 2 - maxItems: 26 - example: [ - { - "marker": "A", - "choice": { - "id": 98, - "src": "https://mysite.tld/wp-content/uploads/2019/05/picture-choice-img-1.png" - }, - "correct": false - }, - { - "marker": "B", - "choice": { - "id": 99, - "src": "https://mysite.tld/wp-content/uploads/2019/05/picture-choice-img-2.png" - }, - "correct": true - } - ] - items: - type: object - properties: - id: - description: Unique resource identifier for the choice. - type: string - readOnly: true - marker: - description: | - The marker used to visually identify and order the choices. - - Valid markers: `A` through `Z`. - - If no marker is supplied, the next available marker in the range will be used. - type: string - default: A - choice: - description: Object of image information for the choice. - type: object - properties: - id: - description: WP Attachment ID for the choice image. - type: integer - minimum: 1 - src: - description: Full URL to the image resource on the server. Only returned in edit context - type: string - readOnly: true - correct: - description: | - Determines if the choice is correct. - - When `multi_choices` is disabled, only one choice may be marked as `correct`. - type: boolean - default: false - multi_choices: - description: | - Enable multiple correct answers. - - When disabled only a single correct choice is available, when enabled, one or more correct choices are available. - type: boolean - default: false diff --git a/spec/components/schemas/QuizQuestionTypeTrueFalse.yaml b/spec/components/schemas/QuizQuestionTypeTrueFalse.yaml deleted file mode 100644 index 6a722369..00000000 --- a/spec/components/schemas/QuizQuestionTypeTrueFalse.yaml +++ /dev/null @@ -1,48 +0,0 @@ -title: True / False -description: True / False quiz question type -allOf: - - $ref: '#/components/schemas/QuizQuestion' - - type: object - properties: - question_type: - description: The type of question. - type: string - default: true_false - choices: - description: A collection of choices available for the question. - type: array - minItems: 2 - maxItems: 2 - example: [ - { - "marker": "A", - "choice": "True", - "correct": false - }, - { - "marker": "B", - "choice": "False", - "correct": true - } - ] - items: - type: object - properties: - id: - description: Unique resource identifier for the choice. - type: string - readOnly: true - marker: - description: The marker used to visually identify and order the choices. - type: string - enum: - - A - - B - default: A - choice: - description: Raw choice text. - type: string - correct: - description: Determines if the choice is correct. - type: boolean - default: false diff --git a/spec/components/schemas/QuizQuestionTypesResponseList.yaml b/spec/components/schemas/QuizQuestionTypesResponseList.yaml deleted file mode 100644 index 980cbad8..00000000 --- a/spec/components/schemas/QuizQuestionTypesResponseList.yaml +++ /dev/null @@ -1,25 +0,0 @@ -anyOf: - - title: Multiple Choice - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeChoice' - - $ref: '#/components/schemas/QuizQuestionResponse' - - title: Picture Choice - allOf: - - $ref: '#/components/schemas/QuizQuestionTypePictureChoice' - - $ref: '#/components/schemas/QuizQuestionResponse' - - title: True / False - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeTrueFalse' - - $ref: '#/components/schemas/QuizQuestionResponse' - - title: Content - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeContent' - - $ref: '#/components/schemas/QuizQuestionResponse' - - title: Fill in the Blank - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeBlank' - - $ref: '#/components/schemas/QuizQuestionResponse' - - title: Long Answer - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeLongAnswer' - - $ref: '#/components/schemas/QuizQuestionResponse' diff --git a/spec/components/schemas/QuizRequest.yaml b/spec/components/schemas/QuizRequest.yaml deleted file mode 100644 index dd08bf92..00000000 --- a/spec/components/schemas/QuizRequest.yaml +++ /dev/null @@ -1,12 +0,0 @@ -allOf: - - $ref: '#/components/schemas/Quiz' - - type: object - properties: - title: - type: string - description: Raw title. - example: Final Exam - content: - type: string - description: Raw content. - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

diff --git a/spec/components/schemas/QuizResponse.yaml b/spec/components/schemas/QuizResponse.yaml deleted file mode 100644 index 9cff89fd..00000000 --- a/spec/components/schemas/QuizResponse.yaml +++ /dev/null @@ -1,72 +0,0 @@ -allOf: - - $ref: '#/components/schemas/Quiz' - - type: object - properties: - title: - description: Quiz title. - type: object - properties: - rendered: - type: string - description: Rendered title. - example: Final Exam - raw: - type: string - description: Raw title. Useful when displaying title in the WP Editor. Only returned in `edit` context. - example: Final Exam - content: - description: Post content. - type: object - properties: - rendered: - type: string - description: Rendered content. - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

- raw: - type: string - description: Raw content. Useful when displaying title in the WP Block Editor. Only returned in `edit` context. - example:

Lorem ipsum dolor sit amet.

\n\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

- _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the lesson. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/quizzes/234 - collection: - description: REST URI to the lesson collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/quizzes - course: - description: REST URI to the lesson's parent course. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses/1234 - parent: - description: REST URI to the quiz's parent. - type: array - items: - type: object - properties: - type: - type: string - example: course - href: - type: string - example: /wp-json/llms/v1/lessons/789 diff --git a/spec/components/schemas/ResourceId.yaml b/spec/components/schemas/ResourceId.yaml deleted file mode 100644 index 25b661d9..00000000 --- a/spec/components/schemas/ResourceId.yaml +++ /dev/null @@ -1,5 +0,0 @@ -description: Unique Resource Identifier. -type: integer -minimum: 1 -example: 123 -readOnly: true diff --git a/spec/components/schemas/Section.yaml b/spec/components/schemas/Section.yaml deleted file mode 100644 index 1e6d6098..00000000 --- a/spec/components/schemas/Section.yaml +++ /dev/null @@ -1,41 +0,0 @@ -type: object -properties: - id: - allOf: - - description: Unique section identifier. The WordPress Post `ID`. - readOnly: true - - $ref: '#/components/schemas/ResourceId' - - example: 987 - date_created: - description: 'Creation date. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:22:05' - date_created_gmt: - description: 'Creation date (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:22:05' - date_updated: - description: 'Date last modified. Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 17:25:05' - readOnly: true - date_updated_gmt: - description: 'Date last modified (in GMT). Format: `Y-m-d H:i:s`.' - type: string - example: '2019-05-20 13:25:05' - readOnly: true - order: - description: Order of the section within the course. - type: integer - default: 1 - minimum: 1 - parent_id: - description: WordPress post ID of the parent item.
Must be a Course ID. - type: integer - minimum: 1 - example: 1234 - post_type: - allOf: - - $ref: '#/components/schemas/PostType' - type: string - default: section diff --git a/spec/components/schemas/SectionRequest.yaml b/spec/components/schemas/SectionRequest.yaml deleted file mode 100644 index ed449305..00000000 --- a/spec/components/schemas/SectionRequest.yaml +++ /dev/null @@ -1,12 +0,0 @@ -allOf: - - type: object - required: - - title - - order - - parent_id - properties: - title: - type: string - description: Raw title. - example: Getting Started with LifterLMS - - $ref: '#/components/schemas/Section' diff --git a/spec/components/schemas/SectionResponse.yaml b/spec/components/schemas/SectionResponse.yaml deleted file mode 100644 index d2b1c608..00000000 --- a/spec/components/schemas/SectionResponse.yaml +++ /dev/null @@ -1,88 +0,0 @@ -allOf: - - $ref: '#/components/schemas/Section' - - type: object - properties: - title: - description: Section Title - type: object - properties: - rendered: - description: Rendered title. - type: string - example: Introduction - raw: - description: Raw title. - type: string - example: Introduction - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the section. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/sections/1234 - collection: - description: REST URI to the section collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/sections - content: - description: REST URI to the section's child content. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/sections/1234/content - next: - description: REST URI to the next sibling section in the course. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/sections/3456 - parent: - description: REST URI to the section's parent. - type: array - items: - type: object - properties: - type: - type: string - example: course - href: - type: string - example: /wp-json/llms/v1/courses/1234 - prevous: - description: REST URI to the prevous sibling section in the course. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/sections/7891 - siblings: - description: REST URI to the collection of the section's siblings within its parent. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/courses/1234/content?exclude=7891 - diff --git a/spec/components/schemas/SharedCourseMembership.yaml b/spec/components/schemas/SharedCourseMembership.yaml deleted file mode 100644 index bc033bc0..00000000 --- a/spec/components/schemas/SharedCourseMembership.yaml +++ /dev/null @@ -1,62 +0,0 @@ -description: Properties shared by courses and memberships. -type: object -properties: - catalog_visibility: - description: Visibility of the post in catalogs and search results. - type: string - enum: - - catalog_search - - catalog - - search - - hidden - default: catalog_search - categories: - description: List of post categories. - type: array - default: [] - example: [ 1, 2, 3 ] - items: - type: integer - tags: - description: List of post tags. - type: array - default: [] - example: [ 4, 5, 6 ] - items: - type: integer - instructors: - description: List of post instructors. Defaults to current user when creating a new post. - type: array - default: [] - example: [ 1, 2, 3 ] - minItems: 1 - items: - type: integer - sales_page_type: - description: >- - Defines alternate content displayed to visitors and non-enrolled students when accessing the post.
- - `none` displays the post content.
- - `content` displays alternate content from the `excerpt` property.
- - `page` redirects to the WordPress page defined in `content_page_id`.
- - `url` redirects to the URL defined in `content_page_url`. - type: string - enum: - - none - - content - - page - - url - default: none - sales_page_page_id: - description: >- - The WordPress page ID of the sales page.
- Required when `sales_page_type` equals `page`.
- Only returned when the `sales_page_type` equals `page`. - type: integer - example: 543 - sales_page_url: - description: >- - The URL of the sales page content.
- Required when `sales_page_type` equals `url`.
- Only returned when the `sales_page_type` equals `url`. - type: string - example: https://example.tld/custom-sales-page diff --git a/spec/components/schemas/Student.yaml b/spec/components/schemas/Student.yaml deleted file mode 100644 index 457e9f7f..00000000 --- a/spec/components/schemas/Student.yaml +++ /dev/null @@ -1,59 +0,0 @@ -allOf: - - type: object - properties: - id: - description: Unique Student Identifer. The WordPress User `ID`. - readOnly: true - - $ref: '#/components/schemas/User' - - type: object - properties: - roles: - description: | - The user's WordPress user role. - - Only returned when `context=edit`. - type: array - default: [ student ] - items: - type: string - _links: - description: A map of links to other related API resources. - type: object - readOnly: true - properties: - self: - description: REST URI to the student. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/456 - collection: - description: REST URI to the student collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students - enrollments: - description: REST URI to a collection of the student's enrollments. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/456/enrollments - progress: - description: REST URI to a collection of the student's progress records. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/students/456/progress diff --git a/spec/components/schemas/User.yaml b/spec/components/schemas/User.yaml deleted file mode 100644 index 235e2c42..00000000 --- a/spec/components/schemas/User.yaml +++ /dev/null @@ -1,127 +0,0 @@ -description: Reduced WordPress User object properties shared by LifterLMS custom user types -type: object -properties: - id: - allOf: - - $ref: '#/components/schemas/ResourceId' - - description: Unique User Identifer. The WordPress User `ID`. - example: 456 - email: - description: | - The user's email address. - - Only returned when `context=edit`. - type: string - example: jamie@lifterlms.com - username: - description: | - The user's username. - - Only returned when `context=edit`. - type: string - example: jamie2019 - password: - description: The user's password. - type: string - example: my_l337-p@$5w0rd! - writeOnly: true - description: - description: The user's biography or description. - type: string - example: Lorem ipsum dolor sit amet, consectetur adipiscing elit. - registered_date: - description: | - The user's original site registration date. - - Only returned when `context=edit`. - type: string - example: '2019-05-03 19:25:01' - avatar_urls: - description: | - A list of the Gravatars available for the user. - - The object key is the size (in pixels) of the avatar and the value is the Gravatar's URL. - type: object - readOnly: true - properties: - 24: - type: string - example: https://secure.gravatar.com/avatar/30eab7b16342fe5f772ed30a36da2763?s=24&d=mm&r=g - 48: - type: string - example: https://secure.gravatar.com/avatar/30eab7b16342fe5f772ed30a36da2763?s=48&d=mm&r=g - 96: - type: string - example: https://secure.gravatar.com/avatar/30eab7b16342fe5f772ed30a36da2763?s=48&d=mm&r=g - url: - description: The user's URL. - type: string - example: https://myawesomewebsite.tld - first_name: - description: | - The user's first name. - - Only returned when `context=edit`. - type: string - example: Jamie - last_name: - description: | - The user's last name. - - Only returned when `context=edit`. - type: string - example: Cook - nickname: - description: | - The user's chosen nickname. - - Only returned when `context=edit`. - type: string - example: JamieC - name: - description: The user's public display name. - type: string - example: Jamie Cook - billing_address_1: - description: | - Address line 1. - - Only returned when `context=edit`. - type: string - example: 1234 Somewhere Place - billing_address_2: - description: | - Address line 2. - - Only returned when `context=edit`. - type: string - example: Suite ABC - billing_city: - description: | - City name. - - Only returned when `context=edit`. - type: string - example: Anywhere - billing_state: - description: | - ISO code or state, province, or district name. - - Only returned when `context=edit`. - type: string - example: CA - billing_postcode: - description: | - Postal code. - - Only returned when `context=edit`. - type: string - example: 12345-678 - billing_country: - description: | - ISO country code. - - Only returned when `context=edit`. - type: string - example: US - diff --git a/spec/components/schemas/UserName.yaml b/spec/components/schemas/UserName.yaml deleted file mode 100644 index 6a5637dc..00000000 --- a/spec/components/schemas/UserName.yaml +++ /dev/null @@ -1,14 +0,0 @@ -type: object -properties: - first: - description: The person's first name. - type: string - example: Jamie - last: - description: The person's last name. - type: string - example: Cook - display: - description: The person's public display name. - type: string - example: Jamie Cook diff --git a/spec/components/schemas/Webhook.yaml b/spec/components/schemas/Webhook.yaml deleted file mode 100644 index ca15f40e..00000000 --- a/spec/components/schemas/Webhook.yaml +++ /dev/null @@ -1,92 +0,0 @@ -type: object -properties: - id: - allOf: - - description: Unique webhook Identifier. The WordPress post `ID`. - - $ref: '#/components/schemas/ResourceId' - - example: 654 - name: - description: A friendly, human-readable name for the webhook. - type: string - minimum: 1 - example: A Student Enrolled in a Course - status: - description: | - The status of the webhook. - - + `active`: Payload will be delivered - + `paused`: Delivery is disabled by an admin. - + `disabled`: Delivery is disabled because of delivery failure. - type: string - enum: - - active - - paused - - disabled - default: disabled - topic: - description: The Webhook topic. - type: string - example: student.created - delivery_url: - description: The webhook payload delivery URL. - type: string - example: https://example.tld/webhook-receipt/endpoint - secret: - description: | - An optional secret key used to generate the webhook delivery signature. - - If no secret is supplied and random string will be generated using `wp_generate_password()`. - type: string - example: $P3CI41-$3CR37! - resource: - description: The parsed `topic` resource. - type: string - readOnly: true - example: student - event: - description: The parsed `topic` event. - type: string - readOnly: true - example: created - hooks: - description: An array of hook names associated with the topic. - type: array - items: - type: string - example: 'llms_user_registered' - readOnly: true - created: - description: Creation date. - type: string - format: date-time - example: '2019-03-20T17:22:05' - readOnly: true - updated: - description: Date last modified. - type: string - format: date-time - example: '2019-05-20T17:25:05' - readOnly: true - _links: - description: A map of links to other related API resources. - readOnly: true - type: object - properties: - self: - description: REST URI to the webhook. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/webhooks/654 - collection: - description: REST URI to the webhooks collection. - type: array - items: - type: object - properties: - href: - type: string - example: /wp-json/llms/v1/webhooks/ diff --git a/spec/components/securitySchemes/Basic-Authentication.yaml b/spec/components/securitySchemes/Basic-Authentication.yaml deleted file mode 100644 index d0166009..00000000 --- a/spec/components/securitySchemes/Basic-Authentication.yaml +++ /dev/null @@ -1,2 +0,0 @@ -type: http -scheme: basic diff --git a/spec/openapi.yaml b/spec/openapi.yaml deleted file mode 100644 index 88d94f81..00000000 --- a/spec/openapi.yaml +++ /dev/null @@ -1,450 +0,0 @@ -openapi: 3.0.0 -info: - version: 1.0.0-beta.25 - title: LifterLMS REST API - description: >- - # Introduction - - LifterLMS (LLMS) is fully integrated with the [WordPress REST API](https://developer.wordpress.org/rest-api/). This allows LifterLMS data to be created, read, updated, and deleted using requests in JSON format and using WordPress REST API Authentication methods and standard HTTP verbs which are understood by most HTTP clients. - - ## Public Beta - - As of LifterLMS version 3.34.0, the LifterLMS REST API is included in the LifterLMS core plugin for public evaluation and testing. - - The specification may change over the next few months as we evaluate feedback and use-cases. If you are building integrations relying on the REST API please keep your eye on our changelog and let us know how things are going! - - If you're interested in contributing or discussing the REST API, please join us in [GitHub](https://github.com/gocodebox/lifterlms-rest) and post in `#developers` on the [LifterLMS Community Slack](https://lifterlms.com/slack). - - ## Requirements - - To use the latest version of the REST API you must be using the following: - - + LifterLMS Version 3.34.0+. - + WordPress 5.2+. - + Pretty permalinks in `Settings -> Permalinks` so that the custom endpoints are supported. **Default permalinks will not work.** - + An SSL certificate. - - ## Libraries and Tools - - ### Official Libraries - - LifterLMS develops and maintains official libraries for different programming languages so you can easily build around the REST API. - - + [Node/Javascript](https://github.com/gocodebox/llms-api-node) - + PHP (coming soon) - - ### Tools - - Some useful tools to help develop and access the REST API: - - + [Postman](https://www.getpostman.com/) - A multi platform REST API GUI client. - + [RESTCLient](https://addons.mozilla.org/en-US/firefox/addon/restclient/) - A free Firefox add-on. - + [Advanced REST client](https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo) - A free Google Chrome extension. - + [RequestBin](https://requestbin.com/) - A free service allowing you to quickly test webhooks. - - # Base URL - - The LifterLMS REST API extends the [WordPress REST API](https://developer.wordpress.org/rest-api/) which is a [distributed API](https://developer.wordpress.org/rest-api/reference/#a-distributed-api) available individually on any WordPress website. - - - As a distributed API, there is no singular root or base URL to use when performing API requests. - - - For most WordPress websites, the base REST URL is located at `/wp-json/`, but this can be customized on a site-by-site basis. - - - If you're not sure what your site's base REST URL is, you can discover it using the [WordPress REST API discovery proccess](https://developer.wordpress.org/rest-api/using-the-rest-api/discovery/). - - - The examples found throughout this reference use `https://example.tld/wp-json/` as the base REST URL. This should be replaced with your website's actual base URL when using the REST API. - - # Authentication - - Requests to most API resources require authentication. Authentication can be preformed by providing API Credentials by using as the username and password via [HTTP Basic Authentication](http://en.wikipedia.org/wiki/Basic_access_authentication) or through request headers. - - - Requests to the REST API may only be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Requests made over HTTP will fail. - - ## Basic Authentication - - The preferred authentication method is HTTP Basic Authentication. - - To use HTTP Basic Auth, provide the Consumer Key as the username and the Consumer Secret as the password. - - ``` - curl https://example.tld/wp-json/llms/v1/courses \ - -u ck_d7W85twOWT0poKzDSAQzI7:cs_8bsMmRfjW1HgEFw5ad7BIF - ``` - - ## Header Authentication - - Alternatively, requests may be authenticated by providing the Consumer Key and Consumer Secret as the request headers `X-LLMS-CONSUMER-KEY` and `X-LLMS-CONSUMER-SECRET`. - - ``` - curl https://example.tld/wp-json/llms/v1/courses \ - -H X-LLMS-CONSUMER-KEY:ck_d7W85twOWT0poKzDSAQzI7 \ - -H X-LLMS-CONSUMER-SECRET:cs_8bsMmRfjW1HgEFw5ad7BIF - ``` - - x-logo: - altText: LifterLMS - url: "https://gocodebox.github.io/lifterlms-brand/assets/img/png/logo/lifterlms-logo.png" - href: "https://lifterlms.com/" - -servers: - - url: https://example.tld/wp-json/llms/v1 - -security: - - Basic-Authentication: [] - -tags: - - - name: API Keys - description: | - API Keys are used to authenticate REST API requests. - - The API keys API allows you to create, view, update, and delete API keys. - - ## API Key Properties - - - - - name: Access Plans - description: | - Access plans allow you to define how LMS content is purchased and accessed by your students. - - The access plans API allows you to create, view, update, and delete access plans. - - ## Access Plan Properties - - - - - name: Courses - description: | - The courses API allows you to create, view, update, and delete courses. - - ## Course Properties - - - - - name: Instructors - description: | - Instructors are members of your site who have the ability to create and manage LMS content and students. Instructors may be Adminstators, LMS Managers, Instructors, and Instructors Assistants. - - The instructors API allows you to create, view, update, and delete student accounts. - - ## Instructor Properties - - - - - name: Memberships - description: | - The memberships API allows you to create, view, update, and delete memberships. - - ## Membership Properties - - - - - name: Quiz Questions - description: | - The quiz questions API allows you to create, view, update, and delete quiz questions. - - ## Question Types - - There are four unique question types available via the LifterLMS Core: - - + Multiple Choice - + Picture Choice - + True / False - + Content - - An additional eight question types are available with the LifterLMS Advanced Quizzes Add-on: - - + Fill in the Blank - + Reorder Items - + Reorder Pictures - + Short Answer - + Long Answer - + File Upload - + Code - + Scale - - While these additional question types are documented here, they are only available when the LifterLMS Advanced Quizzes Add-on is installed and activated on your site. - - - name: Quizzes - description: | - The quizzes API allows you to create, view, update, and delete quizzes. - - ## Quiz Properties - - - - - name: Sections - description: | - The sections API allows you to create, view, update, and delete sections. - - Sections are used within courses to organize content (lessons) into groups. - - ## Section Properties - - - - - name: Lessons - description: | - The lessons API allows you to create, view, update, and delete lessons. - - ## Lesson Properties - - - - - name: Students - description: | - Students are members of your site who are (or were) enrolled in your courses and memberships. Students can be any WordPress user account on your site (not exclusively the "student" role). - - The students API allows you to create, view, update, and delete student accounts as well as view information about the student's LMS content. - - ## Student Properties - - - - - name: Student Enrollments - description: | - The Student Enrollments API allows you to create, view, update, and delete records of a student's enrollment into courses and memberships. - - ## Enrollment Properties - - - - - name: Student Progress - description: | - The Student Progress API allows you to create, view, update, and delete a student's progress through courses. - - A student's progress through a course is calculated by dividing the number of lessons completed by the student by the total number of lessons available in a course. It is not possible to manually update the `progress` percentage property of a course, instead you must update the status of each lesson in the course. - - When updating the status of a course or a section, the status of the lessons within that course or section will be automatically updated to match the status of the course or section. For example, when updating a course's status to `complete` a new `complete` progress record will be created/updated for each incomplete lesson in the course. - - Finally, the `progress` property of a lesson will _always_ be either `0` _or_ `100` whereas the `progress` of courses and sections will range from `0` _to_ `100`. - - ## Progress Properties - - - - - name: Webhooks - description: | - Webhooks can be created to notify you about LMS-related events that happen on your site. - - The Webhooks API allows you to create, view, update, and delete webhooks. - - Webhooks may additionally be managed on the LifterLMS Webhooks screen on your site's WordPress admin panel. - - ## Topics - - The `topic` is a combination of the resource (e.g. student) and event (e.g. created). Each `topic` maps to one or more hook names (e.g. `llms_user_registered`). The proper hooks are automatically added based on the `topic`. - - The following topics are available: - - + Courses - + `course.created` - + `course.updated` - + `course.deleted` - + `course.restored` - + Sections - + `section.created` - + `section.updated` - + `section.deleted` - + `section.restored` - + Lessons - + `lesson.created` - + `lesson.updated` - + `lesson.deleted` - + `lesson.restored` - + Memberships - + `membership.created` - + `membership.updated` - + `membership.deleted` - + `membership.restored` - + Students - + `student.created` - + `student.updated` - + `student.deleted` - + Student Enrollment - + `enrollment.created` - + `enrollment.updated` - + `enrollment.deleted` - + Student Progress - + `progress.updated` - + `progress.deleted` - + Instructors - + `instructor.created` - + `instructor.updated` - + `instructor.deleted` - - Custom topics can also be used in order to create a webhook triggered by an arbitrary WordPress hook. For a custom topic use the `action` resource with any hook as the event. For example, to create a webhook triggered by the `user_register` hook the topic would be `action.user_register`. - - ## Delivery - - Webhook payloads are delivered in the background using wp-cron and `wp_remote_post()` (HTTP POST). - - Custom headers are supplied to assist with the receipt of the webhook: - - | Header | Description | Example | - | ------------------------ | -------------------------------------------------- | ------------------- | - | X-LLMS-Webhook-Source | The URL of the LifterLMS website. | https://example.tld | - | X-LLMS-Webhook-Topic | The webhook `topic` property. | student.created | - | X-LLMS-Webhook-Resource | The webhook `resource` property. | student | - | X-LLMS-Webhook-Event | The webhook `event` property. | created | - | X-LLMS-Webhook-Signature | A base64 encoded HMAC-SHA256 hash of the payload. | | - | X-LLMS-Webhook-ID | The unique webhook identifier (WordPress post ID). | 654 | - | X-LLMS-Delivery-ID | A unique ID for the webhook delivery. | 765 | - - The payload is a JSON-encoded object of the API resource as if retrieved by a `GET` request. - - The payload for a custom hook will be a JSON-encoded version of the first parameter supplied by the hook. - - ## Signature Verification - - Webhooks are signed by LifterLMS and the event's unique signature is included in the `X-LLMS-Webhook-Signature` header. The signature allows you to verify that the webhook was sent by LifterLMS and not by a third party. We recommend verifying all webhooks and discarding any payloads which cannot be verified. - - The `X-LLMS-Webhook-Signature` contains a timestamp and one or more signatures. The timestamp is prefixed by `t=` and the signatures are prefixed by `v` and an integer. Currently the only valid signature scheme is `v1`. - - ``` - X-LLMS-Webhook-Signature: t=1562715579,v1=0d579d62ef442b6e2d1d522924aafed480fdaaacbe498486a94445de8b995819 - ``` - - The signature is generated using a hash-based message authentication code ([HMAC](https://en.wikipedia.org/wiki/HMAC)) with [SHA-256](https://en.wikipedia.org/wiki/SHA-2). - - To verify a webhook signature you must construct an _expected_ webhook signature which you can then compare against the webhook signature supplied with delivery. - - #### Step 1: Extract the timestamps and signatures from the header - - Split the header, using the `,` character as the separator, to get a list of elements. Then split each element, using the `=` character as the separator, to get a prefix and value pair. - - The value for the prefix `t` corresponds to the timestamp, and `v1` corresponds to the signature. You can discard all other elements. - - #### Step 2: Prepare the payload string for signing - - You achieve this by concatenating: - - + The timestamp (as a string) - + The character `.` - + The actual JSON payload (i.e. the request's body) - - #### Step 3: Generate the expected signature string - - Compute an HMAC with the SHA256 hash function. Use the endpoints signing secret as the key, and use the string from Step 2 as the message. - - #### Step 4: Compare the signatures - - Compare the signature(s) in the header to the expected signature. If a signature matches, compute the difference between the current timestamp and the received timestamp, then decide if the difference is within your tolerance. We recommend accepting a difference of no more than five minutes between the provided timestamp and the current time. - - ## Webook Properties - - - - - name: Add-On Requirements - description: | - API documentation for add-ons developed and maintained by the LifterLMS core team are included for completeness, however the API endpoints for each add-on are only available when the required add-on plugin is installed and activated on your LifterLMS-powered website. - - - name: Groups - description: | - - Groups are an organizational unit of students. The groups API allows you to create, view, update, and delete groups. - - ## Requirements - - The groups API is only available through the [LifterLMS Groups advanced add-on](https://lifterlms.com/product/groups). This plugin must be installed and activated in order to utilize the Groups API. - - ## Group Properties - - - - - name: Group Invitations - description: | - - The group invitations API allows creation, deletion, and listing of group invitations. - - ## Requirements - - The groups API is only available through the [LifterLMS Groups advanced add-on](https://lifterlms.com/product/groups). This plugin must be installed and activated in order to utilize the Groups API. - - ## Group Invitation Properties - - - - - name: Group Members - description: | - - The group members API allows listing and retrieval of group members. The role of a member within a group may be updated and removed from a group using this API as well. - - It is not possible to *add* a memeber directly to a group. Instead a new group invitation should be created (and accepted by the user). - - ## Requirements - - The groups API is only available through the [LifterLMS Groups advanced add-on](https://lifterlms.com/product/groups). This plugin must be installed and activated in order to utilize the Groups API. - - ## Group Member Properties - - - - - name: Group Seats - description: | - - The group seats API allows querying and updating information related to the number of seats available for a group. - - ## Requirements - - The groups API is only available through the [LifterLMS Groups advanced add-on](https://lifterlms.com/product/groups). This plugin must be installed and activated in order to utilize the Groups API. - - ## Group Seat Properties - - - -x-tagGroups: - - - name: API Keys - tags: - - API Keys - - - name: Courses - tags: - - Courses - - Sections - - Lessons - - - name: E-Commerce - tags: - - Access Plans - - - name: Instructors - tags: - - Instructors - - - name: Memberships - tags: - - Memberships - - # @todo: Implement. - # - name: Quizzes - # tags: - # - Quizzes - # - Quiz Questions - # - Quiz Attempts - - - name: Students - tags: - - Students - - Student Enrollments - - Student Progress - - - name: Webhooks - tags: - - Webhooks - - - name: Add-Ons - tags: - - Add-On Requirements - - Groups - - Group Invitations - - Group Members - - Group Seats - diff --git a/spec/paths/README.md b/spec/paths/README.md deleted file mode 100644 index 8d584cde..00000000 --- a/spec/paths/README.md +++ /dev/null @@ -1,5 +0,0 @@ -Paths -===== - -* Write each path specification in separate file -* Filename is mapped to path by replacing `@` with `/`, i.e. `user@{username}.yaml` matches to `user/{username}` path diff --git a/spec/paths/access-plans.yaml b/spec/paths/access-plans.yaml deleted file mode 100644 index d63517d7..00000000 --- a/spec/paths/access-plans.yaml +++ /dev/null @@ -1,92 +0,0 @@ -get: - summary: List access plans - description: Retrieve a list of access plans. - tags: - - Access Plans - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/Search' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - title - - date_created - - date_updated - - menu_order - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: post_id - description: Retrieve access plans for a specific list of one or more posts. Accepts a course/membership id or comma separated list of course/membership ids. - in: query - schema: - type: string - example: 123,456 - responses: - 200: - description: Successfully returned a list of access plans. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/AccessPlanResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create an access plan - description: Create a new access plan object. - tags: - - Access Plans - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/AccessPlanRequest' - - required: - - title - - price - - post_id - responses: - 201: - description: Successfully created the student. - content: - application/json: - schema: - $ref: '#/components/schemas/AccessPlanResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/access-plans@{id}.yaml b/spec/paths/access-plans@{id}.yaml deleted file mode 100644 index 9b87eaa5..00000000 --- a/spec/paths/access-plans@{id}.yaml +++ /dev/null @@ -1,74 +0,0 @@ -parameters: - - name: id - in: path - description: Unique AccessPlan Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve an access plan - description: Retrieve the details of an existing access plan. - tags: - - Access Plans - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the access plan. - content: - application/json: - schema: - $ref: '#/components/schemas/AccessPlanResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update an access plan - description: >- - Update the specified access plan by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Access Plans - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/AccessPlanRequest' - responses: - 200: - description: Successfully updated the access plan. - content: - application/json: - schema: - $ref: '#/components/schemas/AccessPlanResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete an access plan - description: Delete an existing access plan. - tags: - - Access Plans - responses: - 204: - description: Successfully deleted the access plan. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/api-keys.yaml b/spec/paths/api-keys.yaml deleted file mode 100644 index c533f32d..00000000 --- a/spec/paths/api-keys.yaml +++ /dev/null @@ -1,117 +0,0 @@ -get: - summary: List API keys - description: Retrieve a list of API keys. - tags: - - API Keys - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - description - - last_access - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: user - description: Include only keys for the specified user(s). Accepts a single id or a comma separated list of ids. - in: query - required: false - schema: - type: integer - example: [ 123, 456 ] - - name: user_not_in - description: Exclude keys for the specified user(s). Accepts a single id or a comma separated list of ids. - in: query - required: false - schema: - type: integer - example: [ 123, 456 ] - - name: permissions - description: Include only API keys matching a specific permission. - in: query - required: false - schema: - type: string - enum: - - read - - write - - read_write - responses: - 200: - description: Successfully returned a list of API keys. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/APIKey' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create an API key - description: Create a new API key. - tags: - - API Keys - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/APIKey' - - required: - - user_id - - description - - permissions - responses: - 201: - description: Successfully created the student. - content: - application/json: - schema: - allOf: - - type: object - properties: - consumer_key: - description: The Consumer Key. Only returned once with the initial creation request. - type: string - example: ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - consumer_secret: - description: The Consumer Secret. Only returned once with the initial creation request. - type: string - example: cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx - - $ref: '#/components/schemas/APIKey' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/api-keys@{id}.yaml b/spec/paths/api-keys@{id}.yaml deleted file mode 100644 index 27c4e917..00000000 --- a/spec/paths/api-keys@{id}.yaml +++ /dev/null @@ -1,75 +0,0 @@ -parameters: - - name: id - in: path - description: Unique API Key Identifier. - required: true - example: 987 - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve an API key - description: Retrieve the details of an existing API key. - tags: - - API Keys - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the API key. - content: - application/json: - schema: - $ref: '#/components/schemas/APIKey' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update an API key - description: >- - Update the specified API key by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - API Keys - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/APIKey' - responses: - 200: - description: Successfully updated the API key. - content: - application/json: - schema: - $ref: '#/components/schemas/APIKey' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete an API key - description: Delete an existing API key. - tags: - - API Keys - responses: - 204: - description: Successfully deleted the API key. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/courses.yaml b/spec/paths/courses.yaml deleted file mode 100644 index 563e9c9f..00000000 --- a/spec/paths/courses.yaml +++ /dev/null @@ -1,86 +0,0 @@ -get: - summary: List courses - description: Retrieve a list of courses. - tags: - - Courses - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/Search' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - title - - date_created - - date_updated - - menu_order - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - $ref: '#/components/parameters/PostStatus' - responses: - 200: - description: Successfully returned a list of courses. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/CourseResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create a course - description: Create a new course object. - tags: - - Courses - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/CourseRequest' - - required: - - title - - content - responses: - 201: - description: Successfully created the course. - content: - application/json: - schema: - $ref: '#/components/schemas/CourseResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/courses@{id}.yaml b/spec/paths/courses@{id}.yaml deleted file mode 100644 index 89661f4f..00000000 --- a/spec/paths/courses@{id}.yaml +++ /dev/null @@ -1,98 +0,0 @@ -parameters: - - name: id - in: path - description: Unique Course Identifier. The WordPress Post `ID`. - required: true - example: 123 - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a course - description: Retrieve the details of an existing course. - tags: - - Courses - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/PostPassword' - responses: - 200: - description: Successfully retrieved the course. - content: - application/json: - schema: - $ref: '#/components/schemas/CourseResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a course - description: >- - Update the specified course by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Courses - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/CourseRequest' - responses: - 200: - description: Successfully updated the course. - content: - application/json: - schema: - $ref: '#/components/schemas/CourseResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a course - description: Delete an existing course. - tags: - - Courses - requestBody: - content: - application/json: - schema: - type: object - properties: - force: - description: Bypass the trash and force course deletion. - type: boolean - default: false - responses: - 200: - description: Successfully moved the course to the trash. - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/CourseResponse' - - type: object - properties: - status: - type: string - default: trash - 204: - description: Successfully deleted the course. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/courses@{id}@content.yaml b/spec/paths/courses@{id}@content.yaml deleted file mode 100644 index b475dc92..00000000 --- a/spec/paths/courses@{id}@content.yaml +++ /dev/null @@ -1,63 +0,0 @@ -parameters: - - name: id - in: path - description: Unique course Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - - -get: - summary: List course content - description: Retrieve a collection of an existing course's content. - tags: - - Courses - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - order - - id - - title - default: order - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - responses: - 200: - description: Successfully retrieved the course outline. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/SectionResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' diff --git a/spec/paths/courses@{id}@enrollments.yaml b/spec/paths/courses@{id}@enrollments.yaml deleted file mode 100644 index 04a2f843..00000000 --- a/spec/paths/courses@{id}@enrollments.yaml +++ /dev/null @@ -1,71 +0,0 @@ -parameters: - - name: id - in: path - description: Unique course Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - - -get: - summary: List course enrollments - description: Retrieve a collection of an existing course's enrollments. - tags: - - Courses - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for the collection of results. - in: query - schema: - type: string - enum: - - date_updated - - date_created - default: date_updated - - name: status - description: Filter results to records matching the specified status. - in: query - required: false - schema: - $ref: '#/components/schemas/EnrollmentStatus' - - name: student - in: query - description: Limit results to a specific student or a list of students. Accepts a single student `id` or a comma separated list of student `id`s. - schema: - type: string - example: [1,2,3] - responses: - 200: - description: Successfully retrieved the course's enrollments. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Enrollment' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' diff --git a/spec/paths/groups.yaml b/spec/paths/groups.yaml deleted file mode 100644 index fded2e0e..00000000 --- a/spec/paths/groups.yaml +++ /dev/null @@ -1,83 +0,0 @@ -get: - summary: List groups - description: Retrieves a list of all groups. - tags: - - Groups - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/Search' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - name - - date_created - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - responses: - 200: - description: Successfully returned a list of groups - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: | - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/GroupResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - - -post: - summary: Create a group - description: Creates a new group. - tags: - - Groups - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/GroupRequest' - - required: - - email - responses: - 201: - description: Successfully created the group. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/groups@{id}.yaml b/spec/paths/groups@{id}.yaml deleted file mode 100644 index df77b54b..00000000 --- a/spec/paths/groups@{id}.yaml +++ /dev/null @@ -1,96 +0,0 @@ -parameters: - - name: id - in: path - description: Unique group Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a group - description: Retrieve the details of an existing group. - tags: - - Groups - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the group. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a group - description: >- - Update the specified group by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Groups - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/GroupRequest' - responses: - 200: - description: Successfully updated the group. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a group - description: Delete an existing group. - tags: - - Groups - requestBody: - content: - application/json: - schema: - type: object - properties: - force: - description: Bypass the trash and force group deletion. - type: boolean - default: false - responses: - 200: - description: Successfully moved the group to the trash. - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/GroupResponse' - - type: object - properties: - status: - type: string - default: trash - 204: - description: Successfully deleted the group. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/groups@{id}@invitations.yaml b/spec/paths/groups@{id}@invitations.yaml deleted file mode 100644 index 794d9721..00000000 --- a/spec/paths/groups@{id}@invitations.yaml +++ /dev/null @@ -1,103 +0,0 @@ -parameters: - - name: id - in: path - description: Unique group Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: List group invitations - description: Retrieves a list of all group invitations. - tags: - - Group Invitations - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: email - description: Limit results to a list of email addresses. Accepts a single email or a comma-separated list of emails. - in: query - required: false - schema: - type: string - example: jeffrey@fakewebsite.tld - - name: role - description: Limit results to a list of roles. Accepts a single role or a comma-separated list of roles. - in: query - required: false - schema: - type: string - enum: - - member - - leader - - admin - example: leader,admin - default: member,leader,admin - responses: - 200: - description: Successfully returned a list of group invitations - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: | - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/GroupInvitation' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - - -post: - summary: Create an invitation - description: Creates a new group invitation. - tags: - - Group Invitations - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/GroupInvitation' - responses: - 201: - description: Successfully created the group invitation. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupInvitation' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/groups@{id}@invitations@{invitation_id}.yaml b/spec/paths/groups@{id}@invitations@{invitation_id}.yaml deleted file mode 100644 index a2208b8c..00000000 --- a/spec/paths/groups@{id}@invitations@{invitation_id}.yaml +++ /dev/null @@ -1,51 +0,0 @@ -parameters: - - name: id - in: path - description: Unique group Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - - name: invitation_id - in: path - description: Unique invitation Identifier - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a group invitation - description: Retrieve the details of an existing group invitation. - tags: - - Group Invitations - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the group invitation. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupInvitation' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a group invitation - description: Delete an existing group invitation. - tags: - - Group Invitations - responses: - 204: - description: Successfully deleted the group. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/groups@{id}@members.yaml b/spec/paths/groups@{id}@members.yaml deleted file mode 100644 index af3676eb..00000000 --- a/spec/paths/groups@{id}@members.yaml +++ /dev/null @@ -1,73 +0,0 @@ -parameters: - - name: id - in: path - description: Unique group Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: List group members - description: Retrieves a list of all group members. - tags: - - Group Members - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - name - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: group_roles - description: | - Filter members by group role. - - Accepts a single role or a comma separated list of roles. - in: query - required: false - schema: - type: string - enum: - - member - - leader - - admin - - primary_admin - responses: - 200: - description: Successfully returned a list of group members - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: | - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/GroupMember' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/groups@{id}@members@{member_id}.yaml b/spec/paths/groups@{id}@members@{member_id}.yaml deleted file mode 100644 index c262eb40..00000000 --- a/spec/paths/groups@{id}@members@{member_id}.yaml +++ /dev/null @@ -1,81 +0,0 @@ -parameters: - - name: id - in: path - description: Unique group Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - - name: member_id - in: path - description: Unique member Identifier. The WordPress User `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a group member - description: Retrieve the details of an existing group member. - tags: - - Group Members - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the group member. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupMember' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a group member - description: Update the details of an existing group member. - tags: - - Group Members - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/GroupMember' - responses: - 200: - description: Successfully updated the group member. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupMember' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - - -delete: - summary: Remove a group member - description: Remove an existing group member. - tags: - - Group Members - parameters: - - $ref: '#/components/parameters/EnrollmentTrigger' - responses: - 204: - description: Successfully removed from the member from the group. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/groups@{id}@seats.yaml b/spec/paths/groups@{id}@seats.yaml deleted file mode 100644 index 3b0d34d2..00000000 --- a/spec/paths/groups@{id}@seats.yaml +++ /dev/null @@ -1,56 +0,0 @@ -parameters: - - name: id - description: Unique group Identifer. The WordPress User `ID`. - example: 123 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Get group seats - description: Retrieves information about the group's seats. - tags: - - Group Seats - responses: - 200: - description: Successfully retrieved the groups's seats. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupSeat' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -put: - summary: Update group seats - description: Update the seat information for a group. - tags: - - Group Seats - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/GroupSeat' - responses: - 200: - description: Successfully updated the group's seats. - content: - application/json: - schema: - $ref: '#/components/schemas/GroupSeat' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' diff --git a/spec/paths/instructors.yaml b/spec/paths/instructors.yaml deleted file mode 100644 index 45fce663..00000000 --- a/spec/paths/instructors.yaml +++ /dev/null @@ -1,115 +0,0 @@ -get: - summary: List instructors - description: Retrieves a list of all instructors. - tags: - - Instructors - parameters: - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/SearchUsers' - - $ref: '#/components/parameters/SearchColumns' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - email - - name - - registered_date - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: post_in - description: | - Retrieve only instructors for the specified course(s) and/or - membership(s). - - Accepts a single WP Post ID or a comma separated list of IDs. - in: query - required: false - schema: - type: string - example: [1,2,3] - - name: post_not_in - description: | - Retrieve only instructors for in the specified course(s) and/or - membership(s). - - Accepts a single WP Post ID or a comma separated list of IDs. - in: query - required: false - schema: - type: string - example: [4,5,6] - - name: roles - description: | - Retrieve instructors by a specific role. - - Accepts a single role name or a comma separated list of role names. - in: query - required: false - schema: - type: string - example: [instructor,lms_manager] - responses: - 200: - description: Successfully returned a list of instructors - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Instructor' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - - -post: - summary: Create an instructor - description: Creates a new instructor object. - tags: - - Instructors - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Instructor' - - required: - - email - responses: - 201: - description: Successfully created the instructor. - content: - application/json: - schema: - $ref: '#/components/schemas/Instructor' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/instructors@{id}.yaml b/spec/paths/instructors@{id}.yaml deleted file mode 100644 index 9d981bcb..00000000 --- a/spec/paths/instructors@{id}.yaml +++ /dev/null @@ -1,94 +0,0 @@ -parameters: - - name: id - description: Unique Instructor Identifer. The WordPress User `ID`. - example: 123 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve an instructor - description: Retrieve the details of an existing instructor. - tags: - - Instructors - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the instructor. - content: - application/json: - schema: - $ref: '#/components/schemas/Instructor' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update an instructor - description: >- - Update the specified instructor by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Instructors - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/Instructor' - responses: - 200: - description: Successfully updated the instructor. - content: - application/json: - schema: - $ref: '#/components/schemas/Instructor' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete an instructor - description: Delete an existing instructor. - tags: - - Instructors - requestBody: - content: - application/json: - schema: - type: object - properties: - reassign: - description: | - ID of a WordPress User. - - Any posts owned by the deleted user will be reassigned to this user. - - LMS content and statuses (enrollments, for example), are not reassigned. - - Default (passing `0` or nothing) delete's the users's content. - type: integer - minimum: 0 - default: 0 - example: 456 - responses: - 204: - description: Successfully deleted the instructor. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/instructors@{id}@content.yaml b/spec/paths/instructors@{id}@content.yaml deleted file mode 100644 index 387f06c2..00000000 --- a/spec/paths/instructors@{id}@content.yaml +++ /dev/null @@ -1,74 +0,0 @@ -parameters: - - name: id - description: The instructor's ID. - example: 123 - in: path - required: true - schema: - type: integer - -get: - summary: List an instructor's content - description: Retrieves a list of all the instructor's LMS content. - tags: - - Instructors - parameters: - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - email - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: post - description: Retrieve content for a specific list of one or more posts. Accepts a post `id` or comma separated list of post `id`s. - in: query - schema: - type: string - example: 123,456 - - name: post_exclude - description: Exclude content for a specific list of one or more posts. Accepts a post `id` or comma separated list of post `id`s. - in: query - schema: - type: string - example: 789,324 - - $ref: '#/components/parameters/PostType' - responses: - 200: - description: Successfully returned a list of the instructor's content. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - anyOf: - - $ref: '#/components/schemas/CourseResponse' - - $ref: '#/components/schemas/MembershipResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/lessons.yaml b/spec/paths/lessons.yaml deleted file mode 100644 index f4e9245d..00000000 --- a/spec/paths/lessons.yaml +++ /dev/null @@ -1,95 +0,0 @@ -get: - summary: List lessons - description: Retrieve a list of lessons. - tags: - - Lessons - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/Search' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - title - - date_created - - date_updated - - order - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - $ref: '#/components/parameters/PostStatus' - - name: parent - description: Filter lessons by the parent post (section) ID. - in: query - required: false - schema: - type: integer - minimum: 1 - example: 987 - - responses: - 200: - description: Successfully returned a list of lessons. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/LessonResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create a lesson - description: Create a new lesson object. - tags: - - Lessons - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/LessonRequest' - - required: - - title - - content - responses: - 201: - description: Successfully created the lesson. - content: - application/json: - schema: - $ref: '#/components/schemas/LessonResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/lessons@{id}.yaml b/spec/paths/lessons@{id}.yaml deleted file mode 100644 index 086c6009..00000000 --- a/spec/paths/lessons@{id}.yaml +++ /dev/null @@ -1,97 +0,0 @@ -parameters: - - name: id - in: path - description: Unique lesson Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a lesson - description: Retrieve the details of an existing lesson. - tags: - - Lessons - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/PostPassword' - responses: - 200: - description: Successfully retrieved the lesson. - content: - application/json: - schema: - $ref: '#/components/schemas/LessonResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a lesson - description: >- - Update the specified lesson by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Lessons - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/LessonRequest' - responses: - 200: - description: Successfully updated the lesson. - content: - application/json: - schema: - $ref: '#/components/schemas/LessonResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a lesson - description: Delete an existing lesson. - tags: - - Lessons - requestBody: - content: - application/json: - schema: - type: object - properties: - force: - description: Bypass the trash and force lesson deletion. - type: boolean - default: false - responses: - 200: - description: Successfully moved the lesson to the trash. - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/LessonResponse' - - type: object - properties: - status: - type: string - default: trash - 204: - description: Successfully deleted the lesson. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/memberships.yaml b/spec/paths/memberships.yaml deleted file mode 100644 index 2d7bdd1c..00000000 --- a/spec/paths/memberships.yaml +++ /dev/null @@ -1,86 +0,0 @@ -get: - summary: List memberships - description: Retrieve a list of memberships. - tags: - - Memberships - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/Search' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - title - - date_created - - date_updated - - menu_order - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - $ref: '#/components/parameters/PostStatus' - responses: - 200: - description: Successfully returned a list of memberships. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/MembershipResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create a membership - description: Create a new membership object. - tags: - - Memberships - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/MembershipRequest' - - required: - - title - - content - responses: - 201: - description: Successfully created the membership. - content: - application/json: - schema: - $ref: '#/components/schemas/MembershipResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/memberships@{id}.yaml b/spec/paths/memberships@{id}.yaml deleted file mode 100644 index 471139b2..00000000 --- a/spec/paths/memberships@{id}.yaml +++ /dev/null @@ -1,97 +0,0 @@ -parameters: - - name: id - in: path - description: Unique membership Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a membership - description: Retrieve the details of an existing membership. - tags: - - Memberships - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/PostPassword' - responses: - 200: - description: Successfully retrieved the membership. - content: - application/json: - schema: - $ref: '#/components/schemas/MembershipResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a membership - description: >- - Update the specified membership by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Memberships - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/MembershipRequest' - responses: - 200: - description: Successfully updated the membership. - content: - application/json: - schema: - $ref: '#/components/schemas/MembershipResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a membership - description: Delete an existing membership. - tags: - - Memberships - requestBody: - content: - application/json: - schema: - type: object - properties: - force: - description: Bypass the trash and force membership deletion. - type: boolean - default: false - responses: - 200: - description: Successfully moved the membership to the trash. - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/MembershipResponse' - - type: object - properties: - status: - type: string - default: trash - 204: - description: Successfully deleted the membership. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/memberships@{id}@enrollments.yaml b/spec/paths/memberships@{id}@enrollments.yaml deleted file mode 100644 index 45af64d3..00000000 --- a/spec/paths/memberships@{id}@enrollments.yaml +++ /dev/null @@ -1,72 +0,0 @@ -parameters: - - name: id - in: path - description: Unique membership Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - - -get: - summary: List membership enrollments - description: Retrieve a collection of an existing membership's enrollments. - tags: - - Memberships - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for the collection of results. - in: query - schema: - type: string - enum: - - date_updated - - date_created - default: date_updated - - $ref: '#/components/parameters/Include' - - name: status - description: Filter results to records matching the specified status. - in: query - required: false - schema: - $ref: '#/components/schemas/EnrollmentStatus' - - name: student - in: query - description: Limit results to a specific student or a list of students. Accepts a single student `id` or a comma separated list of student `id`s. - schema: - type: string - example: [1,2,3] - responses: - 200: - description: Successfully retrieved the membership's enrollments. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Enrollment' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' diff --git a/spec/paths/quiz-questions.yaml b/spec/paths/quiz-questions.yaml deleted file mode 100644 index 822bb08e..00000000 --- a/spec/paths/quiz-questions.yaml +++ /dev/null @@ -1,141 +0,0 @@ -get: - summary: List quiz questions - description: Retrieve a list of quiz questions. - tags: - - Quiz Questions - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/Search' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - schema: - type: string - enum: - - id - - title - - date_created - - date_updated - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: quiz - description: Filter quiz questions by the parent post (quiz) ID. - in: query - schema: - type: integer - minimum: 1 - example: 789 - - responses: - 200: - description: Successfully returned a list of quiz questions. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/QuizQuestionTypesResponseList' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create a quiz question - description: Create a new quiz question object. - tags: - - Quiz Questions - requestBody: - required: true - content: - application/json: - schema: - anyOf: - - title: Multiple Choice - allOf: - - required: - - title - - choices - - question_type - - $ref: '#/components/schemas/QuizQuestionTypeChoice' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: Picture Choice - allOf: - - required: - - title - - choices - - question_type - - $ref: '#/components/schemas/QuizQuestionTypePictureChoice' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: True / False - allOf: - - required: - - title - - choices - - question_type - - $ref: '#/components/schemas/QuizQuestionTypeTrueFalse' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: Content - allOf: - - required: - - title - - question_type - - $ref: '#/components/schemas/QuizQuestionTypeContent' - - $ref: '#/components/schemas/QuizQuestionRequest' - - - title: Fill in the Blank - allOf: - - required: - - title - - question_type - - $ref: '#/components/schemas/QuizQuestionTypeBlank' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: Long Answer - allOf: - - required: - - title - - question_type - - $ref: '#/components/schemas/QuizQuestionTypeLongAnswer' - - $ref: '#/components/schemas/QuizQuestionRequest' - - responses: - 201: - description: Successfully created the quiz question. - content: - application/json: - examples: - choice: - summary: Multiple Choice Question - value: {} - long_answer: - summary: Long Answer Question - value: {} - schema: - $ref: '#/components/schemas/QuizQuestionTypesResponseList' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/quiz-questions@{id}.yaml b/spec/paths/quiz-questions@{id}.yaml deleted file mode 100644 index 5a868a3a..00000000 --- a/spec/paths/quiz-questions@{id}.yaml +++ /dev/null @@ -1,100 +0,0 @@ -parameters: - - name: id - in: path - description: Unique quiz question identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a quiz question - description: Retrieve the details of an existing quiz question. - tags: - - Quiz Questions - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the quiz question. - content: - application/json: - schema: - $ref: '#/components/schemas/QuizQuestionTypesResponseList' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a quiz question - description: >- - Update the specified quiz question by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Quiz Questions - requestBody: - required: true - content: - application/json: - schema: - anyOf: - - title: Multiple Choice - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeChoice' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: Picture Choice - allOf: - - $ref: '#/components/schemas/QuizQuestionTypePictureChoice' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: True / False - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeTrueFalse' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: Content - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeContent' - - $ref: '#/components/schemas/QuizQuestionRequest' - - - title: Fill in the Blank - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeBlank' - - $ref: '#/components/schemas/QuizQuestionRequest' - - title: Long Answer - allOf: - - $ref: '#/components/schemas/QuizQuestionTypeLongAnswer' - - $ref: '#/components/schemas/QuizQuestionRequest' - - responses: - 200: - description: Successfully updated the quiz question. - content: - application/json: - schema: - $ref: '#/components/schemas/QuizQuestionTypesResponseList' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a quiz question - description: Delete an existing quiz question. - tags: - - Quiz Questions - responses: - 204: - description: Successfully deleted the quiz question. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/quizzes.yaml b/spec/paths/quizzes.yaml deleted file mode 100644 index 2a66fbfb..00000000 --- a/spec/paths/quizzes.yaml +++ /dev/null @@ -1,106 +0,0 @@ -get: - summary: List quizzes - description: Retrieve a list of quizzes. - tags: - - Quizzes - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/Search' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - schema: - type: string - enum: - - id - - title - - date_created - - date_updated - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: parent - description: Filter quizzes by the parent post (lesson) ID. - in: query - schema: - type: integer - minimum: 1 - example: 789 - - name: course - description: Filter quizzes by the parent couse ID. - in: query - schema: - type: integer - minimum: 1 - example: 1234 - - name: status - description: Filter quizzes by the post status. - in: query - schema: - type: string - enum: - - publish - - draft - - responses: - 200: - description: Successfully returned a list of quizzes. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/QuizResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create a quiz - description: Create a new quiz object. - tags: - - Quizzes - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/QuizRequest' - - required: - - title - - content - responses: - 201: - description: Successfully created the quiz. - content: - application/json: - schema: - $ref: '#/components/schemas/QuizResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/quizzes@{id}.yaml b/spec/paths/quizzes@{id}.yaml deleted file mode 100644 index 6a194ce3..00000000 --- a/spec/paths/quizzes@{id}.yaml +++ /dev/null @@ -1,74 +0,0 @@ -parameters: - - name: id - in: path - description: Unique Quiz Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a quiz - description: Retrieve the details of an existing quiz. - tags: - - Quizzes - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the quiz. - content: - application/json: - schema: - $ref: '#/components/schemas/QuizResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a quiz - description: >- - Update the specified quiz by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Quizzes - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/QuizRequest' - responses: - 200: - description: Successfully updated the quiz. - content: - application/json: - schema: - $ref: '#/components/schemas/QuizResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a quiz - description: Delete an existing quiz. - tags: - - Quizzes - responses: - 204: - description: Successfully deleted the quiz. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/sections.yaml b/spec/paths/sections.yaml deleted file mode 100644 index d1bae558..00000000 --- a/spec/paths/sections.yaml +++ /dev/null @@ -1,88 +0,0 @@ -get: - summary: List sections - description: Retrieve a list of sections. - tags: - - Sections - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - title - - date_created - - date_updated - - order - - relevance - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: parent - description: Filter sections by the parent post (course) ID. - in: query - required: false - schema: - type: integer - minimum: 1 - example: 1234 - responses: - 200: - description: Successfully returned a list of sections. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/SectionResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create a section - description: Create a new section object. - tags: - - Sections - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/SectionRequest' - responses: - 201: - description: Successfully created the section. - content: - application/json: - schema: - $ref: '#/components/schemas/SectionResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/sections@{id}.yaml b/spec/paths/sections@{id}.yaml deleted file mode 100644 index af93913e..00000000 --- a/spec/paths/sections@{id}.yaml +++ /dev/null @@ -1,74 +0,0 @@ -parameters: - - name: id - in: path - description: Unique Section Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a section - description: Retrieve the details of an existing section. - tags: - - Sections - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the section. - content: - application/json: - schema: - $ref: '#/components/schemas/SectionResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a section - description: >- - Update the specified section by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Sections - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/SectionRequest' - responses: - 200: - description: Successfully updated the section. - content: - application/json: - schema: - $ref: '#/components/schemas/SectionResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a section - description: Delete an existing section. - tags: - - Sections - responses: - 204: - description: Successfully deleted the section. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/sections@{id}@content.yaml b/spec/paths/sections@{id}@content.yaml deleted file mode 100644 index 2c909c99..00000000 --- a/spec/paths/sections@{id}@content.yaml +++ /dev/null @@ -1,69 +0,0 @@ -parameters: - - name: id - in: path - description: Unique section Identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: List section content - description: Retrieve a collection of an existing section's content. - tags: - - Sections - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - order - - id - - title - default: order - - $ref: '#/components/parameters/Include' - - name: parent - description: Filter results to those belonging to the specified parent. - in: query - required: false - schema: - type: integer - minimum: 1 - example: 987 - responses: - 200: - description: Successfully retrieved the section contents. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/LessonResponse' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' diff --git a/spec/paths/students.yaml b/spec/paths/students.yaml deleted file mode 100644 index 6fe7ca52..00000000 --- a/spec/paths/students.yaml +++ /dev/null @@ -1,116 +0,0 @@ -get: - summary: List students - description: Retrieves a list of all students. - tags: - - Students - parameters: - - $ref: '#/components/parameters/Context' - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - $ref: '#/components/parameters/SearchUsers' - - $ref: '#/components/parameters/SearchColumns' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - required: false - schema: - type: string - enum: - - id - - email - - name - - registered_date - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: enrolled_in - description: | - Retrieve only students enrolled in the specified course(s) and/or - membership(s). - - Accepts a single WP Post ID or a comma separated list of IDs. - in: query - required: false - schema: - type: string - example: [1,2,3] - - name: enrolled_not_in - description: | - Retrieve only students not enrolled in the specified course(s) and/or - membership(s). - - Accepts a single WP Post ID or a comma separated list of IDs. - in: query - required: false - schema: - type: string - example: [4,5,6] - - name: roles - description: | - Retrieve students by a specific role. - - Accepts a single role name or a comma separated list of role names. - in: query - required: false - schema: - type: string - example: [student,customer] - responses: - 200: - description: Successfully returned a list of students - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: | - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Student' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - - -post: - summary: Create a student - description: Creates a new student object. - tags: - - Students - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Student' - - required: - - email - responses: - 201: - description: Successfully created the student. - content: - application/json: - schema: - $ref: '#/components/schemas/Student' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/students@{id}.yaml b/spec/paths/students@{id}.yaml deleted file mode 100644 index 0e24cd21..00000000 --- a/spec/paths/students@{id}.yaml +++ /dev/null @@ -1,94 +0,0 @@ -parameters: - - name: id - description: Unique student Identifer. The WordPress User `ID`. - example: 123 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a student - description: Retrieve the details of an existing student. - tags: - - Students - parameters: - - $ref: '#/components/parameters/Context' - responses: - 200: - description: Successfully retrieved the student. - content: - application/json: - schema: - $ref: '#/components/schemas/Student' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a student - description: >- - Update the specified student by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Students - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/Student' - responses: - 200: - description: Successfully updated the student. - content: - application/json: - schema: - $ref: '#/components/schemas/Student' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a student - description: Delete an existing student. - tags: - - Students - requestBody: - content: - application/json: - schema: - type: object - properties: - reassign: - description: | - ID of a WordPress User. - - Any posts owned by the deleted user will be reassigned to this user. - - LMS content and statuses (enrollments, for example), are not reassigned. - - Default (passing `0` or nothing) delete's the users's content. - type: integer - minimum: 0 - default: 0 - example: 456 - responses: - 204: - description: Successfully deleted the student. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/students@{id}@enrollments.yaml b/spec/paths/students@{id}@enrollments.yaml deleted file mode 100644 index a78f824b..00000000 --- a/spec/paths/students@{id}@enrollments.yaml +++ /dev/null @@ -1,70 +0,0 @@ -parameters: - - name: id - description: Unique student Identifer. The WordPress User `ID`. - example: 123 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: List student enrollments - description: Retrieves a list of a student's enrollment records. - tags: - - Student Enrollments - parameters: - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - schema: - type: string - enum: - - date_updated - - date_created - default: date_updated - - name: status - description: Filter results to records matching the specified status. - in: query - required: false - schema: - $ref: '#/components/schemas/EnrollmentStatus' - - name: post - in: query - description: Limit results to a specific course or membership or a list of courses and/or memberships. Accepts a single post `id` or a comma separated list of post `id`s. - schema: - type: string - example: [1,2,3] - responses: - 200: - description: Successfully returned a list of a student's enrollment records. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Enrollment' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' diff --git a/spec/paths/students@{id}@enrollments@{post_id}.yaml b/spec/paths/students@{id}@enrollments@{post_id}.yaml deleted file mode 100644 index 03d74c6a..00000000 --- a/spec/paths/students@{id}@enrollments@{post_id}.yaml +++ /dev/null @@ -1,105 +0,0 @@ -parameters: - - name: id - description: Unique student Identifer. The WordPress User `ID`. - example: 123 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - - name: post_id - description: Unique course or membership Identifier. The WordPress Post `ID`. - example: 456 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Get student enrollment - description: Retrieves information about a student's enrollment in a course or membership. - tags: - - Student Enrollments - responses: - 200: - description: Successfully retrieved student's enrollment. - content: - application/json: - schema: - $ref: '#/components/schemas/Enrollment' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Create student enrollment - description: Create a new enrollment for a student in a course or membership. - tags: - - Student Enrollments - parameters: - - $ref: '#/components/parameters/EnrollmentTrigger' - responses: - 201: - description: Successfully created the student's enrollment. - content: - application/json: - schema: - $ref: '#/components/schemas/Enrollment' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -patch: - summary: Update student enrollment - description: Update an enrollment for a student in a course or membership. - tags: - - Student Enrollments - parameters: - - $ref: '#/components/parameters/EnrollmentTrigger' - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/Enrollment' - responses: - 200: - description: Successfully updated student's enrollment. - content: - application/json: - schema: - $ref: '#/components/schemas/Enrollment' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete student enrollment - description: Deletes the record of a student's enrollment in a course or membership. - tags: - - Student Enrollments - parameters: - - $ref: '#/components/parameters/EnrollmentTrigger' - responses: - 204: - description: Successfully deleted student's enrollment. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/students@{id}@progress@{post_id}.yaml b/spec/paths/students@{id}@progress@{post_id}.yaml deleted file mode 100644 index e770a407..00000000 --- a/spec/paths/students@{id}@progress@{post_id}.yaml +++ /dev/null @@ -1,78 +0,0 @@ -parameters: - - name: id - description: Unique student Identifer. The WordPress User `ID`. - example: 123 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - - name: post_id - description: Unique course, lesson, or section Identifer. The WordPress Post `ID`. - example: 456 - in: path - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Get student progress - description: Retrieves information about a student's progress through course content. - tags: - - Student Progress - responses: - 200: - description: Successfully retrieved student's progress. - content: - application/json: - schema: - $ref: '#/components/schemas/Progress' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update student progress - description: Update the status of a student's progress through course content. - tags: - - Student Progress - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/Progress' - responses: - 200: - description: Successfully updated student's progress. - content: - application/json: - schema: - $ref: '#/components/schemas/Progress' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete student progress - description: Deletes the record of a student's progress through course content. - tags: - - Student Progress - responses: - 204: - description: Successfully deleted the student. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/webhooks.yaml b/spec/paths/webhooks.yaml deleted file mode 100644 index 2efedcc3..00000000 --- a/spec/paths/webhooks.yaml +++ /dev/null @@ -1,89 +0,0 @@ -get: - summary: List webhooks - description: Retrieve a list of webhooks. - tags: - - Webhooks - parameters: - - $ref: '#/components/parameters/Page' - - $ref: '#/components/parameters/PerPage' - - $ref: '#/components/parameters/Order' - - name: orderby - description: Specify the sort field for a collection of results. - in: query - schema: - type: string - enum: - - id - - name - - created - - updated - default: id - - $ref: '#/components/parameters/Include' - - $ref: '#/components/parameters/Exclude' - - name: status - description: Filter results to those matching a specific status. - in: query - schema: - type: string - enum: - - active - - paused - - disabled - responses: - 200: - description: Successfully returned a list of webhooks. - headers: - Link: - description: Pagination links for the collection. - schema: - type: string - example: >- - ; rel="first", - ; rel="prev", - ; rel="next", - ; rel="last" - X-WP-Total: - $ref: '#/components/headers/PaginationTotalResults' - X-WP-TotalPages: - $ref: '#/components/headers/PaginationTotalPages' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/Webhook' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - -post: - summary: Create a webhook - description: Create a new webhook object. - tags: - - Webhooks - requestBody: - required: true - content: - application/json: - schema: - allOf: - - $ref: '#/components/schemas/Webhook' - - required: - - topic - - delivery_url - responses: - 201: - description: Successfully created the webhook. - content: - application/json: - schema: - $ref: '#/components/schemas/Webhook' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/spec/paths/webhooks@{id}.yaml b/spec/paths/webhooks@{id}.yaml deleted file mode 100644 index 014dc259..00000000 --- a/spec/paths/webhooks@{id}.yaml +++ /dev/null @@ -1,72 +0,0 @@ -parameters: - - name: id - in: path - description: Unique webhook identifier. The WordPress Post `ID`. - required: true - schema: - $ref: '#/components/schemas/ResourceId' - -get: - summary: Retrieve a webhook - description: Retrieve the details of an existing webhook. - tags: - - Webhooks - responses: - 200: - description: Successfully retrieved the webhook. - content: - application/json: - schema: - $ref: '#/components/schemas/Webhook' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -post: - summary: Update a webhook - description: >- - Update the specified webhook by setting the values of the parameters passed. - Any parameters not provided will be left unchanged. - tags: - - Webhooks - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/Webhook' - responses: - 200: - description: Successfully updated the webhook. - content: - application/json: - schema: - $ref: '#/components/schemas/Webhook' - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' - 404: - $ref: '#/components/responses/Error404' - -delete: - summary: Delete a webhook - description: Delete an existing webhook. - tags: - - Webhooks - responses: - 204: - description: Successfully deleted the webhook. - 400: - $ref: '#/components/responses/Error400' - 401: - $ref: '#/components/responses/Error401' - 403: - $ref: '#/components/responses/Error403' diff --git a/tests/assets/lifterlms-rest-en_US.mo b/tests/assets/lifterlms-rest-en_US.mo deleted file mode 100644 index 41b67dda8a96f1968a30947a5056c8777865b495..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 679 zcmZWn&2AGh5MBYN<<=`4%o%zA1a0LI1Z`6kX;-Y04dND@&2($JYp?8CNc#kRfu49b zo`rFuHc&!L{(n_y0H9Q@ly*DsUSa- z2!drvmhd#?$=fPTMRF+8j3-ATNr=p6@I(3L9&ytnmJv67osfjNbjT|!wQD6BD_8}x z`)itaNdAX^+Ivq)x*22x+>-@c=qqi0>W8pkH=9jZwu6-|KR32>g6V$ix^XsQJ2=*_ z#_1?5rp08xM%r0;YBYkTuC99;5n+RI-%6!NtiF`i0ge~dIX~X>eD@b%`9#-dt#l*U z@k(L%mFK25d~OC?gU7O^`#>)jb2|G38tiUlPustQ=P3u#O5Mc7J2M^C7VKdK_xF~* a7g|_L*~{KL%iaVhfRDe<6rsESI)4CG8_PQY diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index fb801a8e..00000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,78 +0,0 @@ -plugin_dir . '/includes/class-llms-rest-install.php'; - - // Adds filters so tables will be created during LLMS Core installs. - LLMS_REST_Install::init(); - parent::install(); - - add_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - } - - /** - * Load the plugin - * - * @since 1.0.0-beta.2 - * - * @return void - */ - public function load() { - - if ( $this->plugin_main ) { - require_once( $this->plugin_dir . '/' . $this->plugin_main ); - } - - parent::load(); - - } - -} - -global $llms_tests_bootstrap; -$llms_tests_bootstrap = new LLMS_REST_Tests_Bootstrap(); -return $llms_tests_bootstrap; diff --git a/tests/framework/class-llms-rest-unit-test-case-base.php b/tests/framework/class-llms-rest-unit-test-case-base.php deleted file mode 100644 index 4f899f9d..00000000 --- a/tests/framework/class-llms-rest-unit-test-case-base.php +++ /dev/null @@ -1,165 +0,0 @@ -keys()->create( array( - 'description' => 'Test Key', - 'user_id' => $user_id ? $user_id : $this->factory->user->create(), - 'permissions' => $permissions, - ) ); - - if ( $authorize ) { - $this->mock_authorization( $key->get( 'consumer_key_one_time' ), $key->get( 'consumer_secret' ) ); - } - - return $key; - - } - - /** - * Create multiple API Keys - * - * @since 1.0.0-beta.1 - * - * @param int $count Number of keys to create. - * @param string $permissions Define permissions for the keys. If not specified assigns a random permission to each key. - * @param int $user WP_User Id to assign the key to. If not supplied uses the user factory to create a new admin user for each created key. - * @return void - */ - protected function create_many_api_keys( $count, $permissions = 'rand', $user = null ) { - - $pems_available = array_keys( LLMS_REST_API()->keys()->get_permissions() ); - $num_pems = count( $pems_available ) - 1; - - $i = 1; - while ( $i <= $count ) { - - $pem = 'rand' === $permissions ? $pems_available[ rand( 0, $num_pems ) ] : $permissions; - $uid = $user ? $user : $this->factory->user->create( array( 'role' => 'administrator' ) ); - - $this->get_mock_api_key( $pem, $uid, false ); - $i++; - } - - } - - /** - * Create many webhooks. - * - * @since 1.0.0-beta.1 - * - * @param int $count Number to create. - * @param string $status Status or rand to use a random status. - * @param string $topic Topic or rand to use a random topic. - * @return void - */ - public function create_many_webhooks( $count, $status = 'rand', $topic = 'rand' ) { - - $statuses = array_keys( LLMS_REST_API()->webhooks()->get_statuses() ); - $num_statuses = count( $statuses ) - 1; - - $topics = array_keys( LLMS_REST_API()->webhooks()->get_topics() ); - $num_topics = count( $topics ) - 2; // don't use the custom "action" topic. - - $i = 1; - while ( $i <= $count ) { - - $args = array( - 'status' => 'rand' === $status ? $statuses[ rand( 0, $num_statuses ) ] : $status, - 'topic' => 'rand' === $topic ? $topics[ rand( 0, $num_topics ) ] : $topic, - 'delivery_url' => 'https://mock.tld', - ); - - LLMS_REST_API()->webhooks()->create( $args ); - $i++; - - } - - } - - /** - * Create a hook - * - * @since 1.0.0-beta.3 - * - * @param array $args Webhook creation args. - * @return LLMS_REST_Webhook - */ - protected function get_hook( $args = array() ) { - - return LLMS_REST_API()->webhooks()->create( $this->get_hook_args( $args ) ); - - } - - /** - * Retrieve default args for creating a hook - * - * @since 1.0.0-beta.3 - * - * @param array $args Webhook creation args. - * @return array - */ - protected function get_hook_args( $args = array() ) { - - return wp_parse_args( $args, array( - 'delivery_url' => 'https://mock.tld/200', - 'status' => 'active', - 'topic' => 'action.mock', - ) ); - - } - - /** - * Mock authorization headers. - * - * @since 1.0.0-beta.1 - * - * @param string $key Consumer key. - * @param string $secret Consumer secret. - * @return void - */ - protected function mock_authorization( $key = null, $secret = null ) { - - $_SERVER['HTTP_X_LLMS_CONSUMER_KEY'] = $key; - $_SERVER['HTTP_X_LLMS_CONSUMER_SECRET'] = $secret; - } - - /** - * test teardown. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function tear_down() { - - parent::tear_down(); - - // Remove possibly mocked headers. - unset( $_SERVER['HTTP_X_LLMS_CONSUMER_KEY'], $_SERVER['HTTP_X_LLMS_CONSUMER_SECRET'] ); - - } - -} diff --git a/tests/framework/class-llms-rest-unit-test-case-posts.php b/tests/framework/class-llms-rest-unit-test-case-posts.php deleted file mode 100644 index 47147511..00000000 --- a/tests/framework/class-llms-rest-unit-test-case-posts.php +++ /dev/null @@ -1,495 +0,0 @@ -remove_template_hooks(); - - // clean the db from this post type - global $wpdb; - $wpdb->delete( $wpdb->prefix . 'posts', array( 'post_type' => $this->post_type ) ); - } - - - /** - * Test getting links to terms based on the current user caps. - * - * @since 1.0.0-beta.8 - */ - public function test_get_links_terms() { - - if ( empty( $this->rest_taxonomies ) ) { - $this->markTestSkipped( 'No taxonomies to test' ); - return; - } - - // create a post first. - $llms_post = $this->factory->post->create( array( 'post_type' => $this->post_type ) ); - $llms_post = llms_get_post($llms_post); - - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $llms_post->get( 'id' ) ); - $links = $response->get_links(); - - // I expect no wp terms, as who made the request has no right caps to show the posts's taxonomies in rest. - $this->assertArrayNotHasKey( 'https://api.w.org/term', $links ); - - // same request with right caps. - $instructor = $this->factory->instructor->create(); - wp_set_current_user( $instructor ); - - // clean and register the taxonomies again so that the show_in_rest property is set to true. - foreach ( get_object_taxonomies( $this->post_type ) as $taxonomy ) { - unregister_taxonomy( $taxonomy ); - } - LLMS_Post_Types::register_taxonomies(); - - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $llms_post->get( 'id' ) ); - $links = $response->get_links(); - - // I expect wp terms, as who made the request has the right caps to show the llms_post's taxonomies in rest. - $this->assertArrayHasKey( 'https://api.w.org/term', $links ); - $this->assertEquals( - wp_list_pluck( wp_list_pluck($links['https://api.w.org/term'], 'attributes' ), 'taxonomy' ), - $this->rest_taxonomies - ); - - } - - /** - * Utility to compare an LLMS_Post with an array of data, tipically coming from a rest response. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.7 Fixed some expected properties not tested at all, and wrong excerpts. - * - * @param LLMS_Post_Model $llms_post An LLMS_Post_Model. - * @param array $llms_post_data An array of llms post data. - * @param string $context Optional. Default 'view'. - * @return void - */ - protected function llms_posts_fields_match( $llms_post, $llms_post_data, $context = 'view' ) { - - $password_required = post_password_required( $llms_post->get( 'id' ) ); - global $post; - $temp = $post; - $post = $llms_post->get( 'post' ); - - $expected = array( - 'id' => $llms_post->get( 'id' ), - 'title' => array( - 'raw' => $llms_post->get( 'title', true ), - 'rendered' => $llms_post->get( 'title' ), - ), - 'status' => $llms_post->get( 'status' ), - 'content' => array( - 'raw' => $llms_post->get( 'content', true ), - 'rendered' => $password_required ? '' : apply_filters( 'the_content', $llms_post->get( 'content', true ) ), - ), - 'excerpt' => array( - 'raw' => $llms_post->get( 'excerpt', true ), - 'rendered' => $password_required ? '' : apply_filters( 'the_excerpt', $llms_post->get( 'excerpt' ) ), - ), - 'date_created' => $llms_post->get( 'date', 'Y-m-d H:i:s' ), - 'date_created_gmt' => $llms_post->get( 'date_gmt', 'Y-m-d H:i:s' ), - 'date_updated' => $llms_post->get( 'modified', 'Y-m-d H:i:s' ), - 'date_updated_gmt' => $llms_post->get( 'modified_gmt', 'Y-m-d H:i:s' ), - ); - - if ( 'edit' !== $context ) { - unset( - $expected['content']['raw'], - $expected['excerpt']['raw'], - $expected['title']['raw'] - ); - } - - $expected = $this->filter_expected_fields( $expected, $llms_post ); - - /** - * The rtrim below is not ideal but at the moment we have templates printed after the llms_post summary (e.g. prerequisites) that, - * even when printing no data they still print "\n". Let's pretend we're not interested in testing the trailing "\n" presence. - */ - foreach ( $expected as $key => $value ) { - if ( ! isset( $llms_post_data[ $key ] ) ) { - continue; - } - if ( is_array( $value ) ) { - foreach ( $value as $k => $v ) { - if ( 'content' === $key ) { - if ( ! isset( $llms_post_data[ $key ][ $k ] ) ) { - continue; - } - $this->assertEquals( rtrim( $v, "\n" ), rtrim( $llms_post_data[ $key ][ $k ], "\n" ) ); - } else { - $this->assertEquals( $v, $llms_post_data[ $key ][ $k ] ); - } - } - } else { - if ( 'content' === $key ) { - $this->assertEquals( rtrim( $value, "\n" ), rtrim( $llms_post_data[ $key ], "\n" ) ); - } else { - $this->assertEquals( $value, $llms_post_data[ $key ] ); - } - } - } - - $post = $temp; - } - - /** - * Test collection params contain 'status' - * - * @since 1.0.0-beta.19 - * - * @return void - */ - public function test_collection_params_contain_status() { - if ( isset( $this->endpoint->get_item_schema()['properties']['status'] ) ) { - $this->assertContains( - 'status', - array_keys( $this->endpoint->get_collection_params() ) - ); - }else { - $this->assertNotContains( - 'status', - array_keys( $this->endpoint->get_collection_params() ) - ); - } - } - - /** - * Test collection filter by post status - * - * @since 1.0.0-beta.19 - * - * @return void - */ - public function test_filter_by_post_status() { - - // Skip those post types which have no status property. - if ( ! isset( $this->endpoint->get_item_schema()['properties']['status'] ) ){ - $this->markTestSkipped( sprintf( 'post status not available for %1$s', $this->post_type ) ); - } - - wp_set_current_user( - $this->factory->user->create( - array( - 'role' => 'administrator', - ) - ) - ); - - // Create two posts. - $posts = $this->factory->post->create_many( - 2, - array( - 'post_type' => $this->post_type, - ) - ); - - $response = $this->perform_mock_request( - 'GET', - $this->route - ); - $res_data = $response->get_data(); - $this->assertEquals( 2, count( $res_data ), $this->post_type ); - - // Make one of them 'draft'. - wp_update_post( - array( - 'ID' => $posts[0], - 'post_status' => 'draft', - ) - ); - - $response = $this->perform_mock_request( - 'GET', - $this->route - ); - // By default only published posts are returned. - $res_data = $response->get_data(); - $this->assertEquals( 1, count( $res_data ), $this->post_type ); - $this->assertEquals( $posts[1], $res_data[0]['id'], $this->post_type ); - - // Get only draft courses. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'status' => 'draft', - ) - ); - - $res_data = $response->get_data(); - $this->assertEquals( 1, count( $res_data ), $this->post_type ); - $this->assertEquals( $posts[0], $res_data[0]['id'], $this->post_type ); - - // Get both published and draft posts. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'status' => 'publish,draft', - ) - ); - - $res_data = $response->get_data(); - $this->assertEquals( 2, count( $res_data ), $this->post_type ); - - // Change user to someone who cannot edit drafts. - wp_set_current_user( - $this->factory->user->create( - array( - 'role' => 'subscriber', - ) - ) - ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'status' => 'draft', - ) - ); - // We expect an authorization error. - $this->assertResponseStatusEquals( 400, $response, $this->post_type ); - - // Change user to someone who cannot edit drafts generated by the admin. - $author = $this->factory->user->create( - array( - 'role' => 'instructor', - ) - ); - - wp_set_current_user( - $author - ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'status' => 'draft', - ) - ); - // We expect an empty list of posts. - $res_data = $response->get_data(); - $this->assertResponseStatusEquals( 200, $response, $this->post_type ); - $this->assertEquals( 0, count( $res_data ), $this->post_type ); - - // Check instructor will get their own drafts. - $post = $this->factory->post->create( - array( - 'post_type' => $this->post_type, - 'post_author' => $author, - 'post_status' => 'draft', - ) - ); - $llms_post = llms_get_post( $post ); - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'status' => 'draft', - ) - ); - $res_data = $response->get_data(); - - $this->assertEquals( 1, count( $res_data ), $this->post_type ); - $this->assertEquals( $post, $res_data[0]['id'], $this->post_type ); - - } - - - /** - * Test collection search. - * - * @since 1.0.0-beta.21 - * - * @return void - */ - public function test_search() { - - if ( ! LLMS_Unit_Test_Util::get_private_property_value( $this->endpoint, 'is_searchable' ) ) { - $this->markTestSkipped( - sprintf( - 'The %1$s endpoint is not searchable', - LLMS_Unit_Test_Util::get_private_property_value( $this->endpoint, 'rest_base' ) - ) - ); - } - - wp_set_current_user( - $this->factory->user->create( - array( - 'role' => 'administrator', - ) - ) - ); - - // Create two posts. - $post_match = $this->factory->post->create( - array( - 'post_type' => $this->post_type, - 'post_title' => 'Match when searching with the term "whatever"', - ) - ); - - $post_unmatch = $this->factory->post->create( - array( - 'post_type' => $this->post_type, - 'post_title' => 'This doesn\'t match the search', - ) - ); - // Access plans need a product id. - if ( 'llms_access_plan' === $this->post_type ) { - $course = $this->factory->post->create( array( 'post_type' => 'course' ) ); - llms_get_post( $post_match )->set( 'product_id', $course ); - llms_get_post( $post_unmatch )->set( 'product_id', $course ); - } - - $response = $this->perform_mock_request( - 'GET', - $this->route - ); - $res_data = $response->get_data(); - $this->assertEquals( 2, count( $res_data ), $this->post_type ); - - // Search. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => 'whatever', - ) - ); - $res_data = $response->get_data(); - $this->assertEquals( 1, count( $res_data ), $this->post_type ); - $this->assertEquals( $post_match, $res_data[0]['id'], $this->post_type ); - - // Search no matches. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => 'foreveryoung', - ) - ); - $res_data = $response->get_data(); - $this->assertEquals( 0, count( $res_data ), $this->post_type ); - - } - - /** - * Test updating post meta using the same value as the stored one. - * - * @since 1.0.0-beta.25 - * - * @return void - */ - public function test_update_meta_same_stored_value() { - - wp_set_current_user( - $this->factory->user->create( - array( - 'role' => 'administrator', - ) - ) - ); - - // Create a post type and get the resource. - $pt = $this->create_post_resource(); - - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $pt->ID, - ); - - // Update the resource with exactly the same data. - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $pt->ID, - $response->get_data() - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response, $this->post_type ); - - } - - /** - * Create a resource for this post type. - * - * @since 1.0.0-beta.25 - * - * @param array $params Array of request params. - * @return WP_Post - */ - protected function create_post_resource( $params = array() ) { - - $resource = $this->perform_mock_request( - 'POST', - $this->route, - array_merge( - array( - 'title' => sprintf( "A %s", $this->post_type ), - 'content' => sprintf( "Some content for %s", $this->post_type ), - ), - $params - ) - ); - - return get_post( $resource->get_data()['id'] ); - - } - - /** - * Utility to compare an LLMS_Post with an array of data, tipically coming from a rest response. - * - * Stub. - * - * @since 1.0.0-beta.1 - */ - protected function filter_expected_fields( $expected, $llms_post ) { - return $expected; - } - -} diff --git a/tests/framework/class-llms-rest-unit-test-case-server.php b/tests/framework/class-llms-rest-unit-test-case-server.php deleted file mode 100644 index 6c1979f0..00000000 --- a/tests/framework/class-llms-rest-unit-test-case-server.php +++ /dev/null @@ -1,400 +0,0 @@ -server = rest_get_server(); - - } - - /** - * Assert a WP_REST_Response code equals an expected code. - * - * @since 1.0.0-beta.1 - * - * @param string $expected Expected response code. - * @param WP_REST_Response $response Response object. - * @return void - */ - protected function assertResponseCodeEquals( $expected, WP_REST_Response $response ) { - - $data = $response->get_data(); - $this->assertEquals( $expected, $data['code'] ); - - } - - /** - * Assert a WP_REST_Response message equals an expected message. - * - * @since 1.0.0-beta.1 - * - * @param int $expected Expected response message. - * @param WP_REST_Response $response Response object. - * @return void - */ - protected function assertResponseMessageEquals( $expected, WP_REST_Response $response ) { - - $data = $response->get_data(); - $this->assertEquals( $expected, $data['message'] ); - - } - - /** - * Assert a WP_REST_Response status code equals an expected status code. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.18 Added optional message on failure as third param. - * - * @param int $expected Expected response http status code. - * @param WP_REST_Response $response Response object. - * @param string $message Optional. Message on failure. Default is empty string. - * @return void - */ - protected function assertResponseStatusEquals( $expected, WP_REST_Response $response, $msg = '' ) { - - $this->assertEquals( $expected, $response->get_status(), $msg ); - - } - - /** - * Test collection params contain 'search'. - * - * @since 1.0.0-beta.21 - * - * @return void - */ - public function test_collection_params_contain_search() { - - if ( ! isset( $this->endpoint ) ) { - $this->markTestSkipped( - sprintf( - 'No endpoint set, cannot check its collection params. (%1$s)', - get_class( $this ) - ) - ); - } - - if ( LLMS_Unit_Test_Util::get_private_property_value( $this->endpoint, 'is_searchable' ) ) { - $this->assertContains( - 'search', - array_keys( $this->endpoint->get_collection_params() ) - ); - } else { - $this->assertNotContains( - 'search', - array_keys( $this->endpoint->get_collection_params() ) - ); - } - } - - /** - * Test allowing 'relevance' orderby - * - * @since 1.0.0-beta.21 - * - * @return void - */ - public function test_allow_relevance_orderby() { - - if ( ! isset( $this->endpoint ) ) { - $this->markTestSkipped( - sprintf( - 'No endpoint set, cannot check its collection params. (%1$s)', - get_class( $this ) - ) - ); - } - - if ( ! LLMS_Unit_Test_Util::get_private_property_value( $this->endpoint, 'is_searchable' ) ) { - $this->markTestSkipped( - sprintf( - 'The %1$s endpoint is not searchable', - LLMS_Unit_Test_Util::get_private_property_value( $this->endpoint, 'rest_base' ) - ) - ); - } - - if ( ! in_array( 'relevance', (array) LLMS_Unit_Test_Util::get_private_property_value( $this->endpoint, 'orderby_properties' ), true ) ) { - $this->markTestSkipped( - sprintf( - 'The %1$s endpoint\'s orderby_properties property doesn\'t contain "relevance"', - LLMS_Unit_Test_Util::get_private_property_value( $this->endpoint, 'rest_base' ) - ) - ); - } - - // No search term defined. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'orderby' => 'relevance' - ) - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseMessageEquals( 'You need to define a search term to order by relevance.', $response ); - - // Search term defined. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'orderby' => 'relevance', - 'search' => 'a', - ) - ); - - // Fine. - $this->assertResponseStatusEquals( 200, $response ); - - } - - /** - * Parse the `Link` header to pull all links into an associative array of rel => uri - * - * @since 1.0.0-beta.1 - * - * @param WP_REST_Response $response Response object. - * @return array - */ - protected function parse_link_headers( WP_REST_Response $response ) { - - $headers = $response->get_headers(); - $links = isset( $headers['Link'] ) ? $headers['Link'] : ''; - - $parsed = array(); - if ( $links ) { - - foreach ( explode( ',', $links ) as $link ) { - preg_match( '/<(.*)>; rel="(.*)"/i', trim( $link, ',' ), $match ); - if ( 3 === count( $match ) ) { - $parsed[ $match[2] ] = $match[1]; - } - } - - } - - return $parsed; - - } - - /** - * Utility to perform pagination test - * - * @since 1.0.0-beta.7 - * @since 1.0.0-beta.11 Post revisions are now taken into account when comparing list of resource ids. - * @since 1.0.0-beta.17 Better accounting of the automatic creation of post revisions. - * - * @param string $route Optional. Request route, eg: '/llms/v1/courses'. Default empty string, will fall back on this->route. - * @param int $start_id Optional. The id of the first item. Default `1`. - * @param int $per_page Optional. The number of items per page. Default `10`. - * @param string $id_field Optional. The field name for the id item that should be present in the response. Set to empty to not perform any check. Default `'id'`. - * @param int $total Optional. Total expected items. Default `25` - * @param int|null $ids_step Optional. Ids difference between two subsequent resources. Default `null`. - * @return void - */ - protected function pagination_test( $route = '', $start_id = 1, $per_page = 10, $id_field = 'id', $total = 25, $ids_step = null ) { - - $route = empty( $route ) ? $this->route : $route; - $total_pages = (int) ceil( $total / $per_page ); - $initial_id = $start_id; - if ( is_null( $ids_step ) ) { - $ids_step = isset( $this->post_type ) && post_type_supports( $this->post_type, 'revisions' ) && ! empty( $this->generates_revision_on_creation ) ? 2 : 1; - } - - for ( $i = 1; $i <= $total_pages; $i++ ) { - - $args = array( 'per_page' => $per_page ); - if ( $i > 1 ) { - $args[ 'page' ] = $i; - } - - // Page $i. - $response = $this->perform_mock_request( 'GET', $route, array(), $args ); - - $body = $response->get_data(); - $headers = $response->get_headers(); - - $links = $this->parse_link_headers( $response ); - - $this->assertResponseStatusEquals( 200, $response ); - $this->assertEquals( $total, $headers['X-WP-Total'] ); - $this->assertEquals( $total_pages, $headers['X-WP-TotalPages'] ); - - // Pagination links check. - if ( 1 !== $total_pages ) { - switch ( $i ) : - // First page we expect only 'next' and 'last' links. - case 1 : $links_array = array( 'next', 'last' ); break; - // Last page we expect only 'first' and 'prev' links. - case $total_pages: $links_array = array( 'first', 'prev' ); break; - default : $links_array = array( 'first', 'prev', 'next', 'last' ); - endswitch; - - $this->assertEquals( $links_array, array_keys( $links ) ); - } - - if ( $id_field) { - $stop_id = ( $i !== $total_pages ) ? ( $start_id + ( $per_page * $ids_step ) - $ids_step ) : ( $initial_id + ( $total * $ids_step ) - $ids_step ); - $this->assertEquals( range( $start_id, $stop_id, $ids_step ), wp_list_pluck( $body, $id_field ) ); - $start_id += $per_page * $ids_step; - } - - } - - // Big per page. - $response = $this->perform_mock_request( 'GET', $route, array(), array( 'per_page' => $total + 10 ) ); - - // Check Pagination headers. - $headers = $response->get_headers(); - $this->assertEquals( $total, $headers['X-WP-Total'] ); - $this->assertEquals( 1, $headers['X-WP-TotalPages'] ); - - // No links because this is the only page. - $links = $this->parse_link_headers( $response ); - $this->assertEquals( array(), array_keys( $links ) ); - - // Out of bounds. - $response = $this->perform_mock_request( 'GET', $route, array(), array( 'per_page' => $per_page, 'page' => $total_pages + 1 ) ); - - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseCodeEquals( 'llms_rest_bad_request', $response ); - } - - /** - * Preform a mock WP_REST_Request - * - * @since 1.0.0-beta.1 - * - * @param string $method Request method. - * @param string $route Request route, eg: '/llms/v1/courses'. - * @param array $body Optional request body. - * @param array $query Optional query arguments. - * @return WP_REST_Response - */ - protected function perform_mock_request( $method, $route, $body = array(), $query = array() ) { - - $request = new WP_REST_Request( $method, $route ); - if ( $body ) { - $request->set_body_params( $body ); - } - if( $query ) { - $request->set_query_params( $query ); - } - return $this->server->dispatch( $request ); - - } - - /** - * Retrieve default properties from the endpoint schema - * - * @since 1.0.0-beta.18 - * - * @return array - */ - public function get_defaults() { - - $props = $this->endpoint->get_item_schema()['properties']; - $defaults = array(); - - foreach ( $props as $prop => $options ) { - if ( isset( $options['default'] ) ) { - $defaults[ $prop ] = $options['default']; - } - } - - return $defaults; - } - - /** - * Set default properties from the endpoint schema - * - * @since 1.0.0-beta.18 - * - * @return array - */ - public function set_defaults() { - - $this->defaults = $this->get_defaults(); - - } - - /** - * Unset the server. - * - * @since 1.0.0-beta.1 - */ - public function tear_down() { - - parent::tear_down(); - - global $wp_rest_server; - unset( $this->server ); - - $wp_rest_server = null; - - } - -} diff --git a/tests/unit-tests/admin/class-llms-rest-test-admin-form-controller.php b/tests/unit-tests/admin/class-llms-rest-test-admin-form-controller.php deleted file mode 100644 index 67181ec2..00000000 --- a/tests/unit-tests/admin/class-llms-rest-test-admin-form-controller.php +++ /dev/null @@ -1,531 +0,0 @@ -includes(); - include_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.notices.php'; - - $this->obj = new LLMS_REST_Admin_Form_Controller(); - - } - - /** - * Clean up admin notices between tests - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function tear_down() { - - parent::tear_down(); - foreach( LLMS_Admin_Notices::get_notices() as $id ) { - LLMS_Admin_Notices::delete_notice( $id ); - } - - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}lifterlms_webhooks" ); - - } - - /** - * Test no events are run on regular admin screens. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_handle_events_no_submit() { - - $this->assertFalse( $this->obj->handle_events() ); - - } - - /** - * Ensure required field errors are returned when creating a webhook. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_webhook_required_fields() { - - $data = array( - 'llms_rest_webhook_nonce' => wp_create_nonce( 'create-update-webhook' ), - ); - - // Missing topic required field. - $this->mockPostRequest( $data ); - $ret = $this->obj->handle_events(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_missing_topic', $ret ); - - // Missing delivery url. - $data['llms_rest_webhook_topic'] = 'course.created'; - $this->mockPostRequest( $data ); - $ret = $this->obj->handle_events(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_missing_delivery_url', $ret ); - - // Success. - // redirect and exit back to webooks's edit page. - $data['llms_rest_webhook_delivery_url'] = 'https://mock.tld'; - $this->mockPostRequest( $data ); - $this->expectException( LLMS_Unit_Test_Exception_Redirect::class ); - $this->expectExceptionMessage( 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=webhooks&edit-webhook=1 [301] YES' ); - - try { - $this->obj->handle_events(); - } catch ( LLMS_Unit_Test_Exception_Redirect $exception ) { - - $hook = LLMS_REST_API()->webhooks()->get( 1 ); - - $this->assertEquals( 'https://mock.tld', $hook->get( 'delivery_url' ) ); - $this->assertEquals( 'course.created', $hook->get( 'topic' ) ); - $this->assertEquals( 'disabled', $hook->get( 'status' ) ); - $this->assertEquals( 50, strlen( $hook->get( 'secret' ) ) ); - $this->assertEquals( 0, strpos( $hook->get( 'secret' ), 'Webhook created on ' ) ); - - throw $exception; - - } - - } - - /** - * Ensure all submittable fields are added to the hook on creation. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_webhook_all_fields() { - - $data = array( - 'llms_rest_webhook_nonce' => wp_create_nonce( 'create-update-webhook' ), - 'llms_rest_webhook_name' => 'Webhook Name', - 'llms_rest_webhook_topic' => 'course.created', - 'llms_rest_webhook_secret' => 'myawesomesecret', - 'llms_rest_webhook_delivery_url' => 'https://mock.tld', - 'llms_rest_webhook_status' => 'active', - ); - - $this->mockPostRequest( $data ); - $this->expectException( LLMS_Unit_Test_Exception_Redirect::class ); - $this->expectExceptionMessage( 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=webhooks&edit-webhook=1 [301] YES' ); - - try { - $this->obj->handle_events(); - } catch ( LLMS_Unit_Test_Exception_Redirect $exception ) { - - $hook = LLMS_REST_API()->webhooks()->get( 1 ); - - $this->assertEquals( $data['llms_rest_webhook_name'], $hook->get( 'name' ) ); - $this->assertEquals( $data['llms_rest_webhook_topic'], $hook->get( 'topic' ) ); - $this->assertEquals( $data['llms_rest_webhook_secret'], $hook->get( 'secret' ) ); - $this->assertEquals( $data['llms_rest_webhook_delivery_url'], $hook->get( 'delivery_url' ) ); - $this->assertEquals( $data['llms_rest_webhook_status'], $hook->get( 'status' ) ); - - throw $exception; - - } - - } - - /** - * Test creating a webhook with a custom action. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_webhook_custom_action() { - - $data = array( - 'llms_rest_webhook_nonce' => wp_create_nonce( 'create-update-webhook' ), - 'llms_rest_webhook_name' => 'Webhook Name', - 'llms_rest_webhook_topic' => 'action', - 'llms_rest_webhook_secret' => 'myawesomesecret', - 'llms_rest_webhook_delivery_url' => 'https://mock.tld', - 'llms_rest_webhook_status' => 'active', - ); - - $this->mockPostRequest( $data ); - $ret = $this->obj->handle_events(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_topic', $ret ); - - $data['llms_rest_webhook_action'] = 'mock'; - $this->mockPostRequest( $data ); - - $this->expectException( LLMS_Unit_Test_Exception_Redirect::class ); - $this->expectExceptionMessage( 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=webhooks&edit-webhook=1 [301] YES' ); - - try { - $this->obj->handle_events(); - } catch ( LLMS_Unit_Test_Exception_Redirect $exception ) { - - $hook = LLMS_REST_API()->webhooks()->get( 1 ); - - $this->assertEquals( 'action.mock', $hook->get( 'topic' ) ); - - throw $exception; - - } - - } - - /** - * Test upserting a webhook with weird or invalid ids. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_upsert_webhook_weird_ids() { - - $data = array( - 'llms_rest_webhook_nonce' => wp_create_nonce( 'create-update-webhook' ), - ); - - $tests = array( - 'llms_rest_api_webhook_not_found' => array( 999, '999', ), // Will preform a lookup for numeric values. - 'llms_rest_webhook_missing_topic' => array( 0, '0', 'string', false, null, '', ' ' ), // Will attempt to create. - ); - foreach ( $tests as $code => $ids ) { - - foreach ( $ids as $id ) { - - $data['llms_rest_webhook_id'] = $id; - $this->mockPostRequest( $data ); - - $ret = $this->obj->handle_events(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( $code, $ret ); - - } - - } - - } - - /** - * Test required fields for upserting a webhook. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_webhook_required_fields() { - - $hook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.com', - 'topic' => 'course.created', - ) ); - - // Can't nullify delivery url. - $this->mockPostRequest( array( - 'llms_rest_webhook_nonce' => wp_create_nonce( 'create-update-webhook' ), - 'llms_rest_webhook_id' => $hook->get( 'id' ), - 'llms_rest_webhook_delivery_url' => '', - ) ); - $ret = $this->obj->handle_events(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_delivery_url', $ret ); - - } - - - /** - * Test updating an existing webhook. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_webhook() { - - $hook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.com', - 'topic' => 'course.created', - ) ); - - $data = array( - 'llms_rest_webhook_nonce' => wp_create_nonce( 'create-update-webhook' ), - 'llms_rest_webhook_id' => $hook->get( 'id' ), - - 'llms_rest_webhook_name' => 'Webhook Name', - 'llms_rest_webhook_topic' => 'course.created', - 'llms_rest_webhook_secret' => 'myawesomesecret', - 'llms_rest_webhook_delivery_url' => 'https://mock.tld', - 'llms_rest_webhook_status' => 'active', - ); - - $this->mockPostRequest( $data ); - - $this->assertTrue( $this->obj->handle_events() ); - - $hook = LLMS_REST_API()->webhooks()->get( $hook->get( 'id' ) ); - - $this->assertEquals( $data['llms_rest_webhook_name'], $hook->get( 'name' ) ); - $this->assertEquals( $data['llms_rest_webhook_topic'], $hook->get( 'topic' ) ); - $this->assertEquals( $data['llms_rest_webhook_secret'], $hook->get( 'secret' ) ); - $this->assertEquals( $data['llms_rest_webhook_delivery_url'], $hook->get( 'delivery_url' ) ); - $this->assertEquals( $data['llms_rest_webhook_status'], $hook->get( 'status' ) ); - - } - - /** - * Test updating a webhook with a custom action. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_webhook_custom_action() { - - $hook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.com', - 'topic' => 'course.created', - ) ); - - $data = array( - 'llms_rest_webhook_nonce' => wp_create_nonce( 'create-update-webhook' ), - 'llms_rest_webhook_id' => $hook->get( 'id' ), - - 'llms_rest_webhook_topic' => 'action', - ); - - $this->mockPostRequest( $data ); - $ret = $this->obj->handle_events(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_topic', $ret ); - - $data['llms_rest_webhook_action'] = 'mock'; - $this->mockPostRequest( $data ); - - $this->obj->handle_events(); - - $hook = LLMS_REST_API()->webhooks()->get( $hook->get( 'id' ) ); - - $this->assertEquals( 'action.mock', $hook->get( 'topic' ) ); - - } - - /** - * Test the "Revoke" nonce URL for deleting api keys. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Store key id in a variable so we can look it up later. - * - * @return void - */ - public function test_revoke_key() { - - // Key id but no nonce. - $this->mockGetRequest( array( - 'revoke-key' => 9324234, - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Nonce present but no key. - $this->mockGetRequest( array( - 'key-revoke-nonce' => wp_create_nonce( 'revoke' ), - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Nonce & key but key is fake. - $this->mockGetRequest( array( - 'revoke-key' => 9324234, - 'key-revoke-nonce' => wp_create_nonce( 'revoke' ), - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Nonce is fake. - $this->mockGetRequest( array( - 'revoke-key' => 9324234, - 'key-revoke-nonce' => 'arstarstarst', - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Real key and real nonce. - $key = LLMS_REST_API()->keys()->create( array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ) ); - $key_id = $key->get( 'id' ); - $this->mockGetRequest( array( - 'revoke-key' => $key->get( 'id' ), - 'key-revoke-nonce' => wp_create_nonce( 'revoke' ), - ) ); - - // redirect and exit back to the keys list. - $this->expectException( LLMS_Unit_Test_Exception_Redirect::class ); - $this->expectExceptionMessage( 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=keys [302] YES' ); - - try { - - $this->obj->handle_events(); - - } catch ( LLMS_Unit_Test_Exception_Redirect $exception ) { - - // Key will no longer exist. - $this->assertFalse( LLMS_REST_API()->keys()->get( $key_id ) ); - - // Should have an admin notice. - $notices = LLMS_Admin_Notices::get_notices(); - $this->assertEquals( 1, count( $notices ) ); - $this->assertEquals( 'The API Key has been successfully deleted.', LLMS_Admin_Notices::get_notice( $notices[0] )['html'] ); - - throw $exception; - } - - } - - /** - * Test the delete nonce URL for deleting webhooks. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Store webhook id in a variable so we can look it up later. - * - * @return void - */ - public function test_delete_webhook() { - - // Key id but no nonce. - $this->mockGetRequest( array( - 'delete-webhook' => 9324234, - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Nonce present but no key. - $this->mockGetRequest( array( - 'delete-webhook-nonce' => wp_create_nonce( 'delete' ), - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Nonce & key but key is fake. - $this->mockGetRequest( array( - 'delete-webhook' => 9324234, - 'delete-webhook-nonce' => wp_create_nonce( 'delete' ), - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Nonce is fake. - $this->mockGetRequest( array( - 'delete-webhook' => 9324234, - 'delete-webhook-nonce' => 'arstarstarst', - ) ); - $this->assertFalse( $this->obj->handle_events() ); - - // Real webhook and real nonce. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.tld', - ) ); - $webhook_id = $webhook->get( 'id' ); - $this->mockGetRequest( array( - 'delete-webhook' => $webhook->get( 'id' ), - 'delete-webhook-nonce' => wp_create_nonce( 'delete' ), - ) ); - - // redirect and exit back to the webhooks list. - $this->expectException( LLMS_Unit_Test_Exception_Redirect::class ); - $this->expectExceptionMessage( 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=webhooks [302] YES' ); - - try { - - $this->obj->handle_events(); - - } catch ( LLMS_Unit_Test_Exception_Redirect $exception ) { - - // Key will no longer exist. - $this->assertFalse( LLMS_REST_API()->webhooks()->get( $webhook_id ) ); - - // Should have an admin notice. - $notices = LLMS_Admin_Notices::get_notices(); - $this->assertEquals( 1, count( $notices ) ); - $this->assertEquals( 'The webhook has been successfully deleted.', LLMS_Admin_Notices::get_notice( $notices[0] )['html'] ); - - throw $exception; - } - - } - - /** - * Test prepare_key_download() method - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_prepare_key_download() { - - // Missing key & id. - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->obj, 'prepare_key_download' ) ); - - // Missing CK. - $this->mockGetRequest( array( - 'id' => 1, - ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->obj, 'prepare_key_download' ) ); - - // Missing ID. - $this->mockGetRequest( array( - 'ck' => 'arst', - ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->obj, 'prepare_key_download' ) ); - - $key = $this->get_mock_api_key(); - - // Fake ID. - $this->mockGetRequest( array( - 'id' => $key->get( 'id' ) + 1, - 'ck' => 'arst', - ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->obj, 'prepare_key_download' ) ); - - // Fake CK. - $this->mockGetRequest( array( - 'id' => $key->get( 'id' ), - 'ck' => 'arst', - ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->obj, 'prepare_key_download' ) ); - - $this->mockGetRequest( array( - 'id' => $key->get( 'id' ), - 'ck' => base64_encode( $key->get( 'consumer_key_one_time' ) ), - ) ); - $this->assertEquals( array( - 'fn' => 'Test-Key.txt', - 'ck' => $key->get( 'consumer_key_one_time' ), - 'cs' => $key->get( 'consumer_secret' ), - ), LLMS_Unit_Test_Util::call_method( $this->obj, 'prepare_key_download' ) ); - - } - -} diff --git a/tests/unit-tests/admin/class-llms-rest-test-admin-settings-page.php b/tests/unit-tests/admin/class-llms-rest-test-admin-settings-page.php deleted file mode 100644 index b3d36e10..00000000 --- a/tests/unit-tests/admin/class-llms-rest-test-admin-settings-page.php +++ /dev/null @@ -1,106 +0,0 @@ -includes(); - include_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.notices.php'; - include_once LLMS_REST_API_PLUGIN_DIR . 'includes/admin/class-llms-rest-admin-settings-page.php'; - $this->page = new LLMS_REST_Admin_Settings_Page(); - - $this->user = $this->factory->user->create( array( 'role' => 'administrator' ) ); - - } - - /** - * Tear down the test case. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function tear_down() { - parent::tear_down(); - } - - /** - * test hooks are added from the constructor - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_hooks() { - - $this->assertEquals( 20, has_filter( 'lifterlms_settings_tabs_array', array( $this->page, 'add_settings_page' ) ) ); - $this->assertEquals( 10, has_action( 'lifterlms_sections_rest-api', array( $this->page, 'output_sections_nav' ) ) ); - $this->assertEquals( 10, has_action( 'lifterlms_settings_rest-api', array( $this->page, 'output' ) ) ); - - $this->assertEquals( 10, has_action( 'lifterlms_settings_save_rest-api', array( 'LLMS_Rest_Admin_Settings_API_Keys', 'save' ) ) ); - - $this->assertEquals( 10, has_filter( 'llms_settings_rest-api_has_save_button', '__return_false' ) ); - $this->assertEquals( 10, has_filter( 'llms_table_get_table_classes', array( $this->page, 'get_table_classes' ) ) ); - - $this->assertEquals( 10, has_action( 'lifterlms_admin_field_title-with-html', array( $this->page, 'output_title_field' ) ) ); - - } - - /** - * Test get_current_section() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_current_section() { - - // Default with no permissions. - $this->assertEquals( 'main', LLMS_Unit_Test_Util::call_method( $this->page, 'get_current_section' ) ); - - // Default with permissions. - wp_set_current_user( $this->user ); - $this->assertEquals( 'keys', LLMS_Unit_Test_Util::call_method( $this->page, 'get_current_section' ) ); - - } - - /** - * Test get_sections() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_sections() { - - // None without permissions. - $this->assertEquals( array(), $this->page->get_sections() ); - - // With permissions. - wp_set_current_user( $this->user ); - $this->assertEquals( array( 'keys', 'webhooks' ), array_keys( $this->page->get_sections() ) ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-api-key.php b/tests/unit-tests/class-llms-rest-test-api-key.php deleted file mode 100644 index 94249cd0..00000000 --- a/tests/unit-tests/class-llms-rest-test-api-key.php +++ /dev/null @@ -1,114 +0,0 @@ -keys()->create( array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ) ); - - $this->assertEquals( - 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=keys&edit-key=' . $key->get( 'id' ), - $key->get_edit_link() - ); - - } - - /** - * Test the get_delete_link() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_delete_link() { - - $key = LLMS_REST_API()->keys()->create( array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ) ); - - $link = $key->get_delete_link(); - - $this->assertEquals( 0, strpos( 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=keys&revoke-key=' . $key->get( 'id' ), $key->get_delete_link() ) ); - parse_str( wp_parse_url( $link, PHP_URL_QUERY ), $parts ); - $this->assertTrue( array_key_exists( 'key-revoke-nonce', $parts ) ); - - } - - /** - * Test has_permissions() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_has_permission() { - - $key = $this->get_mock_api_key( 'read' ); - $tests = array( - 'HEAD' => true, - 'GET' => true, - 'POST' => false, - 'PUT' => false, - 'PATCH' => false, - 'DELETE' => false, - 'OPTIONS' => true, - 'FAKE' => false, - ); - foreach ( $tests as $method => $expect ) { - $this->assertEquals( $expect, $key->has_permission( $method ), $method ); - } - - $key = $this->get_mock_api_key( 'write' ); - $tests = array( - 'HEAD' => false, - 'GET' => false, - 'POST' => true, - 'PUT' => true, - 'PATCH' => true, - 'DELETE' => true, - 'OPTIONS' => true, - 'FAKE' => false, - ); - foreach ( $tests as $method => $expect ) { - $this->assertEquals( $expect, $key->has_permission( $method ), $method ); - } - - $key = $this->get_mock_api_key( 'read_write' ); - $tests = array( - 'HEAD' => true, - 'GET' => true, - 'POST' => true, - 'PUT' => true, - 'PATCH' => true, - 'DELETE' => true, - 'OPTIONS' => true, - 'FAKE' => false, - ); - foreach ( $tests as $method => $expect ) { - $this->assertEquals( $expect, $key->has_permission( $method ), $method ); - } - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-api-keys-query.php b/tests/unit-tests/class-llms-rest-test-api-keys-query.php deleted file mode 100644 index 90636d07..00000000 --- a/tests/unit-tests/class-llms-rest-test-api-keys-query.php +++ /dev/null @@ -1,265 +0,0 @@ -factory is set. - * @version 1.0.0-beta.8 - */ -class LLMS_REST_Test_API_Keys_Query extends LLMS_REST_Unit_Test_Case_Base { - - /** - * Setup test. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.8 Added call to parent::setup() so that $this->factory is set. - * - * @return void - */ - public function set_up() { - - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}lifterlms_api_keys" ); - parent::set_up(); - } - - /** - * Test the get_keys() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_keys() { - - $query = new LLMS_REST_API_Keys_Query(); - $this->assertEquals( array(), $query->get_keys() ); - - $this->create_many_api_keys( 3 ); - - foreach ( array( true, false ) as $with_filters ) { - - $query = new LLMS_REST_API_Keys_Query( array( 'suppress_filters' => $with_filters ) ); - $keys = $query->get_keys(); - foreach ( $keys as $key ) { - $this->assertTrue( is_a( $key, 'LLMS_REST_API_Key' ) ); - } - - } - - - } - - /** - * Test the include and exclude arguments. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta-24 Fixed access of protected LLMS_Abstract_Query properties. - * - * @return void - */ - public function test_query_args_include_and_exclude() { - - $this->create_many_api_keys( 5 ); - $query = new LLMS_REST_API_Keys_Query( array() ); - $ids = range( 1, 5 ); - - $this->create_many_api_keys( 5 ); - - $query = new LLMS_REST_API_Keys_Query( array( - 'include' => $ids, - ) ); - $this->assertEquals( 5, $query->get_found_results() ); - $this->assertEquals( $ids, wp_list_pluck( $query->get_results(), 'id' ) ); - - $query = new LLMS_REST_API_Keys_Query( array( - 'exclude' => $ids, - ) ); - $this->assertEquals( 5, $query->get_found_results() ); - $this->assertEquals( range( 6, 10 ), wp_list_pluck( $query->get_results(), 'id' ) ); - - } - - /** - * Test pagination of query results. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta-24 Fixed access of protected LLMS_Abstract_Query properties. - * - * @return void - */ - public function test_query_args_pagination() { - - $this->create_many_api_keys( 25 ); - - $query = new LLMS_REST_API_Keys_Query( array() ); - $this->assertEquals( 10, count( $query->get_results() ) ); - $this->assertEquals( 25, $query->get_found_results() ); - $this->assertEquals( 3, $query->get_max_pages() ); - $this->assertEquals( range( 1, 10 ), wp_list_pluck( $query->get_results(), 'id' ) ); - $this->assertTrue( $query->is_first_page() ); - - $query = new LLMS_REST_API_Keys_Query( array( 'page' => 2 ) ); - $this->assertEquals( range( 11, 20 ), wp_list_pluck( $query->get_results(), 'id' ) ); - - $query = new LLMS_REST_API_Keys_Query( array( 'page' => 3 ) ); - $this->assertEquals( range( 21, 25 ), wp_list_pluck( $query->get_results(), 'id' ) ); - $this->assertTrue( $query->is_last_page() ); - - } - - /** - * Test the permissions arguments. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta-24 Fixed access of protected LLMS_Abstract_Query properties. - * - * @return void - */ - public function test_query_args_permissions() { - - $this->create_many_api_keys( 5, 'read' ); - $this->create_many_api_keys( 5, 'read_write' ); - $this->create_many_api_keys( 5, 'write' ); - - $query = new LLMS_REST_API_Keys_Query( array() ); - $this->assertEquals( 15, $query->get_found_results() ); - - foreach ( array_keys( LLMS_REST_API()->keys()->get_permissions() ) as $pem ) { - - $query = new LLMS_REST_API_Keys_Query( array( 'permissions' => $pem ) ); - $this->assertEquals( 5, $query->get_found_results() ); - - } - - } - - /** - * Test setting up default query args. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_query_args_setup_with_defaults() { - - $query = new LLMS_REST_API_Keys_Query(); - - $args = array( - 'include' => array(), - 'exclude' => array(), - 'permissions' => '', - 'user' => array(), - 'user_not_in' => array(), - 'page' => 1, - 'per_page' => 10, - 'sort' => array( - 'id' => 'ASC' - ), - ); - - foreach ( $args as $arg => $expect ) { - $this->assertEquals( $expect, $query->get( $arg ), $arg ); - } - - } - - /** - * Tests setting up all possible arguments with custom arguments. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_query_args_setup_with_custom() { - - $args = array( - 'include' => array( 1, 2, 3 ), - 'exclude' => array( 4, 5, 6 ), - 'permissions' => 'read', - 'user' => array( 3 ), - 'user_not_in' => array( 234, 432 ), - 'page' => 5, - 'per_page' => 500, - 'sort' => array( - 'description' => 'ASC', - 'id' => 'DESC', - ), - ); - - $query = new LLMS_REST_API_Keys_Query( $args ); - - foreach ( $args as $arg => $expect ) { - $this->assertEquals( $expect, $query->get( $arg ), $arg ); - } - - } - - /** - * Merge default with custom arguments on setup. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_query_args_setup_with_merge() { - - $args = array( - 'include' => array( 1, 2, 3 ), - 'exclude' => array( 4, 5, 6 ), - 'sort' => array( - 'description' => 'ASC', - 'id' => 'DESC', - ), - ); - - $query = new LLMS_REST_API_Keys_Query( $args ); - - $args['page'] = 1; - $args['per_page'] = 10; - $args['permissions'] = ''; - $args['user'] = array(); - $args['user_not_in'] = array(); - - foreach ( $args as $arg => $expect ) { - $this->assertEquals( $expect, $query->get( $arg ), $arg ); - } - - } - - /** - * Test the users include and exclude arguments. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta-24 Fixed access of protected LLMS_Abstract_Query properties. - * - * @return void - */ - public function test_query_args_users_in_and_not_in() { - - $uid = $this->factory->user->create(); - - $this->create_many_api_keys( 5 ); - $this->create_many_api_keys( 5, 'read', $uid ); - - $query = new LLMS_REST_API_Keys_Query( array( - 'user' => $uid, - ) ); - $res_1 = wp_list_pluck( $query->get_results(), 'id' ); - $this->assertEquals( 5, $query->get_found_results() ); - - $query = new LLMS_REST_API_Keys_Query( array( - 'user_not_in' => $uid, - ) ); - $res_2 = wp_list_pluck( $query->get_results(), 'id' ); - $this->assertEquals( 5, $query->get_found_results() ); - $this->assertTrue( $res_1 !== $res_2 ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-api-keys.php b/tests/unit-tests/class-llms-rest-test-api-keys.php deleted file mode 100644 index 06c51260..00000000 --- a/tests/unit-tests/class-llms-rest-test-api-keys.php +++ /dev/null @@ -1,322 +0,0 @@ -keys = LLMS_REST_API()->keys(); - - } - - /** - * Test all potential errors encountered during API Key creation. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_errors() { - - // Can't create when an ID is supplied. - $ret = $this->keys->create( array( - 'id' => 1, - ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_exists', $ret ); - - $data = array(); - - // No description. - $ret = $this->keys->create( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_missing_description', $ret ); - - $data['description'] = 'Mock key description'; - - // No user_ids. - foreach( array( '0', 0, '' ) as $uid ) { - $data['user_id'] = $uid; - $ret = $this->keys->create( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_missing_user_id', $ret ); - } - - // Invalid user_id. - $data['user_id'] = 92349234; - $ret = $this->keys->create( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_invalid_user_id', $ret ); - - $data['user_id'] = $this->factory->user->create(); - - // Invalid permissions. - $data['permissions'] = 'fake'; - $ret = $this->keys->create( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_invalid_permissions', $ret ); - - } - - /** - * Test the success of the create() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_success() { - - $expected_actions = did_action( 'llms_rest_api_key_created' ) + 1; - - // Use default permissions. - $data = array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ); - $ret = $this->keys->create( $data ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_api_key_created' ) ); - $this->assertTrue( is_a( $ret, 'LLMS_REST_API_Key' ) ); - $this->assertTrue( $ret->exists() ); - $this->assertTrue( ! empty( $ret->get( 'consumer_key_one_time' ) ) ); - $this->assertEquals( llms_rest_api_hash( $ret->get( 'consumer_key_one_time' ) ), $ret->get( 'consumer_key' ) ); - $this->assertEquals( 'read', $ret->get( 'permissions' ) ); - $this->assertEquals( substr( $ret->get( 'consumer_key_one_time' ), -7 ), $ret->get( 'truncated_key' ) ); - $this->assertEquals( $data['description'], $ret->get( 'description' ) ); - $this->assertEquals( $data['user_id'], $ret->get( 'user_id' ) ); - $this->assertTrue( 0 === strpos( $ret->get( 'consumer_secret' ), 'cs_' ) ); - - // Create a key for each valid permission. - foreach ( array_keys( $this->keys->get_permissions() ) as $permission ) { - - $expected_actions++; - - $data = array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - 'permissions' => $permission, - ); - $ret = $this->keys->create( $data ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_api_key_created' ) ); - $this->assertTrue( is_a( $ret, 'LLMS_REST_API_Key' ) ); - $this->assertTrue( $ret->exists() ); - $this->assertTrue( ! empty( $ret->get( 'consumer_key_one_time' ) ) ); - $this->assertEquals( llms_rest_api_hash( $ret->get( 'consumer_key_one_time' ) ), $ret->get( 'consumer_key' ) ); - $this->assertEquals( $permission, $ret->get( 'permissions' ) ); - $this->assertEquals( substr( $ret->get( 'consumer_key_one_time' ), -7 ), $ret->get( 'truncated_key' ) ); - $this->assertEquals( $data['description'], $ret->get( 'description' ) ); - $this->assertEquals( $data['user_id'], $ret->get( 'user_id' ) ); - $this->assertTrue( 0 === strpos( $ret->get( 'consumer_secret' ), 'cs_' ) ); - - } - - } - - /** - * Test the delete() method. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Store key id for use after it's deleted. - * - * @return void - */ - public function test_delete() { - - $expected_actions = did_action( 'llms_rest_api_key_deleted' ) + 1; - - // Invalid key. - $this->assertFalse( $this->keys->delete( 99993423423 ) ); - - // Create a mock key to work with. - $orig = $this->keys->create( array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ) ); - $id = $orig->get( 'id' ); - - // Returns true. - $this->assertTrue( $this->keys->delete( $id ) ); - - // Action was run. - $this->assertEquals( $expected_actions, did_action( 'llms_rest_api_key_deleted' ) ); - - // Can't find via new get. - $this->assertFalse( $this->keys->get( $id ) ); - - } - - /** - * Test the get() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get() { - - // Invalid Key. - $this->assertFalse( $this->keys->get( 99993423423 ) ); - - // Create a mock key to work with. - $orig = $this->keys->create( array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ) ); - - // Key exists. - $ret = $this->keys->get( $orig->get( 'id' ) ); - $this->assertTrue( is_a( $ret, 'LLMS_REST_API_Key' ) ); - $this->assertEquals( $orig->get( 'consumer_key' ), $ret->get( 'consumer_key' ) ); - $this->assertEquals( $orig->get( 'consumer_secret' ), $ret->get( 'consumer_secret' ) ); - $this->assertEquals( llms_rest_api_hash( $orig->get( 'consumer_key_one_time' ) ), $ret->get( 'consumer_key' ) ); - - } - - /** - * Test the `get_admin_url()` method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_admin_url() { - - $this->assertEquals( 'http://example.org/wp-admin/admin.php?page=llms-settings&tab=rest-api§ion=keys', $this->keys->get_admin_url() ); - - } - - /** - * Test the get_permissions() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_permissions() { - - $permissions = $this->keys->get_permissions(); - $this->assertEquals( array( 'read', 'write', 'read_write' ), array_keys( $permissions ) ); - $this->assertEquals( array( 'Read', 'Write', 'Read / Write' ), array_values( $permissions ) ); - - } - - /** - * Test update() error conditions. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_errors() { - - // No ID. - $ret = $this->keys->update( array() ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_missing_id', $ret ); - - - // Invalid Key. - $ret = $this->keys->update( array( - 'id' => 99993423423, - ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_invalid_key', $ret ); - - // Create a mock key to work with. - $orig = $this->keys->create( array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ) ); - - $data = array( - 'id' => $orig->get( 'id' ), - ); - - // Empty and invalid user ids. - foreach( array( '', 0, '0', 92349234 ) as $uid ) { - // Invalid user_id. - $data['user_id'] = $uid; - $ret = $this->keys->update( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_invalid_user_id', $ret ); - } - - $data['user_id'] = $this->factory->user->create(); - - // Invalid description. - $data['description'] = ''; - $ret = $this->keys->update( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_invalid_description', $ret ); - - $data['description'] = 'Okay description'; - - // Invalid permissions. - $data['permissions'] = 'fake'; - $ret = $this->keys->update( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_key_invalid_permissions', $ret ); - - } - - /** - * Test update() method success. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_success() { - - // Create a mock key to work with. - $orig = $this->keys->create( array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ) ); - - // New data. - $data = array( - 'id' => $orig->get( 'id' ), - 'description' => 'Update key description', - 'user_id' => $this->factory->user->create(), - 'permissions' => 'read_write', - 'last_access' => current_time( 'mysql' ), - ); - $ret = $this->keys->update( $data ); - $this->assertTrue( is_a( $ret, 'LLMS_REST_API_Key' ) ); - $this->assertEquals( $data['description'], $ret->get( 'description' ) ); - $this->assertEquals( $data['user_id'], $ret->get( 'user_id' ) ); - $this->assertEquals( $data['permissions'], $ret->get( 'permissions' ) ); - $this->assertEquals( $data['last_access'], $ret->get( 'last_access' ) ); - - // Don't allow write-protected keys to be updated. - $data = array_merge( array( - 'consumer_key' => 'ast', - 'consumer_secret' => 'ast', - 'truncated_key' => 'ast', - ), $data ); - $ret = $this->keys->update( $data ); - $this->assertEquals( $orig->get( 'consumer_key' ), $ret->get( 'consumer_key' ) ); - $this->assertEquals( $orig->get( 'consumer_secret' ), $ret->get( 'consumer_secret' ) ); - $this->assertEquals( $orig->get( 'truncated_key' ), $ret->get( 'truncated_key' ) ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-authentication.php b/tests/unit-tests/class-llms-rest-test-authentication.php deleted file mode 100644 index 488ebbe5..00000000 --- a/tests/unit-tests/class-llms-rest-test-authentication.php +++ /dev/null @@ -1,213 +0,0 @@ -auth = new LLMS_REST_Authentication(); - - } - - /** - * Test the authenticate method. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.12 Unset the global `current_user` where needed to catch possibile infinite loops on authentication error. - * - * @return void - */ - public function test_authenticate() { - - $expected_actions = did_action( 'llms_rest_basic_auth_success' ); - - // An already authenticated user. - $this->assertEquals( 123, $this->auth->authenticate( 123 ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - - // No SSL. - $this->assertEquals( false, $this->auth->authenticate( false ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - - $_SERVER['HTTPS'] = 'ON'; - - $this->assertEquals( false, $this->auth->authenticate( false ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - - // Not an LLMS Request. - $_SERVER['REQUEST_URI'] = 'https://example.org/wp-json/wp/v1/mock'; - - $this->assertEquals( false, $this->auth->authenticate( false ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - - $_SERVER['REQUEST_URI'] = 'https://example.org/wp-json/llms/v1/mock'; - - // No credentials. - $this->assertEquals( false, $this->auth->authenticate( false ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - - // Success. - $key = $this->get_mock_api_key(); - $expected_actions++; - $this->assertEquals( $key->get( 'user_id' ), $this->auth->authenticate( false ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - - // Correct key, incorrect secret. - unset($GLOBALS['current_user']); // Make sure the current user is not set: e.g. to catch possibile infinite loops on authentication error. - $_SERVER['HTTP_X_LLMS_CONSUMER_SECRET'] = 'fakesecret'; - $this->assertEquals( false, $this->auth->authenticate( false ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - $this->assertTrue( is_wp_error( LLMS_Unit_Test_Util::call_method( $this->auth, 'get_error' ) ) ); - - // Incorrect key. - $_SERVER['HTTP_X_LLMS_CONSUMER_KEY'] = 'fakekey'; - $this->assertEquals( false, $this->auth->authenticate( false ) ); - $this->assertEquals( $expected_actions, did_action( 'llms_rest_basic_auth_success' ) ); - - } - - /** - * Test key lookup. - * - * @since 1.0.0-beta.1 - * - * @return [type] - */ - public function test_find_key() { - - // No keys to find. - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'find_key', array( 'ck_fake' ) ) ); - - $keys = array(); - $i = 0; - while ( $i < 3 ) { - - $keys[] = LLMS_REST_API()->keys()->create( array( - 'description' => 'Test Key ' . $i, - 'user_id' => $this->factory->user->create(), - ) ); - - // Fake key. - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'find_key', array( 'ck_fake' ) ) ); - - // Find the key - $found = LLMS_Unit_Test_Util::call_method( $this->auth, 'find_key', array( $keys[ $i ]->get( 'consumer_key_one_time' ) ) ); - $this->assertEquals( $keys[ $i ]->get( 'id' ), $found->get( 'id' ) ); - - $i++; - - } - - } - - /** - * Test the get_credentials() method using headers. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_credentials_from_headers() { - - $expect = array( - 'key' => 'mock_key', - 'secret' => 'mock_secret', - ); - - // No key or secret. - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'HTTP_X_LLMS_CONSUMER_KEY', 'HTTP_X_LLMS_CONSUMER_SECRET' ) ) ); - - // Key, no secret. - $_SERVER['HTTP_X_LLMS_CONSUMER_KEY'] = $expect['key']; - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'HTTP_X_LLMS_CONSUMER_KEY', 'HTTP_X_LLMS_CONSUMER_SECRET' ) ) ); - - // Secret, no key. - unset( $_SERVER['HTTP_X_LLMS_CONSUMER_KEY'] ); - $_SERVER['HTTP_X_LLMS_CONSUMER_SECRET'] = $expect['secret']; - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'HTTP_X_LLMS_CONSUMER_KEY', 'HTTP_X_LLMS_CONSUMER_SECRET' ) ) ); - - // Key & Secret - $_SERVER['HTTP_X_LLMS_CONSUMER_KEY'] = $expect['key']; - $this->assertEquals( $expect, LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'HTTP_X_LLMS_CONSUMER_KEY', 'HTTP_X_LLMS_CONSUMER_SECRET' ) ) ); - - unset( $_SERVER['HTTP_X_LLMS_CONSUMER_KEY'], $_SERVER['HTTP_X_LLMS_CONSUMER_SECRET'] ); - - } - - /** - * Test the get_credentials() method using basic auth. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_credentials_from_auth() { - - $expect = array( - 'key' => 'mock_key', - 'secret' => 'mock_secret', - ); - - // No key or secret. - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'PHP_AUTH_USER', 'PHP_AUTH_PW' ) ) ); - - // Key, no secret. - $_SERVER['PHP_AUTH_USER'] = $expect['key']; - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'PHP_AUTH_USER', 'PHP_AUTH_PW' ) ) ); - - // Secret, no key. - unset( $_SERVER['PHP_AUTH_USER'] ); - $_SERVER['PHP_AUTH_PW'] = $expect['secret']; - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'PHP_AUTH_USER', 'PHP_AUTH_PW' ) ) ); - - // Key & Secret - $_SERVER['PHP_AUTH_USER'] = $expect['key']; - $this->assertEquals( $expect, LLMS_Unit_Test_Util::call_method( $this->auth, 'locate_credentials', array( 'PHP_AUTH_USER', 'PHP_AUTH_PW' ) ) ); - - unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'] ); - - } - - /** - * Test the is_rest_request() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_is_rest_request() { - - $tests = array( - '' => false, - 'http://example.com/wp-json/wp/v1/mock' => false, - 'https://example.com/wp-json/mock/v1/mock' => false, - - 'https://example.org/wp-json/llms/v1/mock' => true, - 'https://example.com/wp-json/llms/v1/mock' => true, - 'https://example.com/wp-json/llms/v2/mock' => true, - 'http://example.com/wp-json/llms/v1/mock' => true, - 'http://example.com/wp-json/llms-external/v1/mock' => true, - ); - - foreach ( $tests as $uri => $expect ) { - - $_SERVER['REQUEST_URI'] = $uri; - $this->assertEquals( $expect, LLMS_Unit_Test_Util::call_method( $this->auth, 'is_rest_request' ) ); - - } - - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-capabilities.php b/tests/unit-tests/class-llms-rest-test-capabilities.php deleted file mode 100644 index 6fab5c07..00000000 --- a/tests/unit-tests/class-llms-rest-test-capabilities.php +++ /dev/null @@ -1,61 +0,0 @@ -assertEquals( array( - 'manage_lifterlms_api_keys' => true, - 'manage_lifterlms_webhooks' => true, - ), LLMS_REST_Capabilities::add( array() ) ); - $this->assertEquals( array( - 'some_other_cap' => true, - 'manage_lifterlms_api_keys' => true, - 'manage_lifterlms_webhooks' => true, - ), LLMS_REST_Capabilities::add( array( 'some_other_cap' => true ) ) ); - - } - - /** - * Test various user types to ensure they have the proper capabilities. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_user_capabilites_integration() { - - $admin = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $manager = $this->factory->user->create( array( 'role' => 'lms_manager' ) ); - $student = $this->factory->student->create(); - $subscriber = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - $this->assertTrue( user_can( $admin, 'manage_lifterlms_api_keys' ) ); - $this->assertTrue( user_can( $manager, 'manage_lifterlms_api_keys' ) ); - $this->assertFalse( user_can( $student, 'manage_lifterlms_api_keys' ) ); - $this->assertFalse( user_can( $subscriber, 'manage_lifterlms_api_keys' ) ); - - $this->assertTrue( user_can( $admin, 'manage_lifterlms_webhooks' ) ); - $this->assertTrue( user_can( $manager, 'manage_lifterlms_webhooks' ) ); - $this->assertFalse( user_can( $student, 'manage_lifterlms_webhooks' ) ); - $this->assertFalse( user_can( $subscriber, 'manage_lifterlms_webhooks' ) ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-functions.php b/tests/unit-tests/class-llms-rest-test-functions.php deleted file mode 100644 index f489d618..00000000 --- a/tests/unit-tests/class-llms-rest-test-functions.php +++ /dev/null @@ -1,89 +0,0 @@ -assertTrue( is_string( $hash ) ); - $this->assertEquals( 64, strlen( $hash ) ); - - $hash = llms_rest_api_hash( 'abc' ); - $this->assertTrue( is_string( $hash ) ); - $this->assertEquals( 64, strlen( $hash ) ); - - $hash = llms_rest_api_hash( llms_rest_random_hash() ); - $this->assertTrue( is_string( $hash ) ); - $this->assertEquals( 64, strlen( $hash ) ); - - } - - /** - * test the llms_rest_deliver_webhook_async() method - * - * @since 1.0.0-beta.2 - * - * @return void - */ - public function test_llms_rest_deliver_webhook_async() { - - $action_count = did_action( 'llms_rest_webhook_delivery' ); - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://fake.tld', - 'topic' => 'student.created', - 'status' => 'active', - ) ); - - llms_rest_deliver_webhook_async( $webhook->get( 'id' ), array( $this->factory->student->create() ) ); - - $this->assertEquals( ++$action_count, did_action( 'llms_rest_webhook_delivery' ) ); - - } - - /** - * Test the llms_rest_get_api_endpoint_data() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_llms_rest_get_api_endpoint_data() { - - $res = llms_rest_get_api_endpoint_data( '/llms/v1' ); - $this->assertEquals( 'llms/v1', $res['namespace'] ); - - } - - /** - * Test the llms_rest_random_hash() function - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_llms_rest_random_hash() { - - $hash = llms_rest_random_hash(); - $this->assertTrue( is_string( $hash ) ); - $this->assertEquals( 40, strlen( $hash ) ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-install.php b/tests/unit-tests/class-llms-rest-test-install.php deleted file mode 100644 index 75089d82..00000000 --- a/tests/unit-tests/class-llms-rest-test-install.php +++ /dev/null @@ -1,127 +0,0 @@ -assertEquals( $actions, did_action( 'llms_rest_updated' ) ); - - // Should run if version is not equal to current version. - update_option( 'llms_rest_version', '0.0.1-alpha.1' ); - LLMS_REST_Install::check_version(); - $actions++; - $this->assertEquals( $actions, did_action( 'llms_rest_updated' ) ); - - // Shouldn't run b/c versions are equal - LLMS_REST_Install::check_version(); - update_option( 'llms_rest_version', LLMS_REST_API()->version ); - $this->assertEquals( $actions, did_action( 'llms_rest_updated' ) ); - - // Shouldn't run b/c iframe request. - define( 'IFRAME_REQUEST', true ); - LLMS_REST_Install::check_version(); - $this->assertEquals( $actions, did_action( 'llms_rest_updated' ) ); - - } - - /** - * Test the LLMS_REST_Install::get_schema() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_schema() { - - global $wpdb; - - $collate = ''; - if ( $wpdb->has_cap( 'collation' ) ) { - if ( ! empty( $wpdb->charset ) ) { - $collate .= "DEFAULT CHARACTER SET $wpdb->charset"; - } - if ( ! empty( $wpdb->collate ) ) { - $collate .= " COLLATE $wpdb->collate"; - } - } - - $default = "CREATE TABLE `{$wpdb->prefix}lifterlms_fake_table` ( -`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT -) $collate;"; - - $schema = LLMS_REST_Install::get_schema( $default, $collate ); - $this->assertTrue( is_string( $schema ) ); - $this->assertTrue( 0 === strpos( $schema, $default ) ); - $this->assertTrue( false !== strpos( $schema, "CREATE TABLE `{$wpdb->prefix}lifterlms_api_keys`" ) ); - $this->assertTrue( false !== strpos( $schema, "CREATE TABLE `{$wpdb->prefix}lifterlms_webhooks`" ) ); - - } - - /** - * Test the install method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_install() { - - // clean existing install first. - if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { - define( 'WP_UNINSTALL_PLUGIN', true ); - define( 'LLMS_REMOVE_ALL_DATA', true ); - } - include dirname( dirname( dirname( __FILE__ ) ) ) . '/uninstall.php'; - - LLMS_REST_Install::install(); - $this->assertEquals( get_option( 'llms_rest_version' ), LLMS_REST_API()->version ); - - global $wpdb; - $this->assertEquals( $wpdb->prefix . 'lifterlms_api_keys', $wpdb->get_var( "SHOW TABLES LIKE '%lifterlms_api_keys'" ) ); - $this->assertEquals( $wpdb->prefix . 'lifterlms_webhooks', $wpdb->get_var( "SHOW TABLES LIKE '%lifterlms_webhooks'" ) ); - - } - - /** - * Test the update_version() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_version() { - - LLMS_REST_Install::update_version( '1' ); - $this->assertEquals( '1', get_option( 'llms_rest_version' ) ); - - LLMS_REST_Install::update_version(); - $this->assertEquals( LLMS_REST_API()->version, get_option( 'llms_rest_version' ) ); - - LLMS_REST_Install::update_version( '1.2.3' ); - $this->assertEquals( '1.2.3', get_option( 'llms_rest_version' ) ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-main.php b/tests/unit-tests/class-llms-rest-test-main.php deleted file mode 100644 index 760ded62..00000000 --- a/tests/unit-tests/class-llms-rest-test-main.php +++ /dev/null @@ -1,225 +0,0 @@ -main = LLMS_REST_API(); - - } - - /** - * Copies the tests MO file to a directory so it can be loaded by `load_textdomain()`. - * - * @since 1.0.0-beta.17 - * - * @param string $dest Directory to copy the MO file to. - * @return string Full path to the created file. - */ - protected function copy_mo( $dest ) { - - global $llms_tests_bootstrap; - - $assets_dir = $llms_tests_bootstrap->tests_dir . '/assets'; - $name = '/lifterlms-rest-en_US.mo'; - $orig = $assets_dir . $name; - $file = $dest . $name; - - // Delete the file if it exists so copy doesn't fail later. - $this->clear_mo( $file ); - - // Make sure the destination dir exists. - if ( ! file_exists( $dest ) ) { - mkdir( $dest, 0777, true ); - } - - // Copy the mo to the dest directoy. - copy( $orig, $file ); - - return $file; - - } - - /** - * Delete an MO file created by `copy_mo()`. - * - * @since 1.0.0-beta.17 - * - * @param string $file Full path to the MO file to be deleted. - * @return void - */ - protected function clear_mo( $file ) { - - if ( file_exists( $file ) ) { - unlink( $file ); - } - - } - - /** - * Test class constructor. - * - * @since 1.0.0-beta.17 - * - * @return void - */ - public function test_constructor() { - - remove_action( 'init', array( $this->main, 'load_textdomain' ), 0 ); - LLMS_Unit_Test_Util::call_method( $this->main, '__construct' ); - $this->assertEquals( 0, has_action( 'init', array( $this->main, 'load_textdomain' ) ) ); - - } - - /** - * Test keys() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_keys() { - - $this->assertTrue( is_a( $this->main->keys(), 'LLMS_REST_API_Keys' ) ); - - } - - /** - * Test load_textdomain(). - * - * @since 1.0.0-beta.17 - * - * @return void - */ - public function test_load_textdomain() { - - // Make sure textdomain is not loaded. - unload_textdomain( 'lifterlms' ); - - $dirs = array( - WP_LANG_DIR . '/lifterlms', // "Safe" directory. - WP_LANG_DIR . '/plugins', // Default language directory. - LLMS_REST_API_PLUGIN_DIR . '/i18n', // Plugin language directory. - ); - - foreach ( $dirs as $dir ) { - - // Make sure the initial strings work. - $this->assertEquals( 'LifterLMS REST API', __( 'LifterLMS REST API', 'lifterlms' ), $dir); - $this->assertEquals( 'Post title.', __( 'Post title.', 'lifterlms' ), $dir ); - - // Load from the "safe" directory. - $file = $this->copy_mo( $dir ); - $this->main->load_textdomain(); - - $this->assertEquals( 'BetterLMS REST API', __( 'LifterLMS REST API', 'lifterlms' ), $dir ); - $this->assertEquals( 'Item title.', __( 'Item title.', 'lifterlms' ), $dir ); - - // Clean up. - $this->clear_mo( $file ); - unload_textdomain( 'lifterlms' ); - - } - - } - - /** - * Test webhooks() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_webhooks() { - - $this->assertTrue( is_a( $this->main->webhooks(), 'LLMS_REST_Webhooks' ) ); - - } - - /** - * Test on_user_deletion() method: api keys deletion. - * - * @since 1.0.0-beta.25 - * - * @return void - */ - public function test_on_user_deletion_keys_deletion() { - - $api_keys = $this->main->keys(); - - // Use default permissions. - $data = array( - 'description' => 'Test Key', - 'user_id' => $this->factory->user->create(), - ); - $ret = $api_keys->create( $data ); - $this->assertTrue( is_a( $ret, 'LLMS_REST_API_Key' ) ); - $this->assertTrue( $ret->exists() ); - - // Create user A. - $user_a = $this->factory->user->create(); - // Create user B. - $user_b = $this->factory->user->create(); - - // Create 2 api keys for user A. - $data = array( - 'description' => 'Test Key', - 'user_id' => $user_a, - ); - $keys_a_1= $api_keys->create( $data ); - $this->assertTrue( is_a( $keys_a_1, 'LLMS_REST_API_Key' ) ); - $this->assertTrue( $keys_a_1->exists() ); - $data = array( - 'description' => 'Test Key', - 'user_id' => $user_a, - ); - $keys_a_2 = $api_keys->create( $data ); - $this->assertTrue( is_a( $keys_a_2, 'LLMS_REST_API_Key' ) ); - $this->assertTrue( $keys_a_2->exists() ); - - // Create api keys for user B. - $data = array( - 'description' => 'Test Key', - 'user_id' => $user_b, - ); - $keys_b_1= $api_keys->create( $data ); - $this->assertTrue( is_a( $keys_b_1, 'LLMS_REST_API_Key' ) ); - $this->assertTrue( $keys_b_1->exists() ); - - // Delete user B. - wp_delete_user( $user_b ); - - // Check user B keys are deleted. - $this->assertFalse( $keys_b_1->exists() ); - - // Check user A keys are still there. - $this->assertTrue( $keys_a_1->exists() ); - $this->assertTrue( $keys_a_2->exists() ); - - // Delete user A. - wp_delete_user( $user_a ); - - // Check user A keys are deleted. - $this->assertFalse( $keys_a_1->exists() ); - $this->assertFalse( $keys_a_2->exists() ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-webhook-delivery.php b/tests/unit-tests/class-llms-rest-test-webhook-delivery.php deleted file mode 100644 index 13ceec8e..00000000 --- a/tests/unit-tests/class-llms-rest-test-webhook-delivery.php +++ /dev/null @@ -1,172 +0,0 @@ -assertEquals( 200, wp_remote_retrieve_response_code( $res ) ); - $this->assertEquals( $this->hook->get( 'id' ), $webhook->get( 'id' ) ); - $this->res = compact( 'http_args', 'res', 'duration', 'args', 'webhook', 'body' ); - - } - - private function setup_hook( $topic ) { - - $this->hook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => $this->endpoint, - 'topic' => $topic, - 'status' => 'active', - ) ); - $this->hook->enqueue(); - - } - - /** - * Setup the test case. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function set_up() { - parent::set_up(); - add_filter( 'llms_rest_webhook_deliver_async', '__return_false' ); - add_action( 'llms_rest_webhook_delivery', array( $this, 'watch_for_delivery' ), 10, 5 ); - } - - /** - * Tear down the test case. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function tear_down() { - - parent::tear_down(); - remove_filter( 'llms_rest_webhook_deliver_async', '__return_false' ); - remove_action( 'llms_rest_webhook_delivery', array( $this, 'watch_for_delivery' ), 10 ); - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}lifterlms_webhooks" ); - - } - - /* - /$$$$$$ - /$$__ $$ - | $$ \__/ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$$ - | $$ /$$__ $$| $$ | $$ /$$__ $$ /$$_____/ /$$__ $$ /$$_____/ - | $$ | $$ \ $$| $$ | $$| $$ \__/| $$$$$$ | $$$$$$$$| $$$$$$ - | $$ $$| $$ | $$| $$ | $$| $$ \____ $$| $$_____/ \____ $$ - | $$$$$$/| $$$$$$/| $$$$$$/| $$ /$$$$$$$/| $$$$$$$ /$$$$$$$/ - \______/ \______/ \______/ |__/ |_______/ \_______/|_______/ - */ - public function test_deliver_course_created() { - - $this->setup_hook( 'course.created' ); - $id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $this->assertEquals( $id, $this->res['body']['id'] ); - - } - - public function test_deliver_course_updated() { - - $this->setup_hook( 'course.updated' ); - $id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - wp_update_post( array( - 'ID' => $id, - 'post_title' => 'New Title', - ) ); - $this->assertEquals( $id, $this->res['body']['id'] ); - $this->assertEquals( 'New Title', $this->res['body']['title']['rendered'] ); - - } - - public function test_deliver_course_deleted() { - - $this->setup_hook( 'course.deleted' ); - $id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - wp_trash_post( $id ); - $this->assertEquals( $id, $this->res['body']['id'] ); - - } - - public function test_deliver_course_deleted_force() { - - $this->setup_hook( 'course.deleted' ); - $id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - wp_delete_post( $id, true ); - $this->assertEquals( $id, $this->res['body']['id'] ); - - } - - public function test_deliver_course_restored() { - - $this->setup_hook( 'course.restored' ); - $id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - wp_trash_post( $id ); - wp_untrash_post( $id ); - $this->assertEquals( $id, $this->res['body']['id'] ); - - } - - /* - /$$$$$$ /$$ /$$ - /$$__ $$ | $$ |__/ - | $$ \__/ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$ - | $$$$$$ /$$__ $$ /$$_____/|_ $$_/ | $$ /$$__ $$| $$__ $$ /$$_____/ - \____ $$| $$$$$$$$| $$ | $$ | $$| $$ \ $$| $$ \ $$| $$$$$$ - /$$ \ $$| $$_____/| $$ | $$ /$$| $$| $$ | $$| $$ | $$ \____ $$ - | $$$$$$/| $$$$$$$| $$$$$$$ | $$$$/| $$| $$$$$$/| $$ | $$ /$$$$$$$/ - \______/ \_______/ \_______/ \___/ |__/ \______/ |__/ |__/|_______/ - */ - public function test_deliver_section_created() { - - $this->setup_hook( 'section.created' ); - $id = $this->factory->post->create( array( 'post_type' => 'section' ) ); - $this->assertEquals( $id, $this->res['body']['id'] ); - - } - - public function test_deliver_section_updated() { - - $this->setup_hook( 'section.updated' ); - $id = $this->factory->post->create( array( 'post_type' => 'section' ) ); - wp_update_post( array( - 'ID' => $id, - 'post_title' => 'New Title', - ) ); - $this->assertEquals( $id, $this->res['body']['id'] ); - $this->assertEquals( 'New Title', $this->res['body']['title']['rendered'] ); - - } - - public function test_deliver_section_deleted() { - - $this->setup_hook( 'section.deleted' ); - $id = $this->factory->post->create( array( 'post_type' => 'section' ) ); - wp_trash_post( $id ); - $this->assertEquals( $id, $this->res['body']['id'] ); - - } - - - -} diff --git a/tests/unit-tests/class-llms-rest-test-webhook.php b/tests/unit-tests/class-llms-rest-test-webhook.php deleted file mode 100644 index 13e6ae65..00000000 --- a/tests/unit-tests/class-llms-rest-test-webhook.php +++ /dev/null @@ -1,912 +0,0 @@ - array( - 'code' => 400, - 'message' => 'Bad Request', - ), - ); - - } elseif ( 'https://mock.tld/200' === $url ) { - - return array( - 'response' => array( - 'code' => 200, - 'message' => 'Success', - ), - ); - - } - - return $ret; - - } - - /** - * Setup the test case. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function set_up() { - parent::set_up(); - } - - /** - * Tear down the test case. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function tear_down() { - parent::tear_down(); - - add_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - remove_filter( 'pre_http_request', array( $this, 'mock_request' ), 10 ); - - } - - public function test_delivery_errors() { - - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/400', - 'topic' => 'course.created', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - - add_filter( 'pre_http_request', array( $this, 'mock_request' ), 10, 3 ); - - $webhook->deliver( array( $course ) ); - - $this->assertEquals( 1, $webhook->get( 'failure_count' ) ); - - $webhook = $webhook->set( 'failure_count', 5 ); - - $webhook->deliver( array( $course ) ); - - $this->assertEquals( 6, $webhook->get( 'failure_count' ) ); - $this->assertEquals( 'disabled', $webhook->get( 'status' ) ); - - } - - /** - * Test delivery success - * - * @since Unknown - * @since 1.0.0-beta.17 Remove checks on `pending_delivery` unused property. - * - * @return void - */ - public function test_delivery_success() { - - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => 'course.created', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - - $webhook->set( 'failure_count', 3 ); - - add_filter( 'pre_http_request', array( $this, 'mock_request' ), 10, 3 ); - - $webhook->deliver( array( $course ) ); - - $this->assertEquals( 0, $webhook->get( 'failure_count' ) ); - - } - - /** - * Test the webhook payload getter for post resources. - * - * @since 1.0.0-beta.6 - * - * @return void - */ - public function test_get_payload_for_posts() { - - $posts = array( - 'course' => 'course', - 'section' => 'section', - 'lesson' => 'lesson', - // 'membership' => 'llms_membership', - // 'order' => 'llms_order', - // 'access_plan' => 'llms_access_plan', - // 'transaction' => 'llms_transaction', - ); - foreach ( $posts as $post => $post_type ) { - - $post_id = $this->factory->post->create( array( 'post_type' => $post_type ) ); - - // Created. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => $post . '.created', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $post_id, null, false ) ) ); - $this->assertEquals( $post_id, $payload['id'] ); - $this->assertArrayHasKey( 'title', $payload ); - - // Updated. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => $post . '.updated', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $post_id, null ) ) ); - $this->assertEquals( $post_id, $payload['id'] ); - $this->assertArrayHasKey( 'title', $payload ); - - // Deleted. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => $post . '.deleted', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $post_id ) ) ); - $this->assertEquals( array( 'id' => $post_id ), $payload ); - - } - - } - - /** - * Test get_payload() method for user webhooks. - * - * @since 1.0.0-beta.6 - * - * @return void - */ - public function test_get_payload_for_users() { - - $roles = array( 'student', 'instructor' ); - - foreach ( $roles as $role ) { - - $user_id = $this->factory->user->create( array( 'role' => $role ) ); - - // Created. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => $role . '.created', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $user_id ) ) ); - $this->assertEquals( $user_id, $payload['id'] ); - $this->assertArrayHasKey( 'name', $payload ); - - // Updated. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => $role . '.updated', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $user_id ) ) ); - $this->assertEquals( $user_id, $payload['id'] ); - $this->assertArrayHasKey( 'name', $payload ); - - // Deleted. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => $role . '.deleted', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $user_id ) ) ); - $this->assertEquals( array( 'id' => $user_id ), $payload ); - - } - - } - - /** - * test get_payload() for enrollment resources. - * - * @since 1.0.0-beta.6 - * - * @return void - */ - public function test_get_payload_for_enrollments() { - - $user = $this->factory->student->create(); - $course = $this->factory->course->create(); - - llms_enroll_student( $user, $course ); - - // Created. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => 'enrollment.created', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $user, $course ) ) ); - $this->assertEquals( $user, $payload['student_id'] ); - $this->assertEquals( $course, $payload['post_id'] ); - - // Updated. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => 'enrollment.updated', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $user, $course ) ) ); - $this->assertEquals( $user, $payload['student_id'] ); - $this->assertEquals( $course, $payload['post_id'] ); - - // Deleted. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => 'enrollment.deleted', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $user, $course ) ) ); - $this->assertEquals( $user, $payload['student_id'] ); - $this->assertEquals( $course, $payload['post_id'] ); - - } - - /** - * test get_payload() for enrollment resources. - * - * @since 1.0.0-beta.6 - * - * @return void - */ - public function test_get_payload_for_progress() { - - $user = $this->factory->student->create(); - $course = $this->factory->course->create(); - - llms_enroll_student( $user, $course ); - - // Updated. - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => 'progress.updated', - 'status' => 'active', - 'user_id' => $this->factory->user->create( array( 'role' => 'administrator' ) ), - ) ); - - $payload = LLMS_Unit_Test_Util::call_method( $webhook, 'get_payload', array( array( $user, $course ) ) ); - $this->assertEquals( $user, $payload['student_id'] ); - $this->assertEquals( $course, $payload['post_id'] ); - - } - - /** - * Test enqueue for an action with a single hook. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_enqueue_single_hook() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'course.created', - ) ); - - $this->assertFalse( has_action( 'save_post_course', array( $webhook, 'process_hook' ) ) ); - $webhook->enqueue(); - $this->assertEquals( 10, has_action( 'save_post_course', array( $webhook, 'process_hook' ) ) ); - - } - - /** - * Test enqueue for an action with a multiple hooks. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_enqueue_multi_hooks() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'enrollment.created', - ) ); - - $this->assertFalse( has_action( 'llms_user_course_enrollment_created', array( $webhook, 'process_hook' ) ) ); - $this->assertFalse( has_action( 'llms_user_membership_enrollment_created', array( $webhook, 'process_hook' ) ) ); - $webhook->enqueue(); - $this->assertEquals( 10, has_action( 'llms_user_course_enrollment_created', array( $webhook, 'process_hook' ) ) ); - $this->assertEquals( 10, has_action( 'llms_user_membership_enrollment_created', array( $webhook, 'process_hook' ) ) ); - - } - - /** - * Test enqueue for a custom action - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_enqueue_custom_action() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'action.mock_hook', - ) ); - - $this->assertFalse( has_action( 'mock_hook', array( $webhook, 'process_hook' ) ) ); - $webhook->enqueue(); - $this->assertEquals( 10, has_action( 'mock_hook', array( $webhook, 'process_hook' ) ) ); - - } - - /** - * Test the get_edit_link() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_edit_link() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'course.created', - ) ); - - $this->assertEquals( - admin_url( 'admin.php?page=llms-settings&tab=rest-api§ion=webhooks&edit-webhook=' . $webhook->get( 'id' ) ), - $webhook->get_edit_link() - ); - - } - - /** - * Test the get_delete_link() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_delete_link() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'course.created', - ) ); - - $link = $webhook->get_delete_link(); - - $this->assertEquals( 0, strpos( admin_url( 'admin.php?page=llms-settings&tab=rest-api§ion=webhooks&revoke-webhook=' . $webhook->get( 'id' ) ), $webhook->get_delete_link() ) ); - parse_str( wp_parse_url( $link, PHP_URL_QUERY ), $parts ); - $this->assertTrue( array_key_exists( 'delete-webhook-nonce', $parts ) ); - - } - - /** - * Test signature generation. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_delivery_signature() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'course.created', - ) ); - - $expected_ts = time(); - llms_tests_mock_current_time( time() ); - $expected_payload = wp_json_encode( array( 'mock' => 'test' ) ); - - $sig = $webhook->get_delivery_signature( $expected_payload ); - llms_tests_reset_current_time(); - - // Make sure the string looks right. - $this->assertEquals( 0, strpos( $sig, 't=' ) ); - $this->assertEquals( 12, strpos( $sig, ',v1=' ) ); - - // Parse the string and run some checks. - $parsed = array(); - $items = explode( ',', $sig ); - foreach ( $items as $item ) { - $item_parts = explode( '=', $item ); - $parsed[ $item_parts[0] ] = $item_parts[1]; - } - - $this->assertEquals( $expected_ts, $parsed['t'] ); - $this->assertArrayHasKey( 'v1', $parsed ); - - // recreate the signature and compare. - $hash = hash_hmac( 'sha256', $expected_ts . '.' . $expected_payload, $webhook->get( 'secret' ) ); - $this->assertEquals( $hash, $parsed['v1'] ); - - } - - /** - * Test event getter. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_event() { - - $tests = array( - 'course.created' => 'created', - 'course.updated' => 'updated', - 'progress.updated' => 'updated', - 'student.deleted' => 'deleted', - 'action.mock' => 'mock', - 'action.fake' => 'fake', - ); - - foreach ( $tests as $topic => $event ) { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => $topic, - ) ); - - $this->assertEquals( $event, $webhook->get_event() ); - - } - - } - - - /** - * test hook getter. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_hooks() { - - foreach ( LLMS_REST_API()->webhooks()->get_hooks() as $topic => $hooks ) { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => $topic, - ) ); - - $this->assertEquals( $hooks, $webhook->get_hooks() ); - - } - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'action.mock', - ) ); - - $this->assertEquals( array( 'mock' => 1 ), $webhook->get_hooks() ); - - } - - /** - * Test resource getter. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_resource() { - - $tests = array( - 'course.created' => 'course', - 'access_plan.updated' => 'access_plan', - 'progress.updated' => 'progress', - 'student.deleted' => 'student', - 'action.mock' => 'action', - 'action.fake' => 'action', - ); - - foreach ( $tests as $topic => $resource ) { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => $topic, - ) ); - - $this->assertEquals( $resource, $webhook->get_resource() ); - - } - - } - - /** - * Test validity of post actions. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_is_valid_post_action() { - - $post_types = array( - 'course' => false, - 'section' => false, - 'lesson' => false, - 'llms_membership' => false, - 'llms_access_plan' => false, - 'llms_order' => false, - 'llms_transaction' => false, - 'post' => false, - 'page' => false, - ); - - $tests = array( - 'course.deleted' => array_merge( $post_types, array( 'course' => true ) ), - 'section.deleted' => array_merge( $post_types, array( 'section' => true ) ), - 'lesson.deleted' => array_merge( $post_types, array( 'lesson' => true ) ), - 'membership.deleted' => array_merge( $post_types, array( 'llms_membership' => true ) ), - 'access_plan.deleted' => array_merge( $post_types, array( 'llms_access_plan' => true ) ), - 'order.deleted' => array_merge( $post_types, array( 'llms_order' => true ) ), - 'transaction.deleted' => array_merge( $post_types, array( 'llms_transaction' => true ) ), - ); - - foreach ( $tests as $topic => $post_types ) { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://fake.tld', - 'topic' => $topic, - ) ); - - foreach ( $post_types as $type => $expect ) { - - $post_id = $this->factory->post->create( array( 'post_type' => $type ) ); - $this->assertEquals( $expect, LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_post_action', array( $post_id ) ) ); - - } - - } - - } - - /** - * Test whether a resource is valid - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.11 Test updated to take into account the new way to discriminate between course creation/update - * - * @return void - */ - public function test_is_valid_resource() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://fake.tld', - 'topic' => 'course.created', - ) ); - - $course = $this->factory->post->create_and_get( array( 'post_type' => 'course' ) ); - - global $wp_current_filter; - $wp_current_filter = array( 'save_post_course' ); - $this->assertTrue( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_resource', array( array( $course->ID, $course ) ) ) ); - - // Alter the post creation date so to simulate an update: A resource is considered created when the hook is executed within 10 seconds of the post creation date. - $course->post_date = date( 'Y-m-d H:i:s', strtotime('-11 seconds') ); - wp_update_post( $course ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_resource', array( array( $course->ID, $course ) ) ) ); - $wp_current_filter = array(); - - // it's a draft. - $course->post_status = 'auto-draft'; - wp_update_post( $course ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_resource', array( array( $course->ID, $course ) ) ) ); - - } - - /** - * Test is_valid_user_action() method - * - * @since Unknown - * - * @return void - */ - public function test_is_valid_user_action() { - - $student = $this->factory->student->create(); - $admin = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $instructor = $this->factory->user->create( array( 'role' => 'instructor' ) ); - $subscriber = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - $fake = $subscriber + 1; - - // Student topics. - $topics = array( - 'student.created', - 'student.updated', - 'student.deleted', - ); - - foreach ( $topics as $topic ) { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://fake.tld', - 'topic' => $topic, - ) ); - - $this->assertTrue( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $student ) ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $admin ) ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $instructor ) ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $subscriber ) ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $fake ) ) ); - - } - - // Instructor topics. - $topics = array( - 'instructor.created', - 'instructor.updated', - 'instructor.deleted', - ); - - foreach ( $topics as $topic ) { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://fake.tld', - 'topic' => $topic, - ) ); - - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $student ) ) ); - $this->assertTrue( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $admin ) ) ); - $this->assertTrue( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $instructor ) ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $subscriber ) ) ); - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'is_valid_user_action', array( $fake ) ) ); - - } - - } - - /** - * Test scheduling student.created - * - * @since Unknown - * - * @return void - */ - public function test_scheduling_student_created() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'student.created', - 'status' => 'active', - ) ); - - $webhook->enqueue(); - - $schedule_args = array( - 'webhook_id' => $webhook->get( 'id' ), - 'args' => array( $this->factory->student->create() ), - ); - - $this->assertTrue( false !== as_next_scheduled_action( 'lifterlms_rest_deliver_webhook_async', $schedule_args, 'llms-webhooks' ) ); - - } - - /** - * Test scheduling enrollment.created - * - * @since Unknown - * - * @return void - */ - public function test_scheduling_enrollment_created() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'enrollment.created', - 'status' => 'active', - ) ); - - $webhook->enqueue(); - - $student = $this->factory->student->create(); - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - - $schedule_args = array( - 'webhook_id' => $webhook->get( 'id' ), - 'args' => array( $student, $course ), - ); - - llms_enroll_student( $student, $course ); - - $this->assertTrue( false !== as_next_scheduled_action( 'lifterlms_rest_deliver_webhook_async', $schedule_args, 'llms-webhooks' ) ); - - } - - /** - * Test ping() on unresolveable urls. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_ping_unreachable() { - - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://fake.tld', - 'topic' => 'course.created', - ) ); - - remove_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - $ret = $webhook->ping(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_ping_unreachable', $ret ); - - } - - /** - * Test ping() on non 200 responses. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_ping_non_200_status() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/400', - 'topic' => 'course.created', - ) ); - - add_filter( 'pre_http_request', array( $this, 'mock_request' ), 10, 3 ); - remove_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - $ret = $webhook->ping(); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_ping_not_200', $ret ); - - } - - /** - * Test ping() success. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_ping_success() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld/200', - 'topic' => 'course.created', - ) ); - - add_filter( 'pre_http_request', array( $this, 'mock_request' ), 10, 3 ); - remove_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - $this->assertTrue( $webhook->ping() ); - - } - - /** - * Test the delivery failure setter. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_set_delivery_failure() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'student.created', - 'status' => 'active', - ) ); - - $i = 1; - while ( $i <= 6 ) { - - $webhook = LLMS_Unit_Test_Util::call_method( $webhook, 'set_delivery_failure' ); - - $this->assertEquals( $i, $webhook->get( 'failure_count' ) ); - $this->assertEquals( 6 === $i ? 'disabled' : 'active', $webhook->get( 'status' ) ); - $i++; - - } - - } - - /** - * Test the status condition of the should_deliver() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_should_deliver_status() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'student.created', - ) ); - - // Inactive. - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'should_deliver', array( array( $this->factory->student->create() ) ) ) ); - - // Active. - $webhook->set( 'status', 'active' )->save(); - $this->assertTrue( LLMS_Unit_Test_Util::call_method( $webhook, 'should_deliver', array( array( $this->factory->student->create() ) ) ) ); - - } - - /** - * Test should_deliver() method with already processed hooks(). - * - * @since 1.0.0-beta.17 - * - * @return void - */ - public function test_should_deliver_already_processed() { - - $webhook = LLMS_REST_API()->webhooks()->create( array( - 'delivery_url' => 'https://mock.tld', - 'topic' => 'student.created', - 'status' => 'active', - ) ); - - $student_id = $this->factory->student->create(); - - // Not processed. - $this->assertTrue( LLMS_Unit_Test_Util::call_method( $webhook, 'should_deliver', array( array( $student_id ) ) ) ); - - // Process the hook. - $webhook->process_hook( $student_id ); - - // Processed. - $this->assertFalse( LLMS_Unit_Test_Util::call_method( $webhook, 'should_deliver', array( array( $student_id ) ) ) ); - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-webhooks-query.php b/tests/unit-tests/class-llms-rest-test-webhooks-query.php deleted file mode 100644 index f0d52518..00000000 --- a/tests/unit-tests/class-llms-rest-test-webhooks-query.php +++ /dev/null @@ -1,227 +0,0 @@ -query( "TRUNCATE TABLE {$wpdb->prefix}lifterlms_webhooks" ); - - } - - /** - * Test the get_webhooks() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_webhooks() { - - $query = new LLMS_REST_Webhooks_Query(); - $this->assertEquals( array(), $query->get_webhooks() ); - - $this->create_many_webhooks( 3 ); - - foreach ( array( true, false ) as $with_filters ) { - - $query = new LLMS_REST_Webhooks_Query( array( 'suppress_filters' => $with_filters ) ); - $keys = $query->get_webhooks(); - foreach ( $keys as $key ) { - $this->assertTrue( is_a( $key, 'LLMS_REST_Webhook' ) ); - } - - } - - - } - - /** - * Test the include and exclude arguments. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta-24 Fixed access of protected LLMS_Abstract_Query properties. - * - * @return void - */ - public function test_query_args_include_and_exclude() { - - $this->create_many_webhooks( 5 ); - $query = new LLMS_REST_Webhooks_Query( array() ); - $ids = range( 1, 5 ); - - $this->create_many_webhooks( 5 ); - - $query = new LLMS_REST_Webhooks_Query( array( - 'include' => $ids, - ) ); - $this->assertEquals( 5, $query->get_found_results() ); - $this->assertEquals( $ids, wp_list_pluck( $query->get_results(), 'id' ) ); - - $query = new LLMS_REST_Webhooks_Query( array( - 'exclude' => $ids, - ) ); - $this->assertEquals( 5, $query->get_found_results() ); - $this->assertEquals( range( 6, 10 ), wp_list_pluck( $query->get_results(), 'id' ) ); - - } - - /** - * Test pagination of query results. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta-24 Fixed access of protected LLMS_Abstract_Query properties. - * - * @return void - */ - public function test_query_args_pagination() { - - $this->create_many_webhooks( 25 ); - - $query = new LLMS_REST_Webhooks_Query( array() ); - $this->assertEquals( 10, count( $query->get_results() ) ); - $this->assertEquals( 25, $query->get_found_results() ); - $this->assertEquals( 3, $query->get_max_pages() ); - $this->assertEquals( range( 1, 10 ), wp_list_pluck( $query->get_results(), 'id' ) ); - $this->assertTrue( $query->is_first_page() ); - - $query = new LLMS_REST_Webhooks_Query( array( 'page' => 2 ) ); - $this->assertEquals( range( 11, 20 ), wp_list_pluck( $query->get_results(), 'id' ) ); - - $query = new LLMS_REST_Webhooks_Query( array( 'page' => 3 ) ); - $this->assertEquals( range( 21, 25 ), wp_list_pluck( $query->get_results(), 'id' ) ); - $this->assertTrue( $query->is_last_page() ); - - } - - /** - * Test the status filter arguments. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta-24 Fixed access of protected LLMS_Abstract_Query properties. - * - * @return void - */ - public function test_query_args_status() { - - $this->create_many_webhooks( 5, 'active' ); - $this->create_many_webhooks( 5, 'disabled' ); - $this->create_many_webhooks( 5, 'paused' ); - - $query = new LLMS_REST_Webhooks_Query( array() ); - $this->assertEquals( 15, $query->get_found_results() ); - - foreach ( array_keys( LLMS_REST_API()->webhooks()->get_statuses() ) as $status ) { - - $query = new LLMS_REST_Webhooks_Query( array( 'status' => $status ) ); - $this->assertEquals( 5, $query->get_found_results() ); - - } - - } - - /** - * Test setting up default query args. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_query_args_setup_with_defaults() { - - $query = new LLMS_REST_Webhooks_Query(); - - $args = array( - 'include' => array(), - 'exclude' => array(), - 'page' => 1, - 'per_page' => 10, - 'sort' => array( - 'id' => 'ASC' - ), - ); - - foreach ( $args as $arg => $expect ) { - $this->assertEquals( $expect, $query->get( $arg ), $arg ); - } - - } - - /** - * Tests setting up all possible arguments with custom arguments. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_query_args_setup_with_custom() { - - $args = array( - 'include' => array( 1, 2, 3 ), - 'exclude' => array( 4, 5, 6 ), - 'page' => 5, - 'per_page' => 500, - 'sort' => array( - 'name' => 'ASC', - 'id' => 'DESC', - ), - ); - - $query = new LLMS_REST_Webhooks_Query( $args ); - - foreach ( $args as $arg => $expect ) { - $this->assertEquals( $expect, $query->get( $arg ), $arg ); - } - - } - - /** - * Merge default with custom arguments on setup. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_query_args_setup_with_merge() { - - $args = array( - 'include' => array( 1, 2, 3 ), - 'exclude' => array( 4, 5, 6 ), - 'sort' => array( - 'name' => 'ASC', - 'id' => 'DESC', - ), - ); - - $query = new LLMS_REST_Webhooks_Query( $args ); - - $args['page'] = 1; - $args['per_page'] = 10; - - foreach ( $args as $arg => $expect ) { - $this->assertEquals( $expect, $query->get( $arg ), $arg ); - } - - } - -} diff --git a/tests/unit-tests/class-llms-rest-test-webhooks.php b/tests/unit-tests/class-llms-rest-test-webhooks.php deleted file mode 100644 index 2697166b..00000000 --- a/tests/unit-tests/class-llms-rest-test-webhooks.php +++ /dev/null @@ -1,525 +0,0 @@ -webhooks = LLMS_REST_API()->webhooks(); - - } - - /** - * Can't create a webhook with an ID. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_with_id() { - - $ret = $this->webhooks->create( array( 'id' => 1 ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_exists', $ret ); - - } - - /** - * Can't create a webhook with a bad url. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_bad_url() { - - remove_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - $ret = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_ping_unreachable', $ret ); - - add_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - } - - /** - * Creation attempts missing required columns should fail. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_required_cols() { - - $to_test = array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ); - $data = array(); - - foreach ( $to_test as $key => $val ) { - - $ret = $this->webhooks->create( $data ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_missing_' . $key, $ret ); - $data[ $key ] = $val; - - } - - } - - /** - * Fill required data with default data during creation. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_with_defaults() { - - $data = array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ); - - $user_id = $this->factory->user->create(); - wp_set_current_user( $user_id ); - - $ret = $this->webhooks->create( $data ); - - $this->assertEquals( 'disabled', $ret->get( 'status' ) ); - $this->assertEquals( 0, $ret->get( 'failure_count' ) ); - $this->assertEquals( $user_id, $ret->get( 'user_id' ) ); - - $this->assertEquals( 50, strlen( $ret->get( 'secret' ) ) ); - - $this->assertEquals( 0, strpos( $ret->get( 'name' ), 'Webhook created on ' ) ); - - } - - /** - * Create with entirely custom values. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_all_vals() { - - $data = array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - 'name' => 'Mock Webhook Name', - 'status' => 'active', - 'secret' => 'DontTellAnyonePlease', - ); - - $ret = $this->webhooks->create( $data ); - - foreach ( $data as $key => $val ) { - $this->assertEquals( $val, $ret->get( $key ) ); - } - - } - - /** - * Ensure created/updated dates are automatically added during creation. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_dates() { - - $time = current_time( 'timestamp' ); - llms_tests_mock_current_time( $time ); - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - $this->assertEquals( $time, strtotime( $hook->get( 'created' ) ) ); - $this->assertEquals( $time, strtotime( $hook->get( 'updated' ) ) ); - - llms_tests_reset_current_time( $time ); - - } - - /** - * Test deleting a webhook. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Store hook id for use after the hook is deleted. - * - * @return void - */ - public function test_delete() { - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - $id = $hook->get( 'id' ); - - // Can't delete a non-existant webhook. - $this->assertFalse( $this->webhooks->delete( $id + 1 ) ); - - // Deleted. - $this->assertTrue( $this->webhooks->delete( $id ) ); - - // Can't be found. - $this->assertFalse( $this->webhooks->get( $id ) ); - - // Can't be deleted again. - $this->assertFalse( $this->webhooks->delete( $id ) ); - - } - - /** - * Test hook getter. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get() { - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - // Get the hook. - $get = $this->webhooks->get( $hook->get( 'id' ) ); - $this->assertEquals( $hook->get( 'id' ), $get->get( 'id' ) ); - - // Non-existant hook. - $this->assertFalse( $this->webhooks->get( $hook->get( 'id' ) + 1 ) ); - - } - - /** - * Can't create with invalid status - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_is_data_valid_status() { - - $data = array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ); - - $tests = array( 'mock', '', false, true ); - foreach ( $tests as $val ) { - - $data['status'] = $val; - $ret = LLMS_Unit_Test_Util::call_method( $this->webhooks, 'is_data_valid', array( $data ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_status', $ret ); - - } - - } - - /** - * Can't create with invalid topic - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_is_data_valid_topic() { - - $data = array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - 'status' => 'disabled', - ); - - $tests = array( 'mock', '', false, true, 'course.fake' ); - foreach ( $tests as $val ) { - - $data['topic'] = $val; - $ret = LLMS_Unit_Test_Util::call_method( $this->webhooks, 'is_data_valid', array( $data ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_topic', $ret ); - - } - - } - - /** - * Can't create/update with an empty description. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_is_data_valid_description() { - - $data = array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - 'status' => 'disabled', - ); - - $tests = array( false, 0, '' ); - foreach ( $tests as $val ) { - - $data['name'] = $val; - $ret = LLMS_Unit_Test_Util::call_method( $this->webhooks, 'is_data_valid', array( $data ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_name', $ret ); - - } - - } - - /** - * Validate delivery url (can't be empty) - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_is_data_valid_delivery_url() { - - $data = array( - 'topic' => 'course.created', - 'status' => 'disabled', - ); - - $tests = array( false, 0, '' ); - foreach ( $tests as $val ) { - - $data['delivery_url'] = $val; - $ret = LLMS_Unit_Test_Util::call_method( $this->webhooks, 'is_data_valid', array( $data ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_delivery_url', $ret ); - - } - - } - - /** - * Test default column values getter - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_default_column_values() { - - $vals = $this->webhooks->get_default_column_values(); - - $this->assertEquals( 50, strlen( $vals['secret'] ) ); - $this->assertEquals( 'disabled', $vals['status'] ); - $this->assertEquals( 0, $vals['failure_count'] ); - - } - - /** - * Test the is_topic_valid() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_is_topic_valid() { - - $tests = array_fill_keys( array_keys( $this->webhooks->get_topics() ), true ); - - $tests['action.mock'] = true; - $tests['course.fake'] = false; - $tests['courses.created'] = false; - $tests['action'] = false; - $tests['action.'] = false; - - foreach ( $tests as $topic => $expected ) { - - $this->assertEquals( $expected, LLMS_Unit_Test_Util::call_method( $this->webhooks, 'is_topic_valid', array( $topic ) ), $topic ); - - } - - } - - /** - * Can't update without supplying an ID - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_no_id() { - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - $ret = $this->webhooks->update( array() ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_missing_id', $ret ); - - } - - /** - * Can't update something that doesn't exist - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_non_existant() { - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - $ret = $this->webhooks->update( array( 'id' => $hook->get( 'id' ) + 1 ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_webhook', $ret ); - - } - - /** - * Can't supply an empty url during an update - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_blank_url() { - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - $ret = $this->webhooks->update( array( - 'id' => $hook->get( 'id' ), - 'delivery_url' => '', - ) ); - - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_invalid_delivery_url', $ret ); - - } - - /** - * test updating - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update() { - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - $args = array( - 'id' => $hook->get( 'id' ), - 'topic' => 'action.mock', - 'delivery_url' => 'http://mock.com', - 'failure_count' => 5, - 'name' => 'Changed it', - 'secret' => 'new secret', - ); - - $ret = $this->webhooks->update( $args ); - - foreach ( $args as $key => $expected ) { - - $this->assertEquals( $expected, $ret->get( $key ) ); - - } - - } - - /** - * Test updating delivery_url to a bad url. - * - * @since 1.0.0-beta.1 - * - * @see {Reference} - * @link {URL} - * - * @return [type] - */ - public function test_update_bad_url() { - - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - - remove_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - $ret = $this->webhooks->update( array( - 'id' => $hook->get( 'id' ), - 'delivery_url' => 'https://mock.tld' - ) ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_webhook_ping_unreachable', $ret ); - - add_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - } - - /** - * Test that the updated date is automatically updated during an update. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_updated_date() { - - llms_tests_mock_current_time( strtotime( '-10 minutes' ) ); - $hook = $this->webhooks->create( array( - 'topic' => 'course.created', - 'delivery_url' => 'https://mock.com', - ) ); - llms_tests_reset_current_time(); - - $ret = $this->webhooks->update( array( - 'id' => $hook->get( 'id' ), - 'topic' => 'action.mock', - ) ); - - $this->assertTrue( $ret->get( 'updated' ) > $ret->get( 'created' ) ); - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-abstract-users-controller.php b/tests/unit-tests/server/class-llms-rest-test-abstract-users-controller.php deleted file mode 100644 index 7356a146..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-abstract-users-controller.php +++ /dev/null @@ -1,102 +0,0 @@ -stub = new class extends LLMS_REST_Users_Controller { - - // stub required abstract method. - protected function get_object( $id ) { return $id; } - - }; - - $this->request = new WP_REST_Request( 'POST', 'mock' ); - - } - - /** - * Filter for testing banned usernames added via the `illegal_user_logins` filter. - * - * @since 1.0.0-beta.1 - * - * @param string[] $illegal List of illegal usernames. - * @return string[] - */ - public function get_illegal_user_logins( $illegal ) { - $illegal[] = 'illegal'; - return $illegal; - } - - - /** - * Test the sanitize_password method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_sanitize_password() { - - // Good. - $this->assertEquals( 'password', $this->stub->sanitize_username( 'password', $this->request, 'username' ) ); - - // Illegal chars. - $ret = $this->stub->sanitize_username( 'mock\\password', $this->request, 'username' ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_bad_request', $ret ); - - } - - - /** - * Test the sanitize_username method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_sanitize_username() { - - // Good. - $this->assertEquals( 'okay', $this->stub->sanitize_username( 'okay', $this->request, 'username' ) ); - - // Illegal chars. - $ret = $this->stub->sanitize_username( '¯\_(ツ)_/¯', $this->request, 'username' ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_bad_request', $ret ); - - // Banned username. - add_filter( 'illegal_user_logins', array( $this, 'get_illegal_user_logins' ) ); - - $ret = $this->stub->sanitize_username( 'illegal', $this->request, 'username' ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_bad_request', $ret ); - - $this->assertEquals( 'something-else', $this->stub->sanitize_username( 'something-else', $this->request, 'username' ) ); - - remove_filter( 'illegal_user_logins', array( $this, 'get_illegal_user_logins' ) ); - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-access-plans.php b/tests/unit-tests/server/class-llms-rest-test-access-plans.php deleted file mode 100644 index 519881dd..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-access-plans.php +++ /dev/null @@ -1,1301 +0,0 @@ - '1.99', - 'title' => 'What a title', - ); - - /** - * This is an internal flag we use to determine whether or not - * we need to use a step of 2 ids when testing the pagination. - * - * @var array - */ - protected $generates_revision_on_creation = false; - - /** - * Schema properties - * - * @var array - */ - private $schema_properties = array( - 'access_expiration', - 'access_expires', - 'access_length', - 'access_period', - 'availability_restrictions', - 'content', - 'date_created', - 'date_created_gmt', - 'date_updated', - 'date_updated_gmt', - 'enroll_text', - 'frequency', - 'id', - 'length', - 'menu_order', - 'period', - 'permalink', - 'price', - 'post_id', - 'post_type', - 'redirect_forced', - 'redirect_page', - 'redirect_type', - 'redirect_url', - 'sale_date_end', - 'sale_date_start', - 'sale_enabled', - 'sale_price', - 'sku', - 'title', - 'trial_enabled', - 'trial_length', - 'trial_period', - 'trial_price', - 'visibility', - ); - - /** - * Array of link $rels expected for each item. - * - * @var string[] - */ - private $expected_link_rels = array( - 'self', - 'collection', - 'post', - 'restrictions', - ); - - /** - * - * Setup our test server, endpoints, and user info. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function set_up() { - parent::set_up(); - $this->endpoint = new LLMS_REST_Access_Plans_Controller(); - $this->user_allowed = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $this->user_forbidden = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - $this->set_defaults(); - } - - /** - * Test the item schema - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_get_item_schema() { - $schema = $this->endpoint->get_item_schema(); - - $this->assertEquals( 'llms_access_plan', $schema['title'] ); - - $props = $this->schema_properties; - $schema_keys = array_keys( $schema['properties'] ); - - $this->assertEqualSets( $props, $schema_keys ); - } - - /** - * Test list access plans pagination success. - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_get_access_plans_with_pagination() { - wp_set_current_user( $this->user_allowed ); - - $access_plan_ids = $this->factory->post->create_many( 25, array( 'post_type' => $this->post_type ) ); - $course = $this->factory->course->create(); - foreach ( $access_plan_ids as $id ) { - update_post_meta( $id, '_llms_product_id', $course ); - } - $start_access_plan_id = $access_plan_ids[0]; - $this->pagination_test( $this->route, $start_access_plan_id ); - } - - /** - * Test getting single access plan that doesn't exist. - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_get_nonexistent_access_plan() { - - wp_set_current_user( 0 ); - - // Setup access plan - $access_plan_id = $this->factory->post->create( array( 'post_type' => $this->post_type ) ); - - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $access_plan_id . '2' - ); - - // The access plan doesn't exist. - $this->assertResponseStatusEquals( 404, $response ); - - } - - /** - * Test creating a single access plan. - * - * @since 1.0.0-beta.20 - * - * @return void - */ - public function test_create_and_get_access_plan() { - - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - ) - ); - - $create_response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - $access_plan = $create_response->get_data(); - - // Success. - $this->assertResponseStatusEquals( 201, $create_response ); - - // Get the access plan. - $get_response = $this->perform_mock_request( - 'GET', - trailingslashit( $this->route ) . $access_plan['id'], - array(), - array( 'context' => 'edit' ) - ); - - $this->assertResponseStatusEquals( 200, $get_response ); - $this->assertEquals( $access_plan, $get_response->get_data() ); - - $this->assertEqualSets( $this->schema_properties, array_keys( $get_response->get_data() ) ); - - } - - /** - * Test producing bad request error when creating a single access-plans - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_create_access_plan_bad_request() { - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - ) - ); - - // Creating an access plan passing an id produces a bad request. - $sample_args['id'] = '123'; - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseMessageEquals( 'Cannot create existing Access Plans.', $response ); - - unset( $sample_args['id'] ); - - // Create an access plan without title. - unset( $sample_args['title'] ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseMessageEquals( 'Missing parameter(s): title', $response ); - - $sample_args['title'] = $this->sample_access_plan_args['title']; - - // Create an access plan without price. - unset( $sample_args['price'] ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseMessageEquals( 'Missing parameter(s): price', $response ); - - - // Create an access plan without post_id. - $response = $this->perform_mock_request( - 'POST', - $this->route, - $this->sample_access_plan_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseMessageEquals( 'Missing parameter(s): post_id', $response ); - - } - - /** - * Test access plan alteration is allowed to who can edit parent post - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_altering_access_plan_allowed_to_who_can_edit_parent_post() { - - $instructor = $this->factory->user->create( - array( 'role' => 'instructor' ) - ); - $assistant = $this->factory->user->create( - array( 'role' => 'instructors_assistant' ) - ); - $course = $this->factory->course->create_and_get(); - - // Assign the instructors to the course. - $course->set_instructors( - array( - array( - 'id' => $instructor - ), - array( - 'id' => $assistant - ), - ) - ); - - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - ) - ); - - // Instructors of the Course with post_id can manipulate. - wp_set_current_user( $instructor ); - - // Creation is allowed. - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - $this->assertResponseStatusEquals( 201, $response ); - $new_plan_id = $response->get_data()['id']; - - // Update is allowed. - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $new_plan_id, - array( - 'title' => 'Title can change', - ) - ); - - // Update is allowed. - $this->assertResponseStatusEquals( 200, $response ); - - // Deletion is allowed. - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $new_plan_id - ); - $this->assertResponseStatusEquals( 204, $response ); - - // Check the same happens with intructors assistants - - // Instructor's Assistant of the Course with post_id can manipulate. - wp_set_current_user( $assistant ); - - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - ) - ); - - // Creation is allowed. - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - $this->assertResponseStatusEquals( 201, $response ); - $new_plan_id = $response->get_data()['id']; - - // Update is allowed. - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $new_plan_id, - array( - 'title' => 'Title can change', - ) - ); - - // Update is allowed. - $this->assertResponseStatusEquals( 200, $response ); - - // Deletion is allowed. - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $new_plan_id - ); - $this->assertResponseStatusEquals( 204, $response ); - - } - - /** - * Test deleting a non existent access plan - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_delete_non_existent_access_plan() { - - wp_set_current_user( $this->user_allowed ); - - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/12569' - ); - - $this->assertResponseStatusEquals( 204, $response ); - $this->assertEquals( '', $response->get_data() ); - - } - - /** - * Test updating a non existent access plan - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_update_non_existent_access_plan() { - - wp_set_current_user( $this->user_allowed ); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/12569', - $this->sample_access_plan_args - ); - - // Not found. - $this->assertResponseStatusEquals( 404, $response ); - - } - - /** - * Test forbidden single access plan creation - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_create_access_plan_forbidden() { - wp_set_current_user( $this->user_forbidden ); - - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $this->factory->course->create(), - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Forbidden. - $this->assertResponseStatusEquals( 403, $response ); - - // Check that a generic instructor can't create an access plan. - wp_set_current_user( $this->factory->user->create( array( 'role' => 'instructor' ) ) ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - } - - /** - * Test creating single access plan without permissions - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_create_access_plan_without_permissions() { - wp_set_current_user( 0 ); - - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $this->factory->course->create(), - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Unauthorized. - $this->assertResponseStatusEquals( 401, $response ); - - } - - /** - * Test create free access plan - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_create_free_access_plan() { - - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - 'price' => 0, - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Check that the access plan has the following properties values: - $free_props = array( - 'is_free' => 'yes', - 'price' => 0, - 'frequency' => 0, - 'on_sale' => 'no', - 'trial_offer' => 'no', - ); - - $ap = new LLMS_Access_Plan( $response->get_data()['id'] ); - foreach ( $free_props as $prop => $value ) { - $this->assertEquals( $value, $ap->get( $prop ), $prop ); - } - - // Check again, that even the passed properties are "reset". - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - 'price' => 0, - 'frequency' => 6, - 'sale_enabled' => true, - 'trial_enabled' => true, - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - $ap = new LLMS_Access_Plan( $response->get_data()['id'] ); - foreach ( $free_props as $prop => $value ) { - $this->assertEquals( $value, $ap->get( $prop ), $prop ); - } - - } - - /** - * Test update free access plan. - * - * @since 1.0.0-beta-24 - * - * @return void - */ - public function test_update_free_access_plan() { - // Create free access plan. - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - 'price' => 0, - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - $access_plan_id = $response->get_data()['id']; - - // Update the title. - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $access_plan_id, - array( - 'title' => 'Updated Title', - ) - ); - - // Update is allowed. - $this->assertResponseStatusEquals( 200, $response ); - $ap = new LLMS_Access_Plan( $access_plan_id ); - $this->assertEquals( $ap->get('title'), 'Updated Title' ); - - } - - /** - * Test create free paid access plan - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_create_paid_access_plan() { - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - 'price' => 10, - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Check that the access plan has the following properties values: - $paid_props = array( - 'is_free' => 'no', - ); - - $ap = new LLMS_Access_Plan( $response->get_data()['id'] ); - foreach ( $paid_props as $prop => $value ) { - $this->assertEquals( $value, $ap->get( $prop ), $prop ); - } - - // Now test that if the frequency is 0 (default) and we enable the trial, the trial is still disabled. - $sample_args['trial_enabled'] = true; - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Check that the access plan has the following properties values: - $paid_props = array( - 'is_free' => 'no', - 'trial_offer' => 'no', - 'frequency' => 0, - ); - - $ap = new LLMS_Access_Plan( $response->get_data()['id'] ); - foreach ( $paid_props as $prop => $value ) { - $this->assertEquals( $value, $ap->get( $prop ), $prop ); - } - - // Test that a frequency > 0 unlocks trials. - $sample_args['frequency'] = 1; - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - $this->assertTrue( - llms_parse_bool( - ( new LLMS_Access_Plan( $response->get_data()['id'] ) )->get( 'trial_offer' ) - ) - ); - } - - /** - * Test availability_restrictions. - * - * @since 1.0.0-beta-24 - * - * @return void - */ - public function test_availability_restrictions() { - - // Create an access plan. - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - $this->assertResponseStatusEquals( 201, $response ); - $this->assertEmpty( $response->get_data()['availability_restrictions'] ); - - // Add availability_restrictions. - // Create two memberships. - $membership_ids = $this->factory->post->create_many( 2, array( 'post_type' => 'llms_membership' ) ); - $sample_args = array_merge( - $this->sample_access_plan_args, - - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $response->get_data()['id'], - array( - 'availability_restrictions' => $membership_ids, - ) - ); - - $this->assertResponseStatusEquals( 200, $response ); - $this->assertEqualSets( $membership_ids, $response->get_data()['availability_restrictions'] ); - $access_plan = new LLMS_Access_Plan( $response->get_data()['id'] ); - $this->assertEquals( 'members', $access_plan->get( 'availability' ) ); - - // Turn the product post type to a membership. - $membership_id = $this->factory->post->create( array( 'post_type' => 'llms_membership' ) ); - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $response->get_data()['id'], - array( - 'post_id' => $membership_id, - ) - ); - $this->assertEquals( 'open', $access_plan->get( 'availability' ) ); - $this->assertEquals( array(), $access_plan->get( 'availability_restrictions' ) ); - $this->assertFalse( array_key_exists( 'availability_restrictions', $response->get_data() ) ); - // Update the access plan related to membership: no issues: - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $response->get_data()['id'], - array( - 'title' => 'Update this title' - ) - ); - $this->assertEquals( 'open', $access_plan->get( 'availability' ) ); - $this->assertEquals( array(), $access_plan->get( 'availability_restrictions' ) ); - $this->assertFalse( array_key_exists( 'availability_restrictions', $response->get_data() ) ); - - // Turn back the product post type to a course and assign back the restrictions - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $response->get_data()['id'], - array( - 'post_id' => $course->get( 'id' ), - 'availability_restrictions' => $membership_ids, - ) - ); - // Availability restricted again. - $this->assertEquals( 'members', $access_plan->get( 'availability' ) ); - // Availability restrictions returned for memberships in edit context. - $this->assertEqualSets( $membership_ids, $response->get_data()['availability_restrictions'] ); - - // Flush the availability restrictions. - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $response->get_data()['id'], - array( - 'availability_restrictions' => array(), - ) - ); - $this->assertEquals( 'open', $access_plan->get( 'availability' ) ); - $this->assertEmpty( $response->get_data()['availability_restrictions'] ); - - } - - /** - * Test availability_restrictions validation. - * - * @since 1.0.0-beta-24 - * - * @return void - */ - public function test_availability_restrictions_validation_error() { - - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - 'availability_restrictions' => 7, // Not valid. - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - $this->assertResponseStatusEquals( 400, $response ); - $this->assertEquals( 'Invalid parameter.', $response->get_data()['data']['params']['availability_restrictions'] ); - - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - 'availability_restrictions' => array( 20 ), // Not valid. - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - $this->assertResponseStatusEquals( 400, $response ); - $this->assertEquals( 'Invalid parameter.', $response->get_data()['data']['params']['availability_restrictions'] ); - - } - - /** - * Test frequency validation. - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_frequency_validation_error() { - - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - 'frequency' => 7 // Not valid. - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - // Invalid. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertEquals( 'Must be an integer in the range 0-6', $response->get_data()['data']['params']['frequency'] ); - - } - - /** - * Test post id validation - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_post_id_validation_error() { - - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( - 'POST', - $this->route, - array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $this->factory->course->create() + 10, // This post id doesn't exist at all. - ) - ) - ); - - // Invalid. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertEquals( 'Must be a valid course or membership ID', $response->get_data()['data']['params']['post_id'] ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $this->factory->post->create(), // This post id is not of a course or membership. - ) - ) - ); - // Invalid. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertEquals( 'Must be a valid course or membership ID', $response->get_data()['data']['params']['post_id'] ); - - // Test same thing when updating. - $access_plan_id = $this->factory->post->create( array( 'post_type' => $this->post_type ) ); - update_post_meta( $access_plan_id, '_llms_product_id', $this->factory->course->create() ); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $access_plan_id, - array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $this->factory->post->create(), // This post id is not of a course or membership. - ) - ) - ); - - // Blocked. - $this->assertResponseStatusEquals( 400, $response ); - $this->assertEquals( 'Must be a valid course or membership ID', $response->get_data()['data']['params']['post_id'] ); - - } - - /** - * Test access plan limit. - * - * @since 1.0.0-beta.18 - * @since 1.0.0-beta-24 Check updating an access plan of a product with access plan limit reached. - * - * @return void - */ - public function test_access_plan_limit() { - - wp_set_current_user( $this->user_allowed ); - - foreach ( array( 'course', 'llms_membership' ) as $pt ) { - - // Create 5 access plans, by default the limit is 6 per product. - $access_plan_ids = $this->factory->post->create_many( 5, array( 'post_type' => $this->post_type ) ); - - $product = $this->factory->post->create( array( 'post_type' => $pt ) ); - - foreach ( $access_plan_ids as $access_plan_id ) { - update_post_meta( $access_plan_id, '_llms_product_id', $product ); - } - - // Create an ap through api with same product id. - $response = $this->perform_mock_request( - 'POST', - $this->route, - array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $product, - ) - ) - ); - $sixth_ap = $response->get_data()['id']; - // The 6th passes. - $this->assertResponseStatusEquals( 201, $response, $pt ); - - // Create the 7th ap. - $response = $this->perform_mock_request( - 'POST', - $this->route, - array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $product, - ) - ) - ); - - // The 7th is blocked. - $this->assertResponseStatusEquals( 400, $response, $pt ); - $this->assertResponseMessageEquals( - sprintf( - 'Only %1$d %2$s allowed per %3$s', - 6, - strtolower( get_post_type_object( $this->post_type )->labels->name ), - strtolower( get_post_type_object( $pt )->labels->singular_name ) - ), - $response - ); - - // Update the 6th. - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $sixth_ap, - array( - 'title' => 'Updated', - ) - ); - - // Update passes. - $this->assertResponseStatusEquals( 200, $response, $pt ); - - // Create an ap linked to a different product. - $access_plan = $this->factory->post->create( array( 'post_type' => $this->post_type ) ); - $new_product = $this->factory->post->create( array( 'post_type' => $pt ) ); - update_post_meta( $access_plan, '_llms_product_id', $new_product ); - - // Update its post_id so that it becomes the 7th ap of the first product. - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $access_plan, - array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $product, - ) - ) - ); - - // The 7th is blocked. - $this->assertResponseStatusEquals( 400, $response, $pt ); - $this->assertResponseMessageEquals( - sprintf( - 'Only %1$d %2$s allowed per %3$s', - 6, - strtolower( get_post_type_object( $this->post_type )->labels->name ), - strtolower( get_post_type_object( $pt )->labels->singular_name ) - ), - $response - ); - } - } - - /** - * Test creation defaults respected - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_creation_defaults_respected() { - - wp_set_current_user( $this->user_allowed ); - - $course = $this->factory->course->create_and_get(); - $sample_args = array_merge( - $this->sample_access_plan_args, - array( - 'post_id' => $course->get( 'id' ), - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_args - ); - - /** - * see LLMS_REST_Access_Plans_Controller::unset_subordinate_props() - */ - $deps = array( - 'access_length' => 0, // This is not set if 'access_expiration' is not 'limited-period' (default is 'lifetime'). - 'access_period' => '', // This is not set if 'access_expiration' is not 'limited-period' (default is 'lifetime'). - 'access_expires' => '', // This is not set if 'access_expiration' is not 'limited-period' (default is 'lifetime'). - - 'period' => '' , // This is not set if 'frequency' is 0 (default). - - 'trial_length' => 0, // This is not set if 'trial_offer' is 'no' (default). - 'trial_period' => '', // This is not set if 'trial_offer' is 'no' (default). - ); - - foreach ( array_merge( $this->defaults, $deps ) as $prop => $val ) { - $this->assertEquals( $val, $response->get_data()[$prop], $prop ); - } - - } - - /** - * Test filter collection by post_id - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_collection_filtering() { - - wp_set_current_user( $this->user_allowed ); - - $access_plan_ids = $this->factory->post->create_many( 5, array( 'post_type' => $this->post_type ) ); - - // Link the plans to two different courses. - $course_one = $this->factory->course->create(); - $course_two = $this->factory->course->create(); - $i = 0; - foreach ( $access_plan_ids as $access_plan_id ) { - update_post_meta( $access_plan_id, '_llms_product_id', ${ 0 === ( ++$i % 2 ) ? 'course_one' : 'course_two' } ); - } - - // Filter by first course. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'post_id' => $course_one, - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( array_fill( 0, 2, $course_one ), array_column( $res_data, 'post_id' ) ); - - // Filter by second course. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'post_id' => $course_two, - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( array_fill( 0, 3, $course_two ), array_column( $res_data, 'post_id' ) ); - - // Filter by both. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'post_id' => array( - $course_two, - $course_one - ) - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $array_of_five = array_fill( 0, 5, null ); - $this->assertEquals( - array_map( - function( $val, $i ) use ( $course_one, $course_two ){ - return ${ 0 === ( ++$i % 2 ) ? 'course_one' : 'course_two' }; - }, - $array_of_five, - array_keys( $array_of_five ) - ), - array_column( - $res_data, 'post_id' - ) - ); - - // Add another course. - $access_plan_id = $this->factory->post->create( array( 'post_type' => $this->post_type ) ); - $course_three = $this->factory->course->create(); - update_post_meta( $access_plan_id, '_llms_product_id', $course_three ); - - // Check again filtering by one and two. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'post_id' => array( - $course_two, - $course_one - ) - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $array_of_five = array_fill( 0, 5, null ); - $this->assertEquals( - array_map( - function( $val, $i ) use ( $course_one, $course_two ){ - return ${ 0 === ( ++$i % 2 ) ? 'course_one' : 'course_two' }; - }, - $array_of_five, - array_keys( $array_of_five ) - ), - array_column( - $res_data, 'post_id' - ) - ); - - } - - /** - * Test links - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_links() { - - wp_set_current_user( $this->user_allowed ); - - $access_plan_id = $this->factory->post->create( array( 'post_type' => $this->post_type ) ); - $expected_link_rels = $this->expected_link_rels; - - // Link the plan to a course. - $course = $this->factory->course->create(); - update_post_meta( $access_plan_id, '_llms_product_id', $course ); - - // Limit it by membership. - $membership = $this->factory->membership->create(); - update_post_meta( $access_plan_id, '_llms_availability_restrictions', array( $membership ) ); - update_post_meta( $access_plan_id, '_llms_availability', 'members' ); - - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $access_plan_id ); - - $this->assertEquals( $expected_link_rels, array_keys( $response->get_links() ) ); - - // Expect the related resource is the course. - $this->assertStringEndsWith( - sprintf( - 'rest_route=/%s/%s/%s', - 'llms/v1', - 'courses', - $course - ), - $response->get_links()['post'][0]['href'] - ); - - // Remove availability restrictions. - update_post_meta( $access_plan_id, '_llms_availability', '' ); - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $access_plan_id ); - unset( $expected_link_rels[ array_search( 'restrictions', $expected_link_rels, true ) ] ); - - $this->assertEquals( $expected_link_rels, array_keys( $response->get_links() ) ); - - // Link the plan to a membership. - $membership = $this->factory->post->create( array( 'post_type' => 'llms_membership' ) ); - update_post_meta( $access_plan_id, '_llms_product_id', $membership ); - - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $access_plan_id ); - - $this->assertEquals( $expected_link_rels, array_keys( $response->get_links() ) ); - - // Expect the related resource is the membership. - $this->assertStringEndsWith( - sprintf( - 'rest_route=/%s/%s/%s', - 'llms/v1', - 'memberships', - $membership - ), - $response->get_links()['post'][0]['href'] - ); - - - } - - /** - * Create a resource for this post type. - * - * @since 1.0.0-beta.25 - * - * @param array $params Array of request params. - * @return WP_Post - */ - protected function create_post_resource( $params = array() ) { - - $course_id = $this->factory->course->create( - array( - 'sections' => 0, - ) - ); - - return parent::create_post_resource( - array( - 'price' => 0, - 'post_id' => $course_id, - ) - ); - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-api-keys-controller.php b/tests/unit-tests/server/class-llms-rest-test-api-keys-controller.php deleted file mode 100644 index 5d96d08b..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-api-keys-controller.php +++ /dev/null @@ -1,426 +0,0 @@ -user_allowed = $this->factory->user->create( array( 'role' => 'administrator', ) ); - $this->user_forbidden = $this->factory->user->create( array( 'role' => 'subscriber', ) ); - $this->endpoint = new LLMS_REST_API_Keys_Controller(); - - } - - /** - * Teardown test - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function tear_down() { - - parent::tear_down(); - - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}lifterlms_api_keys" ); - - } - - /** - * Test route registration. - * - * @since 1.0.0-beta.1 - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - } - - public function test_get_item_schema() { - - $schema = $this->endpoint->get_item_schema(); - $this->assertTrue( array_key_exists( '$schema', $schema ) ); - $this->assertTrue( array_key_exists( 'title', $schema ) ); - $this->assertTrue( array_key_exists( 'type', $schema ) ); - $this->assertTrue( array_key_exists( 'properties', $schema ) ); - $this->assertTrue( array_key_exists( 'description', $schema['properties'] ) ); - $this->assertTrue( array_key_exists( 'permissions', $schema['properties'] ) ); - $this->assertTrue( array_key_exists( 'user_id', $schema['properties'] ) ); - $this->assertTrue( array_key_exists( 'truncated_key', $schema['properties'] ) ); - $this->assertTrue( array_key_exists( 'last_access', $schema['properties'] ) ); - - } - - /** - * Test error responses for creating a key - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_item_errors() { - - // Empty body. - $response = $this->perform_mock_request( 'POST', $this->route ); - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseCodeEquals( 'rest_missing_callback_param', $response ); - - // Unauthorized. - $args = array( - 'description' => 'Mock Description', - 'user_id' => $this->factory->user->create(), - 'permissions' => 'read', - ); - $response = $this->perform_mock_request( 'POST', $this->route, $args ); - $this->assertResponseStatusEquals( 401, $response ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $response ); - - // Forbidden. - wp_set_current_user( $this->user_forbidden ); - $response = $this->perform_mock_request( 'POST', $this->route, $args ); - $this->assertResponseStatusEquals( 403, $response ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $response ); - - // Invalid submitted user_id - wp_set_current_user( $this->user_allowed ); - $args['user_id'] = 9032423402934; - $response = $this->perform_mock_request( 'POST', $this->route, $args ); - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseCodeEquals( 'rest_invalid_param', $response ); - - } - - /** - * Test creation of a new key success. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_item_success() { - - wp_set_current_user( $this->user_allowed ); - $args = array( - 'description' => 'Mock Description', - 'user_id' => $this->factory->user->create(), - 'permissions' => 'read', - ); - $response = $this->perform_mock_request( 'POST', $this->route, $args ); - - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( $args['description'], $res_data['description'] ); - $this->assertEquals( $args['user_id'], $res_data['user_id'] ); - $this->assertEquals( $args['permissions'], $res_data['permissions'] ); - $this->assertTrue( array_key_exists( 'id', $res_data ) ); - $this->assertTrue( array_key_exists( 'consumer_key', $res_data ) ); - $this->assertTrue( array_key_exists( 'consumer_secret', $res_data ) ); - $this->assertTrue( array_key_exists( 'last_access', $res_data ) ); - $this->assertEquals( $res_data['truncated_key'], substr( $res_data['consumer_key'], -7 ) ); - - $headers = $response->get_headers(); - $this->assertTrue( array_key_exists( 'Location', $headers ) ); - - $links = $response->get_links(); - $this->assertTrue( array_key_exists( 'self', $links ) ); - $this->assertTrue( array_key_exists( 'collection', $links ) ); - $this->assertTrue( array_key_exists( 'user', $links ) ); - - } - - /** - * Test the permissions check methods. - * - * @return void - */ - public function test_check_permissions() { - - $request = new WP_REST_Request( 'GET', $this->route ); - - $methods = array( - 'create_item_permissions_check', - 'delete_item_permissions_check', - 'get_item_permissions_check', - 'get_items_permissions_check', - 'update_item_permissions_check', - ); - - // No user. - wp_set_current_user( null ); - foreach ( $methods as $method ) { - $res = $this->endpoint->{$method}( $request ); - $this->assertIsWPError( $res ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $res ); - } - - - // Disallowed User. - wp_set_current_user( $this->user_forbidden ); - foreach ( $methods as $method ) { - $res = $this->endpoint->{$method}( $request ); - $this->assertIsWPError( $res ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $res ); - } - - // Allowed User. - wp_set_current_user( $this->user_allowed ); - foreach ( $methods as $method ) { - $this->assertTrue( $this->endpoint->{$method}( $request ) ); - } - - } - - /** - * test the delete_item() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_delete_item() { - - wp_set_current_user( $this->user_allowed ); - - $key = $this->get_mock_api_key( 'read_write', $this->user_allowed, false ); - $id = $key->get( 'id' ); - - // Successful deletion. - $response = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 204, $response ); - $this->assertFalse( LLMS_REST_API()->keys()->get( $id ) ); - - // Responds 204 even if resource can't be found. - $response = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 204, $response ); - - } - - /** - * test the get_item() for an invalid resource. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_item_not_found() { - - wp_set_current_user( $this->user_allowed ); - - $key = $this->get_mock_api_key( 'read_write', $this->user_allowed, false ); - $id = $key->get( 'id' ) + 1; - - $response = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 404, $response ); - $this->assertResponseCodeEquals( 'llms_rest_not_found', $response ); - - } - - /** - * test the get_item() for an invalid resource. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_item_success() { - - wp_set_current_user( $this->user_allowed ); - - $key = $this->get_mock_api_key( 'read_write', $this->user_allowed, false ); - $id = $key->get( 'id' ); - - $response = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( $id, $res_data['id'] ); - $this->assertEquals( $key->get( 'description' ), $res_data['description'] ); - $this->assertEquals( $key->get( 'permissions' ), $res_data['permissions'] ); - $this->assertEquals( $key->get( 'user_id' ), $res_data['user_id'] ); - $this->assertEquals( $key->get( 'user_id' ), $res_data['user_id'] ); - $this->assertEquals( $key->get( 'truncated_key' ), $res_data['truncated_key'] ); - $this->assertTrue( array_key_exists( 'last_access', $res_data ) ); - - $links = $response->get_links(); - $this->assertTrue( array_key_exists( 'self', $links ) ); - $this->assertTrue( array_key_exists( 'collection', $links ) ); - $this->assertTrue( array_key_exists( 'user', $links ) ); - - } - - /** - * test the get_items() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_items_pagination() { - - wp_set_current_user( $this->user_allowed ); - - // No results. - $response = $this->perform_mock_request( 'GET', $this->route ); - $this->assertResponseStatusEquals( 200, $response ); - - // Make keys for remaining tests. - $keys = $this->create_many_api_keys( 25 ); - - $this->pagination_test(); - - } - - /** - * test the update_item() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_item() { - - wp_set_current_user( $this->user_allowed ); - - $key = $this->get_mock_api_key( 'read_write', $this->user_allowed, false ); - $id = $key->get( 'id' ); - - $updates = array( - 'description' => 'New Description', - 'user_id' => $this->factory->user->create(), - 'permissions' => 'read', - ); - - $response = $this->perform_mock_request( 'POST', sprintf( '%1$s/%2$d', $this->route, $id ), $updates ); - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( $id, $res_data['id'] ); - $this->assertEquals( $updates['description'], $res_data['description'] ); - $this->assertEquals( $updates['permissions'], $res_data['permissions'] ); - $this->assertEquals( $updates['user_id'], $res_data['user_id'] ); - $this->assertEquals( $key->get( 'truncated_key' ), $res_data['truncated_key'] ); - - $links = $response->get_links(); - $this->assertTrue( array_key_exists( 'self', $links ) ); - $this->assertTrue( array_key_exists( 'collection', $links ) ); - $this->assertTrue( array_key_exists( 'user', $links ) ); - - } - - /** - * Test the prepare collection query args method. - * - * @since 1.0.0-beta.1 - * - * @return [type] - */ - public function test_prepare_collection_query_args() { - - $route = $this->route; - - // Defaults (no args passed). - $request = new WP_REST_Request( 'GET', $route ); - $args = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_collection_query_args', array( $request ) ); - $this->assertEquals( array(), $args ); - - // Pass order and use default orderby. - $request = new WP_REST_Request( 'GET', $route ); - $request->set_query_params( array( 'order' => 'desc' ) ); - $args = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_collection_query_args', array( $request ) ); - $this->assertEquals( array( - 'sort' => array( - 'id' => 'desc', - ), - ), $args ); - - // Pass orderby and use default order. - $request = new WP_REST_Request( 'GET', $route ); - $request->set_query_params( array( 'orderby' => 'last_access' ) ); - $args = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_collection_query_args', array( $request ) ); - $this->assertEquals( array( - 'sort' => array( - 'last_access' => 'asc', - ), - ), $args ); - - // Pass orderby and order. - $request = new WP_REST_Request( 'GET', $route ); - $request->set_query_params( array( - 'orderby' => 'last_access', - 'order' => 'desc' - ) ); - $args = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_collection_query_args', array( $request ) ); - $this->assertEquals( array( - 'sort' => array( - 'last_access' => 'desc', - ), - ), $args ); - - // Set other args. - // Pass orderby and order. - $request = new WP_REST_Request( 'GET', $route ); - $request->set_query_params( array( - 'include' => '1,2,3,4,5', - 'exclude' => '83', - 'user' => '1', - 'user_not_in' => '25,26', - 'permissions' => 'read', - ) ); - $args = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_collection_query_args', array( $request ) ); - $this->assertEquals( array( - 'include' => range( 1, 5 ), - 'exclude' => array( 83 ), - 'user' => array( 1 ), - 'user_not_in' => array( 25, 26 ), - 'permissions' => 'read', - ), $args ); - - } - - /** - * Test the validate_user_exists callback method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_validate_user_exists() { - - $this->assertTrue( $this->endpoint->validate_user_exists( $this->user_allowed ) ); - $this->assertFalse( $this->endpoint->validate_user_exists( $this->factory->user->create() + 1 ) ); - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-courses.php b/tests/unit-tests/server/class-llms-rest-test-courses.php deleted file mode 100644 index 9326a3b9..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-courses.php +++ /dev/null @@ -1,1676 +0,0 @@ -perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * Added `@return` to doc. - * Use the far less predictable `wp_wp_rand()` in place of `wp_rand()`. - * @version 1.0.0-beta.17 - * - * @todo update tests to check links. - * @todo do more tests on the courses update/delete. - */ -class LLMS_REST_Test_Courses extends LLMS_REST_Unit_Test_Case_Posts { - - /** - * Route. - * - * @var string - */ - protected $route = '/llms/v1/courses'; - - /** - * Post type. - * - * @var string - */ - protected $post_type = 'course'; - - /** - * Taxonomies shown in rest. - * - * @var string[] - */ - protected $rest_taxonomies = array( - 'course_cat', - 'course_difficulty', - 'course_tag', - 'course_track', - ); - - /** - * This is an internal flag we use to determine whether or not - * we need to use a step of 2 ids when testing the pagination. - * - * @var array - */ - protected $generates_revision_on_creation = true; - - /** - * - * Setup our test server, endpoints, and user info. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.7 Block migration forcing and db cleanup moved in LLMS_REST_Unit_Test_Case_Posts::set_up() - * - * @return void - */ - public function set_up() { - - parent::set_up(); - $this->endpoint = new LLMS_REST_Courses_Controller(); - $this->user_allowed = $this->factory->user->create( - array( - 'role' => 'administrator', - ) - ); - - $this->user_forbidden = $this->factory->user->create( - array( - 'role' => 'subscriber', - ) - ); - - $this->sample_course_args = array( - 'title' => array( - 'rendered' => 'Getting Started with LifterLMS', - 'raw' => 'Getting Started with LifterLMS', - ), - 'content' => array( - 'rendered' => "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - 'raw' => "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - ), - 'date_created' => '2019-05-20 17:22:05', - 'status' => 'publish', - ); - - } - - /** - * Test route registration. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - // Enrollments. - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)/enrollments', $routes ); - // Child sections. - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)/content', $routes ); - } - - - /** - * Test list courses. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_courses() { - - wp_set_current_user( $this->user_allowed ); - - // create 12 courses. - $courses = $this->factory->course->create_many( 12, array( 'sections' => 0 ) ); - - $response = $this->perform_mock_request( - 'GET', - $this->route - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - $this->assertEquals( 10, count( $res_data ) ); // default per_page is 10. - - // Check retrieved courses are the same as the generated ones. - // Note: the check can be done in this simple way as by default the rest api courses are ordered by id. - for ( $i = 0; $i < 10; $i++ ) { - $this->llms_posts_fields_match( new LLMS_Course( $courses[ $i ] ), $res_data[ $i ] ); - } - - $headers = $response->get_headers(); - $this->assertEquals( 12, $headers['X-WP-Total'] ); - $this->assertEquals( 2, $headers['X-WP-TotalPages'] ); - - } - - /** - * Test list courses pagination success. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_courses_with_pagination() { - - wp_set_current_user( $this->user_allowed ); - - $course_ids = $this->factory->course->create_many( 25, array( 'sections' => 0 ) ); - $start_course_id = $course_ids[0]; - $this->pagination_test( $this->route, $start_course_id ); - - } - - /** - * Test list courses include arg. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_courses_include() { - - wp_set_current_user( $this->user_allowed ); - - // create 15 courses. - $courses = $this->factory->course->create_many( 5, array( 'sections' => 0 ) ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - // get only the 2nd and 3rd course. - 'include' => "$courses[1], $courses[2]", - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - $this->assertEquals( 2, count( $res_data ) ); - - // Check retrieved courses are the same as the second and third generated courses. - for ( $i = 0; $i < 2; $i++ ) { - $this->llms_posts_fields_match( new LLMS_Course( $courses[ $i + 1 ] ), $res_data[ $i ] ); - } - - } - - /** - * Test list courses exclude arg. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_courses_exclude() { - - wp_set_current_user( $this->user_allowed ); - - // create 15 courses. - $courses = $this->factory->course->create_many( 5, array( 'sections' => 0 ) ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - // esclude 1st and 2nd course. - array( - 'exclude' => "$courses[0], $courses[1]", - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - $this->assertEquals( 3, count( $res_data ) ); - - // Check retrieved data do not contain first and second created courses. - $this->assertEquals( array_slice( $courses, 2 ), wp_list_pluck( $res_data, 'id' ) ); - } - - /** - * Test list courses ordered by id desc. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_courses_ordered_by_id_desc() { - - wp_set_current_user( $this->user_allowed ); - - // create 5 courses. - $courses = $this->factory->course->create_many( 5, array( 'sections' => 0 ) ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'order' => 'desc', // default is 'asc'. - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - // Check retrieved courses are the same as the generated ones but in the reversed order. - // Note: the check can be done in this simple way as by default the rest api courses are ordered by id. - $reversed_data = array_reverse( $res_data ); - for ( $i = 0; $i < 5; $i++ ) { - $this->llms_posts_fields_match( new LLMS_Course( $courses[ $i ] ), $reversed_data[ $i ] ); - } - - } - - /** - * Test list courses ordered by title. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_courses_ordered_by_title() { - - wp_set_current_user( $this->user_allowed ); - - // create 3 courses. - $courses = $this->factory->course->create_many( 3, array( 'sections' => 0 ) ); - - $course_first = new LLMS_Course( $courses[0] ); - $course_first->set( 'title', 'Course B' ); - $course_second = new LLMS_Course( $courses[1] ); - $course_second->set( 'title', 'Course A' ); - $course_second = new LLMS_Course( $courses[2] ); - $course_second->set( 'title', 'Course C' ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'orderby' => 'title', // default is id. - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - // Check retrieved courses are ordered by title asc. - $this->assertEquals( 'Course A', $res_data[0]['title']['rendered'] ); - $this->assertEquals( 'Course B', $res_data[1]['title']['rendered'] ); - $this->assertEquals( 'Course C', $res_data[2]['title']['rendered'] ); - - } - - /** - * Test list courses ordered by title - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_courses_ordered_by_title_desc() { - - wp_set_current_user( $this->user_allowed ); - - // create 3 courses. - $courses = $this->factory->course->create_many( 3, array( 'sections' => 0 ) ); - - $course_first = new LLMS_Course( $courses[0] ); - $course_first->set( 'title', 'Course B' ); - $course_second = new LLMS_Course( $courses[1] ); - $course_second->set( 'title', 'Course A' ); - $course_second = new LLMS_Course( $courses[2] ); - $course_second->set( 'title', 'Course C' ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'orderby' => 'title', // default is id. - 'order' => 'desc', // default is 'asc'. - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - // Check retrieved courses are ordered by title desc. - $this->assertEquals( 'Course C', $res_data[0]['title']['rendered'] ); - $this->assertEquals( 'Course B', $res_data[1]['title']['rendered'] ); - $this->assertEquals( 'Course A', $res_data[2]['title']['rendered'] ); - } - - /** - * Test getting courses: bad request. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_courses_bad_request() { - - wp_set_current_user( $this->user_allowed ); - - // create 5 courses. - $courses = $this->factory->course->create_many( 5, array( 'sections' => 0 ) ); - - // Bad request, there's no page 2. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'page' => 2, - ) - ); - - // Success. - $this->assertResponseStatusEquals( 400, $response ); - - // Bad request, order param allowed are only "desc" and "asc" (enum). - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'order' => 'not_desc', - ) - ); - - // Success. - $this->assertResponseStatusEquals( 400, $response ); - - } - - /** - * Test getting a single course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.8 Added check on `sales_page_*` defaults. - * Also renamed `sales_page_page_type` and `sales_page_page_url` properties, - * respectively to `sales_page_type` and `sales_page_url` according to the specs. - * @since 1.0.0-beta.9 Added checks on `sales_page_page_id` and - * `sales_page_page_url` always returned in `edit` context. - * Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_course() { - - wp_set_current_user( $this->user_allowed ); - - // Setup course. - $course = $this->factory->course->create_and_get(); - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course->get( 'id' ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - // Check retrieved course matches the created ones. - $this->llms_posts_fields_match( $course, $res_data ); - - // Sales page type. - $this->assertEquals( 'none', $res_data['sales_page_type'] ); - $this->assertFalse( array_key_exists( 'sales_page_page_id', $res_data ) ); - $this->assertFalse( array_key_exists( 'sales_page_url', $res_data ) ); - - // Check that in edit context `sales_page_page_id` and `sales_page_url`, - // are still returned. - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course->get( 'id' ), - array(), - array( 'context' => 'edit' ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( 'none', $res_data['sales_page_type'] ); - $this->assertTrue( array_key_exists( 'sales_page_page_id', $res_data ) ); - $this->assertTrue( array_key_exists( 'sales_page_url', $res_data ) ); - - } - - /** - * Test getting single course that doesn't exist - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_get_nonexistent_course() { - - wp_set_current_user( 0 ); - - // Setup course. - $course_id = $this->factory->course->create(); - - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course_id . '4' - ); - - // The Course doesn't exist. - $this->assertResponseStatusEquals( 404, $response ); - - } - - /** - * Test creating a single course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.7 Add checks on nullable dates. - * @since 1.0.0-beta.8 Add missing quotes in enrollment/access default messages shortcodes. - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course() { - - wp_set_current_user( $this->user_allowed ); - - $catalog_visibility = array_keys( llms_get_product_visibility_options() )[2]; - $sample_course_args = array_merge( - $this->sample_course_args, - array( - 'catalog_visibility' => $catalog_visibility, - 'instructors' => array( - get_current_user_id(), - $this->factory->user->create( - array( - 'role' => 'instructor', - ) - ), - ), - 'video_tile' => true, - 'access_opens_date' => '', - 'access_closes_date' => '', - 'enrollment_opens_date' => '', - 'enrollment_closes_date' => '', - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( $sample_course_args['title']['rendered'], $res_data['title']['rendered'] ); - /** - * The rtrim below is not ideal but at the moment we have templates printed after the course summary (e.g. prerequisites) that, - * even when printing no data they still print "\n". Let's pretend we're not interested in testing the trailing "\n" presence. - */ - $this->assertEquals( rtrim( $sample_course_args['content']['rendered'], "\n" ), rtrim( $res_data['content']['rendered'], "\n" ) ); - - $this->assertEquals( $sample_course_args['date_created'], $res_data['date_created'] ); - $this->assertEquals( $sample_course_args['status'], $res_data['status'] ); - $this->assertEquals( $sample_course_args['catalog_visibility'], $res_data['catalog_visibility'] ); - $this->assertEquals( $sample_course_args['instructors'], $res_data['instructors'] ); - $this->assertEquals( $sample_course_args['video_tile'], $res_data['video_tile'] ); - - $date_props = array( - 'access_opens_date', - 'access_closes_date', - 'enrollment_opens_date', - 'enrollment_closes_date', - ); - foreach ( $date_props as $empty_prop ) { - $this->assertEquals( '', $res_data[ $empty_prop ] ); - } - } - - /** - * Test creating a single course without a list of instructors. - * - * @since 1.0.0-beta.9 - */ - public function test_create_course_create_with_empty_instructors() { - - wp_set_current_user( $this->user_allowed ); - - $response = $this->perform_mock_request( 'POST', $this->route, $this->sample_course_args ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - $res_data = $response->get_data(); - - // check the instructors post meta has been set as expected. - $this->assertEquals( array( $this->user_allowed ), wp_list_pluck( get_post_meta( $res_data['id'], '_llms_instructors', true ), 'id' ) ); - - } - - - /** - * Test creating a single course with incorrect list of instructors. - * - * @since 1.0.0-beta.9 - */ - public function test_create_course_create_with_bad_instructors_list() { - wp_set_current_user( $this->user_allowed ); - - // The list cannot contain not existent ids. - $sample_course_args = array_merge( - $this->sample_course_args, - array( - 'instructors' => array( - get_current_user_id(), - 7383931 - ), - ) - ); - - $response = $this->perform_mock_request( 'POST', $this->route, $sample_course_args ); - - // 400 error. - $this->assertResponseStatusEquals( 400, $response ); - - // The list cannot be empty. - $sample_course_args = array_merge( - $this->sample_course_args, - array( - 'instructors' => array(), - ) - ); - - $response = $this->perform_mock_request( 'POST', $this->route, $sample_course_args ); - - // 400 error. - $this->assertResponseStatusEquals( 400, $response ); - - } - - /** - * Test creating a single course defaults are correctly set. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.8 Renamed `sales_page_page_type` to `sales_page_type` according to the specs. - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_check_defaults() { - - wp_set_current_user( $this->user_allowed ); - - $course_args = array( - 'title' => 'Title', - 'content' => 'Content', - 'access_opens_date' => '2019-05-22 17:20:05', - 'access_closes_date' => '2019-05-22 17:23:08', - 'enrollment_opens_date' => '2019-05-22 17:22:05', - 'enrollment_closes_date' => '2019-05-22 17:22:08', - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - $res_data = $response->get_data(); - - // Check defaults. - // Access period messages. - $this->assertEquals( 'This course opens on [lifterlms_course_info id="' . $res_data['id'] . '" key="start_date"].', $res_data['access_opens_message']['raw'] ); - $this->assertEquals( do_shortcode( 'This course opens on [lifterlms_course_info id="' . $res_data['id'] . '" key="start_date"].' ), $res_data['access_opens_message']['rendered'] ); - $this->assertEquals( 'This course closed on [lifterlms_course_info id="' . $res_data['id'] . '" key="end_date"].', $res_data['access_closes_message']['raw'] ); - $this->assertEquals( do_shortcode( 'This course closed on [lifterlms_course_info id="' . $res_data['id'] . '" key="end_date"].' ), $res_data['access_closes_message']['rendered'] ); - - // Enrollment period messages. - $this->assertEquals( 'Enrollment in this course opens on [lifterlms_course_info id="' . $res_data['id'] . '" key="enrollment_start_date"].', $res_data['enrollment_opens_message']['raw'] ); - $this->assertEquals( do_shortcode( 'Enrollment in this course opens on [lifterlms_course_info id="' . $res_data['id'] . '" key="enrollment_start_date"].' ), $res_data['enrollment_opens_message']['rendered'] ); - $this->assertEquals( 'Enrollment in this course closed on [lifterlms_course_info id="' . $res_data['id'] . '" key="enrollment_end_date"].', $res_data['enrollment_closes_message']['raw'] ); - $this->assertEquals( do_shortcode( 'Enrollment in this course closed on [lifterlms_course_info id="' . $res_data['id'] . '" key="enrollment_end_date"].' ), $res_data['enrollment_closes_message']['rendered'] ); - - // Capacity enabled. - $this->assertFalse( $res_data['capacity_enabled'] ); - - // Catalog visibility. - $this->assertEquals( 'catalog_search', $res_data['catalog_visibility'] ); - - // Categories. - $this->assertEquals( array(), $res_data['categories'] ); - - // Comment_status. - $this->assertEquals( 'open', $res_data['comment_status'] ); - - // Difficulties. - $this->assertEquals( array(), $res_data['difficulties'] ); - - // Instructors. If empty, llms core responds with the course author in an array. - $this->assertEquals( array( get_current_user_id() ), $res_data['instructors'] ); - - // Menu order. - $this->assertEquals( 0, $res_data['menu_order'] ); - - // Comment_status. - $this->assertEquals( 'open', $res_data['ping_status'] ); - - // Sales page type. - $this->assertEquals( 'none', $res_data['sales_page_type'] ); - - // Status. - $this->assertEquals( 'publish', $res_data['status'] ); - - // Tags. - $this->assertEquals( array(), $res_data['tags'] ); - - // Tracks. - $this->assertEquals( array(), $res_data['tracks'] ); - - // Video tile. - $this->assertFalse( $res_data['video_tile'] ); - } - - /** - * Test creating a single course special props. - * These props, when set, alter the rendered content so we test them separetaly. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_special() { - - wp_set_current_user( $this->user_allowed ); - - $sample_course_args = array_merge( - $this->sample_course_args, - array( - 'audio_embed' => 'https://www.youtube.com/abc', - 'video_embed' => 'www.youtube.com/efg', - 'capacity_limit' => 22, - 'capacity_enabled' => true, - 'capacity_message' => 'Enrollment has closed because the maximum number of allowed students has been reached.', - 'access_opens_date' => '2019-05-22 17:20:05', - 'access_closes_date' => '2019-05-22 17:23:08', - 'enrollment_opens_date' => '2019-05-22 17:22:05', - 'enrollment_closes_date' => '2019-05-22 17:22:08', - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $sample_course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( esc_url_raw( $sample_course_args['audio_embed'] ), $res_data['audio_embed'] ); - $this->assertEquals( esc_url_raw( $sample_course_args['video_embed'] ), $res_data['video_embed'] ); - $this->assertEquals( $sample_course_args['capacity_enabled'], $res_data['capacity_enabled'] ); - $this->assertEquals( do_shortcode( $sample_course_args['capacity_message'] ), $res_data['capacity_message']['rendered'] ); - $this->assertEquals( $sample_course_args['capacity_limit'], $res_data['capacity_limit'] ); - - // Dates. - $this->assertEquals( $sample_course_args['access_opens_date'], $res_data['access_opens_date'] ); - $this->assertEquals( $sample_course_args['access_closes_date'], $res_data['access_closes_date'] ); - $this->assertEquals( $sample_course_args['enrollment_opens_date'], $res_data['enrollment_opens_date'] ); - $this->assertEquals( $sample_course_args['enrollment_closes_date'], $res_data['enrollment_closes_date'] ); - } - - /** - * Test creating a single course with taxonomies - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_with_taxonomies() { - - wp_set_current_user( $this->user_allowed ); - $taxonomies = array( - 'categories' => array( - 1, - 2, - 3, - ), - 'tags' => array( - 6, - 4, - 8, - ), - 'difficulties' => array( - 9, - ), - 'tracks' => array( - 7, - 5, - 6, - ), - ); - - $course_args = array_merge( - $this->sample_course_args, - $taxonomies - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Terms have not ben created, I expect the course is created with empty taxonomies. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - foreach ( $taxonomies as $tax => $tid ) { - $this->assertEquals( array(), $res_data[ $tax ] ); - } - - // let's create the terms. - $taxonomies = array( - 'categories' => $this->factory()->term->create_many( - 3, - array( - 'taxonomy' => 'course_cat', - ) - ), - 'tags' => $this->factory()->term->create_many( - 3, - array( - 'taxonomy' => 'course_tag', - ) - ), - 'difficulties' => $this->factory()->term->create_many( - 1, - array( - 'taxonomy' => 'course_difficulty', - ) - ), - 'tracks' => $this->factory()->term->create_many( - 3, - array( - 'taxonomy' => 'course_track', - ) - ), - ); - - $course_args = array_merge( - $this->sample_course_args, - $taxonomies - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Terms have been created, I expect the course is created with taxonomies set. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - foreach ( $taxonomies as $tax => $tid ) { - $this->assertEquals( $tid, $res_data[ $tax ] ); - } - } - - /** - * Test creating a single course with taxonomies - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_with_prerequisites() { - wp_set_current_user( $this->user_allowed ); - - $course_args = array_merge( - $this->sample_course_args, - array( - 'prerequisite' => 2, - 'prerequisite_track' => 5, - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - // Courses with id 2 do not exist, hence I expect an empty prerequisite property. - $this->assertEquals( 0, $res_data['prerequisite'] ); - // Tracks with id 5 do not exist, hence I expect an empty prerequisite track. - $this->assertEquals( 0, $res_data['prerequisite_track'] ); - - $course = new LLMS_Course( $res_data['id'] ); - - // Check that the created course's has_prerequisite is set accordingly. - $this->assertEquals( 'no', $course->get( 'has_prerequisite' ) ); - - // Create a course and a track. - $prereq_course = $this->factory->course->create( array( 'sections' => 0 ) ); - $prereq_track = $this->factory()->term->create( - array( - 'taxonomy' => 'course_track', - ) - ); - - $course_args = array_merge( - $this->sample_course_args, - array( - 'prerequisite' => $prereq_course, - 'prerequisite_track' => $prereq_track, - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - // I expect prerequisites now match. - $this->assertEquals( $prereq_course, $res_data['prerequisite'] ); - $this->assertEquals( $prereq_track, $res_data['prerequisite_track'] ); - - $course = new LLMS_Course( $res_data['id'] ); - - // Check that the created course's has_prerequisite is set accordingly. - $this->assertEquals( 'yes', $course->get( 'has_prerequisite' ) ); - - } - - /** - * Test course "periods". - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_and_periods() { - - wp_set_current_user( $this->user_allowed ); - - $course_args = array_merge( - $this->sample_course_args, - array( - 'access_opens_date' => '2019-05-22 17:20:05', - 'enrollment_closes_date' => '2019-05-22 17:22:05', - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - $course = new LLMS_Course( $res_data['id'] ); - - // Check that the created course's 'time_period' is enabled, since one of access_opens_date and access_closes_date is set. - $this->assertEquals( 'yes', $course->get( 'time_period' ) ); - // Check that the created course's 'enrollment_period' is enabled, since one of enrollment_opens_date and enrollment_closes_date is set. - $this->assertEquals( 'yes', $course->get( 'enrollment_period' ) ); - - $course_args = array_merge( - $this->sample_course_args, - array( - 'access_closes_date' => '2019-05-22 17:20:05', - 'enrollment_opens_date' => '2019-05-22 17:22:05', - ) - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - $course = new LLMS_Course( $res_data['id'] ); - - // Check that the created course's 'time_period' is enabled, since one of access_opens_date and access_closes_date is set. - $this->assertEquals( 'yes', $course->get( 'time_period' ) ); - // Check that the created course's 'enrollment_period' is enabled, since one of enrollment_opens_date and enrollment_closes_date is set. - $this->assertEquals( 'yes', $course->get( 'enrollment_period' ) ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $this->sample_course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - $course = new LLMS_Course( $res_data['id'] ); - - // Check that the created course's 'time_period' is not enabled, since none of access_opens_date and access_closes_date is set. - $this->assertEquals( 'no', $course->get( 'time_period' ) ); - // Check that the created course's 'enrollment_period' is not enabled, since none of enrollment_opens_date and enrollment_closes_date is set. - $this->assertEquals( 'no', $course->get( 'enrollment_period' ) ); - - } - - /** - * Test create course with raw properties. - * Check textual properties are still set when supplying them as 'raw'. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_and_raws() { - - wp_set_current_user( $this->user_allowed ); - - $course_raw_messages = array( - 'length' => array( - 'raw' => 'Length raw message', - ), - 'restricted_message' => array( - 'raw' => 'Restricted raw message', - ), - 'capacity_message' => array( - 'raw' => 'Capacity raw message', - ), - 'access_opens_message' => array( - 'raw' => 'Access opens raw message', - ), - 'access_closes_message' => array( - 'raw' => 'Access closes raw message', - ), - 'enrollment_opens_message' => array( - 'raw' => 'Enrollment opens raw message', - ), - 'enrollment_closes_message' => array( - 'raw' => 'Enrollment closess raw message', - ), - ); - - $course_args = array_merge( - $this->sample_course_args, - $course_raw_messages - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - - $res_data = $response->get_data(); - - foreach ( $course_raw_messages as $property => $content ) { - $this->assertEquals( $content['raw'], $res_data[ $property ]['raw'] ); - } - - } - - /** - * Test producing bad request error when creating a single course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * Use the far less predictable `wp_wp_rand()` in place of `wp_rand()`. - * @return void - */ - public function test_create_course_bad_request() { - - wp_set_current_user( $this->user_allowed ); - - $course_args = $this->sample_course_args; - - // Creating a course passing an id produces a bad request. - $course_args['id'] = '123'; - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - - // create a course without title. - $course_args = $this->sample_course_args; - unset( $course_args['title'] ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - - // create a course without content. - $course_args = $this->sample_course_args; - unset( $course_args['content'] ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - - // status param must respect the item scehma, hence one of "publish" "pending" "draft" "auto-draft" "future" "private" "trash". - $course_args = $this->sample_course_args; - $status = array_merge( array_keys( get_post_statuses() ), array( 'future', 'trash', 'auto-draft' ) ); - $course_args['status'] = $status[0] . wp_rand() . 'not_in_enum'; - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - - // catalog_visibility param must respect the item schema, hence one of array_keys( llms_get_product_visibility_options() ). - $course_args = $this->sample_course_args; - $catalog_visibility = array_keys( llms_get_product_visibility_options() ); - $course_args['catalog_visibility'] = $catalog_visibility[0] . wp_rand() . 'not_in_enum'; - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $course_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 400, $response ); - - } - - /** - * Test creating single course without permissions. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_without_permissions() { - - wp_set_current_user( 0 ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $this->sample_course_args - ); - - // Unhauthorized. - $this->assertResponseStatusEquals( 401, $response ); - - } - - /** - * Test forbidden single course creation. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_create_course_forbidden() { - - wp_set_current_user( $this->user_forbidden ); - - $response = $this->perform_mock_request( - 'POST', - $this->route, - $this->sample_course_args - ); - - // Forbidden. - $this->assertResponseStatusEquals( 403, $response ); - - } - - - /** - * Test updating a course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.7 Add tests on prerequisites. - * @since 1.0.0-beta.9 Use `$this->assertResponseStatusEquals()` util. - * - * @return void - */ - public function test_update_course() { - - // create a course first. - $course = $this->factory->course->create_and_get(); - - wp_set_current_user( $this->user_allowed ); - - // update. - $update_data = array( - 'title' => 'A TITLE UPDTAED', - 'content' => '

CONTENT UPDATED

', - 'date_created' => '2019-05-22 17:22:05', - 'status' => 'draft', - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $course->get( 'id' ), - $update_data - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( $update_data['title'], $res_data['title']['raw'] ); - $this->assertEquals( $update_data['title'], $res_data['title']['rendered'] ); - $this->assertEquals( rtrim( apply_filters( 'the_content', $update_data['content'] ), "\n" ), rtrim( $res_data['content']['rendered'], "\n" ) ); - $this->assertEquals( $update_data['date_created'], $res_data['date_created'] ); - $this->assertEquals( $update_data['status'], $res_data['status'] ); - - // Check the course has no prerequisites. - $course = new LLMS_Course( $res_data['id'] ); - $this->assertFalse( $course->has_prerequisite() ); - - // Create a course prerequisite. - $prerequisite_id = $this->factory->course->create(); - $track = wp_insert_term( 'mock track', 'course_track' ); - $prerequisite_track_id = $track['term_id']; - - // Update prerequisites. - $update_data = array( - 'prerequisite' => (int) $prerequisite_id, - 'prerequisite_track' => $prerequisite_track_id, - ); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $course->get( 'id' ), - $update_data - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - // Check the course has prerequisites. - $course = new LLMS_Course( $res_data['id'] ); - $this->assertTrue( $course->has_prerequisite() ); - $this->assertTrue( $course->has_prerequisite( 'course' ) ); - $this->assertTrue( $course->has_prerequisite( 'course_track' ) ); - $this->assertEquals( $course->get( 'prerequisite' ), $res_data['prerequisite'] ); - $this->assertEquals( $update_data['prerequisite'], $res_data['prerequisite'] ); - $this->assertEquals( $course->get( 'prerequisite_track' ), $res_data['prerequisite_track'] ); - $this->assertEquals( $update_data['prerequisite_track'], $res_data['prerequisite_track'] ); - - } - - /** - * Test updating a nonexistent course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_update_nonexistent_course() { - - wp_set_current_user( $this->user_allowed ); - - $id = 48987456; - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $id, - $this->sample_course_args - ); - - // Not found. - $this->assertResponseStatusEquals( 404, $response ); - - } - - /** - * Test forbidden single course update. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_update_forbidden_course() { - - // create a course first. - $course = $this->factory->course->create_and_get(); - - wp_set_current_user( $this->user_forbidden ); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $course->get( 'id' ), - $this->sample_course_args - ); - - // Bad request. - $this->assertResponseStatusEquals( 403, $response ); - - } - - /** - * Test single course update without authorization. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_update_course_without_authorization() { - - // create a course first. - $course = $this->factory->course->create_and_get(); - - wp_set_current_user( 0 ); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $course->get( 'id' ), - $this->sample_course_args - ); - - // Unauthorized. - $this->assertResponseStatusEquals( 401, $response ); - - } - - /** - * Test deleting a single course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_delete_course() { - - wp_set_current_user( $this->user_allowed ); - - // create a course first. - $course = $this->factory->course->create_and_get(); - - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $course->get( 'id' ), - array(), - array( - 'force' => true, - ) - ); - - // Success. - $this->assertResponseStatusEquals( 204, $response ); - // empty body. - $this->assertEquals( null, $response->get_data() ); - - // Cannot find just deleted post. - $this->assertFalse( get_post_status( $course->get( 'id' ) ) ); - - } - - /** - * Test trashing a single course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_trash_course() { - - wp_set_current_user( $this->user_allowed ); - - // create a course first. - $course = $this->factory->course->create_and_get(); - - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $course->get( 'id' ), - array(), - array( - 'force' => false, - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - // Non empty body. - $this->assertTrue( ! empty( $res_data ) ); - // Deleted post status should be 'trash'. - $this->assertEquals( 'trash', get_post_status( $course->get( 'id' ) ) ); - // check the trashed post returned into the response is the correct one. - $this->assertEquals( $course->get( 'id' ), $res_data['id'] ); - // check the trashed post returned into the response has the correct status 'trash'. - $this->assertEquals( 'trash', $res_data['status'] ); - - // Trash again I expect the same as above. - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $course->get( 'id' ), - array(), - array( - 'force' => false, - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - // Non empty body. - $this->assertTrue( ! empty( $res_data ) ); - // Deleted post status should be 'trash'. - $this->assertEquals( 'trash', get_post_status( $course->get( 'id' ) ) ); - // check the trashed post returned into the response is the correct one. - $this->assertEquals( $course->get( 'id' ), $res_data['id'] ); - // check the trashed post returned into the response has the correct status 'trash'. - $this->assertEquals( 'trash', $res_data['status'] ); - - } - - /** - * Test deleting a nonexistent single course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_delete_nonexistent_course() { - - wp_set_current_user( $this->user_allowed ); - - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/747484940' - ); - - // Post not found, so it's "deleted". - $this->assertResponseStatusEquals( 204, $response ); - $this->assertEquals( '', $response->get_data() ); - - } - - /** - * Test getting bad request response when deleting a course. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_delete_bad_request_course() { - - wp_set_current_user( $this->user_allowed ); - - // create a course first. - $course = $this->factory->course->create_and_get(); - - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $course->get( 'id' ), - array(), - array( - 'force' => 'bad_parameter_value', - ) - ); - - // Bad request because of a bad parameter. - $this->assertResponseStatusEquals( 400, $response ); - - } - - /** - * Test single course update without authorization. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_delete_forbidden_course() { - - // create a course first. - $course = $this->factory->course->create_and_get(); - - wp_set_current_user( $this->user_forbidden ); - - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $course->get( 'id' ) - ); - - // Forbidden. - $this->assertResponseStatusEquals( 403, $response ); - - } - - /** - * Test single course deletion without authorization. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @return void - */ - public function test_delete_course_without_authorization() { - - // create a course first. - $course = $this->factory->course->create_and_get(); - - wp_set_current_user( 0 ); - - $response = $this->perform_mock_request( - 'DELETE', - $this->route . '/' . $course->get( 'id' ) - ); - - // Unauthorized. - $this->assertResponseStatusEquals( 401, $response ); - - } - - /** - * Test list course content. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @todo test order and orderby - * - * @return void - */ - public function test_get_course_content() { - - wp_set_current_user( $this->user_allowed ); - - // create 1 course with no sections. - $course = $this->factory->course->create( - array( - 'sections' => 0, - ) - ); - - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course . '/content' - ); - - // We have no sections for this course so we expect a 404. - $this->assertResponseStatusEquals( 404, $response ); - - // create 1 course with 5 sections. - $course = $this->factory->course->create( - array( - 'sections' => 5, - ) - ); - - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course . '/content' - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - $this->assertEquals( 5, count( $res_data ) ); - - } - - /** - * Test list course content. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.9 Use `$this->perform_mock_request()` and `$this->assertResponseStatusEquals()` utils. - * - * @todo test order and orderby - * - * @return void - */ - public function test_get_course_enrollments() { - - wp_set_current_user( $this->user_allowed ); - - // create 1 course. - $course = $this->factory->course->create(); - - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course . '/enrollments' - ); - - // We have no students enrolled for this course so we expect a 404. - $this->assertResponseStatusEquals( 404, $response ); - - // create 5 students and enroll them. - $student_ids = $this->factory->student->create_and_enroll_many( 5, $course ); - - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course . '/enrollments' - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - $this->assertEquals( 5, count( $res_data ) ); - - // Filter by student_id. - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $course . '/enrollments', - array(), - array( - 'student' => "$student_ids[0]", - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - $this->assertEquals( 1, count( $res_data ) ); - $this->assertEquals( $student_ids[0], $res_data[0]['student_id'] ); - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-enrollments.php b/tests/unit-tests/server/class-llms-rest-test-enrollments.php deleted file mode 100644 index eb6d80b8..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-enrollments.php +++ /dev/null @@ -1,744 +0,0 @@ -[\d]+)/enrollments'; - - /** - * Consider dates equal for +/- 1 mins - * - * @var integer - */ - private $date_delta = 60; - - - /** - * Array of link $rels expected for each item. - * - * @var array - */ - private $expected_link_rels = array( 'self', 'collection', 'student', 'post' ); - - /** - * Setup our test server, endpoints, and user info. - */ - public function set_up() { - parent::set_up(); - - global $wpdb; - $wpdb->query( "DELETE FROM {$wpdb->prefix}lifterlms_user_postmeta" ); - - $this->endpoint = new LLMS_REST_Enrollments_Controller(); - - $this->user_allowed = $this->factory->user->create( - array( - 'role' => 'administrator', - ) - ); - - $this->user_forbidden = $this->factory->user->create( - array( - 'role' => 'subscriber', - ) - ); - } - - - /** - * Test route registration. - * - * @since 1.0.0-beta.1 - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - } - - /** - * Test list student enrollments. - * - * @since 1.0.0-beta.1 - */ - public function test_get_enrollments() { - - wp_set_current_user( $this->user_allowed ); - - // Create user. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - // Create new courses. - $course_ids = $this->factory->post->create_many( 5, array( 'post_type' => 'course' ) ); - - foreach ( $course_ids as $course_id ) { - // Enroll Student in newly created course. - llms_enroll_student( $user_id, $course_id, 'test_get_enrollments' ); - } - - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ) ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - - // Expect 5 enrollments. - $this->assertEquals( 5, count( $res_data ) ); - - // Check enrollments post_id. - $i = 0; - foreach ( $res_data as $enrollment ) { - $this->assertEquals( $course_ids[$i], $res_data[$i]['post_id'] ); - // Make sure post_id and student_id are integers. - $this->assertIsInt( $res_data[$i]['post_id'] ); - $this->assertIsInt( $res_data[$i]['student_id'] ); - $i++; - } - - } - - /** - * Test list student enrollments pagination. - * - * @since 1.0.0-beta.3 - * @since 1.0.0-beta.11 Fixed pagination test taking into account course post revisions. - */ - public function test_get_enrollments_pagination() { - - wp_set_current_user( $this->user_allowed ); - - // Create enrollments. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - // Create new courses. - $course_ids = $this->factory->post->create_many( 25, array( 'post_type' => 'course' ) ); - $start_course_id = $course_ids[0]; - - foreach ( $course_ids as $course_id ) { - // Enroll Student in newly created course. - llms_enroll_student( $user_id, $course_id, 'test_get_enrollments_pagination' ); - } - - $route = $this->parse_route( $user_id ); - - $this->pagination_test( $route, $start_course_id, 10, 'post_id', $total = 25, $ids_step = 2 ); - } - - /** - * Test list student enrollments filter by post_id. - * - * @since 1.0.0-beta.1 - */ - public function test_get_enrollments_filter_post() { - - wp_set_current_user( $this->user_allowed ); - - // Create enrollments. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - // Create new courses. - $course_ids = $this->factory->post->create_many( 10, array( 'post_type' => 'course' ) ); - - $j = 0; - $courses = array(); - foreach ( $course_ids as $course_id ) { - if ( 0 === ( $j++ % 2 ) ) { - // Enroll Student in newly created course. - llms_enroll_student( $user_id, $course_id, 'test_filter_enrollments' ); - $courses[] = $course_id; - } - } - - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ), array(), array( 'post' => "$courses[1],$courses[2]" ) ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - - // Expect 2 enrollments. - $this->assertEquals( 2, count( $res_data ) ); - - // Check enrollments post_id. - $i = 0; - foreach ( $res_data as $enrollment ) { - $this->assertEquals( $courses[$i+1], $res_data[$i++]['post_id'] ); - } - - } - - /** - * Test getting current user enrollments permissions. - * - * @since 1.0.0-beta.4 - */ - public function test_get_current_user_enrollments_permissions() { - - // Create an user. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - // Setup course. - $course_id = $this->factory->course->create(); - wp_set_current_user( $this->user_allowed ); - llms_enroll_student( $user_id, $course_id, 'test_get_current_user_enrollments' ); - - wp_set_current_user( $user_id ); - - // Check we can list our own enrollments. - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ) ); - - // Check we have permissions to make this request. - $this->assertNotEquals( 403, $response->get_status() ); - // And that the list of enrollments contains the enrolled course. - $enrollments = $response->get_data(); - $this->assertEquals( $course_id, $enrollments[0]['post_id'] ); - - // Check we can get our own single enrollment. - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ) . '/' . $course_id ); - - // Check we have permissions to make this request. - $this->assertNotEquals( 403, $response->get_status() ); - // And that the list of enrollments contains the enrolled course. - $enrollment = $response->get_data(); - $this->assertEquals( $course_id, $enrollment['post_id'] ); - - } - - /** - * Test getting enrollments without permission. - * - * @since 1.0.0-beta.1 - */ - public function test_get_enrollments_without_permission() { - - wp_set_current_user( 0 ); - - // Setup course. - $this->factory->course->create(); - - $response = $this->perform_mock_request( 'GET', $this->parse_route( 1 ) ); - // Check we don't have permissions to make this request. - $this->assertResponseStatusEquals( 401, $response ); - - } - - /** - * Test getting enrollments: forbidden request. - * - * @since 1.0.0-beta.1 - */ - public function test_get_enrollments_forbidden() { - - wp_set_current_user( $this->user_forbidden ); - - // Setup course. - $this->factory->course->create(); - - $response = $this->perform_mock_request( 'GET', $this->parse_route( 1 ) ); - - // Check we're not allowed to get results. - $this->assertResponseStatusEquals( 403, $response ); - - } - - /** - * Test get single student enrollment - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Added test on the trigger property. - * @since 1.0.0-beta.16 Compare dates as timestamps. - */ - public function test_get_enrollment() { - - wp_set_current_user( $this->user_allowed ); - - // Create enrollment. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - // Create new courses. - $course_id = $this->factory->post->create_many( 2, array( 'post_type' => 'course' ) ); - $date_now = date( 'Y-m-d H:i:s' ); - llms_enroll_student( $user_id, $course_id[0], 'test_get_enrollment' ); - - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ) . '/' . $course_id[0] ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - - // Check: - $this->assertEquals( $user_id, $res_data['student_id'] ); - $this->assertEquals( $course_id[0], $res_data['post_id'] ); - $this->assertEquals( 'enrolled', $res_data['status'] ); - $this->assertEqualsWithdelta( strtotime( $date_now ), strtotime( $res_data['date_created'] ), $this->date_delta ); - $this->assertEquals( $res_data['date_created'], $res_data['date_updated'] ); - - $student = new LLMS_Student($user_id); - $this->assertEquals( $res_data['status'], $student->get_enrollment_status( $course_id[0] ) ); - $this->assertEquals( $res_data['date_created'], $student->get_enrollment_date( $course_id[0], 'enrolled', 'Y-m-d H:i:s' ) ); - $this->assertEquals( $res_data['date_updated'], $student->get_enrollment_date( $course_id[0], 'updated', 'Y-m-d H:i:s' ) ); - $this->assertEquals( $res_data['trigger'], $student->get_enrollment_trigger( $course_id[0] ) ); - - } - - /** - * Test getting enrollment without permission. - * - * @since 1.0.0-beta.1 - */ - public function test_get_enrollment_without_permission() { - - wp_set_current_user( $this->user_allowed ); - - // Create enrollment. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - // Create new courses. - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - llms_enroll_student( $user_id, $course_id, 'test_get_enrollment_noperm' ); - - wp_set_current_user( 0 ); - - // Setup course. - $this->factory->course->create(); - - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ) . '/' . $course_id ); - - // Check we don't have permissions to make this request. - $this->assertResponseStatusEquals( 401, $response ); - - } - - /** - * Test getting enrollment: forbidden request. - * - * @since 1.0.0-beta.1 - */ - public function test_get_enrollment_forbidden() { - - wp_set_current_user( $this->user_forbidden ); - - // Create enrollment. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - // Create new courses. - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - llms_enroll_student( $user_id, $course_id, 'test_get_enrollment_forbidden' ); - - // Setup course. - $this->factory->course->create(); - - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ) . '/' . $course_id ); - - // Check we're not allowed to get results. - $this->assertResponseStatusEquals( 403, $response ); - - } - - /** - * Test create enrollment. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Added test on the trigger property. - * @since 1.0.0-beta.16 Compare dates as timestamps. - */ - public function test_create_enrollment() { - - wp_set_current_user( $this->user_allowed ); - - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - $response = $this->perform_mock_request( 'POST', $this->parse_route( $user_id ) . '/' . $course_id ); - $date_now = date( 'Y-m-d H:i:s' ); - - // Success. - $this->assertResponseStatusEquals( 201, $response ); - $res_data = $response->get_data(); - - // Check: - $this->assertEquals( $user_id, $res_data['student_id'] ); - $this->assertEquals( $course_id, $res_data['post_id'] ); - $this->assertEquals( 'enrolled', $res_data['status'] ); - $this->assertEqualsWithDelta( strtotime( $date_now ), strtotime( $res_data['date_created'] ), $this->date_delta ); - $this->assertEquals( $res_data['date_created'], $res_data['date_updated'] ); - $this->assertEquals( 'unspecified', $res_data['trigger'] ); - - // Links. - $this->assertEquals( $this->expected_link_rels, array_keys( $response->get_links() ) ); - - } - - /** - * Test producing bad request error when creating a single enrollment. - * - * @since 1.0.0-beta.1 - */ - public function test_create_enrollment_bad_request() { - - wp_set_current_user( $this->user_allowed ); - - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - // Bad request: post is not enrollable. - $lesson_id = $this->factory->post->create( array( 'post_type' => 'lesson' ) ); - $response = $this->perform_mock_request( 'POST', $this->parse_route( $user_id ) . '/' . $lesson_id ); - - $this->assertResponseStatusEquals( 400, $response ); - - // Invalid date. - llms_enroll_student( $user_id, $course_id ); - $response = $this->perform_mock_request( 'PATCH', $this->parse_route( $user_id ) . '/' . $course_id, array( 'date_created' => 'some_invalid_date' ) ); - $this->assertResponseStatusEquals( 400, $response ); - - } - - /** - * Test update enrollment status. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Added test on the trigger property/arg. - */ - public function test_update_enrollment_status() { - - wp_set_current_user( $this->user_allowed ); - - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - // Enroll Student in newly created course/membership - llms_enroll_student( $user_id, $course_id, 'test_update_status' ); - - sleep(1); //<- to be sure the new status is subsequent the one set on creation. - - $response = $this->perform_mock_request( 'PATCH', $this->parse_route( $user_id ) . '/' . $course_id, array( 'status' => 'expired' ) ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - - // Check: - $this->assertEquals( $user_id, $res_data['student_id'] ); - $this->assertEquals( $course_id, $res_data['post_id'] ); - $this->assertEquals( 'expired', $res_data['status'] ); - $student = new LLMS_Student( $user_id ); - $this->assertEquals( $res_data['status'], $student->get_enrollment_status( $course_id, false ) ); - - // Enroll and check the trigger is admin_{$this->user_allowed}. - // Clean: - $student->delete_enrollment( $course_id ); - // Insert an enrollment with a "different" trigger. - $student->enroll( $course_id, 'whatever_trigger' ); - // Unenroll. - $student->unenroll( $course_id ); - $this->assertEquals( 'expired', $student->get_enrollment_status( $course_id ) ); - $this->assertEquals( 'whatever_trigger', $student->get_enrollment_trigger( $course_id, false ) ); - - // Enroll via api. - sleep(1); //<- To be sure the new status is subsequent the one previously set. - $response = $this->perform_mock_request( 'PATCH', $this->parse_route( $user_id ) . '/' . $course_id, array( 'status' => 'enrolled' ) ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( 'enrolled', $res_data['status'] ); - $this->assertEquals( 'enrolled', $student->get_enrollment_status( $course_id, true ) ); - $this->assertEquals( "admin_{$this->user_allowed}", $student->get_enrollment_trigger( $course_id ) ); - - // Check update passing a trigger. - $status = 'expired'; - $trigger = ( new LLMS_Student( $user_id ) )->get_enrollment_trigger( $course_id ); - sleep(1); //<- To be sure the new status is subsequent the one previously set. - - $response = $this->perform_mock_request( - 'PATCH', $this->parse_route( $user_id ) . '/' . $course_id, - array( - 'status' => $status, - ), - array( - 'trigger' => $trigger, - ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( $status, $res_data['status'] ); - $this->assertEquals( $status, $student->get_enrollment_status( $course_id, true ) ); - $this->assertEquals( $trigger, $student->get_enrollment_trigger( $course_id ) ); - } - - /** - * Test update enrollment creation date. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Added test on the trigger arg. - */ - public function test_update_enrollment_creation_date() { - - wp_set_current_user( $this->user_allowed ); - - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - // Enroll Student in newly created course/membership. - llms_enroll_student( $user_id, $course_id, 'test_update_creation' ); - - $new_date = date( 'Y-m-d H:i:s', strtotime('+1 year') ); - $response = $this->perform_mock_request( - 'PATCH', $this->parse_route( $user_id ) . '/' . $course_id, - array( 'date_created' => $new_date ) - ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - - // Check: - $this->assertEquals( $user_id, $res_data['student_id'] ); - $this->assertEquals( $course_id, $res_data['post_id'] ); - $this->assertEquals( $new_date, $res_data['date_created'] ); - - $student = new LLMS_Student( $user_id ); - $this->assertEquals( $res_data['date_created'], $student->get_enrollment_date( $course_id, 'enrolled', 'Y-m-d H:i:s' ) ); - - // Check update passing a trigger. - $new_date = date( 'Y-m-d H:i:s', strtotime('+2 year') ); - - $response = $this->perform_mock_request( - 'PATCH', $this->parse_route( $user_id ) . '/' . $course_id, - array( - 'date_created' => $new_date, - ), - array( - 'trigger' => ( new LLMS_Student( $user_id ) )->get_enrollment_trigger( $course_id ) - ) - ); - - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - - $this->assertEquals( $user_id, $res_data['student_id'] ); - $this->assertEquals( $course_id, $res_data['post_id'] ); - $this->assertEquals( $new_date, $res_data['date_created'] ); - - } - - /** - * Test producing 404 request errort. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Improve tests on update and add tests on the trigger arg. - */ - public function test_enrollments_not_found() { - - wp_set_current_user( $this->user_allowed ); - - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - /* Create */ - // User not enrolled. - $response = $this->perform_mock_request( 'GET', $this->parse_route( $user_id ) ); - $this->assertResponseStatusEquals( 404, $response ); - - // User id doesn't exist. - $response = $this->perform_mock_request( 'POST', $this->parse_route( $user_id . '1234' ) . '/' . $course_id ); - $this->assertResponseStatusEquals( 404, $response ); - - // Course id doesn't exist. - $response = $this->perform_mock_request( 'POST', $this->parse_route( $user_id ) . '/' . $course_id . '1245' ); - $this->assertResponseStatusEquals( 404, $response ); - - // Update and Retrieve. - foreach ( array( 'PATCH', 'GET' ) as $method ) { - // User id doesn't exist. - $response = $this->perform_mock_request( $method, $this->parse_route( $user_id . '1234' ) . '/' . $course_id ); - $this->assertResponseStatusEquals( 404, $response ); - - // Course id doesn't exist. - $response = $this->perform_mock_request( $method, $this->parse_route( $user_id ) . '/' . $course_id . '1245' ); - $this->assertResponseStatusEquals( 404, $response ); - - // User id and course id exist but the enrollment is not found. - $response = $this->perform_mock_request( $method, $this->parse_route( $user_id ) . '/' . $course_id ); - $this->assertResponseStatusEquals( 404, $response ); - } - - // Enroll Student in newly created course/membership. - llms_enroll_student( $user_id, $course_id, 'test_update_creation' ); - - $new_date = date( 'Y-m-d H:i:s', strtotime('+1 year') ); - $response = $this->perform_mock_request( 'PATCH', $this->parse_route( $user_id ) . '/' . $course_id, array( 'date_created' => $new_date ), array( 'trigger' => 'wrong' ) ); - - // Cannot update because the enrollment with the specified trigger doesn't exist. - $this->assertResponseStatusEquals( 404, $response ); - - } - - /** - * Test retrieving enrollment trigger. - * - * @since 1.0.0-beta.18 - */ - public function test_enrollment_trigger() { - - wp_set_current_user( $this->user_allowed ); - - // Create an enrollment, we need a student and a course/membership. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - $student = new LLMS_Student( $user_id ); - // Create new course. - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - - // Enroll Student in newly created course/membership. - llms_enroll_student( $user_id, $course_id, 'test_enroll' ); - - // Unenroll the student. - sleep(1); //<- To be sure the new status is subsequent the one previously set. - llms_unenroll_student( $user_id, $course_id, 'expired', 'test_enroll' ); - $this->assertEquals( 'expired', $student->get_enrollment_status( $course_id, false ) ); - - // Enroll the student again. - sleep(1); //<- To be sure the new status is subsequent the one previously set. - llms_enroll_student( $user_id, $course_id, 'test_enroll_again' ); - - $response = $this->perform_mock_request( - 'GET', - $this->parse_route( $user_id ) . '/' . $course_id - ); - - $this->assertEquals( - $student->get_enrollment_trigger( $course_id, false ), - $response->get_data()['trigger'] - ); - - } - - /** - * Test deleting a single enrollment. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.10 Added tests on trigger arg. - */ - public function test_delete_enrollment() { - - wp_set_current_user( $this->user_allowed ); - - // Create an enrollment, we need a student and a course/membership. - $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - // Create new course. - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - - // Enroll Student in newly created course/membership. - llms_enroll_student( $user_id, $course_id, 'test_delete' ); - - // Delete user's enrollment. - $response = $this->perform_mock_request( - 'DELETE', - $this->parse_route( $user_id ) . '/' . $course_id - ); - - // Success. - $this->assertResponseStatusEquals( 204, $response ); - // Student should not be enrolled in course. - $this->assertFalse( llms_is_user_enrolled( $user_id, $course_id ) ); - - // Enroll Student in newly created course/membership. - llms_enroll_student( $user_id, $course_id, 'test_delete' ); - - $response = $this->perform_mock_request( - 'DELETE', - $this->parse_route( $user_id ) . '/' . $course_id, - array(), - array( 'trigger' => 'wrong' ) - ); - - // Success (idempotency). - $this->assertResponseStatusEquals( 204, $response ); - // Student should still be enrolled in the course. - $this->assertTrue( llms_is_user_enrolled( $user_id, $course_id ) ); - - // Using the right trigger. - $response = $this->perform_mock_request( - 'DELETE', $this->parse_route( $user_id ) . '/' . $course_id, - array(), - array( - 'trigger' => ( new LLMS_Student( $user_id ) )->get_enrollment_trigger( $course_id ) - ) - ); - - // Success. - $this->assertResponseStatusEquals( 204, $response ); - // Student should still be enrolled in the course. - $this->assertFalse( llms_is_user_enrolled( $user_id, $course_id ) ); - } - - /** - * Test protected enrollment_exists method. - * - * @since 1.0.0-beta.1 - */ - public function test_enrollment_exists() { - $error_code = 'llms_rest_not_found'; - - $result = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'enrollment_exists', array( 789, 879 ) ); - // Enrollment doesn't exist because both student and course/membership do not exist. - $this->assertWPError( $result ); - - $student_id = $this->factory->user->create( array( 'role' => 'student' ) ); - $result = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'enrollment_exists', array( $student_id, 879 ) ); - // Enrollment doesn't exist because course/membership do not exist. - $this->assertWPError( $result ); - - // Create new course. - $course_id = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $result = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'enrollment_exists', array( $student_id, $course_id ) ); - // Enrollment doesn't exist because the $student has not been enrolled yet. - $this->assertWPError( $result ); - $this->assertWPErrorCodeEquals( $error_code, $result ); - - // Enroll Student. - llms_enroll_student( $student_id, $course_id, 'test_exists' ); - $result = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'enrollment_exists', array( $student_id, $course_id ) ); - // Enrollment exists because the $student has been enrolled yet. - $this->assertTrue( $result ); - - // Enenroll Student. - llms_unenroll_student( $student_id, $course_id ); - $result = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'enrollment_exists', array( $student_id, $course_id ) ); - // Enrollment still exists because the $student has been unenrolled but not deleted. - $this->assertTrue( $result ); - - // Delete student's enrollment - llms_delete_student_enrollment( $student_id, $course_id ); - $result = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'enrollment_exists', array( $student_id, $course_id ) ); - // Enrollment still exists because the $student has been unenrolled but not deleted. - $this->assertWPError( $result ); - $this->assertWPErrorCodeEquals( $error_code, $result ); - } - - private function parse_route( $student_id ) { - return str_replace( '(?P[\d]+)', $student_id, $this->route ); - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-instructors-controllers.php b/tests/unit-tests/server/class-llms-rest-test-instructors-controllers.php deleted file mode 100644 index 6c29ccd2..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-instructors-controllers.php +++ /dev/null @@ -1,286 +0,0 @@ -user_admin = $this->factory->user->create( array( 'role' => 'administrator', ) ); - $this->user_subscriber = $this->factory->user->create( array( 'role' => 'subscriber', ) ); - $this->user_instructor = $this->factory->user->create( array( 'role' => 'instructor', ) ); - $this->user_assistant = $this->factory->user->create( array( 'role' => 'instructors_assistant', ) ); - $asst = llms_get_instructor( $this->user_assistant )->add_parent( $this->user_instructor ); - $this->endpoint = new LLMS_REST_Instructors_Controller(); - - } - - /** - * Test route registration - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - } - - /** - * Ensure all collection parameters have been registered. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_collection_params() { - - $params = $this->endpoint->get_collection_params(); - $this->assertArrayHasKey( 'context', $params ); - $this->assertArrayHasKey( 'page', $params ); - $this->assertArrayHasKey( 'per_page', $params ); - $this->assertArrayHasKey( 'order', $params ); - $this->assertArrayHasKey( 'orderby', $params ); - $this->assertArrayHasKey( 'include', $params ); - $this->assertArrayHasKey( 'roles', $params ); - $this->assertArrayHasKey( 'post_in', $params ); - $this->assertArrayHasKey( 'post_not_in', $params ); - - } - - /** - * Test the item schema. - * - * @since 1.0.0-beta.1 - * - * @return [type] - */ - public function test_get_item_schema() { - - $schema = $this->endpoint->get_item_schema(); - - $this->assertEquals( 'instructor', $schema['title'] ); - - $props = array( - 'id', - 'username', - 'name', - 'first_name', - 'last_name', - 'email', - 'url', - 'description', - 'nickname', - 'registered_date', - 'roles', - 'password', - 'billing_address_1', - 'billing_address_2', - 'billing_city', - 'billing_state', - 'billing_postcode', - 'billing_country', - 'avatar_urls', - ); - - $this->assertEquals( $props, array_keys( $schema['properties'] ) ); - - $this->assertEquals( array( 'instructor' ), $schema['properties']['roles']['default'] ); - - $schema = $this->endpoint->get_item_schema(); - update_option( 'show_avatars', '' ); - $this->assertFalse( array_key_exists( 'avatar_urls', array_keys( $schema['properties'] ) ) ); - - update_option( 'show_avatars', 1 ); - - } - - /** - * Test the get_object method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_object() { - - $id = $this->factory->user->create( array( 'role' => 'instructor' ) ); - - // Good. - $instructor = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'get_object', array( $id ) ); - $this->assertTrue( is_a( $instructor, 'LLMS_Instructor' ) ); - - // 404. - $error_404 = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'get_object', array( $id + 1 ) ); - $this->assertIsWPError( $error_404 ); - $this->assertWPErrorCodeEquals( 'llms_rest_not_found', $error_404 ); - - } - - // public function test_get_items_auth() {} - // public function test_get_items_exclude() {} - // public function test_get_items_include() {} - // public function test_get_items_orderby_id() {} - // public function test_get_items_orderby_email() {} - // public function test_get_items_orderby_name() {} - // public function test_get_items_orderby_registered_date() {} - // public function test_get_items_pagination() {} - - /** - * Test list instructors pagination. - * - * @since 1.0.0-beta.7 - */ - public function test_get_items_pagination() { - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->users}" ); - - $admin_id = $this->factory->user->create( array( 'role' => 'administrator' ) ); - - wp_set_current_user( $admin_id ); - // other 24 users except the admin who's an instructor too. - $ids = $this->factory->user->create_many( 24, array( 'role' => 'instructor' ) ); - $this->pagination_test( $this->route, $admin_id ); - - } - - // public function test_get_items_filter_by_posts() {} - // public function test_get_items_filter_by_roles() {} - - public function test_create_item_missing_required() { - - $res = $this->perform_mock_request( 'POST', $this->route ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseCodeEquals( 'rest_missing_callback_param', $res ); - $this->assertResponseMessageEquals( 'Missing parameter(s): email', $res ); - - } - - public function test_create_item_auth_errors() { - - // Unauthorized user. - wp_set_current_user( null ); - $res = $this->perform_mock_request( 'POST', $this->route, array( 'email' => 'mock@mock.mock' ) ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - // Forbidden user. - wp_set_current_user( $this->user_subscriber ); - $res = $this->perform_mock_request( 'POST', $this->route, array( 'email' => 'mock@mock.mock' ) ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - } - - public function test_create_item_as_instructor() { - - // Instructor can only create assistants. - wp_set_current_user( $this->user_instructor ); - $res = $this->perform_mock_request( 'POST', $this->route, array( 'email' => 'mock@mock.mock', ) ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - $this->assertResponseMessageEquals( 'You are not allowed to give users this role.', $res ); - - // Okay. - $res = $this->perform_mock_request( 'POST', $this->route, array( - 'email' => 'mock@mock.mock', - 'roles' => 'instructors_assistant', - ) ); - $this->assertResponseStatusEquals( 201, $res ); - - } - - public function test_create_item_success() { - - wp_set_current_user( $this->user_admin ); - $args = array( - 'email' => 'jamief@mockinstructor.tld', - 'first_name' => 'Jamie', - 'last_name' => 'Fitzgerald', - 'name' => 'Jamie Fitzgerald', - 'nickname' => 'JamieF1932', - 'username' => 'jamief', - 'url' => 'http://jamief.geocities.com', - 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', - 'billing_address_1' => '123 Some Street', - 'billing_address_2' => 'Suite A', - 'billing_city' => 'Some City', - 'billing_state' => 'NH', - 'billing_postcode' => '32319', - 'billing_country' => 'USA', - ); - $res = $this->perform_mock_request( 'POST', $this->route, $args ); - - $this->assertResponseStatusEquals( 201, $res ); - - $data = $res->get_data(); - foreach ( $args as $key => $expected ) { - $this->assertEquals( $expected, $data[ $key ] ); - } - - $this->assertEquals( array( 'instructor' ), $data['roles'] ); - - $this->assertArrayHasKey( 'id', $data ); - $this->assertArrayHasKey( 'avatar_urls', $data ); - $this->assertArrayHasKey( 'registered_date', $data ); - - $this->assertArrayHasKey( 'Location', $res->get_headers() ); - - } - - // public function test_get_item_auth() {} - // public function test_get_item_not_found() {} - // public function test_get_item_success() {} - - // public function test_update_item_auth() {} - // public function test_update_item_errors() {} - // public function test_update_item_success() {} - - // public function test_delete_item_auth() {} - // public function test_delete_item_success() {} - - /** - * Teardown test - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function tear_down() { - - parent::tear_down(); - - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->users}" ); - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-lessons.php b/tests/unit-tests/server/class-llms-rest-test-lessons.php deleted file mode 100644 index 03ae1f15..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-lessons.php +++ /dev/null @@ -1,831 +0,0 @@ -user_allowed = $this->factory->user->create( - array( - 'role' => 'administrator', - ) - ); - - $this->user_forbidden = $this->factory->user->create( - array( - 'role' => 'subscriber', - ) - ); - - $this->sample_lesson = array( - 'title' => array( - 'rendered' => 'Getting Started with LifterLMS', - 'raw' => 'Getting Started with LifterLMS', - ), - 'content' => array( - 'rendered' => "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - 'raw' => "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - ), - 'excerpt' => array( - 'rendered' => '

Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

', - 'raw' => 'Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.', - ), - 'date_created' => '2019-05-20 17:22:05', - 'status' => 'publish', - - ); - - $this->endpoint = new LLMS_REST_Lessons_Controller(); - - } - - - /** - * Test route registration. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - } - - /** - * Test the item schema. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_item_schema() { - - $schema = $this->endpoint->get_item_schema(); - - $this->assertEquals( 'lesson', $schema['title'] ); - - $props = $this->schema_props; - - $schema_keys = array_keys( $schema['properties'] ); - sort( $schema_keys ); - sort( $props ); - - $this->assertEquals( $props, $schema_keys ); - - // check nested items. - $quiz_nested = array( - 'enabled', - 'id', - 'progression', - ); - - $this->assertEquals( $quiz_nested, array_keys( $schema['properties']['quiz']['properties'] ) ); - - } - - /** - * Test getting items. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_items_success() { - - wp_set_current_user( $this->user_allowed ); - - // create 3 courses with 3 lessons per course. - $courses = $this->factory->course->create_many( - 3, - array( - 'sections' => 1, - 'lessons' => 3, - ) - ); - - $response = $this->perform_mock_request( 'GET', $this->route ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - $res_data = $response->get_data(); - $this->assertEquals( 9, count( $res_data ) ); - - // Check parent course and parent section match. - $i = 0; - - // Check retrieved lessons are the same as the generated ones. - foreach ( $courses as $course ) { - $course_obj = new LLMS_Course( $course ); - $lessons = $course_obj->get_lessons(); - - // Easy sequential check as lessons are by default ordered by id. - $j = 0; - foreach ( $lessons as $lesson ) { - $res_lesson = $res_data[ ( $i * count( $lessons ) ) + $j ]; - $this->llms_posts_fields_match( $lesson, $res_lesson ); - $j++; - } - - $i++; - } - - } - - /** - * Test getting lessons filtered by section's parent. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_items_filter_by_parent() { - wp_set_current_user( $this->user_allowed ); - - // create a course with 3 sections and two lessons per section. - $course = $this->factory->course->create( - array( - 'sections' => 3, - 'lessons' => 2, - ) - ); - - $course_obj = new LLMS_Course( $course ); - $sections = $course_obj->get_sections(); - - $i = 0; - - foreach ( $sections as $section ) { - if ( 2 === $i++ ) { - continue; - } - - // filter by parent section. - $response = $this->perform_mock_request( 'GET', $this->route, array(), array( 'parent' => $section->get( 'id' ) ) ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( 2, count( $res_data ) ); - - $lessons = $section->get_lessons(); - - // Easy sequential check as lesson are by default ordered by id. - $j = 0; - foreach ( $lessons as $lesson ) { - - $res_lesson = $res_data[ $j ]; - $this->llms_posts_fields_match( $lesson, $res_lesson ); - $j++; - - } - } - - // Check filtering by a section id which doesn't exist. - $response = $this->perform_mock_request( 'GET', $this->route, array(), array( 'parent' => $section->get( 'id' ) + 999 ) ); - - // Success. - $this->assertResponseStatusEquals( 200, $response ); - - // Expect an empty collection. - $res_data = $response->get_data(); - $this->assertEquals( 0, count( $res_data ) ); - - } - - // public function test_get_items_exclude() {} - // public function test_get_items_include() {} - // public function test_get_items_orderby_id() {} - // public function test_get_items_orderby_title() {} - - /** - * Test getting lessons filtered by section's parent. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_items_orderby_order() { - - wp_set_current_user( $this->user_allowed ); - - // create a course with 1 section and three lessons per section. - $course = $this->factory->course->create( - array( - 'sections' => 1, - 'lessons' => 3, - ) - ); - - $course_obj = new LLMS_Course( $course ); - $lessons = $course_obj->get_lessons( 'ids' ); - - // By default lessons are ordered by id. - $response = $this->perform_mock_request( 'GET', $this->route ); - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( $lessons, wp_list_pluck( $res_data, 'id' ) ); - - // Set first lesson order to 8 and second to 10 so that, when ordered by 'order' ASC the collection will be [last, first, second] - $first_lesson = llms_get_post( $lessons[0] ); - $second_lesson = llms_get_post( $lessons[1] ); - $last_lesson = llms_get_post( $lessons[2] ); - $first_lesson->set( 'order', 8 ); - $second_lesson->set( 'order', 10 ); - - $response = $this->perform_mock_request( 'GET', $this->route, array(), array( 'orderby' => 'order' ) ); - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( array( $lessons[2], $lessons[0], $lessons[1] ), wp_list_pluck( $res_data, 'id' ) ); - - // Check DESC order works as well, we expect [second, first, last]. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'orderby' => 'order', - 'order' => 'desc', - ) - ); - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $res_data = $response->get_data(); - $this->assertEquals( array( $lessons[1], $lessons[0], $lessons[2] ), wp_list_pluck( $res_data, 'id' ) ); - - } - - // public function test_get_items_orderby_date_created() {} - // public function test_get_items_orderby_date_updated() {} - - /** - * Test list lessons pagination. - * - * @since 1.0.0-beta.7 - */ - public function test_get_items_pagination() { - - wp_set_current_user( $this->user_allowed ); - - // Create lessons. - $course = $this->factory->course->create_and_get( array( 'sections' => 1, 'lessons' => 25, 'quiz' => 0 ) ); - $start_lesson_id = $course->get_lessons( 'ids' )[0]; - - $this->pagination_test( $this->route, $start_lesson_id ); - - } - - /** - * Test creating lesson. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_create_item_success() { - - wp_set_current_user( $this->user_allowed ); - - // Create a parent course, a prerequisite and a quiz. - $course_id = $this->factory->course->create( - array( - 'sections' => 1, - 'lessons' => 1, - 'quiz' => 1, - ) - ); - $course = llms_get_post( $course_id ); - $prerequisite_lesson = $course->get_lessons()[0]; - $prerequisite = $prerequisite_lesson->get( 'id' ); - $quiz = $prerequisite_lesson->get( 'quiz' ); - - $sample_lesson_additional = array( - 'parent_id' => 0, // checks also orphaned lessons are available. - 'drip_date' => '', // checks also drip date can be null. - 'order' => 2, - 'public' => true, - 'points' => 3, - 'drip_days' => 20, - 'drip_method' => 'enrollment', - 'prerequisite' => $prerequisite, - 'quiz' => array( - 'enabled' => true, - 'id' => $quiz, - 'progression' => 'pass', - ), - ); - - $sample_lesson = array_merge( - $this->sample_lesson, - $sample_lesson_additional - ); - - $res = $this->perform_mock_request( 'POST', $this->route, $sample_lesson ); - - // Success. - $this->assertResponseStatusEquals( 201, $res ); - $res_data = $res->get_data(); - $lesson = new LLMS_Lesson( $res_data['id'] ); - - // Check fields. - $this->llms_posts_fields_match( $lesson, $res_data ); - - foreach ( $sample_lesson_additional as $key => $value ) { - if ( is_array( $value ) ) { - foreach ( $value as $k => $v ) { - $this->assertEquals( $v, $res_data[ $key ][ $k ] ); - } - } else { - $this->assertEquals( $value, $res_data[ $key ] ); - } - } - - // Check that if we create a course with no prerequisite the $lessons->has_prerequisite() returns false - unset( $sample_lesson['prerequisite'] ); - $res = $this->perform_mock_request( 'POST', $this->route, $sample_lesson ); - - // Success. - $this->assertResponseStatusEquals( 201, $res ); - $res_data = $res->get_data(); - $lesson = new LLMS_Lesson( $res_data['id'] ); - - $this->assertFalse( $lesson->has_prerequisite() ); - } - - - /** - * Test lesson parents. - * - * @since 1.0.0-beta.15 - * - * @return void - */ - public function test_lesson_parents() { - - wp_set_current_user( $this->user_allowed ); - - // Create a parent course, a prerequisite and a quiz. - $course_id = $this->factory->course->create( - array( - 'sections' => 2, - 'lessons' => 0, - 'quiz' => 0, - ) - ); - - $course = llms_get_post( $course_id ); - - $sample_lesson_additional = array( - 'parent_id' => $course->get_sections('ids')[0], - ); - - $sample_lesson = array_merge( - $this->sample_lesson, - $sample_lesson_additional - ); - - $res = $this->perform_mock_request( 'POST', $this->route, $sample_lesson ); - - // Success. - $this->assertResponseStatusEquals( 201, $res ); - $res_data = $res->get_data(); - - // Test course id matches. - $this->assertEquals( $course_id, $res_data['course_id'] ); - - // Test assigning the lesson to section 2 of the same course doesn't produce any error. - $sample_lesson['parent_id'] = $course->get_sections('ids')[1];; - $res = $this->perform_mock_request( 'POST', $this->route, $sample_lesson ); - - // Success. - $this->assertResponseStatusEquals( 201, $res ); - $res_data = $res->get_data(); - - // Test parent section id matches. - $this->assertEquals( $sample_lesson['parent_id'], $res_data['parent_id'] ); - // Test course id matches. - $this->assertEquals( $course_id, $res_data['course_id'] ); - - // Test that using a non existent section produces a lesson with no parent course/section - $sample_lesson['parent_id'] = $course->get_sections('ids')[1]+99; - $res = $this->perform_mock_request( 'POST', $this->route, $sample_lesson ); - - // Success. - $this->assertResponseStatusEquals( 201, $res ); - $res_data = $res->get_data(); - - $this->assertEquals( 0, $res_data['course_id'] ); - $this->assertEquals( 0, $res_data['parent_id'] ); - } - - /** - * Test creating lesson with wrong params. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - //public function test_create_item_wrong_params() { - - /** - * Test creating lesson missing required parameters. - * - * @since 1.0.0-beta.7 - * @todo abstract and move in posts case. - * @return void - */ - public function test_create_item_missing_required() { - - $res = $this->perform_mock_request( 'POST', $this->route ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseCodeEquals( 'rest_missing_callback_param', $res ); - $this->assertResponseMessageEquals( 'Missing parameter(s): title, content', $res ); - - } - - /** - * Test creating lesson auth errors. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_create_item_auth_errors() { - - $res = $this->perform_mock_request( 'POST', $this->route, $this->sample_lesson ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - wp_set_current_user( $this->user_forbidden ); - $res = $this->perform_mock_request( 'POST', $this->route, $this->sample_lesson ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - } - - - /** - * Retrieve success. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_item_success() { - - wp_set_current_user( $this->user_allowed ); - - // create a course with 1 section and 1 lesson with no quizzes - $course = $this->factory->course->create_and_get( - array( - 'sections' => 1, - 'lessons' => 1, - 'quiz' => 0, - ) - ); - $lesson = $course->get_lessons()[0]; - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $lesson->get( 'id' ) ) ); - - $this->assertResponseStatusEquals( 200, $res ); - $res_data = $res->get_data(); - - // check that created and the retrieved lessons match. - $this->llms_posts_fields_match( $lesson, $res_data ); - - // check that the retrieved lesson has exactly the fields we expect. - $props = $this->schema_props; - - // we're not in edit context so 'password' property won't be returned - $props = array_diff( $props, array( 'password' ) ); - - $res_data_keys = array_keys( $res_data ); - sort( $res_data_keys ); - sort( $props ); - - $this->assertEquals( $props, $res_data_keys ); - - // check nested items. - $quiz_nested = array( - 'enabled', - 'id', - 'progression', - ); - - $this->assertEquals( $quiz_nested, array_keys( $res_data['quiz'] ) ); - - } - - /** - * Test getting an item with no auth. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_item_auth_errors() { - - // create a course with 1 section and 1 lesson with no quizzes - $course = $this->factory->course->create_and_get( - array( - 'sections' => 1, - 'lessons' => 1, - 'quiz' => 0, - ) - ); - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $course->get_lessons( 'ids' )[0] ) ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - wp_set_current_user( $this->user_forbidden ); - - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $course->get_lessons( 'ids' )[0] ) ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - } - - /** - * Test not found lesson. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_get_item_not_found() { - - wp_set_current_user( $this->user_allowed ); - - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, 1234 ) ); - $this->assertResponseStatusEquals( 404, $res ); - $this->assertResponseCodeEquals( 'llms_rest_not_found', $res ); - - } - - // public function test_update_item_success() {} - // public function test_update_item_auth_errors() {} - // public function test_update_item_errors() {} - - - // public function test_delete_item_success() {} - // public function test_get_item_auth_errors() {} - - - /** - * Test links. - * - * @since 1.0.0-beta.7 - * - * @return void - */ - public function test_links() { - - // create course with 1 section and 3 lessons per section. - $course = $this->factory->course->create_and_get( - array( - 'sections' => 1, - 'lessons' => 3, - ) - ); - - $course_obj = new LLMS_Course( $course ); - $lessons = $course_obj->get_lessons(); - - wp_set_current_user( $this->user_allowed ); - - $i = 0; - foreach ( $lessons as $lesson ) { - - /** - * Latest lesson: remove the quiz. - */ - if ( 3 === $i ) { - $lesson->set( 'quiz_enabled', 'no' ); - } - - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $lesson->get( 'id' ) ); - - switch ( $i++ ) : - case 0: - $expected_link_rels = array_values( array_diff( $this->expected_link_rels, array( 'previous' ) ) ); - break; - case 2: - $expected_link_rels = array_values( array_diff( $this->expected_link_rels, array( 'next' ) ) ); - break; - default: - $expected_link_rels = $this->expected_link_rels; - endswitch; - - if ( $lesson->is_quiz_enabled() ) { - $expected_link_rels[] = 'quiz'; - } - - $this->assertEquals( $expected_link_rels, array_keys( $response->get_links() ) ); - - } - - } - - /** - * Test updating the lessons parent section. - * - * @since 1.0.0-beta.25 - * - * @link https://github.com/gocodebox/lifterlms-rest/issues/289 - * - * @return void - */ - public function test_update_parent_section() { - - // Setup. - wp_set_current_user( $this->user_allowed ); - $course = $this->factory->course->create_and_get(); - - // Get IDs for the first lesson and the second section. - $sections = $course->get_sections(); - $section_2_id = $sections[1]->get( 'id' ); - $lesson_1_id = $sections[0]->get_lessons( 'ids' )[0]; - - // Update the lesson's parent section. - $route = "{$this->route}/{$lesson_1_id}"; - $response = $this->perform_mock_request( 'POST', $route, array( 'parent_id' => $section_2_id ) ); - $this->assertFalse( $response->is_error() ); - $this->assertEquals( $section_2_id, $response->get_data()['parent_id'] ); - - } - - /** - * Create a resource for this post type. - * - * @since 1.0.0-beta.25 - * - * @param array $params Array of request params. - * @return WP_Post - */ - protected function create_post_resource( $params = array() ) { - - $course = $this->factory->course->create_and_get( - array( - 'sections' => 1, - 'lessons' => 0, - ) - ); - - return parent::create_post_resource( - array( - 'parent_id' => $course->get_sections('ids')[0], - 'course_id' => $course->get('id'), - ) - ); - - } - - /** - * Override. - * - * @since 1.0.0-beta.7 - * @since 1.0.0-beta.23 Replaced the call to the deprecated `LLMS_Lesson::get_parent_course()` method with `LLMS_Lesson::get( 'parent_course' )`. - * - * @param array $expected Array of expected properties. - * @param LLMS_Post_Model $lesson Instance of LLMS_Post_Model. - * @return array - */ - protected function filter_expected_fields( $expected, $lesson ) { - - // Audio Embed. - $expected['audio_embed'] = $lesson->get( 'audio_embed' ); - - // Video Embed. - $expected['video_embed'] = $lesson->get( 'video_embed' ); - - // Parent section. - $expected['parent_id'] = $lesson->get_parent_section(); - - // Parent course. - $expected['course_id'] = $lesson->get( 'parent_course' ); - - // Order. - $expected['order'] = $lesson->get( 'order' ); - - // Public. - $expected['public'] = $lesson->is_free(); - - // Points. - $expected['points'] = $lesson->get( 'points' ); - - // Quiz. - $expected['quiz']['enabled'] = llms_parse_bool( $lesson->get( 'quiz_enabled' ) ); - $expected['quiz']['id'] = absint( $lesson->get( 'quiz' ) ); - $expected['quiz']['progression'] = llms_parse_bool( $lesson->get( 'require_passing_grade' ) ) ? 'pass' : 'completed'; - - // Drip method. - $expected['drip_method'] = $lesson->get( 'drip_method' ); - $expected['drip_method'] = $expected['drip_method'] ? $expected['drip_method'] : 'none'; - - // Drip days. - $expected['drip_days'] = absint( $lesson->get( 'days_before_available' ) ); - - // Drip date. - $date = $lesson->get( 'date_available' ); - if ( $date ) { - $time = $lesson->get( 'time_available' ); - - if ( ! $time ) { - $time = '12:00 AM'; - } - - $drip_date = date_i18n( 'Y-m-d H:i:s', strtotime( $date . ' ' . $time ) ); - } else { - $drip_date = ''; - } - - $expected['drip_date'] = $drip_date; - - // Prerequisite. - $expected['prerequisite'] = absint( $lesson->get_prerequisite() ); - - return $expected; - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-memberships.php b/tests/unit-tests/server/class-llms-rest-test-memberships.php deleted file mode 100644 index 63d3d60e..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-memberships.php +++ /dev/null @@ -1,1355 +0,0 @@ -endpoint = new LLMS_REST_Memberships_Controller(); - $this->user_allowed = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $this->user_forbidden = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - - $this->sample_membership_args = array( - 'title' => array( - 'rendered' => 'Gold', - 'raw' => 'Gold', - ), - 'content' => array( - 'rendered' => "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

Expectoque quid ad id, quod quaerebam, respondeas. " . - "Nec enim, omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - 'raw' => "\\n

Lorem ipsum dolor sit amet.

\\n\\n\\n\\n

" . - "Expectoque quid ad id, quod quaerebam, respondeas. Nec enim, " . - "omnes avaritias si aeque avaritias esse dixerimus, sequetur ut etiam aequas esse dicamus.

\\n", - ), - 'date_created' => '2019-05-20 17:22:05', - 'status' => 'publish', - ); - } - - /** - * Test creating a single membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership() { - wp_set_current_user( $this->user_allowed ); - - $membership_args = array_merge( - $this->sample_membership_args, - array( - 'auto_enroll' => array( - $this->factory->course->create() - ), - // Categories are tested in test_create_membership_with_taxonomies(). - 'catalog_visibility' => 'search', - 'instructors' => array( - get_current_user_id(), - $this->factory->user->create( array( 'role' => 'instructor', ) ), - ), - 'restriction_action' => 'none', - 'restriction_message' => $this->default_restriction_message, - 'restriction_page_id' => 0, - 'restriction_url' => '', - 'sales_page_page_id' => 0, - 'sales_page_type' => 'none', - 'sales_page_url' => '', - // Tags are tested in test_create_membership_with_taxonomies(). - ) - ); - - $response = $this->perform_mock_request( 'POST', $this->route, $membership_args ); - - // Success. - $this->assertEquals( 201, $response->get_status() ); - - $response_data = $response->get_data(); - - /** - * The rtrim below is not ideal but at the moment we have templates printed after the membership summary (e.g. prerequisites) that, - * even when printing no data they still print "\n". Let's pretend we're not interested in testing the trailing "\n" presence. - */ - $this->assertEquals( rtrim( $membership_args['content']['rendered'], "\n" ), rtrim( $response_data['content']['rendered'], "\n" ) ); - - $properties = array( - 'auto_enroll', - 'catalog_visibility', - 'instructors', - 'date_created', - 'status', - 'restriction_action', - 'restriction_page_id', - 'restriction_url', - 'sales_page_page_id', - 'sales_page_type', - 'sales_page_url', - 'title', - ); - foreach ( $properties as $property ) { - $this->assertEquals( $membership_args[ $property ], $response_data[ $property ] ); - } - - $restriction_message_raw = str_replace( '{{membership_id}}', $response_data['id'], $membership_args['restriction_message'] ); - $this->assertEquals( $restriction_message_raw, $response_data['restriction_message']['raw'] ); - $this->assertEquals( do_shortcode( $restriction_message_raw ), $response_data['restriction_message']['rendered'] ); - } - - /** - * Test create membership with raw properties - * - * Check textual properties are still set when supplying them as 'raw'. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_and_raws() { - wp_set_current_user( $this->user_allowed ); - - $membership_raw_messages = array( - 'restriction_message' => array( - 'raw' => 'Restriction raw message', - ), - ); - $membership_args = array_merge( - $this->sample_membership_args, - $membership_raw_messages - ); - - $response = $this->perform_mock_request( 'POST', $this->route, $membership_args ); - $response_data = $response->get_data(); - - foreach ( $membership_raw_messages as $property => $content ) { - $this->assertEquals( $content['raw'], $response_data[ $property ]['raw'] ); - } - } - - /** - * Test producing bad request error when creating a single membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_bad_request() { - wp_set_current_user( $this->user_allowed ); - - $membership_args = $this->sample_membership_args; - - // Creating a membership passing an id produces a bad request. - $membership_args['id'] = '123'; - - $request = new WP_REST_Request( 'POST', $this->route ); - $request->set_body_params( $membership_args ); - $response = $this->server->dispatch( $request ); - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - - // Create a membership without title. - $membership_args = $this->sample_membership_args; - unset( $membership_args['title'] ); - - $request->set_body_params( $membership_args ); - $response = $this->server->dispatch( $request ); - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - - // Create a membership without content. - $membership_args = $this->sample_membership_args; - unset( $membership_args['content'] ); - - $request->set_body_params( $membership_args ); - $response = $this->server->dispatch( $request ); - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - - // Status param must respect the item schema, hence one of "publish" "pending" "draft" "auto-draft" "future" "private" "trash". - $membership_args = $this->sample_membership_args; - $status = array_merge( array_keys( get_post_statuses() ), array( 'future', 'trash', 'auto-draft' ) ); - $membership_args['status'] = $status[0] . rand() . 'not_in_enum'; - - $request->set_body_params( $membership_args ); - $response = $this->server->dispatch( $request ); - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - - // catalog_visibility param must respect the item schema, hence one of array_keys( llms_get_product_visibility_options() ). - $membership_args = $this->sample_membership_args; - $catalog_visibility = array_keys( llms_get_product_visibility_options() ); - $membership_args['catalog_visibility'] = $catalog_visibility[0] . rand() . 'not_in_enum'; - - $request->set_body_params( $membership_args ); - $response = $this->server->dispatch( $request ); - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - } - - /** - * Test creating a single membership defaults are correctly set. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_check_defaults() { - wp_set_current_user( $this->user_allowed ); - - $membership_args = array( - 'title' => 'Gold', - 'content' => 'Content', - ); - - $response = $this->perform_mock_request( 'POST', $this->route, $membership_args ); - $response_data = $response->get_data(); - - // Check defaults. - // Auto enroll. - $this->assertEquals( array(), $response_data['auto_enroll'] ); - - // Catalog visibility. - $this->assertEquals( 'catalog_search', $response_data['catalog_visibility'] ); - - // Categories. - $this->assertEquals( array(), $response_data['categories'] ); - - // Comment status. - $this->assertEquals( 'open', $response_data['comment_status'] ); - - // Instructors. If empty, llms core responds with the current user id in an array. - $this->assertEquals( array( get_current_user_id() ), $response_data['instructors'] ); - - // Menu order. - $this->assertEquals( 0, $response_data['menu_order'] ); - - // Ping status. - $this->assertEquals( 'open', $response_data['ping_status'] ); - - // Restriction action. - $this->assertEquals( 'none', $response_data['restriction_action'] ); - - // Restriction message. - $restriction_message = str_replace( '{{membership_id}}', $response_data['id'], $this->default_restriction_message ); - $this->assertEquals( $restriction_message, $response_data['restriction_message']['raw'] ); - $this->assertEquals( do_shortcode( $restriction_message ), $response_data['restriction_message']['rendered'] ); - - // Sales page type. - $this->assertEquals( 'none', $response_data['sales_page_type'] ); - - // Status. - $this->assertEquals( 'publish', $response_data['status'] ); - - // Tags. - $this->assertEquals( array(), $response_data['tags'] ); - } - - /** - * Test forbidden single membership creation. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_forbidden() { - wp_set_current_user( $this->user_forbidden ); - - $response = $this->perform_mock_request( 'POST', $this->route, $this->sample_membership_args ); - - // Forbidden. - $this->assertEquals( 403, $response->get_status() ); - } - - /** - * Test creating a membership with an instructor that doesn't exist. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_with_bad_instructor() { - wp_set_current_user( $this->user_allowed ); - - // Create instructor. - $good_instructor_id = $this->factory->user->create( array( 'role' => 'instructor' ) ); - $bad_instructor_id = $good_instructor_id + 9; - $membership_args = $this->sample_membership_args; - - // Create membership with non-existing instructor. - $membership_args['instructors'] = array( $bad_instructor_id ); - $response = $this->perform_mock_request( 'POST', $this->route, $membership_args ); - $this->assertResponseStatusEquals( 400, $response ); - - // Create membership with existing instructor and non-existing instructor. - $membership_args['instructors'] = array( $good_instructor_id, $bad_instructor_id ); - $response = $this->perform_mock_request( 'POST', $this->route, $membership_args ); - $this->assertResponseStatusEquals( 400, $response ); - - } - - /** - * Test creating a membership with an empty instructors array. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_with_empty_instructors() { - wp_set_current_user( $this->user_allowed ); - - // Create membership with empty instructors. - $membership_args = $this->sample_membership_args; - $membership_args['instructors'] = array(); - $response = $this->perform_mock_request( 'POST', $this->route, $membership_args ); - $this->assertEquals( 400, $response->get_status() ); - } - - /** - * Test creating a membership without an `instructors` argument. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_without_instructors() { - wp_set_current_user( $this->user_allowed ); - - // Create membership with empty instructors. - $membership_args = $this->sample_membership_args; - unset( $membership_args['instructors'] ); - $response = $this->perform_mock_request( 'POST', $this->route, $membership_args ); - $this->assertEquals( 201, $response->get_status() ); - - // The membership object should NOT have zero instructors. - // Do not use LLMS_Membership->get_instructors() because it will default to `post_author`. - $membership = new LLMS_Membership( $response->data['id'] ); - $instructors = $membership->get( 'instructors' ); - $this->assertCount( 1, $instructors ); - $this->assertEquals( $this->user_allowed, $instructors[0]['id'] ); - } - - /** - * Test creating a single membership with taxonomies. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_with_taxonomies() { - wp_set_current_user( $this->user_allowed ); - $taxonomies = array( - 'categories' => array( - 1, - 2, - 3, - ), - 'tags' => array( - 6, - 4, - 8, - ), - ); - - $membership_args = array_merge( - $this->sample_membership_args, - $taxonomies - ); - - $request = new WP_REST_Request( 'POST', $this->route ); - $request->set_body_params( $membership_args ); - $response = $this->server->dispatch( $request ); - - // Terms have not ben created. We expect the membership is created with empty taxonomies. - $this->assertEquals( 201, $response->get_status() ); - $response_data = $response->get_data(); - foreach ( $taxonomies as $tax => $tid ) { - $this->assertEquals( array(), $response_data[ $tax ] ); - } - - // let's create the terms. - $taxonomies = array( - 'categories' => $this->factory()->term->create_many( - 3, - array( - 'taxonomy' => 'membership_cat', - ) - ), - 'tags' => $this->factory()->term->create_many( - 3, - array( - 'taxonomy' => 'membership_tag', - ) - ), - ); - $membership_args = array_merge( - $this->sample_membership_args, - $taxonomies - ); - $request->set_body_params( $membership_args ); - $response = $this->server->dispatch( $request ); - - // Terms have been created. We expect the membership is created with taxonomies set. - $this->assertEquals( 201, $response->get_status() ); - $response_data = $response->get_data(); - foreach ( $taxonomies as $tax => $tid ) { - $this->assertEquals( $tid, $response_data[ $tax ] ); - } - } - - /** - * Test creating single membership without permissions. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_create_membership_without_permissions() { - wp_set_current_user( 0 ); - - $response = $this->perform_mock_request( 'POST', $this->route, $this->sample_membership_args ); - - // Unauthorized. - $this->assertEquals( 401, $response->get_status() ); - } - - /** - * Test getting bad request response when deleting a membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_delete_bad_request_membership() { - wp_set_current_user( $this->user_allowed ); - - // create a membership first. - $membership = $this->factory->membership->create_and_get(); - - $request = new WP_REST_Request( 'DELETE', $this->route . '/' . $membership->get( 'id' ) ); - $request->set_param( 'force', 'bad_parameter_value' ); - $response = $this->server->dispatch( $request ); - - // Bad request because of a bad parameter. - $this->assertEquals( 400, $response->get_status() ); - } - - /** - * Test single membership update without authorization. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_delete_forbidden_membership() { - // create a membership first. - wp_set_current_user( $this->user_allowed ); - $membership = $this->factory->membership->create_and_get(); - - // Delete membership. - wp_set_current_user( $this->user_forbidden ); - $response = $this->perform_mock_request( 'DELETE', $this->route . '/' . $membership->get( 'id' ) ); - - // Forbidden. - $this->assertEquals( 403, $response->get_status() ); - } - - /** - * Test deleting a single membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_delete_membership() { - wp_set_current_user( $this->user_allowed ); - - // create a membership first. - $membership = $this->factory->membership->create_and_get(); - - $request = new WP_REST_Request( 'DELETE', $this->route . '/' . $membership->get( 'id' ) ); - $request->set_param( 'force', true ); - $response = $this->server->dispatch( $request ); - - // Success. - $this->assertEquals( 204, $response->get_status() ); - // empty body. - $this->assertEquals( null, $response->get_data() ); - - // Cannot find just deleted post. - $this->assertFalse( get_post_status( $membership->get( 'id' ) ) ); - } - - /** - * Test single membership deletion without authorization. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_delete_membership_without_authorization() { - // Create a membership first. - wp_set_current_user( $this->user_allowed ); - $membership = $this->factory->membership->create_and_get(); - - // Delete membership. - wp_set_current_user( 0 ); - $response = $this->perform_mock_request( 'DELETE', $this->route . '/' . $membership->get( 'id' ) ); - - // Unauthorized. - $this->assertEquals( 401, $response->get_status() ); - } - - /** - * Test deleting a nonexistent single membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_delete_nonexistent_membership() { - wp_set_current_user( $this->user_allowed ); - - // Setup membership. - $membership_id = $this->factory->membership->create(); - - $response = $this->perform_mock_request( 'DELETE', $this->route . '/' . $membership_id . '42' ); - - // Post not found, so it's "deleted". - $this->assertEquals( 204, $response->get_status() ); - $this->assertEquals( '', $response->get_data() ); - } - - /** - * Test the item schema. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_item_schema() { - $schema = $this->endpoint->get_item_schema(); - - $this->assertEquals( 'llms_membership', $schema['title'] ); - - $props = $this->schema_properties; - - $schema_keys = array_keys( $schema['properties'] ); - sort( $schema_keys ); - sort( $props ); - - $this->assertEquals( $props, $schema_keys ); - } - - /** - * Test getting a single membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_membership() { - wp_set_current_user( $this->user_allowed ); - - // Setup membership. - $membership = $this->factory->membership->create_and_get(); - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $membership->get( 'id' ) ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - // Check retrieved membership matches the created ones. - $response_data = $response->get_data(); - $this->llms_posts_fields_match( $membership, $response_data ); - } - - /** - * Test list membership content. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_membership_enrollments() { - wp_set_current_user( $this->user_allowed ); - - // create 1 membership. - $membership = $this->factory->membership->create(); - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $membership . '/enrollments' ); - - // We have no students enrolled for this membership so we expect a 404. - $this->assertEquals( 404, $response->get_status() ); - - // create 5 students and enroll them. - $student_ids = $this->factory->student->create_and_enroll_many( 5, $membership ); - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $membership . '/enrollments' ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $response_data = $response->get_data(); - $this->assertEquals( 5, count( $response_data ) ); - - // Filter by student_id. - $request = new WP_REST_Request( 'GET', $this->route . '/' . $membership . '/enrollments' ); - $request->set_param( 'student', "$student_ids[0]" ); - $response = $this->server->dispatch( $request ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $response_data = $response->get_data(); - $this->assertEquals( 1, count( $response_data ) ); - $this->assertEquals( $student_ids[0], $response_data[0]['student_id'] ); - } - - /** - * Test get single membership with forbidden context. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_membership_forbidden() { - wp_set_current_user( $this->user_forbidden ); - - // Setup membership. - $membership_id = $this->factory->membership->create(); - $response = $this->perform_mock_request( - 'GET', - $this->route . '/' . $membership_id, - array(), - array( 'context' => 'edit' ) // Role needs 'edit_post' capability. - ); - - // Check we're not allowed to get results. - $this->assertEquals( 403, $response->get_status() ); - } - - /** - * Test list memberships. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships() { - wp_set_current_user( $this->user_allowed ); - - // Create 12 memberships. Do not create 12 monkeys. - $memberships = $this->factory->membership->create_many( 12 ); - - $response = $this->perform_mock_request( 'GET', $this->route ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $response_data = $response->get_data(); - $this->assertEquals( 10, count( $response_data ) ); // default per_page is 10. - - // Check retrieved memberships are the same as the generated ones. - // Note: the check can be done in this simple way as by default the rest api memberships are ordered by id. - for ( $i = 0; $i < 10; $i ++ ) { - $this->llms_posts_fields_match( new LLMS_Membership( $memberships[ $i ] ), $response_data[ $i ] ); - } - - $headers = $response->get_headers(); - $this->assertEquals( 12, $headers['X-WP-Total'] ); - $this->assertEquals( 2, $headers['X-WP-TotalPages'] ); - } - - /** - * Test getting memberships: bad request. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_bad_request() { - wp_set_current_user( $this->user_allowed ); - - // create 5 memberships. - $this->factory->membership->create_many( 5, array() ); - $request = new WP_REST_Request( 'GET', $this->route ); - - // Bad request, there's no page 2. - $request->set_param( 'page', 2 ); - $response = $this->server->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); - - // Bad request, order param allowed are only "desc" and "asc" (enum). - $request->set_param( 'order', 'not_desc' ); - $response = $this->server->dispatch( $request ); - $this->assertEquals( 400, $response->get_status() ); - } - - /** - * Test list memberships exclude arg. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_exclude() { - wp_set_current_user( $this->user_allowed ); - - // create 15 memberships. - $memberships = $this->factory->membership->create_many( 5, array() ); - $request = new WP_REST_Request( 'GET', $this->route ); - - // get only the 2nd and 3rd membership. - $request->set_param( 'exclude', "$memberships[0], $memberships[1]" ); - - $response = $this->server->dispatch( $request ); - $response_data = $response->get_data(); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 3, count( $response_data ) ); - - // Check retrieved data do not contain first and second created memberships. - $this->assertEquals( array_slice( $memberships, 2 ), wp_list_pluck( $response_data, 'id' ) ); - } - - /** - * Test get memberships with forbidden context. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_forbidden() { - wp_set_current_user( $this->user_forbidden ); - - // Setup membership. - $this->factory->membership->create(); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( 'context' => 'edit' ) // Role needs 'edit_post' capability. - ); - - // Check we're not allowed to get results. - $this->assertEquals( 403, $response->get_status() ); - } - - /** - * Test list memberships include arg. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_include() { - wp_set_current_user( $this->user_allowed ); - - // create 15 memberships. - $memberships = $this->factory->membership->create_many( 5, array() ); - $request = new WP_REST_Request( 'GET', $this->route ); - - // get only the 2nd and 3rd membership. - $request->set_param( 'include', "$memberships[1], $memberships[2]" ); - - $response = $this->server->dispatch( $request ); - $response_data = $response->get_data(); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - $this->assertEquals( 2, count( $response_data ) ); - - // Check retrieved memberships are the same as the second and third generated memberships. - for ( $i = 0; $i < 2; $i ++ ) { - $this->llms_posts_fields_match( new LLMS_Membership( $memberships[ $i + 1 ] ), $response_data[ $i ] ); - } - } - - /** - * Test list memberships ordered by id ascending. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_ordered_by_id_ascending() { - wp_set_current_user( $this->user_allowed ); - - // create 5 memberships. - $memberships = $this->factory->membership->create_many( 5, array() ); - $request = new WP_REST_Request( 'GET', $this->route ); - - // default is 'asc'. - $request->set_param( 'order', 'asc' ); - - $response = $this->server->dispatch( $request ); - $response_data = $response->get_data(); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - // Check retrieved memberships are the same as the generated ones and in the same order. - // Note: the check can be done in this simple way as by default the rest api memberships are ordered by id. - for ( $i = 0; $i < 5; $i ++ ) { - $this->llms_posts_fields_match( new LLMS_Membership( $memberships[ $i ] ), $response_data[ $i ] ); - } - } - - /** - * Test list memberships ordered by id descending. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_ordered_by_id_descending() { - wp_set_current_user( $this->user_allowed ); - - // create 5 memberships. - $memberships = $this->factory->membership->create_many( 5, array() ); - $request = new WP_REST_Request( 'GET', $this->route ); - - // default is 'asc'. - $request->set_param( 'order', 'desc' ); - - $response = $this->server->dispatch( $request ); - $response_data = $response->get_data(); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - // Check retrieved memberships are the same as the generated ones but in the reversed order. - // Note: the check can be done in this simple way as by default the rest api memberships are ordered by id. - $reversed_data = array_reverse( $response_data ); - for ( $i = 0; $i < 5; $i ++ ) { - $this->llms_posts_fields_match( new LLMS_Membership( $memberships[ $i ] ), $reversed_data[ $i ] ); - } - } - - /** - * Test getting memberships orderby `menu_order`. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_ordered_by_menu_order() { - wp_set_current_user( $this->user_allowed ); - - // Create 3 memberships. - $membership_ids = $this->factory->membership->create_many( 3, array() ); - - // By default lessons are ordered by id. - $response = $this->perform_mock_request( 'GET', $this->route ); - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $response_data = $response->get_data(); - $this->assertEquals( $membership_ids, wp_list_pluck( $response_data, 'id' ) ); - - // Set first membership order to 8 and second to 10 so that, when ordered by 'menu_order' ASC the collection will be [last, first, second]. - $first_membership = llms_get_post( $membership_ids[0] ); - $second_membership = llms_get_post( $membership_ids[1] ); - $last_membership = llms_get_post( $membership_ids[2] ); - $first_membership->set( 'menu_order', 8 ); - $second_membership->set( 'menu_order', 10 ); - - $response = $this->perform_mock_request( 'GET', $this->route, array(), array( 'orderby' => 'menu_order' ) ); - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $response_data = $response->get_data(); - $this->assertEquals( array( $membership_ids[2], $membership_ids[0], $membership_ids[1] ), wp_list_pluck( $response_data, 'id' ) ); - - // Check DESC order works as well, we expect [second, first, last]. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'orderby' => 'menu_order', - 'order' => 'desc', - ) - ); - // Success. - $this->assertResponseStatusEquals( 200, $response ); - $response_data = $response->get_data(); - $this->assertEquals( array( $membership_ids[1], $membership_ids[0], $membership_ids[2] ), wp_list_pluck( $response_data, 'id' ) ); - } - - /** - * Test list memberships ordered by title. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_ordered_by_title() { - wp_set_current_user( $this->user_allowed ); - - // create 3 memberships. - $memberships = $this->factory->membership->create_many( 3, array() ); - - $membership_first = new LLMS_Membership( $memberships[0] ); - $membership_first->set( 'title', 'Membership B' ); - $membership_second = new LLMS_Membership( $memberships[1] ); - $membership_second->set( 'title', 'Membership A' ); - $membership_second = new LLMS_Membership( $memberships[2] ); - $membership_second->set( 'title', 'Membership C' ); - - $request = new WP_REST_Request( 'GET', $this->route ); - $request->set_param( 'orderby', 'title' ); // default is id. - - $response = $this->server->dispatch( $request ); - - $response_data = $response->get_data(); - - // Check retrieved memberships are ordered by title asc. - $this->assertEquals( 'Membership A', $response_data[0]['title']['rendered'] ); - $this->assertEquals( 'Membership B', $response_data[1]['title']['rendered'] ); - $this->assertEquals( 'Membership C', $response_data[2]['title']['rendered'] ); - } - - /** - * Test list memberships ordered by title descending. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_ordered_by_title_descending() { - wp_set_current_user( $this->user_allowed ); - - // create 3 memberships. - $memberships = $this->factory->membership->create_many( 3, array() ); - - $membership_first = new LLMS_Membership( $memberships[0] ); - $membership_first->set( 'title', 'Membership B' ); - $membership_second = new LLMS_Membership( $memberships[1] ); - $membership_second->set( 'title', 'Membership A' ); - $membership_second = new LLMS_Membership( $memberships[2] ); - $membership_second->set( 'title', 'Membership C' ); - - $request = new WP_REST_Request( 'GET', $this->route ); - $request->set_param( 'orderby', 'title' ); // default is id. - $request->set_param( 'order', 'desc' ); // default is 'asc'. - - $response = $this->server->dispatch( $request ); - $response_data = $response->get_data(); - - // Check retrieved memberships are ordered by title desc. - $this->assertEquals( 'Membership C', $response_data[0]['title']['rendered'] ); - $this->assertEquals( 'Membership B', $response_data[1]['title']['rendered'] ); - $this->assertEquals( 'Membership A', $response_data[2]['title']['rendered'] ); - } - - /** - * Test list memberships pagination success. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_memberships_with_pagination() { - wp_set_current_user( $this->user_allowed ); - - $membership_ids = $this->factory->membership->create_many( 25, array() ); - $start_membership_id = $membership_ids[0]; - $this->pagination_test( $this->route, $start_membership_id ); - } - - /** - * Test getting single membership that doesn't exist. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_get_nonexistent_membership() { - wp_set_current_user( $this->user_allowed ); - - // Setup membership. - $membership_id = $this->factory->membership->create(); - - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $membership_id . '42' ); - - // Not found. - $this->assertEquals( 404, $response->get_status() ); - } - - /** - * Test links. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_links() { - - wp_set_current_user( $this->user_allowed ); - - // create two courses to autoenroll. - $course_ids = $this->factory->course->create_many( 2, array( 0, 0, 0, 0 ) ); - // create 3 memberships. - $memberships = $this->factory->post->create_many( 3, array( 'post_type' => 'llms_membership' ) ); - - $i = 1; - foreach ( $memberships as $membership_id ) { - $membership = new LLMS_Membership( $membership_id ); - /** - * add auto enroll except for the latest membership. - */ - if ( 3 !== $i++ ) { - $membership->add_auto_enroll_courses( $course_ids, true ); - } - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $membership->get( 'id' ) ); - $expected_link_rels = array(); - if ( empty( $membership->get_auto_enroll_courses() ) ) { - foreach ( $this->expected_link_rels as $link_rel ) { - if ( 'auto_enrollment_courses' !== $link_rel ) { - $expected_link_rels[] = $link_rel; - } - } - } else { - $expected_link_rels = $this->expected_link_rels; - } - $this->assertEquals( $expected_link_rels, array_keys( $response->get_links() ) ); - } - - } - - /** - * Test route registration. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_register_routes() { - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - // Enrollments. - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)/enrollments', $routes ); - } - - /** - * Test trashing a single membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_trash_membership() { - wp_set_current_user( $this->user_allowed ); - - // create a membership first. - $membership = $this->factory->membership->create_and_get(); - - $request = new WP_REST_Request( 'DELETE', $this->route . '/' . $membership->get( 'id' ) ); - $request->set_param( 'force', false ); - $response = $this->server->dispatch( $request ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $response_data = $response->get_data(); - // Non empty body. - $this->assertTrue( ! empty( $response_data ) ); - // Deleted post status should be 'trash'. - $this->assertEquals( 'trash', get_post_status( $membership->get( 'id' ) ) ); - // check the trashed post returned into the response is the correct one. - $this->assertEquals( $membership->get( 'id' ), $response_data['id'] ); - // check the trashed post returned into the response has the correct status 'trash'. - $this->assertEquals( 'trash', $response_data['status'] ); - - // Trash again I expect the same as above. - $request = new WP_REST_Request( 'DELETE', $this->route . '/' . $membership->get( 'id' ) ); - $request->set_param( 'force', false ); - $response = $this->server->dispatch( $request ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $response_data = $response->get_data(); - // Non empty body. - $this->assertTrue( ! empty( $response_data ) ); - // Deleted post status should be 'trash'. - $this->assertEquals( 'trash', get_post_status( $membership->get( 'id' ) ) ); - // check the trashed post returned into the response is the correct one. - $this->assertEquals( $membership->get( 'id' ), $response_data['id'] ); - // check the trashed post returned into the response has the correct status 'trash'. - $this->assertEquals( 'trash', $response_data['status'] ); - } - - /** - * Test forbidden single membership update. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_update_forbidden_membership() { - // create a membership first. - wp_set_current_user( $this->user_allowed ); - $membership = $this->factory->membership->create_and_get(); - - wp_set_current_user( $this->user_forbidden ); - - $request = new WP_REST_Request( 'POST', $this->route . '/' . $membership->get( 'id' ) ); - $request->set_body_params( $this->sample_membership_args ); - $response = $this->server->dispatch( $request ); - - // Bad request. - $this->assertEquals( 403, $response->get_status() ); - } - - /** - * Test updating a membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_update_membership() { - wp_set_current_user( $this->user_allowed ); - - // Create membership and instructor. - $membership_id = $this->factory->membership->create(); - $instructor_id = $this->factory->user->create( array( 'role' => 'instructor' ) ); - - // Update. - $update_data = array( - 'title' => 'A TITLE UPDATED', - 'content' => '

CONTENT UPDATED

', - 'date_created' => '2019-10-31 15:32:15', - 'restriction_message' => str_replace( '{{membership_id}}', $membership_id, $this->default_restriction_message ), - 'status' => 'draft', - 'instructors' => array( $instructor_id ), - ); - $response = $this->perform_mock_request( 'POST', $this->route . '/' . $membership_id, $update_data ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $response_data = $response->get_data(); - - $this->assertEquals( $update_data['title'], $response_data['title']['raw'] ); - $this->assertEquals( $update_data['title'], $response_data['title']['rendered'] ); - $this->assertEquals( - rtrim( apply_filters( 'the_content', $update_data['content'] ), "\n" ), - rtrim( $response_data['content']['rendered'], "\n" ) - ); - $this->assertEquals( $update_data['date_created'], $response_data['date_created'] ); - $this->assertEquals( $update_data['status'], $response_data['status'] ); - $this->assertEqualSets( array( $instructor_id ), $response_data['instructors'] ); - - $restriction_message_raw = $update_data['restriction_message']; - $this->assertEquals( $restriction_message_raw, $response_data['restriction_message']['raw'] ); - $this->assertEquals( do_shortcode( $restriction_message_raw ), $response_data['restriction_message']['rendered'] ); - } - - /** - * Test updating a membership with an instructor that does not exist. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_update_membership_with_bad_instructor() { - wp_set_current_user( $this->user_allowed ); - - // Create membership, before update instructor, after update instructor and non-existing instructor. - $membership_id = $this->factory->membership->create(); - $membership = new LLMS_Membership( $membership_id ); - $original_instructor_id = $this->factory->user->create( array( 'role' => 'instructor' ) ); - $good_instructor_id = $this->factory->user->create( array( 'role' => 'instructor' ) ); - $bad_instructor_id = $good_instructor_id + 9; - - // Update membership with non-existing instructor. - $membership->set_instructors( array( array( 'id' => $original_instructor_id ) ) ); - $update_data = array( 'instructors' => array( $bad_instructor_id ) ); - $response = $this->perform_mock_request( 'POST', $this->route . '/' . $membership_id, $update_data ); - $this->assertResponseStatusEquals( 400, $response ); - - // Update membership with existing instructor and non-existing instructor. - $membership->set_instructors( array( array( 'id' => $original_instructor_id ) ) ); - $update_data = array( 'instructors' => array( $good_instructor_id, $bad_instructor_id ) ); - $response = $this->perform_mock_request( 'POST', $this->route . '/' . $membership_id, $update_data ); - $this->assertResponseStatusEquals( 400, $response ); - } - - /** - * Test updating a membership with an empty instructors array. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_update_membership_with_empty_instructors() { - wp_set_current_user( $this->user_allowed ); - - // Create membership with instructor. - $instructor_id = $this->factory->user->create( array( 'role' => 'instructor' ) ); - $membership_id = $this->factory->membership->create(); - $membership = new LLMS_Membership( $membership_id ); - $membership->set_instructors( array( array( 'id' => $instructor_id ) ) ); - - // Update membership with empty instructors. - $update_data = array( 'instructors' => array() ); - $response = $this->perform_mock_request( 'POST', $this->route . '/' . $membership_id, $update_data ); - $this->assertResponseStatusEquals( 400, $response ); - } - - /** - * Test single membership update without authorization. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_update_membership_without_authorization() { - // create a membership first. - wp_set_current_user( $this->user_allowed ); - $membership_id = $this->factory->membership->create(); - - wp_set_current_user( 0 ); - - $request = new WP_REST_Request( 'POST', $this->route . '/' . $membership_id ); - $request->set_body_params( $this->sample_membership_args ); - $response = $this->server->dispatch( $request ); - - // Unauthorized. - $this->assertEquals( 401, $response->get_status() ); - } - - /** - * Test updating a nonexistent membership. - * - * @since 1.0.0-beta.9 - * - * @return void - */ - public function test_update_nonexistent_membership() { - wp_set_current_user( $this->user_allowed ); - - // Setup membership. - $membership_id = $this->factory->membership->create(); - - $response = $this->perform_mock_request( - 'POST', - $this->route . '/' . $membership_id . '42', - $this->sample_membership_args - ); - - // Not found. - $this->assertEquals( 404, $response->get_status() ); - } -} diff --git a/tests/unit-tests/server/class-llms-rest-test-sections.php b/tests/unit-tests/server/class-llms-rest-test-sections.php deleted file mode 100644 index ab902396..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-sections.php +++ /dev/null @@ -1,448 +0,0 @@ -user_allowed = $this->factory->user->create( - array( - 'role' => 'administrator', - ) - ); - - $this->user_forbidden = $this->factory->user->create( - array( - 'role' => 'subscriber', - ) - ); - - $this->sample_section_args = array( - 'title' => array( - 'rendered' => 'Introduction', - 'raw' => 'Introduction', - ), - ); - - $this->endpoint = new LLMS_REST_Sections_Controller(); - - } - - - /** - * Test route registration. - * - * @since 1.0.0-beta.1 - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - // Child lessons. - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)/content', $routes ); - } - - /** - * Test list sections. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.7 Fixed sections fields check. - */ - public function test_get_sections() { - - wp_set_current_user( $this->user_allowed ); - - // create 3 courses. - $courses = $this->factory->course->create_many( 3, array( 'sections' => 5, 'lessons' => 0 ) ); - - $response = $this->server->dispatch( new WP_REST_Request( 'GET', $this->route ) ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $res_data = $response->get_data(); - $this->assertEquals( 10, count( $res_data ) ); // default per_page is 10. - - $headers = $response->get_headers(); - $this->assertEquals( 15, $headers['X-WP-Total'] ); - $this->assertEquals( 2, $headers['X-WP-TotalPages'] ); - - array_pop($courses); - $i = 0; - // Check retrieved sections are the same as the generated ones. - foreach ( $courses as $course ) { - - $course_obj = new LLMS_Course( $course ); - $sections = $course_obj->get_sections(); - - // Easy sequential check as sections are by default ordered by id. - $j = 0; - foreach ( $sections as $section ) { - $res_section = $res_data[ ( $i * count( $sections ) ) + $j ]; - $this->llms_posts_fields_match( $section, $res_section ); - $j++; - } - - $i++; - } - } - - /** - * Test links. - * - * @since 1.0.0-beta.7 - */ - public function test_links() { - - // create course with 3 sections and 1 lesson per section. - $course = $this->factory->course->create_and_get( array( 'sections' => 3, 'lessons' => 1 ) ); - - $course_obj = new LLMS_Course( $course ); - $sections = $course_obj->get_sections(); - - - $i = 0; - foreach ( $sections as $section ) { - - $response = $this->perform_mock_request( 'GET', $this->route . '/' . $section->get('id') ); - - switch ( $i++ ): - case 0: - $expected_link_rels = array_values( array_diff( $this->expected_link_rels, array( 'previous' ) ) ); - break; - case 2: - $expected_link_rels = array_values( array_diff( $this->expected_link_rels, array( 'next' ) ) ); - break; - default: - $expected_link_rels = $this->expected_link_rels; - endswitch; - - $this->assertEquals( $expected_link_rels, array_keys( $response->get_links() ) ); - - } - - } - - /** - * Test list sections pagination. - * - * @since 1.0.0-beta.7 - */ - public function test_get_sections_pagination() { - - wp_set_current_user( $this->user_allowed ); - - // create sections - $course = $this->factory->course->create_and_get( array( 'sections' => 25, 'lessons' => 0 ) ); - $start_section_id = $course->get_sections( 'ids' )[0]; - - $this->pagination_test( $this->route, $start_section_id ); - - } - - - /** - * Test create a single section. - * - * @since 1.0.0-beta.1 - */ - public function test_create_section() { - - wp_set_current_user( $this->user_allowed ); - - $request = new WP_REST_Request( 'POST', $this->route ); - - // create a course. - $course_id = $this->factory->course->create( array( 'sections' => 0 ) ); - - $section_args = $this->sample_section_args; - $section_args['parent_id'] = $course_id; - - $request->set_body_params( $section_args ); - $response = $this->server->dispatch( $request ); - - // Success. - $this->assertEquals( 201, $response->get_status() ); - - $course = new LLMS_Course( $course_id ); - $sections = $course->get_sections(); // returns an array of one element. - - $res_data = $response->get_data(); - - // Test the created section and the response are equal - $this->llms_posts_fields_match( $sections[0], $res_data ); - $this->assertEquals( $section_args['title']['rendered'], $res_data['title']['rendered'] ); - } - - /** - * Test producing bad request error when creating a single section. - * - * @since 1.0.0-beta.1 - */ - public function test_create_section_bad_request() { - - wp_set_current_user( $this->user_allowed ); - - $request = new WP_REST_Request( 'POST', $this->route ); - // create a course. - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - $post = $this->factory->post->create(); - - // create a section without parent_id. - $section_args = $this->sample_section_args; - - $request->set_body_params( $section_args ); - $response = $this->server->dispatch( $request ); - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - - // Creating a section passing a parent_id which is not a course id produces a bad request. - $section_args = $this->sample_section_args; - - // This post doesn't exist. - $section_args['parent_id'] = 1234; - - $request->set_body_params( $section_args ); - $response = $this->server->dispatch( $request ); - - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - $this->assertResponseMessageEquals( 'Invalid parent_id param. It must be a valid Course ID.', $response ); - - // This post exists but is not a course. - $section_args['parent_id'] = $post; - - $request->set_body_params( $section_args ); - $response = $this->server->dispatch( $request ); - - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - $this->assertResponseMessageEquals( 'Invalid parent_id param. It must be a valid Course ID.', $response ); - - $this->sample_section_args['parent_id'] = $course; - - // Creating a section passing an order equal to 0 produces a bad request. - $section_args = $this->sample_section_args; - $section_args['order'] = 0; - $request->set_body_params( $section_args ); - $response = $this->server->dispatch( $request ); - - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - $this->assertResponseMessageEquals( 'Invalid order param. It must be greater than 0.', $response ); - - // create a section without title. - $section_args = $this->sample_section_args; - unset( $section_args['title'] ); - - $request->set_body_params( $section_args ); - $response = $this->server->dispatch( $request ); - // Bad request. - $this->assertEquals( 400, $response->get_status() ); - - } - - /** - * Test deleting a single section. - * - * @since 1.0.0-beta.1 - */ - public function test_delete_section() { - - wp_set_current_user( $this->user_allowed ); - - // create a section first. - $section = llms_get_post( $this->factory->post->create( array( 'post_type' => 'section' ) ) ); - - $request = new WP_REST_Request( 'DELETE', $this->route . '/' . $section->get( 'id' ) ); - - $response = $this->server->dispatch( $request ); - - // Success. - $this->assertEquals( 204, $response->get_status() ); - - // Cannot find just deleted post. - $this->assertFalse( get_post_status( $section->get( 'id' ) ) ); - - } - - /** - * Test trashing a single section. - * - * @since 1.0.0-beta.1 - */ - public function test_trash_section() { - - wp_set_current_user( $this->user_allowed ); - - // create a section first. - $section = llms_get_post( $this->factory->post->create( array( 'post_type' => 'section' ) ) ); - - $request = new WP_REST_Request( 'DELETE', $this->route . '/' . $section->get( 'id' ) ); - $request->set_param( 'force', false ); - $response = $this->server->dispatch( $request ); - - // We still expect a 204 section are always deleted and not trashed. - $this->assertEquals( 204, $response->get_status() ); - - // Cannot find just deleted post. - $this->assertFalse( get_post_status( $section->get( 'id' ) ) ); - - } - - /** - * Test list sections content. - * - * @since 1.0.0-beta.1 - * - * @todo test order and orderby - */ - public function test_get_sections_content() { - - wp_set_current_user( $this->user_allowed ); - - // create 1 course with 1 section but no lessons. - $course = $this->factory->course->create_and_get( - array( - 'sections' => 1, - 'lessons' => 0, - ) - ); - - $section_id = $course->get_sections( 'ids' )[0]; - - $response = $this->server->dispatch( new WP_REST_Request( 'GET', $this->route . '/' . $section_id . '/content' ) ); - - // We have no lessons for this section so we expect a 404. - $this->assertEquals( 404, $response->get_status() ); - - // create 1 course with 5 sections and 3 lessons per section - $course = $this->factory->course->create_and_get( - array( - 'sections' => 5, - 'lessons' => 3, - ) - ); - - $section_ids = $course->get_sections( 'ids' ); - - foreach ( $section_ids as $section_id ) { - - $response = $this->server->dispatch( new WP_REST_Request( 'GET', $this->route . '/' . $section_id . '/content' ) ); - - // Success. - $this->assertEquals( 200, $response->get_status() ); - - $res_data = $response->get_data(); - $this->assertEquals( 3, count( $res_data ) ); - - for ( $i = 0; $i < 3; $i++ ) { - $this->assertEquals( $section_id, $res_data[ $i ]['parent_id'] ); - } - - } - - } - - /** - * Test sections content controller not initialized when not needed. - * - * @since 1.0.0-beta.1 - */ - public function test_sections_content_not_init() { - - $this->assertNotNull( $this->endpoint->get_content_controller() ); - - $new_sec_controller = new LLMS_REST_Sections_Controller( '' ); - $this->assertNull( $new_sec_controller->get_content_controller() ); - - } - - /** - * Create a resource for this post type. - * - * @since 1.0.0-beta.25 - * - * @param array $params Array of request params. - * @return WP_Post - */ - protected function create_post_resource( $params = array() ) { - - $course_id = $this->factory->course->create( - array( - 'sections' => 0, - ) - ); - - return parent::create_post_resource( - array( - 'parent_id' => $course_id, - ) - ); - - } - - /** - * Override. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.7 Fixed expected 'order' field, added expected 'parent_id'. - * @since 1.0.0-beta.23 Replaced the call to the deprecated `LLMS_Lesson::get_parent_course()` method with `LLMS_Lesson::get( 'parent_course' )`. - * - * @param array $expected Array of expected properties. - * @param LLMS_Post_Model $llms_post Instance of LLMS_Post_Model. - * @return array - */ - protected function filter_expected_fields( $expected, $llms_post ) { - - unset( $expected['content'] ); - $expected['order'] = $llms_post->get( 'order' ); - $expected['parent_id'] = $llms_post->get( 'parent_course' ); - - return $expected; - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-server-functions.php b/tests/unit-tests/server/class-llms-rest-test-server-functions.php deleted file mode 100644 index 80b4e7b4..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-server-functions.php +++ /dev/null @@ -1,449 +0,0 @@ -assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 401 ), $err ); - $this->assertWPErrorMessageEquals( 'The API credentials were invalid.', $err ); - - // Custom message. - $err = llms_rest_authorization_required_error( 'My message.' ); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 401 ), $err ); - $this->assertWPErrorMessageEquals( 'My message.', $err ); - - } - - /** - * Test the llms_rest_authorization_required_error() function when logged in. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_llms_rest_authorization_required_error_logged_in() { - - wp_set_current_user( $this->factory->user->create() ); - - // Default. - $err = llms_rest_authorization_required_error(); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 403 ), $err ); - $this->assertWPErrorMessageEquals( 'You are not authorized to perform this request.', $err ); - - // Custom message. - $err = llms_rest_authorization_required_error( 'My message.' ); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 403 ), $err ); - $this->assertWPErrorMessageEquals( 'My message.', $err ); - - } - - /** - * Test the llms_rest_authorization_required_error() function `$check_authenticated` parameter. - * - * @since 1.0.0-beta.12 - * - * @return void - */ - public function test_llms_rest_authorization_required_error_with_check_authenticated_false() { - - // Default. - $err = llms_rest_authorization_required_error('', false); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 401 ), $err ); - $this->assertWPErrorMessageEquals( 'The API credentials were invalid.', $err ); - - // Custom message. - $err = llms_rest_authorization_required_error( 'My message.', false ); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 401 ), $err ); - $this->assertWPErrorMessageEquals( 'My message.', $err ); - - // Log in. - wp_set_current_user( $this->factory->user->create() ); - - // Default. - $err = llms_rest_authorization_required_error('', false); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 401 ), $err ); - $this->assertWPErrorMessageEquals( 'The API credentials were invalid.', $err ); - - // Custom message. - $err = llms_rest_authorization_required_error( 'My message.', false ); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 401 ), $err ); - $this->assertWPErrorMessageEquals( 'My message.', $err ); - - } - - /** - * Test the llms_rest_bad_request_error() function. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_llms_rest_bad_request_error() { - - // Default. - $err = llms_rest_bad_request_error(); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_bad_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 400 ), $err ); - $this->assertWPErrorMessageEquals( 'Invalid or malformed request syntax.', $err ); - - // Custom message. - $err = llms_rest_bad_request_error( 'My message.' ); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_bad_request', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 400 ), $err ); - $this->assertWPErrorMessageEquals( 'My message.', $err ); - - } - - /** - * Test the llms_rest_not_found_error() function. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_llms_rest_not_found_error() { - - // Default. - $err = llms_rest_not_found_error(); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_not_found', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 404 ), $err ); - $this->assertWPErrorMessageEquals( 'The requested resource could not be found.', $err ); - - // Custom message. - $err = llms_rest_not_found_error( 'My message.' ); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_not_found', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 404 ), $err ); - $this->assertWPErrorMessageEquals( 'My message.', $err ); - - } - - /** - * Test the llms_rest_server_error() function. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_llms_rest_server_error() { - - // Default. - $err = llms_rest_server_error(); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_server_error', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 500 ), $err ); - $this->assertWPErrorMessageEquals( 'Internal Server Error.', $err ); - - // Custom message. - $err = llms_rest_server_error( 'My message.' ); - $this->assertIsWPError( $err ); - $this->assertWPErrorCodeEquals( 'llms_rest_server_error', $err ); - $this->assertWPErrorDataEquals( array( 'status' => 500 ), $err ); - $this->assertWPErrorMessageEquals( 'My message.', $err ); - - } - - /** - * Test the llms_rest_is_authorization_required_error() function - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_llms_rest_is_authorization_required_error() { - // Log out to check 401. - wp_set_current_user( 0 ); - - // True. - $err = llms_rest_authorization_required_error(); - $this->assertTrue( llms_rest_is_authorization_required_error( $err ) ); - $this->assertWPErrorDataEquals( array( 'status' => 401 ), $err ); - - // False. - $err = llms_rest_server_error(); - $this->assertFalse( llms_rest_is_authorization_required_error( $err ) ); - - // Passing something different than a WP_Error: False. - $err = 3; - $this->assertFalse( llms_rest_is_authorization_required_error( $err ) ); - - // Passing a WP_Error with no errors. - $err = new WP_Error(); - $this->assertFalse( llms_rest_is_authorization_required_error( $err ) ); - - // Log in to check 403. - wp_set_current_user( $this->factory->user->create() ); - - // True. - $err = llms_rest_authorization_required_error(); - $this->assertTrue( llms_rest_is_authorization_required_error( $err ) ); - $this->assertWPErrorDataEquals( array( 'status' => 403 ), $err ); - - // False. - $err = llms_rest_server_error(); - $this->assertFalse( llms_rest_is_authorization_required_error( $err ) ); - - // Passing something different than a WP_Error: False. - $err = 3; - $this->assertFalse( llms_rest_is_authorization_required_error( $err ) ); - - // Passing a WP_Error with no errors. - $err = new WP_Error(); - $this->assertFalse( llms_rest_is_authorization_required_error( $err ) ); - - } - - /** - * Test the llms_rest_is_bad_request_error() function - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_llms_rest_is_bad_request_error() { - - // True. - $err = llms_rest_bad_request_error(); - $this->assertTrue( llms_rest_is_bad_request_error( $err ) ); - - // False. - $err = llms_rest_server_error(); - $this->assertFalse( llms_rest_is_bad_request_error( $err ) ); - - // Passing something different than a WP_Error: False. - $err = 3; - $this->assertFalse( llms_rest_is_bad_request_error( $err ) ); - - // Passing a WP_Error with no errors. - $err = new WP_Error(); - $this->assertFalse( llms_rest_is_bad_request_error( $err ) ); - } - - /** - * Test the llms_rest_is_not_found_error() function - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_llms_rest_is_not_found_error() { - - // True. - $err = llms_rest_not_found_error(); - $this->assertTrue( llms_rest_is_not_found_error( $err ) ); - - // False. - $err = llms_rest_server_error(); - $this->assertFalse( llms_rest_is_not_found_error( $err ) ); - - // Passing something different than a WP_Error: False. - $err = 3; - $this->assertFalse( llms_rest_is_not_found_error( $err ) ); - - // Passing a WP_Error with no errors. - $err = new WP_Error(); - $this->assertFalse( llms_rest_is_not_found_error( $err ) ); - } - - /** - * Test the llms_is_rest_server_error() function - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_llms_rest_is_server_error() { - - // True. - $err = llms_rest_server_error(); - $this->assertTrue( llms_rest_is_server_error( $err ) ); - - // False. - $err = llms_rest_not_found_error(); - $this->assertFalse( llms_rest_is_server_error( $err ) ); - - // Passing something different than a WP_Error: False. - $err = 3; - $this->assertFalse( llms_rest_is_server_error( $err ) ); - - // Passing a WP_Error with no errors. - $err = new WP_Error(); - $this->assertFalse( llms_rest_is_server_error( $err ) ); - - } - - /** - * Test llms_rest_get_all_error_statuses() function - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_get_all_error_status() { - $err = llms_rest_server_error(); - // Additional data for the same error code (only makes sense with wp 5.6+). - $err->add_data( - array( - 'status' => 2000 - ) - ); - - $err->add( - 'code', - 'meassage', - array( - 'status' => 800 - ) - ); - $err->add( - 'code_2', - 'message', - array( - 200 - ) - ); - $err->add_data( - array( - 'status' => 500 // Check duplicates. - ) - ); - - $expected = array( - 500, - 800, - ); - - /** - * since WordPress 5.6.0 Errors can now contain more than one item of error data. {@see WP_Error::$additional_data}. - */ - global $wp_version; - if ( version_compare( $wp_version, 5.6, '>=' ) ) { - $expected[] = 2000; - } - - $this->assertEqualSets( $expected, llms_rest_get_all_error_statuses( $err ) ); - - // Check empty error results in empty array returned by the function. - $err = new WP_Error(); - $this->assertEquals( array(), llms_rest_get_all_error_statuses( $err ) ); - - // Check non WP_Error results in empty array returned by the function. - $err = new stdClass(); - $this->assertEquals( array(), llms_rest_get_all_error_statuses( $err ) ); - - } - - /** - * Test llms_rest_validate_memberships() - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_llms_rest_validate_memberships() { - $this->validate_post_types_tests( 'llms_rest_validate_memberships', 'llms_membership' ); - } - - /** - * Test llms_rest_validate_courses() - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_llms_rest_validate_courses() { - $this->validate_post_types_tests( 'llms_rest_validate_courses', 'course' ); - } - - /** - * Test llms_rest_validate_products() - * - * @since 1.0.0-beta.18 - * - * @return void - */ - public function test_llms_rest_validate_products() { - $course = $this->factory->post->create( array( 'post_type' => 'course' ) ); - $membership = $this->factory->post->create( array( 'post_type' => 'llms_membership' ) ); - - $this->validate_post_types_tests( 'llms_rest_validate_products', '', array( $course, $membership ) ); - - // Test mixed with a standard post. - $this->assertFalse( llms_rest_validate_products( array( $course, $membership, $this->factory->post->create() ) ) ); - } - - /** - * Test validate llms_rest_validate_post_types - * - * @since 1.0.0-beta.18 - * - * @return void - */ - private function validate_post_types_tests( $func, $post_type = '', $posts = array() ) { - - // Test an empty array. - $this->assertTrue( $func( array(), true ), $func ); // Allowed. - - $this->assertFalse( $func( array() ), $func ); - - // Create 2 pt. - $pts = empty( $posts ) ? $this->factory->post->create_many( 2, array( 'post_type' => $post_type ) ) : $posts; - - // Test a not existing pt. - $this->assertFalse( $func( end( $pts ) + 1 ), $func ); - - // Test an array of non existing pt. - $this->assertFalse( $func( array( end( $pts ) + 1, end( $pts ) + 2 ) ), $func ); - - // Test an array of an existing and non existing pt. - $this->assertFalse( $func( array( end( $pts ), end( $pts ) + 2 ) ), $func ); - - // Test an array of existting post types. - $this->assertTrue( $func( $pts ) ); - - // Test an existing post type. - $this->assertTrue( $func( end( $pts ) ) ); - - } -} diff --git a/tests/unit-tests/server/class-llms-rest-test-students-controllers.php b/tests/unit-tests/server/class-llms-rest-test-students-controllers.php deleted file mode 100644 index 0cd1da41..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-students-controllers.php +++ /dev/null @@ -1,1327 +0,0 @@ - 'jamief_%d@mockstudent.tld', - 'first_name' => 'Jamie', - 'last_name' => 'Fitzgerald', - 'name' => 'Jamie Fitzgerald', - 'nickname' => 'JamieF1932', - 'username' => 'jamief_%d', - 'url' => 'http://jamief.geocities.com', - 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', - 'billing_address_1' => '123 Some Street', - 'billing_address_2' => 'Suite A', - 'billing_city' => 'Some City', - 'billing_state' => 'NH', - 'billing_postcode' => '32319', - 'billing_country' => 'USA', - ); - - private function get_mock_student_data( $i ) { - - $data = $this->mock_student_data; - - $data['email'] = sprintf( $data['email'], $i ); - $data['username'] = sprintf( $data['username'], $i ); - - return $data; - - } - - /** - * Retrieve an LLMS_Student with data. - * - * @since 1.0.0-beta.1 - * - * @param array $data Array of user information. - * @return LLMS_Student - */ - private function get_student_with_data( $data = array() ) { - - $student = $this->factory->student->create_and_get( array( - 'user_email' => $data['email'], - 'user_login' => $data['username'], - 'user_url' => $data['url'], - 'display_name' => $data['name'] - ) ); - - unset( $data['email'], $data['username'], $data['url'], $data['name'] ); - - foreach ( $data as $key => $val ) { - $student->set( $key, $val, 0 === strpos( $key, 'billing_' ) ? true : false ); - } - - return $student; - - } - - /** - * Setup the test case. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function set_up() { - - parent::set_up(); - $this->user_admin = $this->factory->user->create( array( 'role' => 'administrator', ) ); - $this->user_instructor = $this->factory->user->create( array( 'role' => 'instructor', ) ); - $this->user_subscriber = $this->factory->user->create( array( 'role' => 'subscriber', ) ); - $this->endpoint = new LLMS_REST_Students_Controller(); - - } - - /** - * Teardown test - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function tear_down() { - - parent::tear_down(); - - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->users}" ); - - } - - /** - * Test the create_item method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_item() { - - // Unauthorized user. - wp_set_current_user( null ); - $data = $this->get_mock_student_data( 3 ); - $res = $this->perform_mock_request( 'POST', $this->route, $data ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - // Forbidden user. - wp_set_current_user( $this->user_subscriber ); - $res = $this->perform_mock_request( 'POST', $this->route, $data ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - // Instructor's can't create. - wp_set_current_user( $this->user_instructor ); - $res = $this->perform_mock_request( 'POST', $this->route, $data ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - // Okay. - wp_set_current_user( $this->user_admin ); - $data = $this->get_mock_student_data( 4 ); - $password = wp_generate_password(); - $res = $this->perform_mock_request( 'POST', $this->route, array_merge( compact( 'password' ), $data ) ); - $this->assertResponseStatusEquals( 201, $res ); - - $res_data = $res->get_data(); - foreach ( $data as $key => $expected ) { - $this->assertEquals( $expected, $res_data[ $key ], $key ); - } - - $this->assertEquals( array( 'student' ), $res_data['roles'] ); - - $this->assertArrayHasKey( 'id', $res_data ); - $this->assertArrayHasKey( 'registered_date', $res_data ); - $this->assertArrayHasKey( 'avatar_urls', $res_data ); - - // Check password. - $user = get_user_by( 'id', $res_data['id'] ); - $this->assertTrue( wp_check_password( $password, $user->user_pass ) ); - - // Location header. - $headers = $res->get_headers(); - $this->assertEquals( rest_url( sprintf( '%1$s/%2$d', $this->route, $res_data['id'] ) ), $headers['Location'] ); - - // Links. - $this->assertEquals( $this->expected_link_rels, array_keys( $res->get_links() ) ); - - } - - /** - * Test create user permission check - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_create_item_permissions_check() { - - $request = new WP_REST_Request( 'POST', $this->route ); - - // Unauthorized user. - wp_set_current_user( null ); - $ret = $this->endpoint->create_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $ret ); - - // Cannot create students. - $nay = array( 'subscriber', 'instructor', 'instructors_assistant' ); - foreach ( $nay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $ret = $this->endpoint->create_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $ret ); - } - - // Can create. - $yay = array( 'administrator', 'lms_manager' ); - foreach ( $yay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $this->assertTrue( $this->endpoint->create_item_permissions_check( $request ) ); - } - - } - - /** - * Test custom fields correctly mapped. - * - * @since 1.0.0-beta.11 - * - * @return void - */ - public function test_user_custom_fields_map() { - - wp_set_current_user( $this->user_admin ); - $data = $this->get_mock_student_data( 5 ); - - $res = $this->perform_mock_request( 'POST', $this->route, $data ); - - $this->assertResponseStatusEquals( 201, $res ); - - $res_data = $res->get_data(); - $student = llms_get_student($res_data['id']); - // check the `billing_postcode` meta is empty. - $this->assertEmpty( $student->get( 'billing_postcode' ) ); - // check that `billing_postcode` maps to the llms student `billing_zip` meta. - $this->assertEquals( $res_data['billing_postcode'], $student->get( 'billing_zip' ) ); - - } - - public function test_delete_item() { - - $id = $this->factory->student->create(); - - // no user. - $res = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - // Forbidden user. - wp_set_current_user( $this->user_subscriber ); - $res = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - // Good. - wp_set_current_user( $this->user_admin ); - $res = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertTrue( is_null( $res->get_data() ) ); - $this->assertResponseStatusEquals( 204, $res ); - - // deleting the same user again has the same result. - $res = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertTrue( is_null( $res->get_data() ) ); - $this->assertResponseStatusEquals( 204, $res ); - - } - - /** - * Test delete item permission check - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_delete_item_permissions_check() { - - $user_id = $this->factory->student->create(); - - $request = new WP_REST_Request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $user_id ) ); - $request->set_url_params( array( 'id' => $user_id ) ); - - // Unauthorized user. - wp_set_current_user( null ); - $ret = $this->endpoint->delete_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $ret ); - - // Cannot delete students. - $nay = array( 'subscriber', 'instructor', 'instructors_assistant' ); - foreach ( $nay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $ret = $this->endpoint->delete_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $ret ); - } - - // Can delete student. - $yay = array( 'administrator', 'lms_manager' ); - foreach ( $yay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $this->assertTrue( $this->endpoint->delete_item_permissions_check( $request ) ); - } - - } - - /** - * Test get item permission check - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_item_permissions_check() { - - $user_id = $this->factory->student->create(); - - $request = new WP_REST_Request( 'GET', sprintf( '%1$s/%2$d', $this->route, $user_id ) ); - $request->set_url_params( array( 'id' => $user_id ) ); - - // Unauthorized user. - wp_set_current_user( null ); - $ret = $this->endpoint->get_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $ret ); - - // can get self. - wp_set_current_user( $user_id ); - $this->assertTrue( $this->endpoint->get_item_permissions_check( $request ) ); - - // Cannot get students. - $nay = array( 'subscriber', 'instructor', 'instructors_assistant' ); - foreach ( $nay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $ret = $this->endpoint->get_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $ret ); - } - - // Can get student. - $yay = array( 'administrator', 'lms_manager' ); - foreach ( $yay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $this->assertTrue( $this->endpoint->get_item_permissions_check( $request ) ); - } - - // Can get their own students. - $own = array( 'instructor', 'instructors_assistant' ); - foreach( $own as $role ) { - - $user = $this->factory->user->create( array( 'role' => $role ) ); - $course = $this->factory->course->create_and_get( array( 'sections' => 0 ) ); - $course->instructors()->set_instructors( array( array( 'id' => $user ) ) ); - llms_enroll_student( $user_id, $course->get( 'id' ) ); - - wp_set_current_user( $user ); - - $this->assertTrue( $this->endpoint->get_item_permissions_check( $request ) ); - - } - - } - - /** - * Test get item permission check - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_items_permissions_check() { - - $user_id = $this->factory->student->create(); - - $request = new WP_REST_Request( 'GET', $this->route ); - - // Unauthorized user. - wp_set_current_user( null ); - $ret = $this->endpoint->get_items_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $ret ); - - // Cannot get students. - $nay = array( 'subscriber' ); - foreach ( $nay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $ret = $this->endpoint->get_items_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $ret ); - } - - // Can get students. - $yay = array( 'administrator', 'lms_manager', 'instructor', 'instructors_assistant' ); - foreach ( $yay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $this->assertTrue( $this->endpoint->get_items_permissions_check( $request ) ); - } - - // Add roles to the request. - $request->set_query_params( array( 'roles' => 'student' ) ); - - // Cannot get students by role. - $nay = array( 'instructor', 'instructors_assistant' ); - foreach ( $nay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $ret = $this->endpoint->get_items_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $ret ); - } - - // Can filter students by role. - $yay = array( 'administrator', 'lms_manager' ); - foreach ( $yay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $this->assertTrue( $this->endpoint->get_items_permissions_check( $request ) ); - } - - } - - /** - * Ensure all collection parameters have been registered. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_collection_params() { - - $params = $this->endpoint->get_collection_params(); - $this->assertArrayHasKey( 'context', $params ); - $this->assertArrayHasKey( 'page', $params ); - $this->assertArrayHasKey( 'per_page', $params ); - $this->assertArrayHasKey( 'order', $params ); - $this->assertArrayHasKey( 'orderby', $params ); - $this->assertArrayHasKey( 'include', $params ); - $this->assertArrayHasKey( 'roles', $params ); - $this->assertArrayHasKey( 'enrolled_in', $params ); - $this->assertArrayHasKey( 'enrolled_not_in', $params ); - - } - - /** - * Test the get_item() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_item() { - - $data = $this->get_mock_student_data( 2 ); - $student = $this->get_student_with_data( $data ); - - $route = sprintf( '%1$s/%2$d', $this->route, $student->get( 'id' ) ); - - // No user. - $res = $this->perform_mock_request( 'GET', $route ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - $this->assertResponseStatusEquals( 401, $res ); - - // Forbidden user. - wp_set_current_user( $this->user_subscriber ); - $res = $this->perform_mock_request( 'GET', $route ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - $this->assertResponseStatusEquals( 403, $res ); - - // Admin okay. - wp_set_current_user( $this->user_admin ); - - // Test default (view), view (explicit), and edit contexts. - foreach ( array( null, 'view', 'edit' ) as $context ) { - - if ( $context ) { - $res = $this->perform_mock_request( 'GET', $route, array(), array( 'context' => $context ) ); - } else { - $res = $this->perform_mock_request( 'GET', $route ); - } - - $this->assertResponseStatusEquals( 200, $res ); - - $data = $res->get_data(); - $this->assertEquals( $student->get( 'id' ), $data['id'] ); - $this->assertEquals( $data['name'], $data['name'] ); - $this->assertEquals( $data['url'], $data['url'] ); - $this->assertEquals( $data['description'], $data['description'] ); - $this->assertArrayHasKey( 'avatar_urls', $data ); - - $this->assertEquals( $this->expected_link_rels, array_keys( $res->get_links() ) ); - - if ( 'edit' === $context ) { - - $this->assertEquals( $data['first_name'], $data['first_name'] ); - $this->assertEquals( $data['last_name'], $data['last_name'] ); - $this->assertEquals( $data['username'], $data['username'] ); - $this->assertEquals( $data['email'], $data['email'] ); - $this->assertEquals( $data['nickname'], $data['nickname'] ); - - $this->assertEquals( $data['billing_address_1'], $data['billing_address_1'] ); - $this->assertEquals( $data['billing_address_2'], $data['billing_address_2'] ); - $this->assertEquals( $data['billing_city'], $data['billing_city'] ); - $this->assertEquals( $data['billing_state'], $data['billing_state'] ); - $this->assertEquals( $data['billing_postcode'], $data['billing_postcode'] ); - $this->assertEquals( $data['billing_country'], $data['billing_country'] ); - - $this->assertEquals( array( 'student' ), $data['roles'] ); - $this->assertArrayHasKey( 'registered_date', $data ); - - } - - } - - // Instructor is forbidden. - wp_set_current_user( $this->user_instructor ); - $res = $this->perform_mock_request( 'GET', $route ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - $this->assertResponseStatusEquals( 403, $res ); - - // Instructor can retrieve because student's in their course. - $course = $this->factory->course->create_and_get( array( 'sections' => 0 ) ); - $course->set_instructors( array( array( 'id' => $this->user_instructor ) ) ); - $student->enroll( $course->get( 'id' ) ); - - $res = $this->perform_mock_request( 'GET', $route ); - $this->assertResponseStatusEquals( 200, $res ); - - } - - public function test_get_items_errors() { - - - // No user. - $res = $this->perform_mock_request( 'GET', $this->route ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - $this->assertResponseStatusEquals( 401, $res ); - - // Forbidden user. - wp_set_current_user( $this->user_subscriber ); - $res = $this->perform_mock_request( 'GET', $this->route ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - $this->assertResponseStatusEquals( 403, $res ); - - - } - - public function test_get_items_pagination() { - - global $wpdb; - - $this->factory->user->create_many( 5 ); - $this->factory->student->create_many( 25 ); - $db_total = absint( $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->users}" ) ); - - - $db_pages = ceil( $db_total / 10 ); - - wp_set_current_user( $this->user_admin ); - -// $this->pagination_test( $this->route, $start_id = 1, $per_page = 10, $id_field = null, $total = $db_total ); - - $res = $this->perform_mock_request( 'GET', $this->route ); - - // Correct # of results to default 10 / page - $this->assertEquals( 10, count( $res->get_data() ) ); - - // Check Pagination headers. - $headers = $res->get_headers(); - $this->assertEquals( $db_total, $headers['X-WP-Total'] ); - $this->assertEquals( $db_pages, $headers['X-WP-TotalPages'] ); - - // Link headers. - $links = $this->parse_link_headers( $res ); - $this->assertEquals( array( 'next', 'last' ), array_keys( $links ) ); - - - // Page 2. - $res = $this->perform_mock_request( 'GET', $this->route, array(), array( 'page' => 2 ) ); - - // Link headers. - $links = $this->parse_link_headers( $res ); - $this->assertEquals( array( 'first', 'prev', 'next', 'last' ), array_keys( $links ) ); - - - // Last page. - $res = $this->perform_mock_request( 'GET', $this->route, array(), array( 'page' => $db_pages ) ); - - // Link headers. - $links = $this->parse_link_headers( $res ); - $this->assertEquals( array( 'first', 'prev' ), array_keys( $links ) ); - - - // Big per page. - $res = $this->perform_mock_request( 'GET', $this->route, array(), array( 'per_page' => 100 ) ); - - // Check Pagination headers. - $headers = $res->get_headers(); - $this->assertEquals( $db_total, $headers['X-WP-Total'] ); - $this->assertEquals( 1, $headers['X-WP-TotalPages'] ); - - // No links because this is the only page. - $links = $this->parse_link_headers( $res ); - $this->assertEquals( array(), array_keys( $links ) ); - - // Out of bounds. - $res = $this->perform_mock_request( 'GET', $this->route, array(), array( 'page' => 25, 'per_page' => 100 ) ); - $this->assertResponseStatusEquals( 400, $res ); - - } - - public function test_get_items_orderby_id() { - - wp_set_current_user( $this->user_admin ); - $low = $this->factory->user->create( array() ); - $high = $this->factory->user->create( array() ); - $args = array( 'include' => array( $low, $high ), 'orderby' => 'id' ); - - // Default / asc. - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $low, $res->get_data()[0]['id'] ); - - // Desc. - $args['order'] = 'desc'; - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $high, $res->get_data()[0]['id'] ); - - } - - public function test_get_items_orderby_email() { - - wp_set_current_user( $this->user_admin ); - $low = $this->factory->user->create( array( array( 'user_email' => 'aemail@mock.tld' ) ) ); - $high = $this->factory->user->create( array( array( 'user_email' => 'bemail@mock.tld' ) ) ); - $args = array( 'include' => array( $low, $high ), 'orderby' => 'email' ); - - // Default / asc. - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $low, $res->get_data()[0]['id'] ); - - // Desc. - $args['order'] = 'desc'; - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $high, $res->get_data()[0]['id'] ); - - } - - public function test_get_items_orderby_name() { - - wp_set_current_user( $this->user_admin ); - $low = $this->factory->user->create( array( 'display_name' => 'A Name' ) ); - $high = $this->factory->user->create( array( 'display_name' => 'B Name' ) ); - $args = array( 'include' => array( $low, $high ), 'orderby' => 'name' ); - - // Default / asc. - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $low, $res->get_data()[0]['id'] ); - - // Desc. - $args['order'] = 'desc'; - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $high, $res->get_data()[0]['id'] ); - - } - - public function test_get_items_orderby_registered_date() { - - wp_set_current_user( $this->user_admin ); - $low = $this->factory->user->create( array( 'user_registered' => date( 'Y-m-d h:i:s', strtotime( '-5 days', time() ) ) ) ); - $high = $this->factory->user->create(); - $args = array( 'include' => array( $low, $high ), 'orderby' => 'registered_date' ); - - // Default / asc. - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $low, $res->get_data()[0]['id'] ); - - // Desc. - $args['order'] = 'desc'; - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $high, $res->get_data()[0]['id'] ); - - } - - public function test_get_items_enrollment_filters() { - - wp_set_current_user( $this->user_admin ); - - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - - $args = array( - 'include' => array(), - 'enrolled_in' => $course, - ); - for ( $i = 1; $i <= 3; $i++ ) { - $args['include'][] = $this->factory->student->create(); - } - - // None are enrolled. - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( array(), $res->get_data() ); - - unset( $args['enrolled_in'] ); - $args['enrolled_not_in'] = $course; - - // All are not enrolled. - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( $args['include'], wp_list_pluck( $res->get_data(), 'id' ) ); - - // Enroll a student. - llms_enroll_student( $args['include'][0], $course ); - - // Return only the non-enrolled students. - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( array( $args['include'][1], $args['include'][2] ), wp_list_pluck( $res->get_data(), 'id' ) ); - - // Only return the enrolled student. - unset( $args['enrolled_not_in'] ); - $args['enrolled_in'] = $course; - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( array( $args['include'][0] ), wp_list_pluck( $res->get_data(), 'id' ) ); - - // No one's enrolled in both. - $course_2 = $this->factory->course->create( array( 'sections' => 0 ) ); - $args['enrolled_in'] .= ',' . $course_2; - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( array(), wp_list_pluck( $res->get_data(), 'id' ) ); - - // One enrolled in both. - llms_enroll_student( $args['include'][0], $course_2 ); - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( array( $args['include'][0] ), wp_list_pluck( $res->get_data(), 'id' ) ); - - unset( $args['enrolled_in'] ); - $args['enrolled_not_in'] = array( $course, $course_2 ); - $res = $this->perform_mock_request( 'GET', $this->route, array(), $args ); - $this->assertEquals( array( $args['include'][1], $args['include'][2] ), wp_list_pluck( $res->get_data(), 'id' ) ); - - } - - /** - * Test the item schema. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_item_schema() { - - $schema = $this->endpoint->get_item_schema(); - - $this->assertEquals( 'student', $schema['title'] ); - - $props = array( - 'id', - 'username', - 'name', - 'first_name', - 'last_name', - 'email', - 'url', - 'description', - 'nickname', - 'registered_date', - 'roles', - 'password', - 'billing_address_1', - 'billing_address_2', - 'billing_city', - 'billing_state', - 'billing_postcode', - 'billing_country', - 'avatar_urls', - ); - - $this->assertEquals( $props, array_keys( $schema['properties'] ) ); - - $this->assertEquals( array( 'student' ), $schema['properties']['roles']['default'] ); - - $schema = $this->endpoint->get_item_schema(); - update_option( 'show_avatars', '' ); - $this->assertFalse( array_key_exists( 'avatar_urls', array_keys( $schema['properties'] ) ) ); - - update_option( 'show_avatars', 1 ); - - } - - /** - * Test the get_object method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_get_object() { - - $id = $this->factory->student->create(); - - // Good. - $student = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'get_object', array( $id ) ); - $this->assertTrue( is_a( $student, 'LLMS_Student' ) ); - - // 404. - $error_404 = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'get_object', array( $id + 1 ) ); - $this->assertIsWPError( $error_404 ); - $this->assertWPErrorCodeEquals( 'llms_rest_not_found', $error_404 ); - - } - - /** - * Test the prepare_object_for_response() method - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.11 Updated taking into account custom fields request-db mapping. - * - * @return void - */ - public function test_prepare_object_for_response() { - - $data = $this->get_mock_student_data( 1 ); - - // `billing_postcode` resource's property is the `billing_zip` llms student property. - $db_data = $data; - $db_data['billing_zip'] = $db_data['billing_postcode']; - - $student = $this->get_student_with_data( $db_data ); - $prepared = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_object_for_response', array( $student, new WP_REST_Request( 'GET', $this->route ) ) ); - - foreach ( $data as $key => $val ) { - $this->assertEquals( $val, $prepared[ $key ], $key ); - } - - $this->assertEquals( array( 'student' ), $prepared['roles'] ); - $this->assertArrayHasKey( 'avatar_urls', $prepared ); - - } - - /** - * Test the prepare_item_for_database() method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_prepare_item_for_database() { - - $request = new WP_REST_Request( 'POST', $this->route ); - $args = array( - 'email' => 'mock@mock.tld', - 'registered_date' => current_time( 'mysql' ), - 'first_name' => 'Sarah', - 'username' => 'mockername', - 'password' => wp_generate_password(), - ); - $request->set_body_params( $args ); - $prepared = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_item_for_database', array( $request ) ); - - $this->assertEquals( $args['email'], $prepared['user_email'] ); - $this->assertEquals( $args['registered_date'], $prepared['user_registered'] ); - $this->assertEquals( $args['first_name'], $prepared['first_name'] ); - $this->assertEquals( $args['username'], $prepared['user_login'] ); - $this->assertEquals( $args['password'], $prepared['user_pass'] ); - - // Test setting of "required" optional args during a creation. - $request = new WP_REST_Request( 'POST', $this->route ); - $args = array( - 'email' => 'mock@mock.tld', - ); - $request->set_body_params( $args ); - $prepared = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_item_for_database', array( $request ) ); - - $this->assertEquals( $args['email'], $prepared['user_email'] ); - $this->assertArrayHasKey( 'user_login', $prepared ); - $this->assertArrayHasKey( 'user_pass', $prepared ); - - // Optional args won't be passed in during an UPDATE (only during creation) - $request = new WP_REST_Request( 'POST', $this->route . '/123' ); - $args = array( - 'email' => 'mock@mock.tld', - 'password' => 'MyNewPasswordStinks', - ); - $request->set_body_params( $args ); - $request->set_url_params( array( 'id' => 123 ) ); - $prepared = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_item_for_database', array( $request ) ); - - $this->assertEquals( $args['email'], $prepared['user_email'] ); - $this->assertEquals( $args['password'], $prepared['user_pass'] ); - $this->assertTrue( ! array_key_exists( 'user_login', $prepared ) ); - - } - - /** - * Test the prepare_links method. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.14 Pass second parameter to `prepare_links()`. - * - * @return void - */ - public function test_prepare_links() { - - $student = $this->factory->student->create_and_get(); - $links = LLMS_Unit_Test_Util::call_method( $this->endpoint, 'prepare_links', array( $student, new WP_REST_Request() ) ); - foreach ( array( 'self', 'collection', 'enrollments', 'progress' ) as $rel ) { - $this->assertArrayHasKey( $rel, $links ); - } - - } - - /** - * Test route registration - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - } - - /** - * Test setting roles. - * - * @since 1.0.0-beta.10 - * - * @return void - */ - public function test_set_roles() { - - $updating = $this->factory->student->create(); - $route = sprintf( '%1$s/%2$d', $this->route, $updating ); - wp_set_current_user( $this->user_admin ); - - $request_bodies = array( - // Add instructors_assistant. - array( - 'roles' => array( - 'instructors_assistant', - 'student', - ), - ), - // Remove instructors_assistant. - array( - 'roles' => array( - 'student', - ), - ), - // Replace student with lms_manager. - array( - 'roles' => array( - 'lms_manager', - ), - ), - ); - - foreach ( $request_bodies as $key => $body ) { - $response = $this->perform_mock_request( 'POST', $route, $body ); - $this->assertResponseStatusEquals( 200, $response ); - $response_data = $response->get_data(); - $this->assertEqualSets( $request_bodies[ $key ]['roles'], $response_data['roles'] ); - } - } - - /** - * Test the create_item method. - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_item() { - - $updating = $this->factory->student->create(); - - $route = sprintf( '%1$s/%2$d', $this->route, $updating ); - - // Unauthorized user. - wp_set_current_user( null ); - $data = $this->get_mock_student_data( 10 ); - $res = $this->perform_mock_request( 'POST', $route, $data ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - // Forbidden user. - wp_set_current_user( $this->user_subscriber ); - $res = $this->perform_mock_request( 'POST', $route, $data ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - // Instructor's can't create. - wp_set_current_user( $this->user_instructor ); - $res = $this->perform_mock_request( 'POST', $route, $data ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - - // Can't edit username. - wp_set_current_user( $this->user_admin ); - $data = $this->get_mock_student_data( 11 ); - $password = wp_generate_password(); - $res = $this->perform_mock_request( 'POST', $route, array_merge( compact( 'password' ), $data ) ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseMessageEquals( 'Username is not editable.', $res ); - $this->assertResponseCodeEquals( 'llms_rest_bad_request', $res ); - - unset( $data['username'] ); - - // Okay. - $res = $this->perform_mock_request( 'POST', $route, array_merge( compact( 'password' ), $data ) ); - $this->assertResponseStatusEquals( 200, $res ); - - $res_data = $res->get_data(); - foreach ( $data as $key => $expected ) { - $this->assertEquals( $expected, $res_data[ $key ], $key ); - } - - $this->assertEquals( array( 'student' ), $res_data['roles'] ); - - $this->assertArrayHasKey( 'id', $res_data ); - $this->assertArrayHasKey( 'registered_date', $res_data ); - $this->assertArrayHasKey( 'avatar_urls', $res_data ); - - // Check password. - $user = get_user_by( 'id', $res_data['id'] ); - $this->assertTrue( wp_check_password( $password, $user->user_pass ) ); - - // Links. - $this->assertEquals( $this->expected_link_rels, array_keys( $res->get_links() ) ); - - // user can update self. - wp_set_current_user( $updating ); - $res = $this->perform_mock_request( 'POST', $route, array( - 'first_name' => 'Myself', - ) ); - $this->assertResponseStatusEquals( 200, $res ); - $this->assertEquals( 'Myself', $res->get_data()['first_name'] ); - - // Cannot update email to an email that already exists. - $this->factory->student->create( array( 'user_email' => 'thisemailalreadyexists@test.tld' ) ); - $res = $this->perform_mock_request( 'POST', $route, array( - 'email' => 'thisemailalreadyexists@test.tld', - ) ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseMessageEquals( 'Invalid email address.', $res ); - $this->assertResponseCodeEquals( 'llms_rest_bad_request', $res ); - - } - - - /** - * Test update item permission check - * - * @since 1.0.0-beta.1 - * - * @return void - */ - public function test_update_item_permissions_check() { - - $user_id = $this->factory->student->create(); - - $request = new WP_REST_Request( 'GET', sprintf( '%1$s/%2$d', $this->route, $user_id ) ); - $request->set_url_params( array( 'id' => $user_id ) ); - - // Unauthorized user. - wp_set_current_user( null ); - $ret = $this->endpoint->update_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_unauthorized_request', $ret ); - - // can update self. - wp_set_current_user( $user_id ); - $this->assertTrue( $this->endpoint->update_item_permissions_check( $request ) ); - - // Cannot update students. - $nay = array( 'subscriber', 'instructor', 'instructors_assistant' ); - foreach ( $nay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $ret = $this->endpoint->update_item_permissions_check( $request ); - $this->assertIsWPError( $ret ); - $this->assertWPErrorCodeEquals( 'llms_rest_forbidden_request', $ret ); - } - - // Can update student. - $yay = array( 'administrator', 'lms_manager' ); - foreach ( $yay as $role ) { - wp_set_current_user( $this->factory->user->create( array( 'role' => $role ) ) ); - $this->assertTrue( $this->endpoint->update_item_permissions_check( $request ) ); - } - - } - - /** - * Test search no results - * - * @since 1.0.0-beta.12 - * - * @return void - */ - public function test_search_noresults_all_available_fields() { - - wp_set_current_user( $this->user_admin ); - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => 'cannotfindthis', - ) - ); - - $this->assertResponseStatusEquals( 200, $response ); - $response_data = $response->get_data(); - $this->assertEmpty( $response_data ); - - } - - /** - * Test search with results all available fields - * - * @since 1.0.0-beta.12 - * - * @return void - */ - public function test_search_with_results_all_available_fields() { - - wp_set_current_user( $this->user_admin ); - - $student_id = $this->factory->user->create( array( 'role' => 'student' ) ); - $student_data = get_userdata( $student_id ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => $student_data->display_name, - ) - ); - - $this->assertResponseStatusEquals( 200, $response ); - $response_data = $response->get_data(); - - // Expect to find it in the available columns `name`. - $this->assertNotEmpty( $response_data ); - $this->assertEquals( 1, count( $response_data ) ); - $this->assertEquals( $student_data->display_name, $response_data[0]['name'] ); - - } - - /** - * Test search with wrong search columns - * - * @since 1.0.0-beta.12 - * @since 1.0.0-beta.13 Fix test failing on WP core 5.0. - * - * @return void - */ - public function test_search_wrong_search_columns() { - - wp_set_current_user( $this->user_admin ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => 'whatever', - 'search_columns' => '', - ) - ); - - $this->assertResponseStatusEquals( 400, $response ); - - // Empty search results on WP core 5.0 never hit our custom error message. - global $wp_version; - $expected = 0 === strpos( $wp_version, '5.0' ) ? 'Invalid parameter(s): search_columns' : 'You must provide a valid set of columns to search into.'; - $this->assertResponseMessageEquals( $expected, $response ); - - // Provide a wrong set of columns. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => 'whatever', - 'search_columns' => array('name', 'what'), - ) - ); - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseMessageEquals( 'Invalid parameter(s): search_columns', $response ); - } - - /** - * Test search with unallowed search columns - * - * @since 1.0.0-beta.12 - * - * @return void - */ - public function test_search_unallowed_search_columns() { - - wp_set_current_user( $this->user_admin ); - - // Try to search into an unallowed field. - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => 'whatever', - 'search_columns' => array('name', 'email'), // email is not allowed with the default context=view. - ) - ); - $this->assertResponseStatusEquals( 403, $response ); - $this->assertResponseMessageEquals( 'You are not allowed to search into the provided column(s): email', $response ); - } - - /** - * Test search with allowed search columns - * - * @since 1.0.0-beta.12 - * - * @return void - */ - public function test_search_allowed_search_columns() { - - wp_set_current_user( $this->user_admin ); - - $student_id = $this->factory->user->create( array( 'role' => 'student' ) ); - $student_data = get_userdata( $student_id ); - - // Try to search into an allowed field with match - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => $student_data->user_email, - 'context' => 'edit', - 'search_columns' => array('name', 'email'), // email is now allowed with the context=edit. - ) - ); - - $response_data = $response->get_data(); - - $this->assertNotEmpty( $response_data ); - $this->assertEquals( 1, count( $response_data ) ); - $this->assertEquals( $student_data->display_name, $response_data[0]['name'] ); - - } - - - /** - * Test search no results trying to search for existing email. - * - * @since 1.0.0-beta.12 - * - * @return void - */ - public function test_search_noresults_existing_email() { - - wp_set_current_user( $this->user_admin ); - - $student_id = $this->factory->user->create( array( 'role' => 'student' ) ); - $student_data = get_userdata( $student_id ); - - $response = $this->perform_mock_request( - 'GET', - $this->route, - array(), - array( - 'search' => $student_data->user_email, - ) - ); - - // We cannot look for the search string in the email column, because the email field is only allowed in `context=edit`. - $this->assertResponseStatusEquals( 200, $response ); - $response_data = $response->get_data(); - $this->assertEmpty( $response_data ); - } - - /** - * Test firing student registration action hook - * - * @since 1.0.0-beta.12 - * - * @return void - */ - public function test_firing_student_registered_hook_firing() { - - $did_registration = did_action( 'llms_rest_student_registered' ); - $did_student_insertion = did_action( 'llms_rest_insert_student' ); - $did_student_insertion_after = did_action( 'llms_rest_after_insert_student' ); - - wp_set_current_user( $this->user_admin ); - - $data = $this->get_mock_student_data( 4 ); - - // Create, action triggered. - $res = $this->perform_mock_request( - 'POST', - $this->route, - $data - ); - $this->assertResponseStatusEquals( 201, $res ); - $this->assertEquals( $did_registration + 1, did_action( 'llms_rest_student_registered' ) ); - $this->assertEquals( $did_registration + 1, did_action( 'llms_rest_insert_student' ) ); - $this->assertEquals( $did_registration + 1, did_action( 'llms_rest_after_insert_student' ) ); - - // Update, no action triggered. - $updating = $this->factory->student->create(); - $route = sprintf( '%1$s/%2$d', $this->route, $updating ); - $res = $this->perform_mock_request( - 'POST', - $route, - array( - 'first_name' => 'Whatever', - ) - ); - $this->assertResponseStatusEquals( 200, $res ); - $this->assertEquals( $did_registration + 1, did_action( 'llms_rest_student_registered' ) ); - $this->assertEquals( $did_registration + 2, did_action( 'llms_rest_insert_student' ) ); - $this->assertEquals( $did_registration + 2, did_action( 'llms_rest_after_insert_student' ) ); - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-students-progress-controller.php b/tests/unit-tests/server/class-llms-rest-test-students-progress-controller.php deleted file mode 100644 index 1f39c390..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-students-progress-controller.php +++ /dev/null @@ -1,404 +0,0 @@ -[\d]+)/progress'; - - /** - * Setup our test server, endpoints, and user info. - */ - public function set_up() { - - parent::set_up(); - - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}lifterlms_user_postmeta" ); - - $this->endpoint = new LLMS_REST_Students_Progress_Controller(); - - $this->user_allowed = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $this->user_forbidden = $this->factory->user->create( array( 'role' => 'subscriber' ) ); - $this->user_student = $this->factory->student->create(); - - } - - private function get_route( $student_id, $post_id = null ) { - $route = str_replace( '(?P[\d]+)', $student_id, $this->route ); - if ( $post_id ) { - $route .= '/' . $post_id; - } - return $route; - } - - /** - * Test route registration. - * - * @since 1.0.0-beta.1 - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - } - - /** - * Test delete progress. - * - * @since 1.0.0-beta.1 - * @since 1.0.0-beta.13 Unknown. - * - * @return void - */ - public function test_delete_item() { - - $course = $this->factory->course->create( array( 'sections' => 1, 'lessons' => 1 ) ); - $route = $this->get_route( $this->user_student, $course ); - llms_enroll_student( $this->user_student, $course ); - $student = llms_get_student( $this->user_student ); - - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( 'DELETE', $route ); - $this->assertResponseStatusEquals( 204, $response ); - - // Mark the course complete. - $response = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'complete' - ) ); - $this->assertEquals( 100, $student->get_progress( $course, 'course' ) ); - - $response = $this->perform_mock_request( 'DELETE', $route ); - $this->assertResponseStatusEquals( 204, $response ); - - $this->assertEquals( 0, $student->get_progress( $course, 'course' ) ); - - } - - /** - * Test delete progress of non existing post. - * - * @since 1.0.0-beta.25 - * - * @return void - */ - public function test_delete_item_non_existing_post() { - - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - $route = $this->get_route( $this->user_student, $course + 1 ); - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( 'DELETE', $route ); - - $this->assertResponseStatusEquals( 400, $response ); - - } - - /** - * Test delete progress on existing post but unenrolled user. - * - * @since 1.0.0-beta.25 - * - * @return void - */ - public function test_delete_item_existing_post_unenrolled_user() { - - // Post exists but user is not enrolled. - $course_id = $this->factory->course->create( array( 'sections' => 0 ) ); - $route = $this->get_route( $this->user_student, $course_id ); - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( 'DELETE', $route ); - $student = llms_get_student( $this->user_student ); - - $this->assertResponseStatusEquals( 204, $response ); - $this->assertEquals( 0, $student->get_progress( $course_id, 'course' ) ); - - } - - public function test_get_item_errors() { - - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - $route = $this->get_route( $this->user_student, $course ); - llms_enroll_student( $this->user_student, $course ); - - // Unauthorized. - $response = $this->perform_mock_request( 'GET', $route ); - $this->assertResponseStatusEquals( 401, $response ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $response ); - - // Forbidden. - wp_set_current_user( $this->user_forbidden ); - $response = $this->perform_mock_request( 'GET', $route ); - $this->assertResponseStatusEquals( 403, $response ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $response ); - - } - - public function test_get_item_course() { - - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - $route = $this->get_route( $this->user_student, $course ); - llms_enroll_student( $this->user_student, $course ); - - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( 'GET', $route ); - $this->assertResponseStatusEquals( 200, $response ); - $data = $response->get_data(); - - $this->assertEquals( (float) 0, $data['progress'] ); - $this->assertEquals( 'incomplete', $data['status'] ); - $this->assertEquals( $course, $data['post_id'] ); - $this->assertEquals( $this->user_student, $data['student_id'] ); - $this->assertNull( $data['date_created'] ); - $this->assertNull( $data['date_updated'] ); - - } - - public function test_update_item_errors() { - - $course = $this->factory->course->create( array( 'sections' => 0 ) ); - $route = $this->get_route( $this->user_student, $course ); - llms_enroll_student( $this->user_student, $course ); - - // Missing required params. - $response = $this->perform_mock_request( 'POST', $route ); - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseCodeEquals( 'rest_missing_callback_param', $response ); - - $args = array( - 'status' => 'fake', - ); - - // Invalid status. - $response = $this->perform_mock_request( 'POST', $route, $args ); - $this->assertResponseStatusEquals( 400, $response ); - $this->assertResponseCodeEquals( 'rest_invalid_param', $response ); - - $args['status'] = 'complete'; - - // Unauthorized. - $response = $this->perform_mock_request( 'POST', $route, $args ); - $this->assertResponseStatusEquals( 401, $response ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $response ); - - // Forbidden. - wp_set_current_user( $this->user_forbidden ); - $response = $this->perform_mock_request( 'POST', $route, $args ); - $this->assertResponseStatusEquals( 403, $response ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $response ); - - } - - public function test_update_item_course() { - - $student = llms_get_student( $this->user_student ); - $course = $this->factory->course->create( array( 'sections' => 1 ) ); - $route = $this->get_route( $this->user_student, $course ); - llms_enroll_student( $this->user_student, $course ); - - // Mark course complete. - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'complete' - ) ); - $this->assertResponseStatusEquals( 200, $response ); - $data = $response->get_data(); - - $this->assertEquals( (float) 100, $data['progress'] ); - $this->assertEquals( 'complete', $data['status'] ); - $this->assertEquals( $course, $data['post_id'] ); - $this->assertEquals( $this->user_student, $data['student_id'] ); - $this->assertTrue( ! empty( $data['date_created'] ) ); - $this->assertTrue( ! empty( $data['date_updated'] ) ); - - $this->assertEquals( array( 'self', 'post', 'student' ), array_keys( $response->get_links() ) ); - - $this->assertEquals( (float) 100, $student->get_progress( $course, 'course' ) ); - - // Mark Incomplete. - $response = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'incomplete' - ) ); - $this->assertResponseStatusEquals( 200, $response ); - $data = $response->get_data(); - $this->assertEquals( (float) 0, $data['progress'] ); - $this->assertEquals( 'incomplete', $data['status'] ); - - $this->assertEquals( (float) 0, $student->get_progress( $course, 'course' ) ); - - } - - public function test_update_item_section() { - - $student = llms_get_student( $this->user_student ); - $course = llms_get_post( $this->factory->course->create( array( 'sections' => 1, 'lessons' => 3 ) ) ); - $section = $course->get_sections( 'ids' )[0]; - $route = $this->get_route( $this->user_student, $section ); - llms_enroll_student( $this->user_student, $course->get( 'id' ) ); - - // Mark course complete. - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'complete' - ) ); - $this->assertResponseStatusEquals( 200, $response ); - $data = $response->get_data(); - - $this->assertEquals( (float) 100, $data['progress'] ); - $this->assertEquals( 'complete', $data['status'] ); - $this->assertEquals( $section, $data['post_id'] ); - $this->assertEquals( $this->user_student, $data['student_id'] ); - $this->assertTrue( ! empty( $data['date_created'] ) ); - $this->assertTrue( ! empty( $data['date_updated'] ) ); - - $this->assertEquals( array( 'self', 'post', 'student' ), array_keys( $response->get_links() ) ); - - $this->assertEquals( (float) 100, $student->get_progress( $section, 'section' ) ); - - // Mark Incomplete. - $response = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'incomplete' - ) ); - $this->assertResponseStatusEquals( 200, $response ); - $data = $response->get_data(); - $this->assertEquals( (float) 0, $data['progress'] ); - $this->assertEquals( 'incomplete', $data['status'] ); - - $this->assertEquals( (float) 0, $student->get_progress( $section, 'section' ) ); - - } - - public function test_update_item_lesson() { - - $student = llms_get_student( $this->user_student ); - $course = llms_get_post( $this->factory->course->create( array( 'sections' => 1, 'lessons' => 3 ) ) ); - $lesson = $course->get_lessons( 'ids' )[0]; - $route = $this->get_route( $this->user_student, $lesson ); - llms_enroll_student( $this->user_student, $course->get( 'id' ) ); - - // Mark course complete. - wp_set_current_user( $this->user_allowed ); - $response = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'complete' - ) ); - $this->assertResponseStatusEquals( 200, $response ); - $data = $response->get_data(); - - $this->assertEquals( (float) 100, $data['progress'] ); - $this->assertEquals( 'complete', $data['status'] ); - $this->assertEquals( $lesson, $data['post_id'] ); - $this->assertEquals( $this->user_student, $data['student_id'] ); - $this->assertTrue( ! empty( $data['date_created'] ) ); - $this->assertTrue( ! empty( $data['date_updated'] ) ); - - $this->assertEquals( array( 'self', 'post', 'student' ), array_keys( $response->get_links() ) ); - - $this->assertTrue( llms_is_complete( $this->user_student, $lesson, 'lesson' ) ); - - // Mark Incomplete. - $response = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'incomplete' - ) ); - $this->assertResponseStatusEquals( 200, $response ); - $data = $response->get_data(); - $this->assertEquals( (float) 0, $data['progress'] ); - $this->assertEquals( 'incomplete', $data['status'] ); - - $this->assertFalse( llms_is_complete( $this->user_student, $lesson, 'lesson' ) ); - - } - - public function test_validate_date_created() { - - $course = $this->factory->course->create_and_get( array( 'sections' => 1, 'lessons' => 1 ) ); - $course_id = $course->get( 'id' ); - $request = new WP_REST_Request( 'POST', $this->get_route( $this->user_student, $course_id ) ); - - $res = $this->endpoint->validate_date_created( date( DATE_RFC3339, strtotime( '+1 day' ) ), $request, 'date_created' ); - $this->assertIsWPError( $res ); - $this->assertWPErrorCodeEquals( 'llms_rest_bad_request', $res ); - $this->assertWPErrorMessageEquals( 'Created date cannot be in the future.', $res ); - - $this->assertTrue( $this->endpoint->validate_date_created( date( DATE_RFC3339, strtotime( '-1 day' ) ), $request, 'date_created' ) ); - - } - - public function test_validate_post_id() { - - $post = $this->factory->post->create(); - $course = $this->factory->course->create_and_get( array( 'sections' => 1, 'lessons' => 1 ) ); - $course_id = $course->get( 'id' ); - $request = new WP_REST_Request( 'POST', $this->get_route( $this->user_student, $course_id ) ); - $request->set_url_params( array( 'id' => $this->user_student ) ); - - // Post doesn't exist. - $this->assertFalse( $this->endpoint->validate_post_id( $post + 1, $request, 'post_id' ) ); - - // Post type isn't supported. - $this->assertFalse( $this->endpoint->validate_post_id( $post, $request, 'post_id' ) ); - - // User isn't enrolled. - $this->assertFalse( $this->endpoint->validate_post_id( $course_id, $request, 'post_id' ) ); - - llms_enroll_student( $this->user_student, $course_id ); - - // Valid course. - $this->assertTrue( $this->endpoint->validate_post_id( $course_id, $request, 'post_id' ) ); - - // Valid section. - $this->assertTrue( $this->endpoint->validate_post_id( $course->get_sections( 'ids' )[0], $request, 'post_id' ) ); - - // Valid lesson. - $this->assertTrue( $this->endpoint->validate_post_id( $course->get_lessons( 'ids' )[0], $request, 'post_id' ) ); - - } - - /** - * Test `validate_post_id()` method on DELETE. - * - * @since 1.0.0-beta.25 - * - * @return void - */ - public function test_validate_post_id_delete_method() { - - $course_id = $this->factory->course->create( array( 'sections' => 0 ) ); - - // Post doesn't exist. - $request = new WP_REST_Request( 'DELETE', $this->get_route( $this->user_student, $course_id + 1 ) ); - $request->set_url_params( array( 'id' => $this->user_student ) ); - - // Not valid. - $this->assertFalse( $this->endpoint->validate_post_id( $course_id + 1, $request, 'post_id' ) ); - - // Post exists but user is not enrolled. - $request = new WP_REST_Request( 'POST', $this->get_route( $this->user_student, $course_id ) ); - $request->set_url_params( array( 'id' => $this->user_student ) ); - - $this->assertFalse( $this->endpoint->validate_post_id( $course_id, $request, 'post_id' ) ); - - // Enrolled. - llms_enroll_student( $this->user_student, $course_id ); - - $request = new WP_REST_Request( 'POST', $this->get_route( $this->user_student, $course_id ) ); - $request->set_url_params( array( 'id' => $this->user_student ) ); - - // Valid course. - $this->assertTrue( $this->endpoint->validate_post_id( $course_id, $request, 'post_id' ) ); - - } - -} diff --git a/tests/unit-tests/server/class-llms-rest-test-webhooks-controllers.php b/tests/unit-tests/server/class-llms-rest-test-webhooks-controllers.php deleted file mode 100644 index 7ba71b12..00000000 --- a/tests/unit-tests/server/class-llms-rest-test-webhooks-controllers.php +++ /dev/null @@ -1,486 +0,0 @@ -assertEquals( $keys, array_keys( $data ) ); - - // Correct formats. - $this->assertTrue( is_int( $data['id'] ) ); - $this->assertTrue( is_string( $data['name'] ) ); - $this->assertTrue( is_string( $data['status'] ) ); - $this->assertTrue( is_string( $data['delivery_url'] ) ); - $this->assertTrue( is_string( $data['secret'] ) ); - $this->assertTrue( is_int( rest_parse_date( $data['created'] ) ) ); - $this->assertTrue( is_int( rest_parse_date( $data['updated'] ) ) ); - $this->assertEquals( $data['resource'] . '.' . $data['event'], $data['topic'] ); - $this->assertTrue( is_array( $data['hooks'] ) ); - - } - - /** - * Setup our test server, endpoints, and user info. - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function set_up() { - - parent::set_up(); - - global $wpdb; - $wpdb->query( "TRUNCATE TABLE {$wpdb->prefix}lifterlms_webhooks" ); - - $this->endpoint = new LLMS_REST_Webhooks_Controller(); - - $this->user_allowed = $this->factory->user->create( array( 'role' => 'administrator' ) ); - $this->user_forbidden = $this->factory->user->create( array( 'role' => 'instructor' ) ); - - } - - /** - * Test route registration. - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_register_routes() { - - $routes = $this->server->get_routes(); - $this->assertArrayHasKey( $this->route, $routes ); - $this->assertArrayHasKey( $this->route . '/(?P[\d]+)', $routes ); - - } - - /** - * Error if webhook creation missing required parameters. - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_create_item_missing_required() { - - $res = $this->perform_mock_request( 'POST', $this->route ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseCodeEquals( 'rest_missing_callback_param', $res ); - $this->assertResponseMessageEquals( 'Missing parameter(s): topic, delivery_url', $res ); - - } - - /** - * Error creating webhook with invalid topic - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_create_item_invalid_topic() { - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'POST', $this->route, $this->get_hook_args( array( - 'topic' => 'course.fake', - ) ) ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseCodeEquals( 'rest_invalid_param', $res ); - - } - - /** - * Error creating webhook with invalid status - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_create_item_invalid_status() { - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'POST', $this->route, $this->get_hook_args( array( - 'status' => 'fake', - ) ) ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseCodeEquals( 'rest_invalid_param', $res ); - - } - - /** - * Error for invalid status - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_create_item_bad_url() { - - remove_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'POST', $this->route, $this->get_hook_args() ); - $this->assertResponseStatusEquals( 500, $res ); - $this->assertResponseCodeEquals( 'llms_rest_webhook_ping_unreachable', $res ); - - add_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - } - - /** - * Error creating webhook with an id - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_create_item_no_id_allowed() { - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'POST', $this->route, $this->get_hook_args( array( - 'id' => 123, - ) ) ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseMessageEquals( 'Cannot create an existing resource.', $res ); - $this->assertResponseCodeEquals( 'llms_rest_bad_request', $res ); - - } - - /** - * Works. - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_create_item_okay() { - - $args = $this->get_hook_args(); - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'POST', $this->route, $args ); - - $this->assertResponseStatusEquals( 201, $res ); - $this->assertIsAWebhook( $res->get_data() ); - $this->assertArrayHasKey( 'Location', $res->get_headers() ); - $links = $res->get_links(); - $this->assertArrayHasKey( 'self', $links ); - $this->assertArrayHasKey( 'collection', $links ); - - } - - /** - * Public function test delete item. - * - * @since 1.0.0-beta.3 - * @since 1.0.0-beta.10 Used stored hook id instead of reading it from the db. - * - * @return void - */ - public function test_delete_item() { - - $hook = $this->get_hook(); - $id = $hook->get( 'id' ); - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 204, $res ); - - $this->assertFalse( LLMS_REST_API()->webhooks()->get( $id ) ); - - // Deleting agin still results in 204. - $res = $this->perform_mock_request( 'DELETE', sprintf( '%1$s/%2$d', $this->route, $id ) ); - $this->assertResponseStatusEquals( 204, $res ); - - } - - - /** - * Can't get if unauthorized - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_get_item_error_unauthorized() { - - $hook = $this->get_hook(); - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) ) ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - } - - /** - * Authorized but missing capabilities - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_get_item_error_forbidden() { - - wp_set_current_user( $this->user_forbidden ); - $hook = $this->get_hook(); - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) ) ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - } - - /** - * 404 - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_get_item_error_404() { - - wp_set_current_user( $this->user_allowed ); - $hook = $this->get_hook(); - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) + 1 ) ); - $this->assertResponseStatusEquals( 404, $res ); - $this->assertResponseCodeEquals( 'llms_rest_not_found', $res ); - - } - - /** - * Retrieve success. - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_get_item_success() { - - wp_set_current_user( $this->user_allowed ); - $hook = $this->get_hook(); - $res = $this->perform_mock_request( 'GET', sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) ) ); - $this->assertResponseStatusEquals( 200, $res ); - $data = $res->get_data(); - - $this->assertIsAWebhook( $data ); - - } - - /** - * Cant list unuathorized. - * - * @since 1.0.0-beta.3 - * - * @see {Reference} - * @link {URL} - * - * @return [type] - */ - public function test_get_items_unauthorized() { - - $res = $this->perform_mock_request( 'GET', $this->route ); - $this->assertResponseStatusEquals( 401, $res ); - $this->assertResponseCodeEquals( 'llms_rest_unauthorized_request', $res ); - - } - - /** - * Cant list without permissions. - * - * @since 1.0.0-beta.3 - * - * @see {Reference} - * @link {URL} - * - * @return [type] - */ - public function test_get_items_forbidden() { - - wp_set_current_user( $this->user_forbidden ); - $res = $this->perform_mock_request( 'GET', $this->route ); - $this->assertResponseStatusEquals( 403, $res ); - $this->assertResponseCodeEquals( 'llms_rest_forbidden_request', $res ); - - } - - /** - * None found. - * - * @since 1.0.0-beta.3 - * - * @see {Reference} - * @link {URL} - * - * @return [type] - */ - public function test_get_items_okay_none() { - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'GET', $this->route ); - $this->assertResponseStatusEquals( 200, $res ); - $this->assertEquals( array(), $res->get_data() ); - $headers = $res->get_headers(); - $this->assertEquals( 0, $headers['X-WP-Total'] ); - $this->assertEquals( 0, $headers['X-WP-TotalPages'] ); - $this->assertTrue( ! array_key_exists( 'Link', $headers ) ); - - } - - /** - * Test pagination. - * - * @since 1.0.0-beta.3 - * - * @see {Reference} - * @link {URL} - * - * @return [type] - */ - public function test_get_items_okay_pagination() { - - $total = 6; - $per_page = 2; - $this->create_many_webhooks( $total ); - - wp_set_current_user( $this->user_allowed ); - $res = $this->perform_mock_request( 'GET', $this->route, array(), array( 'per_page' => $per_page ) ); - $this->assertResponseStatusEquals( 200, $res ); - - $data = $res->get_data(); - foreach ( $data as $item ) { - $this->assertIsAWebhook( $item ); - } - - $this->pagination_test( $this->route, $start = 1, $per_page, $id_field = '', $total ); - - } - - /** - * Error for invalid status - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_update_item_invalid_status() { - - $hook = $this->get_hook(); - - wp_set_current_user( $this->user_allowed ); - $route = sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) ); - $res = $this->perform_mock_request( 'POST', $route, array( - 'status' => 'invalid', - ) ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseCodeEquals( 'rest_invalid_param', $res ); - - } - - /** - * Error for invalid status - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_update_item_bad_url() { - - $hook = $this->get_hook(); - - remove_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - wp_set_current_user( $this->user_allowed ); - $route = sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) ); - $res = $this->perform_mock_request( 'POST', $route, array( - 'delivery_url' => 'https://fake.tld', - ) ); - $this->assertResponseStatusEquals( 500, $res ); - $this->assertResponseCodeEquals( 'llms_rest_webhook_ping_unreachable', $res ); - - add_filter( 'llms_rest_webhook_pre_ping', '__return_true' ); - - } - - /** - * Error for invalid topic - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_update_item_invalid_topic() { - - $hook = $this->get_hook(); - - wp_set_current_user( $this->user_allowed ); - $route = sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) ); - $res = $this->perform_mock_request( 'POST', $route, array( - 'topic' => 'invalid', - ) ); - $this->assertResponseStatusEquals( 400, $res ); - $this->assertResponseCodeEquals( 'rest_invalid_param', $res ); - - } - - /** - * Success. - * - * @since 1.0.0-beta.3 - * - * @return void - */ - public function test_update_item_okay() { - - $hook = $this->get_hook( array( - 'status' => 'disabled', - ) ); - - $args = array( - 'name' => 'new name', - 'status' => 'active', - 'topic' => 'action.new_action', - 'secret' => 'newsecret', - 'delivery_url' => 'https://new.tld', - ); - - wp_set_current_user( $this->user_allowed ); - $route = sprintf( '%1$s/%2$d', $this->route, $hook->get( 'id' ) ); - $res = $this->perform_mock_request( 'POST', $route, $args ); - $data = $res->get_data(); - - $this->assertResponseStatusEquals( 200, $res ); - $this->assertIsAWebhook( $data ); - $links = $res->get_links(); - $this->assertArrayHasKey( 'self', $links ); - $this->assertArrayHasKey( 'collection', $links ); - - foreach ( $args as $key => $val ) { - $this->assertEquals( $val, $data[ $key ] ); - } - - } - -} diff --git a/web/favicon.png b/web/favicon.png deleted file mode 100644 index 636907815869468d9db83accf2ffe72325d8f1be..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2138 zcmV-g2&MOlP);ijnDXxngfqHU@=-`Ekc+~sqG{mFUOh=679K@o9fS1wtW1@_*z{dMO3v9q&?Y1+?+!T$*x9ML0a*n;^% z$+Ks3;qmb=H;))$*O!&S2aEqPHaMb(YSP+*prH#EFswuZL15C18FqbH8GNw#1;l}2 zJwkgAdq*BVFiocD9m`3SYD49B2lNk*?gkY+bpHI1SzERcsX_rC5^Y)<{9w@yh6;@u zHBp;1H#bBx>}@cFK+y2y`+pi99pB3kA_|$aZL565;>G9!8x|J_KUlm*a7g@szL^C( zl|553;KgBSZfJdZ??%O?yoF$Zuz6n{3`)z+#%qWI)oS>`q6?b-vljhk)S9hCBnbdz z>v&nGuQ;}=@#%%*ovpP`AW%x&oggTRX_G9@EE zMS@L}H8-X0z^W(q4&sIw||p|Qf94MrJlNeJ$@~>(`mZ2VFM^uB3FV6RQ8Ei^hg?NsxQ4oK!x@h zIT4iGY3XdPy?PoH-`Uav-tES()OPjr&z()x)u5VcE`7(l9d=NmQ6ndUBA^rziRqwB z4W&2TF1rnsxp>bW{b$L^)~d^w@n5pnm6o=iEhvD%<>+iTHUdRM0WS_id3pWTv11!|O`GOwe)<%@fV-`}zG=_&>AcfsgO`q$>IzU&Wz<`sSWsMm zDg>0nW^95Voexf(vON0XoMLotj&l6!)kLaL;B`Da->_rC1ZRs*2OoCJt42`b0A&a$ z0*V2{;6FS(k1lvzPKW98rcI5zr%gk57(ygbX=(7s}0oBC(d?J=g;e(SX)Sz5;vk4RdWof)&C-sjXfg*$< z*6M55;Bq)1u#}xV`C_$3V?4QXrN?GA!;5n4%9SFSN(BKCah$Se(lAi%O%Lya5`iK_ z#P*1v^m`F2m6=}NDYBaNwV+~#Ecr`VbmpY$Tbn<&m~>A+o{+HSr%L?=yZ-)thpwcg z<>bm$ZP&JJ@i?qj+q2^0j@$e96PZdS(Ih2-p~O-t;PF@=U%3J*G-|~7Uj1e+1XWYA zqtIf~Jtd%C>26$f+Dt8=w25#!E zm>*QUG?z0BA%MpNFK%-~L;LLm2OM?x?seQfa>QlS>C~DbqvM9={uR{od;2yT^|yZn zMId-yy8rJ^o2dn0n8XQNPK3vdoerv@`us6aGgBhxK(OZYqrAfIoHzisR+EM8t846aH}` zIJ9rl^LzU?TFnL>{9w62dD5gEr$VDfj0dGJKm27w^|@p4!oo-8wY7`IQgv8Z^q46P z)#r|Znvoni`*v;Xt@#J;zU%RT??0w+Z-_P{%Vsv{p5NWO5q_w8rH$N%;N4DV*}2?VvFXbSTVIwGsbpf6RxOJfx1~7K>Tp}*hUOGT_MN@} z)RUWk`_S#OSs`E;Le!e{Ol{)aoUrK3$pFKE(pMbWS#|xBWjyb4!3TqGj2{p&@o_^( zRqdvHO! zoIQdrFz5y+BAnCBJ43a@vyvz8Jj)Q4MK>H)W3#^e@Rz##2RA$IW)oh6!5boklY~YM z&kBheK29D!V6ar)JBE|URiK>qHlx*4SJT#9ai>Lh<3h`e;!8a5bl?sA8x%%QJZ7Wm QGynhq07*qoM6N<$f*rjMN&o-= diff --git a/web/index.html b/web/index.html deleted file mode 100644 index 15b708e7..00000000 --- a/web/index.html +++ /dev/null @@ -1,68 +0,0 @@ - - - - LifterLMS REST API Reference - - - - - - - - - - - {{redocHead}} - - - - {{redocBody}} - - - diff --git a/web/redoc-config.yaml b/web/redoc-config.yaml deleted file mode 100644 index 50cbe72a..00000000 --- a/web/redoc-config.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# https://github.com/Rebilly/ReDoc/blob/master/src/theme.ts -theme: - logo: - gutter: 20px 80px 10px 20px - colors: - primary: - main: '#466dd8' - typography: - headings: - fontFamily: 'Montserrat' - fontWeight: 600 - fontFamily: 'Montserrat' - fontWeight: 300 - fontSize: 16px - rightPanel: - backgroundColor: '#222' - -noAutoAuth: true -requiredPropsFirst: true -sortPropsAlphabetically: true - -# Use a specific build version -redocURL: https://cdn.jsdelivr.net/npm/redoc@2.0.0-rc.40/bundles/redoc.standalone.js