storemw-core-client 1.0.1

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 (112) hide show
  1. package/.env +1 -0
  2. package/.vscode/launch.json +24 -0
  3. package/dist/config/config.d.ts +6 -0
  4. package/dist/config/config.js +13 -0
  5. package/dist/config/env.d.ts +7 -0
  6. package/dist/config/env.js +16 -0
  7. package/dist/config/index.d.ts +2 -0
  8. package/dist/config/index.js +8 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +32 -0
  11. package/dist/lib/ApiService.d.ts +41 -0
  12. package/dist/lib/ApiService.js +143 -0
  13. package/dist/lib/index.d.ts +4 -0
  14. package/dist/lib/index.js +9 -0
  15. package/dist/lib/queryParams.d.ts +43 -0
  16. package/dist/lib/queryParams.js +99 -0
  17. package/dist/services/account/AccountService.d.ts +52 -0
  18. package/dist/services/account/AccountService.js +119 -0
  19. package/dist/services/auth/AuthService.d.ts +44 -0
  20. package/dist/services/auth/AuthService.js +76 -0
  21. package/dist/services/branch/BranchService.d.ts +124 -0
  22. package/dist/services/branch/BranchService.js +162 -0
  23. package/dist/services/business/BusinessService.d.ts +91 -0
  24. package/dist/services/business/BusinessService.js +153 -0
  25. package/dist/services/document/DocumentService.d.ts +578 -0
  26. package/dist/services/document/DocumentService.js +615 -0
  27. package/dist/services/index.d.ts +36 -0
  28. package/dist/services/index.js +97 -0
  29. package/dist/services/injection_field/InjectionFieldService.d.ts +113 -0
  30. package/dist/services/injection_field/InjectionFieldService.js +220 -0
  31. package/dist/services/inventory/InventoryService.d.ts +27 -0
  32. package/dist/services/inventory/InventoryService.js +231 -0
  33. package/dist/services/item/ItemService.d.ts +227 -0
  34. package/dist/services/item/ItemService.js +411 -0
  35. package/dist/services/location/LocationService.d.ts +154 -0
  36. package/dist/services/location/LocationService.js +256 -0
  37. package/dist/services/logistic/LogisticService.d.ts +104 -0
  38. package/dist/services/logistic/LogisticService.js +150 -0
  39. package/dist/services/permission/PermissionService.d.ts +296 -0
  40. package/dist/services/permission/PermissionService.js +576 -0
  41. package/dist/services/permission/config/custom/adminPermission.d.ts +4 -0
  42. package/dist/services/permission/config/custom/adminPermission.js +18 -0
  43. package/dist/services/permission/config/custom/config.d.ts +40 -0
  44. package/dist/services/permission/config/custom/config.js +23 -0
  45. package/dist/services/permission/config/default/adminPermission.d.ts +2 -0
  46. package/dist/services/permission/config/default/adminPermission.js +129 -0
  47. package/dist/services/permission/config/default/agentPermission.d.ts +2 -0
  48. package/dist/services/permission/config/default/agentPermission.js +43 -0
  49. package/dist/services/permission/config/default/customerPermission.d.ts +2 -0
  50. package/dist/services/permission/config/default/customerPermission.js +10 -0
  51. package/dist/services/permission/config/default/driverPermission.d.ts +2 -0
  52. package/dist/services/permission/config/default/driverPermission.js +4 -0
  53. package/dist/services/permission/config/default/workerPermission.d.ts +2 -0
  54. package/dist/services/permission/config/default/workerPermission.js +25 -0
  55. package/dist/services/rate/RateService.d.ts +201 -0
  56. package/dist/services/rate/RateService.js +303 -0
  57. package/dist/services/region/RegionService.d.ts +111 -0
  58. package/dist/services/region/RegionService.js +193 -0
  59. package/dist/services/repository/RepositoryService.d.ts +153 -0
  60. package/dist/services/repository/RepositoryService.js +243 -0
  61. package/dist/services/transaction/TransactionService.d.ts +153 -0
  62. package/dist/services/transaction/TransactionService.js +173 -0
  63. package/dist/services/user/BranchUserService.d.ts +129 -0
  64. package/dist/services/user/BranchUserService.js +193 -0
  65. package/dist/services/user/UserRoleService.d.ts +105 -0
  66. package/dist/services/user/UserRoleService.js +193 -0
  67. package/dist/services/user/UserService.d.ts +269 -0
  68. package/dist/services/user/UserService.js +477 -0
  69. package/dist/services/wallet/WalletService.d.ts +104 -0
  70. package/dist/services/wallet/WalletService.js +163 -0
  71. package/dist/utils/dateUtils.d.ts +6 -0
  72. package/dist/utils/dateUtils.js +28 -0
  73. package/dist/utils/index.d.ts +2 -0
  74. package/dist/utils/index.js +13 -0
  75. package/package.json +27 -0
  76. package/src/config/config.ts +15 -0
  77. package/src/config/env.ts +18 -0
  78. package/src/config/index.ts +2 -0
  79. package/src/index.ts +41 -0
  80. package/src/lib/ApiService.ts +170 -0
  81. package/src/lib/index.ts +5 -0
  82. package/src/lib/queryParams.ts +162 -0
  83. package/src/services/account/AccountService.ts +232 -0
  84. package/src/services/auth/AuthService.ts +125 -0
  85. package/src/services/branch/BranchService.ts +330 -0
  86. package/src/services/business/BusinessService.ts +277 -0
  87. package/src/services/document/DocumentService.ts +1471 -0
  88. package/src/services/index.ts +73 -0
  89. package/src/services/injection_field/InjectionFieldService.ts +483 -0
  90. package/src/services/inventory/InventoryService.ts +314 -0
  91. package/src/services/item/ItemService.ts +707 -0
  92. package/src/services/location/LocationService.ts +505 -0
  93. package/src/services/logistic/LogisticService.ts +285 -0
  94. package/src/services/permission/PermissionService.ts +1069 -0
  95. package/src/services/permission/config/custom/adminPermission.ts +19 -0
  96. package/src/services/permission/config/custom/config.ts +39 -0
  97. package/src/services/permission/config/default/adminPermission.ts +129 -0
  98. package/src/services/permission/config/default/agentPermission.ts +42 -0
  99. package/src/services/permission/config/default/customerPermission.ts +9 -0
  100. package/src/services/permission/config/default/driverPermission.ts +4 -0
  101. package/src/services/permission/config/default/workerPermission.ts +25 -0
  102. package/src/services/rate/RateService.ts +570 -0
  103. package/src/services/region/RegionService.ts +353 -0
  104. package/src/services/repository/RepositoryService.ts +437 -0
  105. package/src/services/transaction/TransactionService.ts +404 -0
  106. package/src/services/user/BranchUserService.ts +381 -0
  107. package/src/services/user/UserRoleService.ts +342 -0
  108. package/src/services/user/UserService.ts +807 -0
  109. package/src/services/wallet/WalletService.ts +300 -0
  110. package/src/utils/dateUtils.ts +26 -0
  111. package/src/utils/index.ts +2 -0
  112. package/tsconfig.json +119 -0
