nazar-salary 3.5.3 → 3.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +62 -1
  2. package/index.js +16 -2
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -870,6 +870,8 @@ declare module 'nazar-salary' {
870
870
  lessonsDone: number;
871
871
  /** lessons in the course; 12 until set */
872
872
  lessonsTotal: number;
873
+ /** shown on the check page in place of the certificate's type; null until set */
874
+ teacher_full_name: string | null;
873
875
  /** null while the course is not completed */
874
876
  certificate: AkcentCertificate | null;
875
877
  }
@@ -883,6 +885,8 @@ declare module 'nazar-salary' {
883
885
  lessonsDone?: number | null;
884
886
  /** 1–1000 */
885
887
  lessonsTotal?: number | null;
888
+ /** up to 201 characters; "" counts as null */
889
+ teacher_full_name?: string | null;
886
890
  }
887
891
 
888
892
  export interface UpdateAkcentCourseResponse {
@@ -891,6 +895,14 @@ declare module 'nazar-salary' {
891
895
  languageLevel: AkcentLanguageLevel | string;
892
896
  lessonsDone: number;
893
897
  lessonsTotal: number;
898
+ teacher_full_name: string | null;
899
+ }
900
+
901
+ /** Teacher of the student's latest course in Salary (default for teacher_full_name) */
902
+ export interface CertificatesSalaryTeacher {
903
+ id: number;
904
+ first_name: string | null;
905
+ last_name: string | null;
894
906
  }
895
907
 
896
908
  export interface AkcentStudent {
@@ -900,12 +912,60 @@ declare module 'nazar-salary' {
900
912
  logo_url: string | null;
901
913
  phone: string | null;
902
914
  courses: AkcentCourse[];
915
+ /** certificates for offline courses, newest first */
916
+ offline_certificates: AkcentOfflineCertificate[];
917
+ }
918
+
919
+ export interface AkcentOfflineCertificate {
920
+ number: string;
921
+ /** given_date, epoch ms */
922
+ issuedAt: number;
923
+ course_name: string;
924
+ teacher_full_name: string;
925
+ languageLevel: AkcentLanguageLevel | string;
926
+ lessonsDone: number;
927
+ lessonsTotal: number;
928
+ totalGrade: number;
929
+ verifyUrl: string;
930
+ downloadUrl: string;
931
+ }
932
+
933
+ /** Latest course of the student in Salary (defaults for forms) */
934
+ export interface CertificatesSalaryCourse {
935
+ completed_lessons: number;
936
+ total_lessons: number;
903
937
  }
904
938
 
905
939
  export interface StudentCertificatesResponse {
906
- /** false — no Akcent student with this phone */
940
+ /** false — the student could not be loaded from Akcent */
907
941
  found: boolean;
942
+ /** true — the student was just created in Akcent by this request */
943
+ created: boolean;
908
944
  student: AkcentStudent | null;
945
+ salary_teacher: CertificatesSalaryTeacher | null;
946
+ salary_course: CertificatesSalaryCourse | null;
947
+ }
948
+
949
+ export interface CreateOfflineCertificateData {
950
+ /** up to 255 characters */
951
+ course_name: string;
952
+ /** up to 201 characters */
953
+ teacher_full_name: string;
954
+ languageLevel: AkcentLanguageLevel;
955
+ /** 0–1000, not more than lessonsTotal */
956
+ lessonsDone: number;
957
+ /** 1–1000 */
958
+ lessonsTotal: number;
959
+ /** "YYYY-MM-DD" (Almaty day), ISO date-time or epoch ms; today by default; not later than tomorrow */
960
+ given_date?: string | number;
961
+ /** 0–100, 95 by default */
962
+ totalGrade?: number;
963
+ }
964
+
965
+ export interface CreateOfflineCertificateResponse {
966
+ /** false — the certificate given before for this student, course and day (updated) */
967
+ created: boolean;
968
+ certificate: AkcentOfflineCertificate;
909
969
  }
910
970
 
911
971
  export type StopReason = 'student_quit' | 'moved_away' | 'health_issues' | 'financial' | 'other' | 'refund';
@@ -1877,6 +1937,7 @@ declare module 'nazar-salary' {
1877
1937
  getStudent(studentId: number): Promise<StudentDetail>;
1878
1938
  getStudentCertificates(studentId: number): Promise<StudentCertificatesResponse>;
1879
1939
  updateStudentCertificateCourse(studentId: number, courseId: number, data: UpdateAkcentCourseData): Promise<UpdateAkcentCourseResponse>;
1940
+ createStudentOfflineCertificate(studentId: number, data: CreateOfflineCertificateData): Promise<CreateOfflineCertificateResponse>;
1880
1941
  searchStudents(params: SearchStudentsParams): Promise<SearchStudentsResponse>;
1881
1942
  getStoppedStudents(params?: StoppedStudentsParams): Promise<StoppedStudentsResponse>;
1882
1943
  getMyStoppedStudents(params?: MyStoppedStudentsParams): Promise<MyStoppedStudentsResponse>;
package/index.js CHANGED
@@ -757,7 +757,7 @@ class SalaryAPI {
757
757
 
758
758
  /**
759
759
  * Get student's Akcent Online courses and certificates (requireAuth: admin or owner manager)
760
- * The backend finds the student in Akcent by phone.
760
+ * The backend finds the student in Akcent by phone and creates them there if missing.
761
761
  * @param {number} studentId - Student ID
762
762
  * @returns {Promise<StudentCertificatesResponse>}
763
763
  */
@@ -770,7 +770,7 @@ class SalaryAPI {
770
770
  * Shown on the certificate check page (verifyUrl). Send only what changes; null = default.
771
771
  * @param {number} studentId - Student ID
772
772
  * @param {number} courseId - Akcent course ID
773
- * @param {object} data - { languageLevel?, lessonsDone?, lessonsTotal? }
773
+ * @param {object} data - { languageLevel?, lessonsDone?, lessonsTotal?, teacher_full_name? }
774
774
  * @returns {Promise<UpdateAkcentCourseResponse>}
775
775
  */
776
776
  async updateStudentCertificateCourse(studentId, courseId, data) {
@@ -780,6 +780,20 @@ class SalaryAPI {
780
780
  );
781
781
  }
782
782
 
783
+ /**
784
+ * Give an Akcent certificate for an offline course (requireAuth: admin or owner manager)
785
+ * Same student, course_name and day again updates the certificate given before.
786
+ * @param {number} studentId - Student ID
787
+ * @param {object} data - { course_name, teacher_full_name, languageLevel, lessonsDone, lessonsTotal, given_date?, totalGrade? }
788
+ * @returns {Promise<CreateOfflineCertificateResponse>}
789
+ */
790
+ async createStudentOfflineCertificate(studentId, data) {
791
+ return await this.client.post(
792
+ `/api/v1/student/${studentId}/certificates`,
793
+ data,
794
+ );
795
+ }
796
+
783
797
  /**
784
798
  * Search students globally (Admin only)
785
799
  * By default returns only active records; pass is_active=false for stopped.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nazar-salary",
3
- "version": "3.5.3",
3
+ "version": "3.5.5",
4
4
  "description": "Frontend library for Nazar Salary API",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",