kingoftime-cli/src/kingoftime.ts

38 lines
990 B
TypeScript

import axios from 'axios'
const CHECK_IN_ID = 'qmXXCxw9WEWN3X/YrkMWuQ=='
const CHECK_OUT_ID = 'j8ekmJaw6W3M4w3i6hlSIQ=='
async function kingoftime(
operationId: string,
token: string,
userToken: string,
) {
const response = await axios({
method: 'post',
url: 'https://s2.ta.kingoftime.jp/gateway/bprgateway',
headers: {
Accept: 'application/json, text/javascript, */*; q=0.01',
},
data: new URLSearchParams({
id: operationId,
highAccuracyFlg: 'false',
credential_code: '40', // eslint-disable-line camelcase
user_token: userToken, // eslint-disable-line camelcase
version: '1.4.16',
token: token,
}),
})
console.log(response.data)
}
export async function checkin(token: string, userToken: string): Promise<void> {
await kingoftime(CHECK_IN_ID, token, userToken)
}
export async function checkout(
token: string,
userToken: string,
): Promise<void> {
await kingoftime(CHECK_OUT_ID, token, userToken)
}