1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2024-11-24 08:52:18 +02:00

Преобразование OPI -> OInt (workflow)

This commit is contained in:
Vitaly the Alpaca 2024-06-07 21:29:10 +00:00 committed by Vitaly the Alpaca (bot)
parent dd8c97945f
commit afc567a92b
5 changed files with 174 additions and 174 deletions

View File

@ -38,19 +38,19 @@
#Region Public
#Region BooksManagment
#Region SpreadsheetsManagment
// CreateBook
// Creates a new book
// Create spreadsheet
// Creates a new spreadsheet
//
// Parameters:
// Token - String - Token - token
// Name - String - Name - title
// ArrayOfSheetNames - Array of String - Array of names to add new sheets to the book - sheets
// ArrayOfSheetNames - Array of String - Array of names to add new sheets to the spreadsheet - sheets
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function CreateBook(Val Token, Val Name, Val ArrayOfSheetNames) Export
Function CreateSpreadsheet(Val Token, Val Name, Val ArrayOfSheetNames) Export
OPI_TypeConversion.GetLine(Name);
OPI_TypeConversion.GetCollection(ArrayOfSheetNames);
@ -73,16 +73,16 @@ Function CreateBook(Val Token, Val Name, Val ArrayOfSheetNames) Export
EndFunction
// GetBook
// Gets information about the book by ID
// Get spreadsheet
// Gets information about the spreadsheet by ID
//
// Parameters:
// Token - String - Token - token
// Identifier - String - BookIdentifier - spreadsheet
// Identifier - String - Spreadsheet identifier - spreadsheet
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function GetBook(Val Token, Val Identifier) Export
Function GetSpreadsheet(Val Token, Val Identifier) Export
OPI_TypeConversion.GetLine(Identifier);
@ -95,23 +95,23 @@ Function GetBook(Val Token, Val Identifier) Export
EndFunction
// ChangeBookName
// Changes the name of the existing book
// Change spreadsheet name
// Changes the name of the existing spreadsheet
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// Spreadsheet - String - SpreadsheetID - spreadsheet
// Name - String - New name - title
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function EditBookTitle(Val Token, Val Book, Val Name) Export
Function EditSpreadsheetTitle(Val Token, Val Spreadsheet, Val Name) Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetLine(Name);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + ":batchUpdate";
Change = New Structure("title", Name);
ChangeRequest = New Structure("properties,fields", Change, "title");
@ -133,22 +133,22 @@ EndFunction
#Region WorkingWithSheets
// AddSheet
// Adds a new sheet to the book
// Adds a new sheet to the spreadsheet
//
//
// Parameters:
// Token - String - Token - token
// Book - String - BookIdentifier - spreadsheet
// Spreadsheet - String - Spreadsheet identifier - spreadsheet
// Name - String - NewSheetName - title
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function AddSheet(Val Token, Val Book, Val Name) Export
Function AddSheet(Val Token, Val Spreadsheet, Val Name) Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + ":batchUpdate";
Sheet = CreateSheet(Name);
Requests = New Array;
@ -164,22 +164,22 @@ Function AddSheet(Val Token, Val Book, Val Name) Export
EndFunction
// DeleteSheet
// Deletes a sheet from the book
// Deletes a sheet from the spreadsheet
//
// Parameters:
// Token - String - Token - token
// Book - String - BookIdentifier - spreadsheet
// Spreadsheet - String - Spreadsheet identifier - spreadsheet
// Sheet - String - IdentifierOfSheetToDelete - sheet
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function DeleteSheet(Val Token, Val Book, Val Sheet) Export
Function DeleteSheet(Val Token, Val Spreadsheet, Val Sheet) Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetLine(Sheet);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + ":batchUpdate";
Requests = New Array;
Sheet = New Structure("sheetId" , Sheet);
@ -195,12 +195,12 @@ Function DeleteSheet(Val Token, Val Book, Val Sheet) Export
EndFunction
// CopySheet
// Copies a sheet from one book to another
// Copies a sheet from one spreadsheet to another
//
// Parameters:
// Token - String - Token - token
// From - String - SourceBookID - from
// Target - String - DestinationBookID - to
// From - String - Source spreadsheet ID - from
// Target - String - Destination spreadsheet ID - to
// Sheet - String - CopiedSheetID - sheet
//
// Returns:
@ -234,7 +234,7 @@ EndFunction
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// Spreadsheet - String - SpreadsheetID - spreadsheet
// ValueMapping - Map Of KeyAndValue - Fill data where the key is the cell name like A1 - data
// Sheet - String - Sheet name (first sheet by default) - sheetname
// MajorDimension - String - Main dimension when filling the array range - dim
@ -242,12 +242,12 @@ EndFunction
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function SetCellValues(Val Token
, Val Book
, Val Spreadsheet
, Val ValueMapping
, Val Sheet = ""
, Val MajorDimension = "COLUMNS") Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetCollection(ValueMapping);
If Not TypeOf(ValueMapping) = Type("Structure")
@ -256,7 +256,7 @@ Function SetCellValues(Val Token
EndIf;
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + "/values:batchUpdate";
DataArray = FormCellDataArray(ValueMapping, MajorDimension, Sheet);
Parameters = New Structure("data,valueInputOption", DataArray, "USER_ENTERED");
@ -271,19 +271,19 @@ EndFunction
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// Spreadsheet - String - SpreadsheetID - spreadsheet
// CellsArray - Array of String - Array of cells like A1 to be cleared - cells
// Sheet - String - Sheet name (first sheet by default) - sheetname
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function ClearCells(Val Token, Val Book, Val CellsArray, Val Sheet = "") Export
Function ClearCells(Val Token, Val Spreadsheet, Val CellsArray, Val Sheet = "") Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetCollection(CellsArray);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchClear";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + "/values:batchClear";
FormCellNameArray(CellsArray, Sheet);
@ -299,18 +299,18 @@ EndFunction
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// CellsArray - Array of String - Array of A1-type cells to get (whole sheet if not filled) - cells
// Spreadsheet - String - SpreadsheetID - spreadsheet
// CellsArray - Array of String - Array of A1 type cells to get (whole sheet if not filled) - cells
// Sheet - String - Sheet name (first sheet by default) - sheetname
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function GetCellValues(Val Token, Val Book, Val CellsArray = "", Val Sheet = "") Export
Function GetCellValues(Val Token, Val Spreadsheet, Val CellsArray = "", Val Sheet = "") Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchGet";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + "/values:batchGet";
If ValueIsFilled(CellsArray) Then
OPI_TypeConversion.GetCollection(CellsArray);

View File

@ -1935,9 +1935,9 @@ Procedure GT_CreateTable() Export
SheetArray.Add("Sheet1");
SheetArray.Add("Sheet2");
Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray);
Result = OPI_GoogleSheets.CreateSpreadsheet(Token, Name, SheetArray);
OPI_TestDataRetrieval.WriteLog(Result, "CreateBook");
OPI_TestDataRetrieval.WriteLog(Result, "CreateSpreadsheet");
OPI_TestDataRetrieval.ExpectsThat(Result["properties"]["title"]).Равно(Name);
@ -1950,19 +1950,19 @@ Procedure GT_CreateTable() Export
EndDo;
Book = Result["spreadsheetId"];
Spreadsheet = Result["spreadsheetId"];
OPI_TestDataRetrieval.WriteParameter("GS_Spreadsheet", Book);
OPI_TestDataRetrieval.WriteParameter("GS_Spreadsheet", Spreadsheet);
OPI_TestDataRetrieval.WriteParameter("GS_Sheet" , Sheet);
Name = "Test table (new.)";
Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray);
Result = OPI_GoogleSheets.CreateSpreadsheet(Token, Name, SheetArray);
OPI_TestDataRetrieval.WriteLog(Result, "CopySheet (new.)");
Book2 = Result["spreadsheetId"];
Spreadsheet2 = Result["spreadsheetId"];
Result = OPI_GoogleSheets.CopySheet(Token, Book, Book2, Sheet);
Result = OPI_GoogleSheets.CopySheet(Token, Spreadsheet, Spreadsheet2, Sheet);
OPI_TestDataRetrieval.WriteLog(Result, "CopySheet");
@ -1970,38 +1970,38 @@ Procedure GT_CreateTable() Export
Name = "TestSheet";
Result = OPI_GoogleSheets.AddSheet(Token, Book, Name);
Result = OPI_GoogleSheets.AddSheet(Token, Spreadsheet, Name);
OPI_TestDataRetrieval.WriteLog(Result, "AddSheet");
NewSheet = Result["replies"][0]["addSheet"]["properties"]["sheetId"];
NewSheet = OPI_Tools.NumberToString(NewSheet);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
Result = OPI_GoogleSheets.DeleteSheet(Token, Book, NewSheet);
Result = OPI_GoogleSheets.DeleteSheet(Token, Spreadsheet, NewSheet);
OPI_TestDataRetrieval.WriteLog(Result, "DeleteSheet");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
Name = "Test table (change.)";
Result = OPI_GoogleSheets.EditBookTitle(Token, Book, Name);
Result = OPI_GoogleSheets.EditSpreadsheetTitle(Token, Spreadsheet, Name);
OPI_TestDataRetrieval.WriteLog(Result, "EditBookTitle");
OPI_TestDataRetrieval.WriteLog(Result, "EditSpreadsheetTitle");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
EndProcedure
Procedure GT_GetTable() Export
Token = OPI_TestDataRetrieval.GetParameter("Google_Token");
Book = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Spreadsheet = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Name = "Test table (change.)";
Result = OPI_GoogleSheets.GetBook(Token, Book);
Result = OPI_GoogleSheets.GetSpreadsheet(Token, Spreadsheet);
OPI_TestDataRetrieval.WriteLog(Result, "GetTable");
@ -2012,7 +2012,7 @@ EndProcedure
Procedure GT_FillClearCells() Export
Token = OPI_TestDataRetrieval.GetParameter("Google_Token");
Book = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Spreadsheet = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Sheet = "Sheet2";
CellStructure = New Map;
@ -2030,36 +2030,36 @@ Procedure GT_FillClearCells() Export
CellsArray.Add("A3");
CellsArray.Add("B4");
Result = OPI_GoogleSheets.SetCellValues(Token, Book, CellStructure, Sheet);
Result = OPI_GoogleSheets.SetCellValues(Token, Spreadsheet, CellStructure, Sheet);
OPI_TestDataRetrieval.WriteLog(Result, "SetCellValues");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
OPI_TestDataRetrieval.ExpectsThat(Result["totalUpdatedCells"]).Равно(CellStructure.Count());
Result = OPI_GoogleSheets.GetCellValues(Token, Book, CellsArray, Sheet);
Result = OPI_GoogleSheets.GetCellValues(Token, Spreadsheet, CellsArray, Sheet);
OPI_TestDataRetrieval.WriteLog(Result, "GetCellValues");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
OPI_TestDataRetrieval.ExpectsThat(Result["valueRanges"].Count()).Равно(CellsArray.Count());
Result = OPI_GoogleSheets.GetCellValues(Token, Book, , Sheet);
Result = OPI_GoogleSheets.GetCellValues(Token, Spreadsheet, , Sheet);
OPI_TestDataRetrieval.WriteLog(Result, "GetCellValues");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
CellsArray = New Array;
CellsArray.Add("B2");
CellsArray.Add("A3");
CellsArray.Add("B4");
Result = OPI_GoogleSheets.ClearCells(Token, Book, CellsArray, Sheet);
Result = OPI_GoogleSheets.ClearCells(Token, Spreadsheet, CellsArray, Sheet);
OPI_TestDataRetrieval.WriteLog(Result, "ClearCells");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
OPI_TestDataRetrieval.ExpectsThat(Result["clearedRanges"].Count()).Равно(CellsArray.Count());
EndProcedure

