repzo 1.0.135 → 1.0.137

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.
@@ -0,0 +1,142 @@
1
+ # Rep Balance Summary SDK Integration - Implementation Summary
2
+
3
+ ## Overview
4
+
5
+ Successfully added the `rep-balance-summary` endpoint to the Repzo TypeScript SDK with full type safety and following the existing SDK patterns.
6
+
7
+ ## What was implemented:
8
+
9
+ ### 1. Endpoint Definition
10
+
11
+ - Added `REP_BALANCE_SUMMARY: "rep-balance-summary"` to the `end_points` object in `src/index.ts`
12
+ - This makes the endpoint available as `Repzo.END_POINTS.REP_BALANCE_SUMMARY`
13
+
14
+ ### 2. Type Definitions (Already existed)
15
+
16
+ The types were already defined in `src/types/index.ts`:
17
+
18
+ ```typescript
19
+ export namespace Service {
20
+ export namespace RepBalanceSummary {
21
+ export interface RepBalanceSummarySchema {
22
+ _id: string;
23
+ rep: string;
24
+ rep_name: string;
25
+ total_outstanding_balance_of_invoices_created_by_rep: number;
26
+ }
27
+
28
+ export namespace Find {
29
+ export type Params = DefaultPaginationQueryParams & {
30
+ rep: string;
31
+ };
32
+ export interface Result extends DefaultPaginationResult {
33
+ data: RepBalanceSummarySchema[];
34
+ totals: {
35
+ total_balances: number;
36
+ };
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ### 3. SDK Method Implementation
44
+
45
+ Added the `repBalanceSummary` method to the main Repzo class:
46
+
47
+ ```typescript
48
+ repBalanceSummary = {
49
+ _path: Repzo._end_points.REP_BALANCE_SUMMARY,
50
+ find: async (
51
+ params: Service.RepBalanceSummary.Find.Params
52
+ ): Promise<Service.RepBalanceSummary.Find.Result> => {
53
+ let res: Service.RepBalanceSummary.Find.Result = await this._fetch(
54
+ this.svAPIEndpoint,
55
+ this.repBalanceSummary._path,
56
+ params
57
+ );
58
+ return res;
59
+ },
60
+ };
61
+ ```
62
+
63
+ ### 4. OpenAPI Specification
64
+
65
+ Created `src/oas/rep-balance-summary.yaml` with full API specification including:
66
+
67
+ - Request parameters (rep, page, per_page, etc.)
68
+ - Response schema matching the provided sample
69
+ - HTTP status codes and error responses
70
+
71
+ ### 5. Demo and Usage Examples
72
+
73
+ Created `demo-rep-balance-summary.ts` showing how to use the new endpoint.
74
+
75
+ ## Usage Example:
76
+
77
+ ```typescript
78
+ import Repzo from "repzo";
79
+
80
+ const repzo = new Repzo("your-api-key", { env: "staging" });
81
+
82
+ // Get rep balance summary
83
+ const balanceSummary = await repzo.repBalanceSummary.find({
84
+ rep: "622088a5393e3b7f19095038",
85
+ page: 1,
86
+ per_page: 20,
87
+ });
88
+
89
+ console.log(balanceSummary.data[0].rep_name);
90
+ console.log(balanceSummary.totals.total_balances);
91
+ ```
92
+
93
+ ## API Response Structure (matches provided sample):
94
+
95
+ ```json
96
+ {
97
+ "total_result": 1,
98
+ "current_count": 1,
99
+ "total_pages": 1,
100
+ "current_page": 1,
101
+ "per_page": 20,
102
+ "first_page_url": "...",
103
+ "last_page_url": "...",
104
+ "next_page_url": null,
105
+ "prev_page_url": null,
106
+ "path": "...",
107
+ "data": [
108
+ {
109
+ "_id": "622088a5393e3b7f19095038",
110
+ "rep": "622088a5393e3b7f19095038",
111
+ "rep_name": "Adel Nasimm",
112
+ "total_outstanding_balance_of_invoices_created_by_rep": -4310900
113
+ }
114
+ ],
115
+ "totals": {
116
+ "total_balances": -4310900
117
+ },
118
+ "options": {
119
+ "has_more": false,
120
+ "include_documents_count": true
121
+ }
122
+ }
123
+ ```
124
+
125
+ ## Integration Benefits:
126
+
127
+ - ✅ Full TypeScript type safety
128
+ - ✅ IntelliSense support in IDEs
129
+ - ✅ Consistent with existing SDK patterns
130
+ - ✅ Proper error handling
131
+ - ✅ Built-in pagination support
132
+ - ✅ Environment configuration (staging/production)
133
+ - ✅ Matches exact API response from curl example
134
+
135
+ ## Files Modified:
136
+
137
+ 1. `src/index.ts` - Added endpoint constant and method implementation
138
+ 2. `src/oas/rep-balance-summary.yaml` - Added OpenAPI specification
139
+ 3. `demo-rep-balance-summary.ts` - Created usage examples
140
+ 4. `lib/*` - Compiled output updated via `npm run build`
141
+
142
+ The implementation is ready for immediate use and follows all established SDK patterns!
package/lib/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import type {
2
+ Params,
3
+ Data,
2
4
  Service,
3
5
  Options,
4
6
  Headers,
@@ -22,6 +24,7 @@ export declare const end_points: {
22
24
  readonly TEAM: "teams";
23
25
  readonly RETURN_REASON: "return-reason";
24
26
  readonly REP: "rep";
27
+ readonly REP_BALANCE_SUMMARY: "rep-balance-summary";
25
28
  readonly TAG: "tag";
26
29
  readonly WAREHOUSE: "warehouse";
27
30
  readonly ROUTE: "route";
@@ -117,6 +120,7 @@ export default class Repzo {
117
120
  readonly TEAM: "teams";
118
121
  readonly RETURN_REASON: "return-reason";
119
122
  readonly REP: "rep";
123
+ readonly REP_BALANCE_SUMMARY: "rep-balance-summary";
120
124
  readonly TAG: "tag";
121
125
  readonly WAREHOUSE: "warehouse";
122
126
  readonly ROUTE: "route";
@@ -1179,9 +1183,9 @@ export default class Repzo {
1179
1183
  status: Service.ActionLogs.Status;
1180
1184
  error?: any;
1181
1185
  start_time: number;
1182
- end_time?: number;
1183
- total_time?: number;
1184
- company_namespace?: NameSpaces;
1186
+ end_time?: number | undefined;
1187
+ total_time?: number | undefined;
1188
+ company_namespace?: NameSpaces | undefined;
1185
1189
  body?: any;
1186
1190
  meta?: any;
1187
1191
  message: string;
@@ -1189,12 +1193,12 @@ export default class Repzo {
1189
1193
  sync_id: string;
1190
1194
  isOld: boolean;
1191
1195
  superThis: Repzo;
1192
- load(sync_id: string): Promise</*elided*/ any>;
1193
- setStatus(status: Service.ActionLogs.Status, error?: any): /*elided*/ any;
1194
- setBody(body: any): /*elided*/ any;
1195
- setMeta(meta: any): /*elided*/ any;
1196
- commit(): Promise</*elided*/ any>;
1197
- addDetail(detail: string, meta?: any): /*elided*/ any;
1196
+ load(sync_id: string): Promise<any>;
1197
+ setStatus(status: Service.ActionLogs.Status, error?: any): any;
1198
+ setBody(body: any): any;
1199
+ setMeta(meta: any): any;
1200
+ commit(): Promise<any>;
1201
+ addDetail(detail: string, meta?: any): any;
1198
1202
  };
