This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.ThaiPostWebHook = functions.region(REGION).https.onRequest((req, res) => { | |
console.log('Start Webhook'); | |
res.status(200).send("OK").end(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let params = { | |
"status": "all", | |
"language": "TH", | |
"barcode": [ | |
code | |
] | |
}; | |
let promise_track = new Promise(resolve => { | |
var options = { | |
method: 'POST', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let promise_token = new Promise(resolve => { | |
var options = { | |
method: 'POST', | |
uri: 'https://trackwebhook.thailandpost.co.th/post/api/v1/authenticate/token', | |
strictSSL: false, | |
headers: { | |
'Content-Type': 'application/json', | |
'Authorization': 'Token ' + config.thaipost.token | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const REGION = 'asia-northeast1'; | |
const functions = require('firebase-functions'); | |
const request = require('request-promise'); | |
const LINE_MESSAGING_API = 'https://api.line.me/v2/bot/message'; | |
const LINE_HEADER = { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer xxxxx` | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const REGION = 'asia-northeast1'; | |
const functions = require('firebase-functions'); | |
const request = require('request-promise'); | |
const LINE_MESSAGING_API = 'https://api.line.me/v2/bot/message'; | |
const LINE_HEADER = { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer xxxxx` | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.ThaiPostWebHook = functions.region(REGION).https.onRequest((req, res) => { | |
console.log('Start Webhook'); | |
push_update_status(req); | |
res.status(200).send("OK").end(); | |
}); | |
const push_update_status = (req) => { | |
return request({ | |
method: `POST`, | |
uri: `${LINE_MESSAGING_API}/broadcast`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const REGION = 'asia-northeast1'; | |
const functions = require('firebase-functions'); | |
const request = require('request-promise'); | |
const LINE_MESSAGING_API = 'https://api.line.me/v2/bot/message'; | |
const LINE_HEADER = { | |
'Content-Type': 'application/json', | |
'Authorization': `Bearer xxxxx` | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const region = 'asia-northeast1'; | |
const runtimeOpts = { | |
timeoutSeconds: 10, | |
memory: "2GB" | |
}; | |
const functions = require('firebase-functions'); | |
const request = require("request-promise"); | |
const querystring = require('querystring'); | |
const admin = require('firebase-admin'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const region = 'asia-northeast1'; | |
const runtimeOpts = { | |
timeoutSeconds: 10, | |
memory: "2GB" | |
}; | |
const functions = require('firebase-functions'); | |
const request = require("request-promise"); | |
const querystring = require('querystring'); | |
const admin = require('firebase-admin'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const issue_access_token = async() => { | |
let params = { | |
grant_type: 'client_credentials', | |
client_id: CHANNEL_ID, | |
client_secret: CHANNEL_SECRET | |
}; | |
let formData = querystring.stringify(params); | |
let contentLength = formData.length; |