View File

@ -38,19 +38,19 @@
#Region Public
#Region BooksManagment
#Region SpreadsheetsManagment
// CreateBook
// Creates a new book
// Create spreadsheet
// Creates a new spreadsheet
//
// Parameters:
// Token - String - Token - token
// Name - String - Name - title
// ArrayOfSheetNames - Array of String - Array of names to add new sheets to the book - sheets
// ArrayOfSheetNames - Array of String - Array of names to add new sheets to the spreadsheet - sheets
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function CreateBook(Val Token, Val Name, Val ArrayOfSheetNames) Export
Function CreateSpreadsheet(Val Token, Val Name, Val ArrayOfSheetNames) Export
OPI_TypeConversion.GetLine(Name);
OPI_TypeConversion.GetCollection(ArrayOfSheetNames);
@ -73,16 +73,16 @@ Function CreateBook(Val Token, Val Name, Val ArrayOfSheetNames) Export
EndFunction
// GetBook
// Gets information about the book by ID
// Get spreadsheet
// Gets information about the spreadsheet by ID
//
// Parameters:
// Token - String - Token - token
// Identifier - String - BookIdentifier - spreadsheet
// Identifier - String - Spreadsheet identifier - spreadsheet
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function GetBook(Val Token, Val Identifier) Export
Function GetSpreadsheet(Val Token, Val Identifier) Export
OPI_TypeConversion.GetLine(Identifier);
@ -95,23 +95,23 @@ Function GetBook(Val Token, Val Identifier) Export
EndFunction
// ChangeBookName
// Changes the name of the existing book
// Change spreadsheet name
// Changes the name of the existing spreadsheet
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// Spreadsheet - String - SpreadsheetID - spreadsheet
// Name - String - New name - title
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function EditBookTitle(Val Token, Val Book, Val Name) Export
Function EditSpreadsheetTitle(Val Token, Val Spreadsheet, Val Name) Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetLine(Name);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + ":batchUpdate";
Change = New Structure("title", Name);
ChangeRequest = New Structure("properties,fields", Change, "title");
@ -133,22 +133,22 @@ EndFunction
#Region WorkingWithSheets
// AddSheet
// Adds a new sheet to the book
// Adds a new sheet to the spreadsheet
//
//
// Parameters:
// Token - String - Token - token
// Book - String - BookIdentifier - spreadsheet
// Spreadsheet - String - Spreadsheet identifier - spreadsheet
// Name - String - NewSheetName - title
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function AddSheet(Val Token, Val Book, Val Name) Export
Function AddSheet(Val Token, Val Spreadsheet, Val Name) Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + ":batchUpdate";
Sheet = CreateSheet(Name);
Requests = New Array;
@ -164,22 +164,22 @@ Function AddSheet(Val Token, Val Book, Val Name) Export
EndFunction
// DeleteSheet
// Deletes a sheet from the book
// Deletes a sheet from the spreadsheet
//
// Parameters:
// Token - String - Token - token
// Book - String - BookIdentifier - spreadsheet
// Spreadsheet - String - Spreadsheet identifier - spreadsheet
// Sheet - String - IdentifierOfSheetToDelete - sheet
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function DeleteSheet(Val Token, Val Book, Val Sheet) Export
Function DeleteSheet(Val Token, Val Spreadsheet, Val Sheet) Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetLine(Sheet);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + ":batchUpdate";
Requests = New Array;
Sheet = New Structure("sheetId" , Sheet);
@ -195,12 +195,12 @@ Function DeleteSheet(Val Token, Val Book, Val Sheet) Export
EndFunction
// CopySheet
// Copies a sheet from one book to another
// Copies a sheet from one spreadsheet to another
//
// Parameters:
// Token - String - Token - token
// From - String - SourceBookID - from
// Target - String - DestinationBookID - to
// From - String - Source spreadsheet ID - from
// Target - String - Destination spreadsheet ID - to
// Sheet - String - CopiedSheetID - sheet
//
// Returns:
@ -234,7 +234,7 @@ EndFunction
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// Spreadsheet - String - SpreadsheetID - spreadsheet
// ValueMapping - Map Of KeyAndValue - Fill data where the key is the cell name like A1 - data
// Sheet - String - Sheet name (first sheet by default) - sheetname
// MajorDimension - String - Main dimension when filling the array range - dim
@ -242,12 +242,12 @@ EndFunction
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function SetCellValues(Val Token
, Val Book
, Val Spreadsheet
, Val ValueMapping
, Val Sheet = ""
, Val MajorDimension = "COLUMNS") Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetCollection(ValueMapping);
If Not TypeOf(ValueMapping) = Type("Structure")
@ -256,7 +256,7 @@ Function SetCellValues(Val Token
EndIf;
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchUpdate";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + "/values:batchUpdate";
DataArray = FormCellDataArray(ValueMapping, MajorDimension, Sheet);
Parameters = New Structure("data,valueInputOption", DataArray, "USER_ENTERED");
@ -271,19 +271,19 @@ EndFunction
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// Spreadsheet - String - SpreadsheetID - spreadsheet
// CellsArray - Array of String - Array of cells like A1 to be cleared - cells
// Sheet - String - Sheet name (first sheet by default) - sheetname
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function ClearCells(Val Token, Val Book, Val CellsArray, Val Sheet = "") Export
Function ClearCells(Val Token, Val Spreadsheet, Val CellsArray, Val Sheet = "") Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
OPI_TypeConversion.GetCollection(CellsArray);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchClear";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + "/values:batchClear";
FormCellNameArray(CellsArray, Sheet);
@ -299,18 +299,18 @@ EndFunction
//
// Parameters:
// Token - String - Token - token
// Book - String - BookID - spreadsheet
// CellsArray - Array of String - Array of A1-type cells to get (whole sheet if not filled) - cells
// Spreadsheet - String - SpreadsheetID - spreadsheet
// CellsArray - Array of String - Array of A1 type cells to get (whole sheet if not filled) - cells
// Sheet - String - Sheet name (first sheet by default) - sheetname
//
// Returns:
// Map Of KeyAndValue - serialized JSON response from Google
Function GetCellValues(Val Token, Val Book, Val CellsArray = "", Val Sheet = "") Export
Function GetCellValues(Val Token, Val Spreadsheet, Val CellsArray = "", Val Sheet = "") Export
OPI_TypeConversion.GetLine(Book);
OPI_TypeConversion.GetLine(Spreadsheet);
Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token);
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchGet";
URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Spreadsheet + "/values:batchGet";
If ValueIsFilled(CellsArray) Then
OPI_TypeConversion.GetCollection(CellsArray);

