diff --git a/.gitignore b/.gitignore index 6704566..573a820 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# config +config.js + # Logs logs *.log diff --git a/README.md b/README.md index 1193dc1..445ec09 100644 --- a/README.md +++ b/README.md @@ -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? @@ -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=` or `_identity=` -6. open the file `execute.js` and change the variable `cookiesTalenta` to `PHPSESSID=` or `_identity=` +6. open the file `config.js` (copy from `config.js.tmpl`) and change the variable `cookiesTalenta` to `PHPSESSID=` or `_identity=` 6. and good news the cookie will last forever ### How to get Latitude and Longitude? @@ -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 @@ -49,4 +51,13 @@ or ``` yarn run clockout ``` -to clockout \ No newline at end of file +to clockout + +## Methods in module + +### Clock In / ClockOut +Functions: `clockIn` and `clockOut` +Parameters +``` +{ lat: '-6.000', long: '107.000', cookies: 'PHPSESSID=', desc: 'message' } +``` \ No newline at end of file diff --git a/config.js.tmpl b/config.js.tmpl new file mode 100644 index 0000000..c94b94c --- /dev/null +++ b/config.js.tmpl @@ -0,0 +1,7 @@ +// you can use the `_identity=` or `PHPSESSID=` cookie + +module.exports = { + cookiesTalenta: 'PHPSESSID=', + longitude: '107.000', + latitude: '-6.000', +} \ No newline at end of file diff --git a/execute.js b/execute.js index ce19c30..a24ef13 100644 --- a/execute.js +++ b/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' })); -} \ No newline at end of file +(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' })); + } +})(); \ No newline at end of file diff --git a/package.json b/package.json index 559e25a..2df7c46 100644 --- a/package.json +++ b/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": {