Skip to content

Commit

Permalink
Merge pull request #7 from dhurley94/main
Browse files Browse the repository at this point in the history
Make insertDataOption and valueInputOption an argument and fix
  • Loading branch information
johnkhansrc authored Jul 26, 2024
2 parents 5d74ca9 + 6013535 commit 5a20c8d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/google-sheet-connector.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,15 @@ export class GoogleSheetConnectorService{
*/
async writeRange(spreadsheetId: string,
range: string,
values: any[][]): GaxiosPromise<sheets_v4.Schema$UpdateValuesResponse> {
values: any[][],
valueInputOption = 'USER_ENTERED'): GaxiosPromise<sheets_v4.Schema$UpdateValuesResponse> {

const sheets = this.getGoogleSheetConnect()

return await sheets.spreadsheets.values.update({
spreadsheetId,
range,
valueInputOption: 'USER_ENTERED',
valueInputOption,
requestBody: {
values
}
Expand Down Expand Up @@ -205,14 +206,15 @@ export class GoogleSheetConnectorService{
*/
async addRow(spreadsheetId: string,
range: string,
values: any[][]): GaxiosPromise<sheets_v4.Schema$AppendValuesResponse> {
values: any[][],
valueInputOption = 'USER_ENTERED'): GaxiosPromise<sheets_v4.Schema$AppendValuesResponse> {

const sheets = this.getGoogleSheetConnect()

return await sheets.spreadsheets.values.append({
spreadsheetId,
range,
valueInputOption: 'USER_ENTER',
valueInputOption,
requestBody: {
values
}
Expand Down Expand Up @@ -354,16 +356,16 @@ export class GoogleSheetConnectorService{
});
}

async appendRow(spreedsheatId, sheet, rows) {
async appendRow(spreedsheatId, sheet, rows, valueInputOption = 'USER_ENTERED', insertDataOption = 'INSERT_ROWS') {
// Initialize request parameters
const request = {
spreadsheetId: spreedsheatId,
range: `${sheet.properties.title}`,
resource: {
values: rows,
},
valueInputOption: 'USER_ENTERED',
insertDataOption: 'INSERT_ROWS',
valueInputOption,
insertDataOption,
};

return await this.getGoogleSheetConnect().spreadsheets.values.append(request);
Expand Down

0 comments on commit 5a20c8d

Please sign in to comment.