Skip to content

Commit

Permalink
Merge pull request #7 from ans-4175/feat/example
Browse files Browse the repository at this point in the history
feat(execute): separate config from app
  • Loading branch information
k1m0ch1 committed Oct 4, 2021
2 parents 6dfef85 + 6f286d6 commit a3a70e9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -1,3 +1,6 @@
# config
config.js

# Logs
logs
*.log
Expand Down
21 changes: 16 additions & 5 deletions README.md
Expand Up @@ -9,11 +9,13 @@ API HR Talenta for ClockIn and ClockOut, so you don't need to open the app and c
3. yarn

## Installation
Just run `yarn install`
Just run `yarn install` or `npm install`

## How to Run Program

At first you need to specify this three variable `Cookie`, `Latitude` and `Longitude`
At first you need to specify this three variable `Cookie`, `Latitude` and `Longitude`.
You could copy from `config.js.tmpl` to `config.js` then change it according your value.
Then you could run using script defined in `package.json`

### How to get Cookie?

Expand All @@ -24,7 +26,7 @@ At first you need to specify this three variable `Cookie`, `Latitude` and `Longi
![](img/get-cookie.png)
4. copy the value
5. prepare the value for program with `PHPSESSID=<value>` or `_identity=<value>`
6. open the file `execute.js` and change the variable `cookiesTalenta` to `PHPSESSID=<value>` or `_identity=<value>`
6. open the file `config.js` (copy from `config.js.tmpl`) and change the variable `cookiesTalenta` to `PHPSESSID=<value>` or `_identity=<value>`
6. and good news the cookie will last forever

### How to get Latitude and Longitude?
Expand All @@ -37,7 +39,7 @@ At first you need to specify this three variable `Cookie`, `Latitude` and `Longi
-6.861928521923624, 107.63578698474662
Latitude , Longitude
```
4. open the file `execute.js` and change the variable `latitude` and `longitude` following with the value copied from google map
4. open the file `config.js` (copy from `config.js.tmpl`) and change the variable `latitude` and `longitude` following with the value copied from google map

### Example to run the program

Expand All @@ -49,4 +51,13 @@ or
```
yarn run clockout
```
to clockout
to clockout

## Methods in module

### Clock In / ClockOut
Functions: `clockIn` and `clockOut`
Parameters
```
{ lat: '-6.000', long: '107.000', cookies: 'PHPSESSID=<value>', desc: 'message' }
```
7 changes: 7 additions & 0 deletions config.js.tmpl
@@ -0,0 +1,7 @@
// you can use the `_identity=` or `PHPSESSID=` cookie

module.exports = {
cookiesTalenta: 'PHPSESSID=<value>',
longitude: '107.000',
latitude: '-6.000',
}
20 changes: 9 additions & 11 deletions execute.js
@@ -1,12 +1,10 @@
const talenta = require("./index.js")
const talenta = require("./index");
const { cookiesTalenta, longitude, latitude } = require("./config");

// you can use the `_identity=` or `PHPSESSID=` cookie
const cookiesTalenta = "_identity=identityCookie"
const latitude = "-6.861928521923624"
const longitude = "107.63578698474662"

if(process.argv[2] == "clockin"){
console.log(talenta.clockIn({ lat: latitude, long: longitude, cookies: cookiesTalenta, desc: 'Talenta Clock In' }));
}else if(process.argv[2] == "clockout"){
console.log(talenta.clockOut({ lat: latitude, long: longitude, cookies: cookiesTalenta, desc: 'Talenta Clock In' }));
}
(async () => {
if (process.argv[2] == "clockin") {
console.log(await talenta.clockIn({ lat: latitude, long: longitude, cookies: cookiesTalenta, desc: 'Hello I am In' }));
} else if (process.argv[2] == "clockout") {
console.log(await talenta.clockOut({ lat: latitude, long: longitude, cookies: cookiesTalenta, desc: 'Goodbye I am Out' }));
}
})();
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "talenta-api",
"version": "1.0.0",
"version": "1.0.1",
"description": "API HR Talenta for ClockIn and ClockOut",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit a3a70e9

Please sign in to comment.