Skip to content

Commit

Permalink
Merge pull request #510 from ethereum/google-sheet-by-title
Browse files Browse the repository at this point in the history
Recipient's google sheet function: select working sheet by title
  • Loading branch information
samajammin authored Feb 11, 2022
2 parents 08adfa1 + b48c943 commit 9b2e10f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion vue-app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ VUE_APP_OPERATOR=
# Google Service Account credentials in JSON format
GOOGLE_APPLICATION_CREDENTIALS=
# Spreadsheet ID to send recipients data
VUE_APP_GOOGLE_SPREADSHEET_ID=
VUE_APP_GOOGLE_SPREADSHEET_ID=
# Select the sheet's name to write the data, by default 'Raw'
GOOGLE_SHEET_NAME=
4 changes: 3 additions & 1 deletion vue-app/src/lambda/recipient.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { GoogleSpreadsheet } from 'google-spreadsheet'

const GOOGLE_SHEET_NAME = process.env.GOOGLE_SHEET_NAME || 'Raw'

/**
* Creates an object row from a RecipientApplicationData. A row is a key-value
* object where the keys are composed by the concatenation of the nested keys.
Expand Down Expand Up @@ -52,7 +54,7 @@ exports.handler = async function (event) {
await doc.useServiceAccountAuth(creds)

await doc.loadInfo()
const sheet = doc.sheetsByIndex[0]
const sheet = doc.sheetsByTitle[GOOGLE_SHEET_NAME]
const row = recipientToRow(recipient)
await sheet.addRow(row)

Expand Down

0 comments on commit 9b2e10f

Please sign in to comment.