-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasded.js
105 lines (101 loc) · 2.15 KB
/
tasded.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var axios = require("axios").default;
var md5 = require("md5").default;
class Tasdid {
url = "https://api.tasdid.net/v1/api/";
constructor(userName, password) {
const headers = { "Content-Type": "application/json" };
let result = await axios.post(
this.url + "Auth/Token",
{ userName, password },
headers
);
this.Accouunt.token = result.token;
this.Accouunt.providerId = result.providerId;
}
/**
*
* @param {"You-Service-Name"} name
* @param {"Free text"} note
* @returns service info you need to save serviceId
*/
addService = async (name, note) => {
const headers = {
"Content-Type": "application/json",
Authorization: "Bearer " + this.Accouunt.token,
};
let result = await axios.put(
this.url + "Provider/AddService",
{
token: this.Accouunt.token,
providerId: this.Accouunt.providerId,
name,
note,
},
headers
);
return result;
};
/**
*
* @param {*} payId
* @param {*} customerName
* @param {*} payDate
* @param {*} status
* @param {*} clientId
* @param {*} phoneNumber
* @param {*} serviceId
* @param {*} amount
* @param {*} note
* @returns
*/
addBill = async (
payId,
customerName,
payDate,
status,
clientId,
phoneNumber,
serviceId,
amount,
note
) => {
const headers = {
"Content-Type": "application/json",
Authorization: "Bearer " + token,
};
let result = await axios.put(
this.url + "Provider/AddBill",
{
payId,
customerName,
dueDate,
payDate,
status,
clientId,
phoneNumber,
serviceId,
amount,
note,
},
headers
);
return result;
};
/**
*
* @param {*} email
* @param {*} payId
* @param {*} status
* @param {*} body
* @returns
*/
cheakBill = (email, payId, status, body) => {
let md5Str = `${email}|${payId}|${status}`;
md5Str = md5(md5Str).toUpperCase();
return {
sucsses: body.key == md5Str && body.status == 3 ? true : false,
error: " ",
};
};
}
module.exports = Tasdid;