sysone-api-mapper 1.0.141 → 1.0.143

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.
package/index.js CHANGED
@@ -2,8 +2,16 @@ import { apiCall } from "./services";
2
2
  import { endpoints } from "./servicesData";
3
3
  import axiosInstance from "./axiosInstance";
4
4
  import { configureApiMapper, apiMapper } from "./src/mapper/Mapper";
5
+ import { ApiContext, useApi } from "./src/contexts/apiContext";
6
+ import { createApiAdapter } from "./src/adapters/createApiAdapter"
5
7
 
6
-
7
-
8
-
9
- export { apiCall, apiMapper, endpoints, axiosInstance, configureApiMapper };
8
+ export {
9
+ apiCall,
10
+ apiMapper,
11
+ endpoints,
12
+ axiosInstance,
13
+ configureApiMapper,
14
+ ApiContext,
15
+ useApi,
16
+ createApiAdapter
17
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sysone-api-mapper",
3
- "version": "1.0.141",
3
+ "version": "1.0.143",
4
4
  "description": "Paquete mapper para portal de productores",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,10 @@
1
+ import { apiMapper } from "../mapper/Mapper";
2
+ import { financeAdapter } from "./financeAdapter";
3
+ import { locationAdapter } from "./locationAdapter";
4
+ import { partyAdapter } from "./partyAdapter";
5
+
6
+ export const createApiAdapter = (tenant = 'default') => ({
7
+ finance: financeAdapter(tenant),
8
+ party: partyAdapter(tenant),
9
+ location: locationAdapter(tenant)
10
+ });
@@ -0,0 +1,5 @@
1
+ import { apiMapper } from "../mapper/Mapper";
2
+
3
+ export const financeAdapter = (tenant) => ({
4
+ getCurrencies: () => apiMapper("GET_CURRENCIES", tenant),
5
+ });
@@ -0,0 +1,6 @@
1
+ import { apiMapper } from "../mapper/Mapper";
2
+
3
+ export const locationAdapter = (tenant) => ({
4
+ getCountries: () => apiMapper("GET_COUNTRIES", tenant,),
5
+ getProvinces: (countryCode) => apiMapper("GET_PROVINCES", tenant, [countryCode]),
6
+ });
@@ -0,0 +1,8 @@
1
+ import { apiMapper } from "../mapper/Mapper";
2
+
3
+ export const partyAdapter = (tenant) => ({
4
+ getGenders: () => apiMapper("GET_GENDERS", tenant),
5
+ getMaritalStatus: () => apiMapper("GET_MARITAL_STATUS", tenant),
6
+ getActivity: () => apiMapper("GET_ACTIVITY", tenant),
7
+ getIdentificationTypes: (countryCode) => apiMapper("GET_IDENTIFICATION_TYPES", tenant, [countryCode]),
8
+ });
@@ -0,0 +1,9 @@
1
+ import { createContext, useContext } from 'react';
2
+
3
+ export const ApiContext = createContext(null);
4
+
5
+ export const useApi = () => {
6
+ const ctx = useContext(ApiContext);
7
+ if (!ctx) throw new Error("ApiContext not found");
8
+ return ctx;
9
+ };