View File

@ -1935,9 +1935,9 @@ Procedure GT_CreateTable() Export
SheetArray.Add("Sheet1");
SheetArray.Add("Sheet2");
Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray);
Result = OPI_GoogleSheets.CreateSpreadsheet(Token, Name, SheetArray);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "CreateBook");
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "CreateSpreadsheet");
OPI_TestDataRetrieval.ExpectsThat(Result["properties"]["title"]).Равно(Name);
@ -1950,19 +1950,19 @@ Procedure GT_CreateTable() Export
EndDo;
Book = Result["spreadsheetId"];
Spreadsheet = Result["spreadsheetId"];
OPI_TestDataRetrieval.WriteParameter("GS_Spreadsheet", Book);
OPI_TestDataRetrieval.WriteParameter("GS_Spreadsheet", Spreadsheet);
OPI_TestDataRetrieval.WriteParameter("GS_Sheet" , Sheet);
Name = "Test table (new.)";
Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray);
Result = OPI_GoogleSheets.CreateSpreadsheet(Token, Name, SheetArray);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "CopySheet (new.)");
Book2 = Result["spreadsheetId"];
Spreadsheet2 = Result["spreadsheetId"];
Result = OPI_GoogleSheets.CopySheet(Token, Book, Book2, Sheet);
Result = OPI_GoogleSheets.CopySheet(Token, Spreadsheet, Spreadsheet2, Sheet);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "CopySheet");
@ -1970,38 +1970,38 @@ Procedure GT_CreateTable() Export
Name = "TestSheet";
Result = OPI_GoogleSheets.AddSheet(Token, Book, Name);
Result = OPI_GoogleSheets.AddSheet(Token, Spreadsheet, Name);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "AddSheet");
NewSheet = Result["replies"][0]["addSheet"]["properties"]["sheetId"];
NewSheet = OPI_Tools.NumberToString(NewSheet);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
Result = OPI_GoogleSheets.DeleteSheet(Token, Book, NewSheet);
Result = OPI_GoogleSheets.DeleteSheet(Token, Spreadsheet, NewSheet);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "DeleteSheet");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
Name = "Test table (change.)";
Result = OPI_GoogleSheets.EditBookTitle(Token, Book, Name);
Result = OPI_GoogleSheets.EditSpreadsheetTitle(Token, Spreadsheet, Name);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "EditBookTitle");
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "EditSpreadsheetTitle");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
EndProcedure
Procedure GT_GetTable() Export
Token = OPI_TestDataRetrieval.GetParameter("Google_Token");
Book = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Spreadsheet = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Name = "Test table (change.)";
Result = OPI_GoogleSheets.GetBook(Token, Book);
Result = OPI_GoogleSheets.GetSpreadsheet(Token, Spreadsheet);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "GetTable");
@ -2012,7 +2012,7 @@ EndProcedure
Procedure GT_FillClearCells() Export
Token = OPI_TestDataRetrieval.GetParameter("Google_Token");
Book = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Spreadsheet = OPI_TestDataRetrieval.GetParameter("GS_Spreadsheet");
Sheet = "Sheet2";
CellStructure = New Map;
@ -2030,36 +2030,36 @@ Procedure GT_FillClearCells() Export
CellsArray.Add("A3");
CellsArray.Add("B4");
Result = OPI_GoogleSheets.SetCellValues(Token, Book, CellStructure, Sheet);
Result = OPI_GoogleSheets.SetCellValues(Token, Spreadsheet, CellStructure, Sheet);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "SetCellValues");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
OPI_TestDataRetrieval.ExpectsThat(Result["totalUpdatedCells"]).Равно(CellStructure.Count());
Result = OPI_GoogleSheets.GetCellValues(Token, Book, CellsArray, Sheet);
Result = OPI_GoogleSheets.GetCellValues(Token, Spreadsheet, CellsArray, Sheet);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "GetCellValues");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
OPI_TestDataRetrieval.ExpectsThat(Result["valueRanges"].Count()).Равно(CellsArray.Count());
Result = OPI_GoogleSheets.GetCellValues(Token, Book, , Sheet);
Result = OPI_GoogleSheets.GetCellValues(Token, Spreadsheet, , Sheet);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "GetCellValues");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
CellsArray = New Array;
CellsArray.Add("B2");
CellsArray.Add("A3");
CellsArray.Add("B4");
Result = OPI_GoogleSheets.ClearCells(Token, Book, CellsArray, Sheet);
Result = OPI_GoogleSheets.ClearCells(Token, Spreadsheet, CellsArray, Sheet);
// !OInt OPI_TestDataRetrieval.WriteLog(Result, "ClearCells");
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Book);
OPI_TestDataRetrieval.ExpectsThat(Result["spreadsheetId"]).Равно(Spreadsheet);
OPI_TestDataRetrieval.ExpectsThat(Result["clearedRanges"].Count()).Равно(CellsArray.Count());
EndProcedure