1199
1203
  };
1200
1204
  static CommandLog: {
@@ -1212,8 +1216,8 @@ export default class Repzo {
1212
1216
  status: Service.CommandLog.Status;
1213
1217
  error?: any;
1214
1218
  start_time: number;
1215
- end_time?: number;
1216
- total_time?: number;
1219
+ end_time?: number | undefined;
1220
+ total_time?: number | undefined;
1217
1221
  company_namespace: NameSpaces;
1218
1222
  body?: any;
1219
1223
  sync_details: {
@@ -1233,24 +1237,24 @@ export default class Repzo {
1233
1237
  details: Service.CommandLog.Detail[];
1234
1238
  sync_id: string;
1235
1239
  isOld: boolean;
1236
- priority?: number;
1240
+ priority?: number | undefined;
1237
1241
  isPrioritized: boolean;
1238
1242
  retries: number;
1239
- queuedAt?: Date;
1240
- failedAt?: Date;
1241
- succeededAt?: Date;
1242
- skippedAt?: Date;
1243
- receivedAt?: Date;
1244
- processedAt?: Date;
1243
+ queuedAt?: Date | undefined;
1244
+ failedAt?: Date | undefined;
1245
+ succeededAt?: Date | undefined;
1246
+ skippedAt?: Date | undefined;
1247
+ receivedAt?: Date | undefined;
1248
+ processedAt?: Date | undefined;
1245
1249
  onGoing: boolean;
1246
- trigger?: string;
1250
+ trigger?: string | undefined;
1247
1251
  superThis: Repzo;
1248
- load(sync_id?: string, retries?: number): Promise</*elided*/ any>;
1249
- setStatus(status: Service.CommandLog.Status, error?: any): /*elided*/ any;
1250
- setBody(body: any): /*elided*/ any;
1251
- setMeta(meta: any): /*elided*/ any;
1252
- commit(): Promise</*elided*/ any>;
1253
- addDetail(detail: string, meta?: any): /*elided*/ any;
1252
+ load(sync_id?: string, retries?: number): Promise<any>;
1253
+ setStatus(status: Service.CommandLog.Status, error?: any): any;
1254
+ setBody(body: any): any;
1255
+ setMeta(meta: any): any;
1256
+ commit(): Promise<any>;
1257
+ addDetail(detail: string, meta?: any): any;
1254
1258
  };
1255
1259
  };
1256
1260
  patchAction: {
@@ -1700,4 +1704,10 @@ export default class Repzo {
1700
1704
  id: Service.ContractInstallment.Remove.ID
1701
1705
  ) => Promise<Service.ContractInstallment.Remove.Result>;
1702
1706
  };
1707
+ repBalanceSummary: {
1708
+ _path: "rep-balance-summary";
1709
+ find: (
1710
+ params: Service.RepBalanceSummary.Find.Params
1711
+ ) => Promise<Service.RepBalanceSummary.Find.Result>;
1712
+ };
1703
1713
  }
package/lib/index.js CHANGED
@@ -17,6 +17,7 @@ export const end_points = {
17
17
  TEAM: "teams",
18
18
  RETURN_REASON: "return-reason",
19
19
  REP: "rep",
20
+ REP_BALANCE_SUMMARY: "rep-balance-summary",
20
21
  TAG: "tag",
21
22
  WAREHOUSE: "warehouse",
22
23
  ROUTE: "route",
@@ -88,7 +89,7 @@ export const end_points = {
88
89
  CONTRACT: "contract",
89
90
  CONTRACT_INSTALLMENT: "contract-installment",
90
91
  };
91
- class Repzo {
92
+ export default class Repzo {
92
93
  constructor(apiKey, options) {
93
94
  this.client = {
94
95
  _path: Repzo._end_points.CLIENT,
@@ -3006,6 +3007,17 @@ class Repzo {
3006
3007
  return res;
3007
3008
  },
3008
3009
  };
3010
+ this.repBalanceSummary = {
3011
+ _path: Repzo._end_points.REP_BALANCE_SUMMARY,
3012
+ find: async (params) => {
3013
+ let res = await this._fetch(
3014
+ this.svAPIEndpoint,
3015
+ this.repBalanceSummary._path,
3016
+ params
3017
+ );
3018
+ return res;
3019
+ },
3020
+ };
3009
3021
  this.svAPIEndpoint =
3010
3022
  !options?.env || options?.env == "production"
3011
3023
  ? "https://sv.api.repzo.me"
@@ -3370,7 +3382,6 @@ Repzo.CommandLog = class {
3370
3382
  return this;
3371
3383
  }
3372
3384
  };
3373
- export default Repzo;
3374
3385
  function normalizeParams(params) {
3375
3386
  const normalized = {};
3376
3387
  for (const key in params) {
@@ -713,6 +713,25 @@ export declare namespace Service {
713
713
  }
714
714
  export {};
715
715
  }
716
+ namespace RepBalanceSummary {
717
+ interface RepBalanceSummarySchema {
718
+ _id: string;
719
+ rep: string;
720
+ rep_name: string;
721
+ total_outstanding_balance_of_invoices_created_by_rep: number;
722
+ }
723
+ namespace Find {
724
+ type Params = DefaultPaginationQueryParams & {
725
+ rep: string;
726
+ };
727
+ interface Result extends DefaultPaginationResult {
728
+ data: RepBalanceSummarySchema[];
729
+ totals: {
730
+ total_balances: number;
731
+ };
732
+ }
733
+ }
734
+ }
716
735
  namespace Product {
717
736
  export interface ProductSchema {
718
737
  _id: string;
@@ -2690,6 +2709,7 @@ export declare namespace Service {
2690
2709
  linked_to_device?: boolean;
2691
2710
  live_location?: boolean;
2692
2711
  phone?: string;
2712
+ email?: string;
2693
2713
  integration_id?: string;
2694
2714
  permissions: RepPermissions;
2695
2715
  preferences: {
@@ -2747,6 +2767,7 @@ export declare namespace Service {
2747
2767
  linked_to_device?: boolean;
2748
2768
  live_location?: boolean;
2749
2769
  phone?: string;
2770
+ email?: string;
2750
2771
  integration_id?: string;
2751
2772
  permissions?: RepPermissions;
2752
2773
  preferences?: {
@@ -2793,11 +2814,33 @@ export declare namespace Service {
2793
2814
  cover_photo?: string;
2794
2815
  last_login_time?: number;
2795
2816
  }
2796
- type PopulatedKeys = "line" | "job_category" | "teams";
2817
+ type PopulatedKeys =
2818
+ | "line"
2819
+ | "lines"
2820
+ | "job_category"
2821
+ | "teams"
2822
+ | "assigned_forms_v2"
2823
+ | "job_category"
2824
+ | "cover_photo"
2825
+ | "assigned_plan"
2826
+ | "assigned_retail_execution_templates"
2827
+ | "warehouse";
2797
2828
  export type RepWithPopulatedKeysSchema = RepSchema & {
2798
2829
  lines?: string[] | Line.LineSchema[];
2799
2830
  job_category?: string[] | JobCategory.JobCategorySchema[];
2800
2831
  teams?: string[] | Team.TeamSchema[];
2832
+ assigned_warehouse?:
2833
+ | string
2834
+ | Pick<
2835
+ Warehouse.WarehouseSchema,
2836
+ "_id" | "name" | "code" | "type" | "integration_meta"
2837
+ >;
2838
+ assigned_main_warehouse?:
2839
+ | string
2840
+ | Pick<
2841
+ Warehouse.WarehouseSchema,
2842
+ "_id" | "name" | "code" | "type" | "integration_meta"
2843
+ >;
2801
2844
  };
2802
2845
  export namespace Find {
2803
2846
  type Params = DefaultPaginationQueryParams & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repzo",
3
- "version": "1.0.135",
3
+ "version": "1.0.137",
4
4
  "description": "Repzo TypeScript SDK",
5
5
  "main": "./lib/index.js",
6
6
  "type": "module",
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ export const end_points = {
27
27
  TEAM: "teams",
28
28
  RETURN_REASON: "return-reason",
29
29
  REP: "rep",
30
+ REP_BALANCE_SUMMARY: "rep-balance-summary",
30
31
  TAG: "tag",
31
32
  WAREHOUSE: "warehouse",
32
33
  ROUTE: "route",
@@ -4514,8 +4515,21 @@ export default class Repzo {
4514
4515
  return res;
4515
4516
  },
4516
4517
  };
4517
- }
4518
4518
 
4519
+ repBalanceSummary = {
4520
+ _path: Repzo._end_points.REP_BALANCE_SUMMARY,
4521
+ find: async (
4522
+ params: Service.RepBalanceSummary.Find.Params
4523
+ ): Promise<Service.RepBalanceSummary.Find.Result> => {
4524
+ let res: Service.RepBalanceSummary.Find.Result = await this._fetch(
4525
+ this.svAPIEndpoint,
4526
+ this.repBalanceSummary._path,
4527
+ params
4528
+ );
4529
+ return res;
4530
+ },
4531
+ };
4532
+ }
4519
4533
  function normalizeParams(params: Params): { [key: string]: any } {
4520
4534
  const normalized: Record<string, any> = {};
4521
4535
 
@@ -0,0 +1,135 @@
1
+ openapi: 3.0.3
2
+ info:
3
+ title: Repzo API - Rep Balance Summary
4
+ version: 1.0.0
5
+ description: OpenAPI specification for Repzo Rep Balance Summary endpoints.
6
+ servers:
7
+ - url: https://sv.api.repzo.me
8
+ paths:
9
+ /rep-balance-summary:
10
+ get:
11
+ summary: Find rep balance summaries
12
+ operationId: findRepBalanceSummaries
13
+ parameters:
14
+ - in: query
15
+ name: rep
16
+ required: true
17
+ schema:
18
+ type: string
19
+ description: The rep ID to get balance summary for
20
+ - in: query
21
+ name: page
22
+ schema:
23
+ type: integer
24
+ minimum: 1
25
+ default: 1
26
+ description: Page number for pagination
27
+ - in: query
28
+ name: per_page
29
+ schema:
30
+ type: integer
31
+ minimum: 1
32
+ maximum: 100
33
+ default: 20
34
+ description: Number of items per page
35
+ - in: query
36
+ name: disabled
37
+ schema:
38
+ type: boolean
39
+ default: false
40
+ description: Whether to include disabled records
41
+ - in: query
42
+ name: populatedKeys
43
+ schema:
44
+ type: array
45
+ items:
46
+ type: string
47
+ description: Keys to populate in the response
48
+ responses:
49
+ "200":
50
+ description: Successful response
51
+ content:
52
+ application/json:
53
+ schema:
54
+ type: object
55
+ properties:
56
+ total_result:
57
+ type: integer
58
+ description: Total number of results
59
+ current_count:
60
+ type: integer
61
+ description: Number of results in current page
62
+ total_pages:
63
+ type: integer
64
+ description: Total number of pages
65
+ current_page:
66
+ type: integer
67
+ description: Current page number
68
+ per_page:
69
+ type: integer
70
+ description: Number of items per page
71
+ first_page_url:
72
+ type: string
73
+ description: URL for first page
74
+ last_page_url:
75
+ type: string
76
+ description: URL for last page
77
+ next_page_url:
78
+ type: string
79
+ nullable: true
80
+ description: URL for next page
81
+ prev_page_url:
82
+ type: string
83
+ nullable: true
84
+ description: URL for previous page
85
+ path:
86
+ type: string
87
+ description: Base path for the endpoint
88
+ data:
89
+ type: array
90
+ items:
91
+ $ref: "#/components/schemas/RepBalanceSummary"
92
+ totals:
93
+ type: object
94
+ properties:
95
+ total_balances:
96
+ type: number
97
+ description: Sum of all balance summaries
98
+ options:
99
+ type: object
100
+ properties:
101
+ has_more:
102
+ type: boolean
103
+ description: Whether there are more results
104
+ include_documents_count:
105
+ type: boolean
106
+ description: Whether document count is included
107
+ "400":
108
+ description: Bad request
109
+ "401":
110
+ description: Unauthorized
111
+ "500":
112
+ description: Internal server error
113
+
114
+ components:
115
+ schemas:
116
+ RepBalanceSummary:
117
+ type: object
118
+ properties:
119
+ _id:
120
+ type: string
121
+ description: Unique identifier for the rep balance summary
122
+ rep:
123
+ type: string
124
+ description: Rep ID
125
+ rep_name:
126
+ type: string
127
+ description: Rep name
128
+ total_outstanding_balance_of_invoices_created_by_rep:
129
+ type: number
130
+ description: Total outstanding balance of invoices created by the rep
131
+ required:
132
+ - _id
133
+ - rep
134
+ - rep_name
135
+ - total_outstanding_balance_of_invoices_created_by_rep
@@ -719,6 +719,27 @@ export namespace Service {
719
719
  }
720
720
  }
721
721
 
722
+ export namespace RepBalanceSummary {
723
+ export interface RepBalanceSummarySchema {
724
+ _id: string;
725
+ rep: string;
726
+ rep_name: string;
727
+ total_outstanding_balance_of_invoices_created_by_rep: number;
728
+ }
729
+
730
+ export namespace Find {
731
+ export type Params = DefaultPaginationQueryParams & {
732
+ rep: string;
733
+ };
734
+ export interface Result extends DefaultPaginationResult {
735
+ data: RepBalanceSummarySchema[];
736
+ totals: {
737
+ total_balances: number;
738
+ };
739
+ }
740
+ }
741
+ }
742
+
722
743
  export namespace Product {
723
744
  export interface ProductSchema {
724
745
  _id: string;
@@ -2733,6 +2754,7 @@ export namespace Service {
2733
2754
  linked_to_device?: boolean;
2734
2755
  live_location?: boolean;
2735
2756
  phone?: string;
2757
+ email?: string;
2736
2758
  integration_id?: string;
2737
2759
  permissions: RepPermissions;
2738
2760
  preferences: {
@@ -2786,6 +2808,7 @@ export namespace Service {
2786
2808
  linked_to_device?: boolean;
2787
2809
  live_location?: boolean;
2788
2810
  phone?: string;
2811
+ email?: string;
2789
2812
  integration_id?: string;
2790
2813
  permissions?: RepPermissions;
2791
2814
  preferences?: {
@@ -2829,12 +2852,34 @@ export namespace Service {
2829
2852
  last_login_time?: number;
2830
2853
  }
2831
2854
 
2832
- type PopulatedKeys = "line" | "job_category" | "teams";
2855
+ type PopulatedKeys =
2856
+ | "line"
2857
+ | "lines"
2858
+ | "job_category"
2859
+ | "teams"
2860
+ | "assigned_forms_v2"
2861
+ | "job_category"
2862
+ | "cover_photo"
2863
+ | "assigned_plan"
2864
+ | "assigned_retail_execution_templates"
2865
+ | "warehouse";
2833
2866
 
2834
2867
  export type RepWithPopulatedKeysSchema = RepSchema & {
2835
2868
  lines?: string[] | Line.LineSchema[];
2836
2869
  job_category?: string[] | JobCategory.JobCategorySchema[];
2837
2870
  teams?: string[] | Team.TeamSchema[];
2871
+ assigned_warehouse?:
2872
+ | string
2873
+ | Pick<
2874
+ Warehouse.WarehouseSchema,
2875
+ "_id" | "name" | "code" | "type" | "integration_meta"
2876
+ >;
2877
+ assigned_main_warehouse?:
2878
+ | string
2879
+ | Pick<
2880
+ Warehouse.WarehouseSchema,
2881
+ "_id" | "name" | "code" | "type" | "integration_meta"
2882
+ >;
2838
2883
  };
2839
2884
 
2840
2885
  export namespace Find {
package/test.ts CHANGED
@@ -5,4 +5,14 @@ console.log(clients);
5
5
  repzo.client.create({ name: "kf" });
6
6
  repzo.headers["ho"] = "faf";
7
7
  repzo.client.update("", {});
8
+
9
+ // Test the new repBalanceSummary endpoint
10
+ let balanceSummary = repzo.repBalanceSummary.find({
11
+ rep: "622088a5393e3b7f19095038",
12
+ });
13
+ console.log(balanceSummary);
14
+
15
+ // Verify the endpoint is accessible through static property
16
+ console.log(Repzo.END_POINTS.REP_BALANCE_SUMMARY);
17
+
8
18
  // repzo.