1.0.2 • Published 2 years ago
pion-eadisyon v1.0.2
Pionpos - Eadisyon Integration
TODOS:
- Register package to npm or configure github to install package. Preferiblly under the name "@pionpos/eadisyon"
Usage
Local Setup
- Fetch the project from remote repo (Github, Gitlab etc.)
- Run
npm link
- In another npm project run
npm link @pionpos/eadisyon
Production Setup
Install the package.
npm i @pionpos/eadisyon
Import the package, choose your HTTP client and create the adapter.
Currently the adapter is default to "MySoft E-adisyon"
Run the project
import eadisyon from "@pionpos/eadisyon";
import fetch from "node-fetch";
let userEadisyonAdaptorConfig = {
name: "MYSOFT",
config: {
customer: {
name: "",
},
credentials: {
username: "",
password: "",
},
},
};
let account = userEadisyonAdaptorConfig.config.credentials;
async function initEadisyon() {
try {
let accountParams = {
username: account.username,
password: account.password,
};
let eadisyonApi = eadisyon.create(fetch);
let res = await eadisyonApi.getToken(accountParams);
const data = await res.json();
eadisyonApi.setToken(data.access_token);
return eadisyonApi;
} catch (error) {
console.error(error.message);
}
}
const listAllAdisyon = async (payload) => {
try {
let eadisyonApi = await initEadisyon();
let res = await eadisyonApi.list(payload);
const data = await res.json();
console.log(data);
} catch (error) {
console.error(error.message);
}
};
const payload = {
startDate: "2020-01-01",
endDate: "2020-01-31",
isUseDocDate: true,
afterValue: 0,
limit: 0,
tenantIdentifierNumber: "1234567890"
}
listAllAdisyon(payload);