Skip to content

Commit

Permalink
chore(create-access): get app sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis committed Oct 27, 2023
1 parent 6f5cf0b commit 6cfc1ae
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions functions/lib/enivix/create-access.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
const createAxios = require('./create-axios')
const auth = require('./create-auth')
const admin = require('firebase-admin')
const { setup } = require('@ecomplus/application-sdk')

const getAppSdk = () => {
return new Promise(resolve => {
setup(null, true, admin.firestore())
.then(appSdk => resolve(appSdk))
})
}

const firestoreColl = 'enivix_tokens'
module.exports = function (apikey, token, email, storeId) {
Expand All @@ -23,6 +32,7 @@ module.exports = function (apikey, token, email, storeId) {
auth(apikey, token, email, storeId)
.then(async (data) => {
console.log('> Enivix token => ', data.token)
const appSdk = await getAppSdk(admin)
await appSdk.apiApp(storeId, 'hidden_data', 'PATCH', { tokenProd: data.token }).catch(console.error)
authenticate()
if (documentRef) {
Expand Down

0 comments on commit 6cfc1ae

Please sign in to comment.