# whms

> A package simplfy WHMS upload process

Latest version **1.1.1** (published 2021-11-26) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install whms
pnpm add whms
yarn add whms
bun add whms
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-11-26 |
| First published | 2021-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | benny123tw |
| Maintainers | benny123tw |
| Keywords | whms, node |

## Links

- npm: https://www.npmjs.com/package/whms
- Repository: https://github.com/benny123tw/whms
- Homepage: https://github.com/benny123tw/whms#readme
- Issues: https://github.com/benny123tw/whms/issues
- npm.io page: https://npm.io/package/whms

## Dependencies (2)

- [axios](https://npm.io/package/axios.md) ^0.21.1
- [moment](https://npm.io/package/moment.md) ^2.29.1

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2021-11-26
- 1.1.0 — 2021-11-25
- 1.0.9 — 2021-10-05
- 1.0.8 — 2021-09-11
- 1.0.7 — 2021-09-08
- 1.0.6 — 2021-09-06
- 1.0.5 — 2021-09-06
- 1.0.4 — 2021-09-04
- 1.0.3 — 2021-09-02

## README

# WHMS

[![npm version](https://img.shields.io/npm/v/whms.svg?style=flat-square)](https://www.npmjs.org/package/whms)
[![license](https://img.shields.io/github/license/benny123tw/whms)](https://github.com/benny123tw/whms/blob/master/LICENSE)

A package that simplifies the work hour management system (get/post) process.

## new

1. add `id` to `UploadConfig`.
2. fix `upload` function error handling

## Installing

Using npm:

```bash
$ npm install whms
```

## Example

### note: CommonJS usage

In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()` use the following approach:

```js
const whms = require("whms").default;

// whms.<method> will now provide autocomplete and parameter typings
```

Upload Work Reocrd List to database

```ts
import whms from "whms";

whms.upload({
  id: 69,
  employeeAccount: "John Doe",
  projectCode: "C000",
  content: "This is a content",
  dateStart: "2021-09-06",
  dateEnd: "2021-09-08",
  passHoliday: true,
  exclude: ["2021-09-07"],
}).then((response) => {
  console.log(response);
});
```

Get data from work hour management system

```ts
import whms from 'whms';

whms.get({
  method: "getProjects",
  data: {}
});

whms.get({
  method: "getAvalibleProjects",
  data: {}
});

whms.get({
  method: "getProjectsByCondition",
  data: {
    projectCodeSearch: "",
    projectNameSearch: "",
    projectShowAll: false
  }
});

whms.get({
  method: "getWorkRecord",
  data: {
    workRecordEmployeeId: 69,
    workRecordCreateDate: new Date().getTime() // Unix time
  }
});

whms.get({
  method: "getEmployees",
  data: {
    employeeShowDisabled: true
  }
});

whms.get({
  method: "getEmployeesByCondition"
  data: {
    employeeIdSearch: "",
    employeeNameSearch: ""
  }
});

```

Post data to work hour management system

```ts
import whms from "whms";

whms.post({
  method: "addWorkRecord",
  data: {
    workRecordList: [], // Array<WorkRecord> length should be 8
  },
});
```

Generate Work Record List

```ts
import whms, { Employee, WorkRecord } from "whms";

const employee: Employee = {
  id: 69,
  code: "",
  name: "John Doe",
  account: "johndoe",
  password: "password",
  tel: "123-45678",
  ext: "234",
  email: "johndoe@example.com",
  enabled: true,
};

const wrList: WorkRecord[] = whms.generateWorkReocrd({
  employee: employee, // employee object
  projectId: 10, // project index
  content: "This is a content.",
  createDate: 0, // unix time
});
console.log(wrList.length); // print 8
```

## Upload Config

```js
{
  id: 69,
  employeeAccount: "johndoe", // [optional] `employeeaccount` is your account not usernmae
  projectCode: "C000",
  content: "This is a content",

  // date format: "yyyy-MM-dd" or "yyyy/MM/dd"
  dateStart: "2021-09-06",
  dateEnd: "2021-09-08",
  passHoliday: true,
  exclude: ["2021-09-07"]
}
```

---
_Source: https://npm.io/package/whms · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