@@ -0,0 +1,232 @@
1
+ import { ApiService, ApiServiceType } from '@/lib';
2
+
3
+ import {
4
+ buildApiListUrl,
5
+ BuildApiListParamsProps,
6
+ buildApiGetUrl,
7
+ BuildApiGetParamsProps,
8
+ filterOperatorTypes
9
+ } from '@/lib';
10
+
11
+ export const accountTypes = {
12
+ account: "account",
13
+ } as const
14
+
15
+ export const accountTargetTypes = {
16
+ account: "account",
17
+ } as const
18
+
19
+ export type AccountType = typeof accountTypes[keyof typeof accountTypes]
20
+ export type AccountTargetType = typeof accountTargetTypes[keyof typeof accountTargetTypes]
21
+ export type AccountTargetKey = keyof typeof accountTargetTypes
22
+
23
+ export type AccountServiceProps = ApiServiceType & {
24
+ accountTargetType?: AccountTargetType
25
+ accountType?: AccountType
26
+ };
27
+
28
+ export type ListAccountProps = BuildApiListParamsProps & {
29
+ accountType?: AccountType
30
+ }
31
+
32
+ export type GetAccountProps = BuildApiGetParamsProps & {
33
+ id: number | string
34
+ accountType?: AccountType
35
+ }
36
+
37
+ // export type CreateAccountProps = {
38
+ // accountTargetType?: AccountTargetType
39
+ // accountType?: AccountType
40
+ // data:
41
+ // // for Account
42
+ // {
43
+
44
+ // }
45
+ // }
46
+
47
+ export type UpdateAccountProps = {
48
+ id: number
49
+ accountTargetType?: AccountTargetType
50
+ accountType?: AccountType
51
+ data:
52
+ // for Business
53
+ {
54
+ account: {
55
+ name: string
56
+ businessId: number
57
+ }
58
+ }
59
+ }
60
+
61
+ export type RemoveAccountProps = {
62
+ accountTargetType?: AccountTargetType
63
+ ids: number[]
64
+ }
65
+
66
+ export type GetDataTypeAccountProps = {
67
+ accountType?: AccountType
68
+ }
69
+
70
+ // const getCreatePayload = (accountType: AccountType, data: CreateAccountProps["data"]) => {
71
+
72
+ // if (accountType === "account") {
73
+ // return {
74
+
75
+ // }
76
+ // }
77
+
78
+ // }
79
+
80
+ const getUpdatePayload = (accountType: AccountType, data: UpdateAccountProps["data"]) => {
81
+
82
+ if (accountType === "account" && "account" in data) {
83
+ return {
84
+ account: {
85
+ name: data.account.name,
86
+ business_id: data.account.businessId
87
+ }
88
+ }
89
+ }
90
+
91
+ }
92
+
93
+ export const AccountService = (props?: AccountServiceProps) => {
94
+
95
+ const { accountType = "account", accountTargetType, ...rest } = props ?? {};
96
+
97
+ const { makeCall } = ApiService(rest?.customToken ? { customToken: rest.customToken } : {})
98
+
99
+ const endpoint1 = "account";
100
+
101
+ const get = async (props: GetAccountProps) => {
102
+
103
+ const { id, accountType: overrideAccountType } = props;
104
+
105
+
106
+ const url = buildApiGetUrl(
107
+ `${endpoint1}/${overrideAccountType || accountType}/${id}`,
108
+ props
109
+ );
110
+
111
+ const response = await makeCall({
112
+ url,
113
+ method: "get",
114
+ payload: {},
115
+ // configuration
116
+ });
117
+
118
+ return response;
119
+
120
+
121
+ }
122
+
123
+ // const create = async ({ data, accountType: overrideAccountType, accountTargetType: overrideAccountTargetType }: CreateAccountProps) => {
124
+
125
+
126
+ // let payload: any = {}
127
+
128
+ // if (overrideAccountType) {
129
+ // payload = getCreatePayload(overrideAccountType, data)
130
+ // }
131
+
132
+ // let url = `${endpoint1}`;
133
+
134
+ // let postData = {
135
+ // scope: {
136
+ // target: overrideAccountTargetType || accountTargetType,
137
+ // action: "",
138
+ // },
139
+ // payload
140
+ // }
141
+
142
+ // const response = await makeCall({
143
+ // url,
144
+ // method: "post",
145
+ // payload: postData
146
+ // });
147
+
148
+ // return response;
149
+
150
+
151
+ // }
152
+
153
+ const update = async ({ id, data, accountType: overrideAccountType, accountTargetType: overrideAccountTargetType }: UpdateAccountProps) => {
154
+
155
+
156
+ let url = `${endpoint1}/${id}`
157
+
158
+ // let payload: any = {}
159
+
160
+ // if (overrideAccountType) {
161
+ // payload = getUpdatePayload(overrideAccountType, data)
162
+ // }
163
+
164
+ let _accountType = overrideAccountType || accountType
165
+
166
+ let payload: any = getUpdatePayload(_accountType, data)
167
+
168
+ const postData = {
169
+ scope: {
170
+ target: overrideAccountTargetType || accountTargetType,
171
+ action: "",
172
+ },
173
+ payload
174
+ }
175
+
176
+ const response = await makeCall({
177
+ url,
178
+ method: "put",
179
+ payload: postData
180
+ });
181
+
182
+ return response;
183
+
184
+
185
+ }
186
+
187
+ // const remove = async ({ ids, accountTargetType: overrideAccountTargetType }: RemoveAccountProps) => {
188
+
189
+
190
+ // let url = `${endpoint2}/delete`
191
+
192
+ // const postData = {
193
+ // scope: {
194
+ // target: overrideAccountTargetType || accountTargetType,
195
+ // },
196
+ // payload: {
197
+ // ids
198
+ // }
199
+ // }
200
+
201
+ // const response = await makeCall({
202
+ // url,
203
+ // method: "post",
204
+ // payload: postData
205
+ // });
206
+
207
+ // return response;
208
+
209
+ // }
210
+
211
+ // const getDataTypes = async ({ accountType: overrideAccountType }: GetDataTypeAccountProps) => {
212
+
213
+ // let url = `${endpoint1}/data_types/${overrideAccountType || accountType}`
214
+
215
+ // const response = await makeCall({
216
+ // url,
217
+ // method: "get",
218
+ // });
219
+
220
+ // return response;
221
+
222
+ // }
223
+
224
+ return {
225
+ // list,
226
+ get,
227
+ // create,
228
+ update,
229
+ // remove,
230
+ // getDataTypes
231
+ };
232
+ }
@@ -0,0 +1,125 @@
1
+ import { ApiService, ApiServiceType } from '@/lib';
2
+
3
+ export const routeTypes = {
4
+ admin: "admin",
5
+ retail: "retail", // retail
6
+ workstation: "workstation",
7
+ customer: "customer",
8
+ member: "member",
9
+ public: "public",
10
+ driver: "driver",
11
+ console: "console"
12
+ } as const
13
+
14
+ export const authTargetTypes = {
15
+ admin: "administrator",
16
+ // retail: "retailer",
17
+ retailer: "retail",
18
+ workstation: "workstation", // worker
19
+ customer: "customer",
20
+ member: "member",
21
+ public: "public",
22
+ driver: "driver",
23
+ console: "console"
24
+ } as const
25
+
26
+ // Step 2: Infer the value type (e.g., "administrator" | "retailer" | ...)
27
+ export type AuthTargetType = typeof authTargetTypes[keyof typeof authTargetTypes]
28
+
29
+ // Optional: keyof helper to get "admin" | "retail" | ...
30
+ // export type AuthTargetKey = keyof typeof authTargetTypes
31
+
32
+ // Step 3: Define route mapping
33
+ // export const authTargetSystemRouteTypes: Record<AuthTargetType, string> = {
34
+ // [authTargetTypes.admin]: routeTypes.admin,
35
+ // [authTargetTypes.retail]: routeTypes.retail,
36
+ // [authTargetTypes.workstation]: routeTypes.workstation,
37
+ // [authTargetTypes.customer]: routeTypes.customer,
38
+ // [authTargetTypes.member]: routeTypes.member,
39
+ // [authTargetTypes.driver]: routeTypes.driver,
40
+ // }
41
+
42
+ export type AuthServiceProps = ApiServiceType & {
43
+ authTargetType: AuthTargetType
44
+ }
45
+
46
+ export type AuthLoginProps = {
47
+ authTargetType?: AuthTargetType,
48
+ username: string;
49
+ password: string
50
+ };
51
+
52
+ type confirmPasswordProps = {
53
+ current: string
54
+ password: string
55
+ confirm: string
56
+ }
57
+
58
+ export const AuthService = (props?: AuthServiceProps) => {
59
+
60
+ const { authTargetType, customToken } = props ?? {}
61
+
62
+ const { makeCall } = ApiService(customToken ? { customToken } : {})
63
+
64
+ const endpoint1 = "auth/";
65
+
66
+ const authLogin = async (props: AuthLoginProps) => {
67
+
68
+
69
+ const { authTargetType: overrideAuthTargetType, username, password } = props
70
+
71
+ const url = `${endpoint1}token`;
72
+
73
+ const postData = {
74
+ scope: {
75
+ target: overrideAuthTargetType || authTargetType,
76
+ action: "",
77
+ },
78
+ payload: {
79
+ account_id: "1",
80
+ username,
81
+ password
82
+ }
83
+ }
84
+
85
+ const response = await makeCall({
86
+ url,
87
+ method: "post",
88
+ payload: postData
89
+ });
90
+
91
+ return response;
92
+
93
+ }
94
+
95
+ const changePassword = async ({ current, password, confirm }: confirmPasswordProps) => {
96
+
97
+
98
+ const url = `${endpoint1}`;
99
+
100
+ const postData = {
101
+ scope: {
102
+ target: "change_password"
103
+ },
104
+ payload: {
105
+ auth: {
106
+ current_password: current,
107
+ new_password: password,
108
+ confirm_password: confirm
109
+ }
110
+ }
111
+ }
112
+
113
+ const response = await makeCall({
114
+ url,
115
+ method: 'put',
116
+ payload: postData
117
+ });
118
+
119
+ }
120
+
121
+ return {
122
+ authLogin,
123
+ changePassword
124
+ };
125
+ }
@@ -0,0 +1,330 @@
1
+ import { ApiService, ApiServiceType } from '@/lib';
2
+
3
+ import {
4
+ buildApiListUrl,
5
+ BuildApiListParamsProps,
6
+ buildApiGetUrl,
7
+ BuildApiGetParamsProps,
8
+ filterOperatorTypes
9
+ } from '@/lib';
10
+
11
+ export const branchTypes = {
12
+ customer: "customer",
13
+ retailer: "retailer",
14
+ } as const
15
+
16
+ export const branchTargetTypes = {
17
+ customer: "customer",
18
+ retailer: "retailer",
19
+ } as const
20
+
21
+ export type BranchType = typeof branchTypes[keyof typeof branchTypes] // keyof typeof branchTypes
22
+ export type BranchTargetType = typeof branchTargetTypes[keyof typeof branchTargetTypes]
23
+ export type BranchTargetKey = keyof typeof branchTargetTypes
24
+
25
+ export type BranchServiceProps = ApiServiceType & {
26
+ branchTargetType?: BranchTargetType
27
+ branchType?: BranchType
28
+ };
29
+
30
+ export type ListBranchProps = BuildApiListParamsProps & {
31
+ branchType?: BranchType
32
+ }
33
+
34
+ export type GetBranchProps = BuildApiGetParamsProps & {
35
+ id: number | string
36
+ branchType: BranchType
37
+ }
38
+
39
+ type Branch = {
40
+ branchName: string
41
+ branchCode: string
42
+ branchContact: string
43
+ branchEmail: string
44
+ type: "branch_shipping" | "branch_billing"
45
+ address1: string
46
+ address2: string
47
+ countryId: number
48
+ stateId: number
49
+ areaId: number
50
+ postcode: string
51
+ remark: string
52
+ picName: string
53
+ picContact: string
54
+ picEmail: string
55
+ isHq: boolean
56
+ status: boolean
57
+ }
58
+
59
+ export type CreateBranchProps = {
60
+ userId: number
61
+ branchTargetType?: BranchTargetType
62
+ branchType?: BranchType
63
+ // data: BranchCustomer | BranchRetailer
64
+ data:
65
+ // branch customer
66
+ {
67
+ customerBranch: {
68
+ branch: Branch,
69
+ props: {
70
+ marking: string
71
+ }
72
+ }
73
+ } |
74
+ // branch retail
75
+ {
76
+ retailBranch: {
77
+ branch: Branch,
78
+ props: {
79
+ marking: string
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ export type UpdateBranchProps = {
86
+ userId: number
87
+ branchId: number
88
+ branchTargetType?: BranchTargetType
89
+ branchType?: BranchType
90
+ // data: BranchCustomer | BranchRetailer
91
+ data:
92
+ // branch customer
93
+ {
94
+ customerBranch: {
95
+ branch: Branch,
96
+ props: {
97
+ marking: string
98
+ }
99
+ }
100
+ } |
101
+ // branch retail
102
+ {
103
+ retailBranch: {
104
+ branch: Branch,
105
+ props: {
106
+ marking: string
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ export type RemoveBranchProps = {
113
+ branchTargetType?: BranchTargetType
114
+ ids: number[]
115
+ }
116
+
117
+ export type GetDataTypeBranchProps = {
118
+ branchType?: BranchType
119
+ }
120
+
121
+ const getCreatePayload = (branchType: BranchType, data: CreateBranchProps["data"]) => {
122
+
123
+ if (branchType === "customer" && "customerBranch" in data) {
124
+
125
+ return {
126
+ branch: {
127
+ branch_name: data.customerBranch.branch.branchName,
128
+ branch_code: data.customerBranch.branch.branchCode,
129
+ branch_contact: data.customerBranch.branch.branchContact,
130
+ branch_email: data.customerBranch.branch.branchEmail,
131
+ address_1: data.customerBranch.branch.address1,
132
+ address_2: data.customerBranch.branch.address2,
133
+ country_id: data.customerBranch.branch.countryId,
134
+ state_id: data.customerBranch.branch.stateId,
135
+ area_id: data.customerBranch.branch.areaId,
136
+ pic_name: data.customerBranch.branch.picName,
137
+ pic_contact: data.customerBranch.branch.picContact,
138
+ pic_email: data.customerBranch.branch.picEmail,
139
+ is_hq: data.customerBranch.branch.isHq === true ? 1 : 0,
140
+ status: data.customerBranch.branch.status === true ? 1 : 0,
141
+ },
142
+ props: {
143
+ marking: data.customerBranch.props?.marking ?? "",
144
+ }
145
+ }
146
+ }
147
+
148
+ if (branchType === "retailer" && "retailBranch" in data) {
149
+
150
+ return {
151
+ branch: {
152
+ branch_name: data.retailBranch.branch.branchName,
153
+ branch_code: data.retailBranch.branch.branchCode,
154
+ branch_contact: data.retailBranch.branch.branchContact,
155
+ branch_email: data.retailBranch.branch.branchEmail,
156
+ address_1: data.retailBranch.branch.address1,
157
+ address_2: data.retailBranch.branch.address2,
158
+ country_id: data.retailBranch.branch.countryId,
159
+ state_id: data.retailBranch.branch.stateId,
160
+ area_id: data.retailBranch.branch.areaId,
161
+ pic_name: data.retailBranch.branch.picName,
162
+ pic_contact: data.retailBranch.branch.picContact,
163
+ pic_email: data.retailBranch.branch.picEmail,
164
+ is_hq: data.retailBranch.branch.isHq === true ? 1 : 0,
165
+ status: data.retailBranch.branch.status === true ? 1 : 0,
166
+ },
167
+ props: {
168
+ marking: data.retailBranch.props?.marking ?? "",
169
+ }
170
+ }
171
+
172
+ }
173
+
174
+ }
175
+
176
+ const getUpdatePayload = (branchType: BranchType, data: UpdateBranchProps["data"]) => {
177
+ return getCreatePayload(branchType, data)
178
+ }
179
+
180
+ export const BranchService = (props?: BranchServiceProps) => {
181
+
182
+ const { branchType = "customer", branchTargetType, ...rest } = props ?? {};
183
+
184
+ const { makeCall } = ApiService(rest?.customToken ? { customToken: rest.customToken } : {})
185
+
186
+ const endpoint1 = "user/branch";
187
+ const endpoint2 = "user/branches"
188
+
189
+ const list = async (props: ListBranchProps) => {
190
+
191
+ const { branchType: overrideBranchType } = props;
192
+
193
+
194
+ const url = buildApiListUrl(
195
+ `${endpoint2}/${overrideBranchType || branchType}`,
196
+ props
197
+ );
198
+
199
+ const response = await makeCall({
200
+ url,
201
+ method: "get",
202
+ payload: {},
203
+ // configuration
204
+ });
205
+
206
+ return response;
207
+
208
+
209
+ }
210
+
211
+ const get = async (props: GetBranchProps) => {
212
+
213
+ const { id, branchType: overrideBranchType } = props;
214
+
215
+
216
+ const url = buildApiGetUrl(
217
+ `${endpoint1}/${overrideBranchType || branchType}/${id}`,
218
+ props
219
+ );
220
+
221
+ const response = await makeCall({
222
+ url,
223
+ method: "get",
224
+ payload: {},
225
+ // configuration
226
+ });
227
+
228
+ return response;
229
+
230
+
231
+ }
232
+
233
+ const create = async ({ data, userId, branchType: overrideBranchType, branchTargetType: overrideBranchTargetType }: CreateBranchProps) => {
234
+
235
+ let _branchType = overrideBranchType || branchType
236
+
237
+ let payload: any = getCreatePayload(_branchType, data)
238
+
239
+ let url = `${endpoint1}/${userId}`;
240
+
241
+ let postData = {
242
+ scope: {
243
+ target: overrideBranchTargetType || branchTargetType,
244
+ action: "",
245
+ },
246
+ payload
247
+ }
248
+
249
+ const response = await makeCall({
250
+ url,
251
+ method: "post",
252
+ payload: postData
253
+ });
254
+
255
+ return response;
256
+
257
+
258
+ }
259
+
260
+ const update = async ({ userId, branchId, data, branchType: overrideBranchType, branchTargetType: overrideBranchTargetType }: UpdateBranchProps) => {
261
+
262
+ let url = `${endpoint1}/${userId}/${branchId}`
263
+
264
+ let _branchType = overrideBranchType || branchType
265
+
266
+ let payload: any = getUpdatePayload(_branchType, data)
267
+
268
+ const postData = {
269
+ scope: {
270
+ target: overrideBranchTargetType || branchTargetType,
271
+ action: "",
272
+ },
273
+ payload
274
+ }
275
+
276
+ const response = await makeCall({
277
+ url,
278
+ method: "put",
279
+ payload: postData
280
+ });
281
+
282
+ return response;
283
+
284
+ }
285
+
286
+ const remove = async ({ ids, branchTargetType: overrideBranchTargetType }: RemoveBranchProps) => {
287
+
288
+ let url = `${endpoint2}/delete`
289
+
290
+ const postData = {
291
+ scope: {
292
+ target: overrideBranchTargetType || branchTargetType,
293
+ },
294
+ payload: {
295
+ ids
296
+ }
297
+ }
298
+
299
+ const response = await makeCall({
300
+ url,
301
+ method: "post",
302
+ payload: postData
303
+ });
304
+
305
+ return response;
306
+
307
+ }
308
+
309
+ const getDataTypes = async ({ branchType: overrideBranchType }: GetDataTypeBranchProps) => {
310
+
311
+ let url = `${endpoint2}/data_types/${overrideBranchType || branchType}`
312
+
313
+ const response = await makeCall({
314
+ url,
315
+ method: "get",
316
+ });
317
+
318
+ return response;
319
+
320
+ }
321
+
322
+ return {
323
+ list,
324
+ get,
325
+ create,
326
+ update,
327
+ remove,
328
+ getDataTypes
329
+ };
330
+ }