View File

@ -13,84 +13,84 @@
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "CreateBook";
NewLine.МетодПоиска = "CREATEBOOK";
NewLine.Метод = "CreateSpreadsheet";
NewLine.МетодПоиска = "CREATESPREADSHEET";
NewLine.Параметр = "--token";
NewLine.Описание = "Token";
NewLine.Область = "Books managment";
NewLine.ОписаниеМетода = "Creates a new book";
NewLine.Область = "Spreadsheets managment";
NewLine.ОписаниеМетода = "Creates a new spreadsheet";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "CreateBook";
NewLine.МетодПоиска = "CREATEBOOK";
NewLine.Метод = "CreateSpreadsheet";
NewLine.МетодПоиска = "CREATESPREADSHEET";
NewLine.Параметр = "--title";
NewLine.Описание = "Name";
NewLine.Область = "Books managment";
NewLine.Область = "Spreadsheets managment";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "CreateBook";
NewLine.МетодПоиска = "CREATEBOOK";
NewLine.Метод = "CreateSpreadsheet";
NewLine.МетодПоиска = "CREATESPREADSHEET";
NewLine.Параметр = "--sheets";
NewLine.Описание = "Array of names to add new sheets to the book";
NewLine.Область = "Books managment";
NewLine.Описание = "Array of names to add new sheets to the spreadsheet";
NewLine.Область = "Spreadsheets managment";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "GetBook";
NewLine.МетодПоиска = "GETBOOK";
NewLine.Метод = "GetSpreadsheet";
NewLine.МетодПоиска = "GETSPREADSHEET";
NewLine.Параметр = "--token";
NewLine.Описание = "Token";
NewLine.Область = "Books managment";
NewLine.ОписаниеМетода = "Gets information about the book by ID";
NewLine.Область = "Spreadsheets managment";
NewLine.ОписаниеМетода = "Gets information about the spreadsheet by ID";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "GetBook";
NewLine.МетодПоиска = "GETBOOK";
NewLine.Метод = "GetSpreadsheet";
NewLine.МетодПоиска = "GETSPREADSHEET";
NewLine.Параметр = "--spreadsheet";
NewLine.Описание = "BookIdentifier";
NewLine.Область = "Books managment";
NewLine.Описание = "Spreadsheet identifier";
NewLine.Область = "Spreadsheets managment";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "EditBookTitle";
NewLine.МетодПоиска = "EDITBOOKTITLE";
NewLine.Метод = "EditSpreadsheetTitle";
NewLine.МетодПоиска = "EDITSPREADSHEETTITLE";
NewLine.Параметр = "--token";
NewLine.Описание = "Token";
NewLine.Область = "Books managment";
NewLine.ОписаниеМетода = "Changes the name of the existing book";
NewLine.Область = "Spreadsheets managment";
NewLine.ОписаниеМетода = "Changes the name of the existing spreadsheet";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "EditBookTitle";
NewLine.МетодПоиска = "EDITBOOKTITLE";
NewLine.Метод = "EditSpreadsheetTitle";
NewLine.МетодПоиска = "EDITSPREADSHEETTITLE";
NewLine.Параметр = "--spreadsheet";
NewLine.Описание = "BookID";
NewLine.Область = "Books managment";
NewLine.Описание = "SpreadsheetID";
NewLine.Область = "Spreadsheets managment";
NewLine = CompositionTable.Add();
NewLine.Библиотека = "gsheets";
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "EditBookTitle";
NewLine.МетодПоиска = "EDITBOOKTITLE";
NewLine.Метод = "EditSpreadsheetTitle";
NewLine.МетодПоиска = "EDITSPREADSHEETTITLE";
NewLine.Параметр = "--title";
NewLine.Описание = "New name";
NewLine.Область = "Books managment";
NewLine.Область = "Spreadsheets managment";
NewLine = CompositionTable.Add();
@ -101,7 +101,7 @@
NewLine.Параметр = "--token";
NewLine.Описание = "Token";
NewLine.Область = "Working with sheets";
NewLine.ОписаниеМетода = "Adds a new sheet to the book";
NewLine.ОписаниеМетода = "Adds a new sheet to the spreadsheet";
NewLine = CompositionTable.Add();
@ -110,7 +110,7 @@
NewLine.Метод = "AddSheet";
NewLine.МетодПоиска = "ADDSHEET";
NewLine.Параметр = "--spreadsheet";
NewLine.Описание = "BookIdentifier";
NewLine.Описание = "Spreadsheet identifier";
NewLine.Область = "Working with sheets";
@ -132,7 +132,7 @@
NewLine.Параметр = "--token";
NewLine.Описание = "Token";
NewLine.Область = "Working with sheets";
NewLine.ОписаниеМетода = "Deletes a sheet from the book";
NewLine.ОписаниеМетода = "Deletes a sheet from the spreadsheet";
NewLine = CompositionTable.Add();
@ -141,7 +141,7 @@
NewLine.Метод = "DeleteSheet";
NewLine.МетодПоиска = "DELETESHEET";
NewLine.Параметр = "--spreadsheet";
NewLine.Описание = "BookIdentifier";
NewLine.Описание = "Spreadsheet identifier";
NewLine.Область = "Working with sheets";
@ -163,7 +163,7 @@
NewLine.Параметр = "--token";
NewLine.Описание = "Token";
NewLine.Область = "Working with sheets";
NewLine.ОписаниеМетода = "Copies a sheet from one book to another";
NewLine.ОписаниеМетода = "Copies a sheet from one spreadsheet to another";
NewLine = CompositionTable.Add();
@ -172,7 +172,7 @@
NewLine.Метод = "CopySheet";
NewLine.МетодПоиска = "COPYSHEET";
NewLine.Параметр = "--from";
NewLine.Описание = "SourceBookID";
NewLine.Описание = "Source spreadsheet ID";
NewLine.Область = "Working with sheets";
@ -182,7 +182,7 @@
NewLine.Метод = "CopySheet";
NewLine.МетодПоиска = "COPYSHEET";
NewLine.Параметр = "--to";
NewLine.Описание = "DestinationBookID";
NewLine.Описание = "Destination spreadsheet ID";
NewLine.Область = "Working with sheets";
@ -221,7 +221,7 @@
NewLine.Метод = "SetCellValues";
NewLine.МетодПоиска = "SETCELLVALUES";
NewLine.Параметр = "--spreadsheet";
NewLine.Описание = "BookID";
NewLine.Описание = "SpreadsheetID";
NewLine.Область = "Data managment";
@ -272,7 +272,7 @@
NewLine.Метод = "ClearCells";
NewLine.МетодПоиска = "CLEARCELLS";
NewLine.Параметр = "--spreadsheet";
NewLine.Описание = "BookID";
NewLine.Описание = "SpreadsheetID";
NewLine.Область = "Data managment";
@ -313,7 +313,7 @@
NewLine.Метод = "GetCellValues";
NewLine.МетодПоиска = "GETCELLVALUES";
NewLine.Параметр = "--spreadsheet";
NewLine.Описание = "BookID";
NewLine.Описание = "SpreadsheetID";
NewLine.Область = "Data managment";
@ -322,8 +322,8 @@
NewLine.Модуль = "OPI_GoogleSheets";
NewLine.Метод = "GetCellValues";
NewLine.МетодПоиска = "GETCELLVALUES";
NewLine.Параметр = "--type cells to get (whole sheet if not filled)";
NewLine.Описание = "cells (optional, def. val. - Empty)";
NewLine.Параметр = "--cells";
NewLine.Описание = "Array of A1 type cells to get (whole sheet if not filled) (optional, def. val. - Empty)";
NewLine.Область = "Data managment";