From 659d0bf3495d15da294c8b2b39330cb1154d8b72 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 1 Jun 2024 00:49:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B0=D0=B1=D1=83=D0=BB=D1=8F=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/os/opi_translate.os | 7 +- src/en/OPI/.project | 30 +- .../src/CommonModules/OPI_Airtable/Module.bsl | 680 +- .../OPI_Airtable/OPI_Airtable.mdo | 16 +- .../CommonModules/OPI_Cryptography/Module.bsl | 100 +- .../OPI_Cryptography/OPI_Cryptography.mdo | 16 +- .../src/CommonModules/OPI_Dropbox/Module.bsl | 1124 +-- .../CommonModules/OPI_Dropbox/OPI_Dropbox.mdo | 24 +- .../CommonModules/OPI_GetTestData/Module.bsl | 730 +- .../OPI_GetTestData/OPI_GetTestData.mdo | 16 +- .../OPI_GoogleCalendar/Module.bsl | 756 +- .../OPI_GoogleCalendar/OPI_GoogleCalendar.mdo | 16 +- .../CommonModules/OPI_GoogleDrive/Module.bsl | 984 +- .../OPI_GoogleDrive/OPI_GoogleDrive.mdo | 16 +- .../CommonModules/OPI_GoogleSheets/Module.bsl | 460 +- .../OPI_GoogleSheets/OPI_GoogleSheets.mdo | 16 +- .../OPI_GoogleWorkspace/Module.bsl | 172 +- .../OPI_GoogleWorkspace.mdo | 16 +- .../src/CommonModules/OPI_Notion/Module.bsl | 1194 +-- .../CommonModules/OPI_Notion/OPI_Notion.mdo | 16 +- .../src/CommonModules/OPI_Slack/Module.bsl | 1072 +-- .../src/CommonModules/OPI_Slack/OPI_Slack.mdo | 16 +- .../src/CommonModules/OPI_Telegram/Module.bsl | 1312 +-- .../OPI_Telegram/OPI_Telegram.mdo | 16 +- .../src/CommonModules/OPI_Tests/Module.bsl | 8560 ++++++++--------- .../src/CommonModules/OPI_Tests/OPI_Tests.mdo | 24 +- .../src/CommonModules/OPI_Tools/Module.bsl | 1762 ++-- .../src/CommonModules/OPI_Tools/OPI_Tools.mdo | 16 +- .../src/CommonModules/OPI_Twitter/Module.bsl | 948 +- .../CommonModules/OPI_Twitter/OPI_Twitter.mdo | 16 +- .../OPI_TypeConversion/Module.bsl | 506 +- .../OPI_TypeConversion/OPI_TypeConversion.mdo | 16 +- .../OPI/src/CommonModules/OPI_VK/Module.bsl | 2880 +++--- .../OPI/src/CommonModules/OPI_VK/OPI_VK.mdo | 16 +- .../src/CommonModules/OPI_Viber/Module.bsl | 432 +- .../src/CommonModules/OPI_Viber/OPI_Viber.mdo | 16 +- .../CommonModules/OPI_YandexDisk/Module.bsl | 784 +- .../OPI_YandexDisk/OPI_YandexDisk.mdo | 16 +- .../src/CommonModules/OPI_YandexID/Module.bsl | 86 +- .../OPI_YandexID/OPI_YandexID.mdo | 16 +- .../OPI/src/Configuration/Configuration.mdo | 134 +- .../OPI_Integrations/OPI_Integrations.mdo | 50 +- 42 files changed, 12544 insertions(+), 12539 deletions(-) diff --git a/.github/workflows/os/opi_translate.os b/.github/workflows/os/opi_translate.os index 153776b07f..691388b78d 100644 --- a/.github/workflows/os/opi_translate.os +++ b/.github/workflows/os/opi_translate.os @@ -111,11 +111,16 @@ ТекущаяСтрока = СокрЛП(ДокументМодуля.ПолучитьСтроку(Н)); + Если Не ЗначениеЗаполнено(ТекущаяСтрока) Тогда + Продолжить; + КонецЕсли; + Пока СтрНайти(ТекущаяСтрока, " ") <> 0 Цикл ТекущаяСтрока = СтрЗаменить(ТекущаяСтрока, " ", " "); КонецЦикла; - ДокументМодуля.ЗаменитьСтроку(Н, ТекущаяСтрока); + ВыводимаяСтрока = СтрЗаменить(ДокументМодуля.ПолучитьСтроку(Н), СокрЛП(ДокументМодуля.ПолучитьСтроку(Н)), ТекущаяСтрока); + ДокументМодуля.ЗаменитьСтроку(Н, ВыводимаяСтрока); КонецЦикла; diff --git a/src/en/OPI/.project b/src/en/OPI/.project index 244711fc30..5b6683c1ce 100644 --- a/src/en/OPI/.project +++ b/src/en/OPI/.project @@ -1,18 +1,18 @@  -OPI - - - - - -org.eclipse.xtext.ui.shared.xtextBuilder - - - - - -org.eclipse.xtext.ui.shared.xtextNature -com._1c.g5.v8.dt.core.V8ExtensionNature - + OPI + + + + + + org.eclipse.xtext.ui.shared.xtextBuilder + + + + + + org.eclipse.xtext.ui.shared.xtextNature + com._1c.g5.v8.dt.core.V8ExtensionNature + diff --git a/src/en/OPI/src/CommonModules/OPI_Airtable/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Airtable/Module.bsl index 864dc2411b..ec521e6e02 100644 --- a/src/en/OPI/src/CommonModules/OPI_Airtable/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Airtable/Module.bsl @@ -37,92 +37,92 @@ // Get list of bases // Gets the list of available bases -// +// // Parameters: // Token - String - Token - token // Indent - String - Next page identifier of the base list from the previous request - offset -// +// // Return value: -// Key-Value Pair - serialized JSON response from Airtable +// Key-Value Pair - serialized JSON response from Airtable Function GetListOfBases(Val Token, Val Indent = "") Export - -OPI_TypeConversion.GetLine(Indent); - -URL = "https://api.airtable.com/v0/meta/bases"; -Headers = GetAuthorizationHeader(Token); -Parameters = New Structure; - -OPI_Tools.AddField("offset", Indent, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Indent); + + URL = "https://api.airtable.com/v0/meta/bases"; + Headers = GetAuthorizationHeader(Token); + Parameters = New Structure; + + OPI_Tools.AddField("offset", Indent, "String", Parameters); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Get base tables // Gets the schema of base tables -// +// // Parameters: // Token - String - Token - token // Base - String - Base identifier - base -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function GetDatabaseTables(Val Token, Val Base) Export - -OPI_TypeConversion.GetLine(Base); - -URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables"; -Headers = GetAuthorizationHeader(Token); - -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Base); + + URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables"; + Headers = GetAuthorizationHeader(Token); + + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; + EndFunction // Create base // Creates a new database -// +// // Parameters: // Token - String - Token - token // Workspace - String - Workspace identifier - ws // Name - String - New base name - title // TableCollection - Key-Value Pair - Table description: Key > name, Value > array of fields - tablesdata -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function CreateDatabase(Val Token, Val Workspace, Val Name, Val TableCollection) Export - -OPI_TypeConversion.GetCollection(TableCollection); - -If Not TypeValue(TableCollection) = Type("Structure") -And Not TypeValue(TableCollection) = Type("Match") Then - -Raise "Error in table collection data"; - -EndIf; - -URL = "https://api.airtable.com/v0/meta/bases"; -Headers = GetAuthorizationHeader(Token); -TableArray = New Array; - -For Each Table In TableCollection Do - -Description = GenerateTableDescription(Table.Key, Table.Value); -TableArray.Add(Description); - -EndDo; - -Parameters = New Structure; -OPI_Tools.AddField("name" , Name , "String", Parameters); -OPI_Tools.AddField("tables" , TableArray , "Array", Parameters); -OPI_Tools.AddField("workspaceId", Workspace, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetCollection(TableCollection); + + If Not TypeValue(TableCollection) = Type("Structure") + And Not TypeValue(TableCollection) = Type("Match") Then + + Raise "Error in table collection data"; + + EndIf; + + URL = "https://api.airtable.com/v0/meta/bases"; + Headers = GetAuthorizationHeader(Token); + TableArray = New Array; + + For Each Table In TableCollection Do + + Description = GenerateTableDescription(Table.Key, Table.Value); + TableArray.Add(Description); + + EndDo; + + Parameters = New Structure; + OPI_Tools.AddField("name" , Name , "String", Parameters); + OPI_Tools.AddField("tables" , TableArray , "Array", Parameters); + OPI_Tools.AddField("workspaceId", Workspace, "String", Parameters); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction @@ -132,57 +132,57 @@ EndFunction // Create table // Creates a new table in the base -// +// // Parameters: // Token - String - Token - token // Base - String - Base identifier - base // Name - String - New table name - title // FieldArray - Array of Structures - Array of field descriptions - fieldsdata // Description - String - Table description - description -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function CreateTable(Val Token, Val Base, Val Name, Val FieldArray, Val Description = "") Export - -OPI_TypeConversion.GetLine(Base); - -URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables"; -Headers = GetAuthorizationHeader(Token); -Parameters = GenerateTableDescription(Name, FieldArray, Description); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Base); + + URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables"; + Headers = GetAuthorizationHeader(Token); + Parameters = GenerateTableDescription(Name, FieldArray, Description); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Modify table // Changes the name and/or description of the base -// +// // Parameters: // Token - String - Token - token // Base - String - Base identifier - base // Table - String - Table identifier - table // Name - String - New name - title // Description - String - New description - description -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function ModifyTable(Val Token, Val Base, Val Table, Val Name = "", Val Description = "") Export - -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); - -URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables/" + Table; -Headers = GetAuthorizationHeader(Token); -Parameters = New Structure; - -OPI_Tools.AddField("name" , Name, "String", Parameters); -OPI_Tools.AddField("description", Description , "String", Parameters); - -Response = OPI_Tools.Patch(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + + URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables/" + Table; + Headers = GetAuthorizationHeader(Token); + Parameters = New Structure; + + OPI_Tools.AddField("name" , Name, "String", Parameters); + OPI_Tools.AddField("description", Description , "String", Parameters); + + Response = OPI_Tools.Patch(URL, Parameters, Headers); + + Return Response; EndFunction @@ -192,40 +192,40 @@ EndFunction // Create field // Creates a new field in the table -// +// // Parameters: // Token - String - Token - token // Base - String - Base identifier - base // Table - String - Table identifier - table // FieldStructure - Structure of Key-Value - Description of the new field - fielddata -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function CreateField(Val Token, Val Base, Val Table, Val FieldStructure) Export - -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetCollection(FieldStructure); - -If Not TypeValue(FieldStructure) = Type("Structure") -And Not TypeValue(FieldStructure) = Type("Match") Then - -Raise "Error in field description data"; - -EndIf; - -URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables/" + Table + "/fields"; -Headers = GetAuthorizationHeader(Token); - -Response = OPI_Tools.Post(URL, FieldStructure, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetCollection(FieldStructure); + + If Not TypeValue(FieldStructure) = Type("Structure") + And Not TypeValue(FieldStructure) = Type("Match") Then + + Raise "Error in field description data"; + + EndIf; + + URL = "https://api.airtable.com/v0/meta/bases/" + Base + "/tables/" + Table + "/fields"; + Headers = GetAuthorizationHeader(Token); + + Response = OPI_Tools.Post(URL, FieldStructure, Headers); + + Return Response; EndFunction // Modify field // Changes the name and/or description of an existing table field -// +// // Parameters: // Token - String - Token - token // Base - String - Base identifier Base - base @@ -233,142 +233,142 @@ EndFunction // Field - String - Field identifier - field // Name - String - New name - title // Description - String - New description - description -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function ModifyField(Val Token, Val Base, Val Table, Val Field, Val Name = "", Val Description = "") Export - -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetLine(Field); - -URL = "https://api.airtable.com/v0/meta/bases/" -+ Base -+ "/tables/" -+ Table -+ "/fields/" -+ Field; - -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure(); -OPI_Tools.AddField("name" , Name, "String", Parameters); -OPI_Tools.AddField("description", Description , "String", Parameters); - -Response = OPI_Tools.Patch(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetLine(Field); + + URL = "https://api.airtable.com/v0/meta/bases/" + + Base + + "/tables/" + + Table + + "/fields/" + + Field; + + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure(); + OPI_Tools.AddField("name" , Name, "String", Parameters); + OPI_Tools.AddField("description", Description , "String", Parameters); + + Response = OPI_Tools.Patch(URL, Parameters, Headers); + + Return Response; EndFunction // Get поле (withтроtoоinое) // Gets the description of a string field -// +// // Parameters: // Name - String - New field name - title -// +// // Return value: // Structure - Field description Function GetStringField(Val Name) Export -Return PrimitiveFieldDescription(Name, "richText"); + Return PrimitiveFieldDescription(Name, "richText"); EndFunction // Get поле (чиwithлоinое) // Gets the description of a numeric field -// +// // Parameters: // Name - String - New field name - title // Precision - Number, String - Number of decimal places - precision -// +// // Return value: // Structure - Field description Function GetNumberField(Val Name, Val Precision = 0) Export - -OPI_TypeConversion.GetNumber(Precision); - -OptionsStructure = New Structure("precision", Precision); -Return PrimitiveFieldDescription(Name, "number", OptionsStructure); - + + OPI_TypeConversion.GetNumber(Precision); + + OptionsStructure = New Structure("precision", Precision); + Return PrimitiveFieldDescription(Name, "number", OptionsStructure); + EndFunction // Get поле (file) // Gets the description of a file field -// +// // Parameters: // Name - String - Field name - title -// +// // Return value: // Structure - Field description Function GetAttachmentField(Val Name) Export -Return PrimitiveFieldDescription(Name, "multipleAttachments"); + Return PrimitiveFieldDescription(Name, "multipleAttachments"); EndFunction // Get поле (флажоto) // Gets the description of a boolean field -// +// // Parameters: // Name - String - Field name - title -// +// // Return value: // Structure - Field description Function GetCheckboxField(Val Name) Export - -OptionsStructure = New Structure("icon,color", "check", "yellowBright"); -Return PrimitiveFieldDescription(Name, "checkbox", OptionsStructure); - + + OptionsStructure = New Structure("icon,color", "check", "yellowBright"); + Return PrimitiveFieldDescription(Name, "checkbox", OptionsStructure); + EndFunction // Get поле (dата) // Gets the description of a date field -// +// // Parameters: // Name - String - Field name - title -// +// // Return value: // Structure - Field description Function GetDateField(Val Name) Export - -FormatStructure = New Structure("format,name", "YYYY-MM-DD", "iso"); -OptionsStructure = New Structure("dateFormat", FormatStructure); - -Return PrimitiveFieldDescription(Name, "date", OptionsStructure); - + + FormatStructure = New Structure("format,name", "YYYY-MM-DD", "iso"); + OptionsStructure = New Structure("dateFormat", FormatStructure); + + Return PrimitiveFieldDescription(Name, "date", OptionsStructure); + EndFunction // Get поле (email) // Gets the description of an email field -// +// // Parameters: // Name - String - Field name - title -// +// // Return value: // Structure - Field description Function GetEmailField(Val Name) Export -Return PrimitiveFieldDescription(Name, "email"); + Return PrimitiveFieldDescription(Name, "email"); EndFunction // Get поле (телефон) // Gets the description of a phone number field -// +// // Parameters: // Name - String - Field name - title -// +// // Return value: // Structure - Field description Function GetPhoneField(Val Name) Export -Return PrimitiveFieldDescription(Name, "phoneNumber"); + Return PrimitiveFieldDescription(Name, "phoneNumber"); EndFunction // Get поле (url) // Gets the description of a URL field -// +// // Parameters: // Name - String - Field name - title -// +// // Return value: // Structure - Field description Function GetLinkField(Val Name) Export -Return PrimitiveFieldDescription(Name, "url"); + Return PrimitiveFieldDescription(Name, "url"); EndFunction #EndRegion @@ -377,120 +377,120 @@ EndFunction // Get list of records // Gets the list of records of the selected table -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base // Table - String - Table identifier - table // Indent - String - Next page identifier of data from the previous request - offset -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function GetListOfRecords(Val Token, Val Base, Val Table, Val Indent = "") Export -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure(); -OPI_Tools.AddField("offset", Indent, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + + URL = "https://api.airtable.com/v0/" + Base + "/" + Table; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure(); + OPI_Tools.AddField("offset", Indent, "String", Parameters); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Get record // Gets row data of the table by identifier -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base // Table - String - Table identifier - table // Record - String - Record identifier in the table - record -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function GetRecord(Val Token, Val Base, Val Table, Val Record) Export + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetLine(Record); + + URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record; + Headers = GetAuthorizationHeader(Token); -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetLine(Record); - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record; -Headers = GetAuthorizationHeader(Token); - -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; - + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; + EndFunction // Create records // Creates one or an array of records by description or an array of field value descriptions -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base // Table - String - Table identifier - table // Data - Structure, Array of Structures - Set or array of sets of Key : Value pairs > Field : Indicator - data -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function CreatePosts(Val Token, Val Base, Val Table, Val Data) Export -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetCollection(Data); + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetCollection(Data); + + Parameters = New Structure(); + AddDataDescription(Data, Parameters); -Parameters = New Structure(); -AddDataDescription(Data, Parameters); - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table; -Headers = GetAuthorizationHeader(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + URL = "https://api.airtable.com/v0/" + Base + "/" + Table; + Headers = GetAuthorizationHeader(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Delete records // Deletes one or an array of records by identifiers -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base // Table - String - Table identifier - table // Records - String, Array of Strings - Identifier or array of record identifiers - records -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function DeletePosts(Val Token, Val Base, Val Table, Val Records) Export + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetArray(Records); + + RecordString = ""; + + For Each Record In Records Do + RecordString = RecordString + + ?(ValueIsFilled(RecordString), "&", "?") + + "records[]=" + + OPI_Tools.NumberToString(Record); + EndDo; + + URL = "https://api.airtable.com/v0/" + Base + "/" + Table + RecordString; + Headers = GetAuthorizationHeader(Token); -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetArray(Records); - -RecordString = ""; - -For Each Record In Records Do -RecordString = RecordString -+ ?(ValueIsFilled(RecordString), "&", "?") -+ "records[]=" -+ OPI_Tools.NumberToString(Record); -EndDo; - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table + RecordString; -Headers = GetAuthorizationHeader(Token); - -Response = OPI_Tools.Delete(URL, , Headers); - -Return Response; - + Response = OPI_Tools.Delete(URL, , Headers); + + Return Response; + EndFunction #EndRegion @@ -499,67 +499,67 @@ EndFunction // Get comments // Gets the list of comments for a record in the table -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base // Table - String - Table identifier - table // Record - String - Record identifier in the table - record // Indent - String - Next page identifier of data from the previous request - offset -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function GetComments(Val Token, Val Base, Val Table, Val Record, Val Indent = "") Export - -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetLine(Record); - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure(); -OPI_Tools.AddField("offset", Indent, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetLine(Record); + + URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure(); + OPI_Tools.AddField("offset", Indent, "String", Parameters); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Create comment // Creates a comment for a record in the table -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base // Table - String - Table identifier - table // Record - String - Record identifier in the table - record // Text - String - Comment text - text -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function CreateComment(Val Token, Val Base, Val Table, Val Record, Val Text) Export - -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetLine(Record); - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure(); -OPI_Tools.AddField("text", Text, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetLine(Record); + + URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure(); + OPI_Tools.AddField("text", Text, "String", Parameters); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Modify comment // Changes the text of an existing comment -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base @@ -567,54 +567,54 @@ EndFunction // Record - String - Record identifier in the table - record // Comment - String - Comment identifier - comment // Text - String - New comment text - text -// +// // Return value: // Key-Value Pair - serialized JSON response from Airtable Function EditComment(Val Token, Val Base, Val Table, Val Record, Val Comment, Val Text) Export - -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetLine(Record); -OPI_TypeConversion.GetLine(Comment); - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments/" + Comment; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure(); -OPI_Tools.AddField("text", Text, "String", Parameters); - -Response = OPI_Tools.Patch(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetLine(Record); + OPI_TypeConversion.GetLine(Comment); + + URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments/" + Comment; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure(); + OPI_Tools.AddField("text", Text, "String", Parameters); + + Response = OPI_Tools.Patch(URL, Parameters, Headers); + + Return Response; + EndFunction // Delete comment // Deletes a comment for a table record -// +// // Parameters: // Token - String - Token - token // Base - String - Database identifier - base // Table - String - Table identifier - table // Record - String - Record identifier in the table - record // Comment - String - Comment identifier - comment -// +// // Return value: -// Key-Value Pair - serialized JSON response from Airtable +// Key-Value Pair - serialized JSON response from Airtable Function DeleteComment(Val Token, Val Base, Val Table, Val Record, Val Comment) Export -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Table); -OPI_TypeConversion.GetLine(Record); -OPI_TypeConversion.GetLine(Comment); - -URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments/" + Comment; -Headers = GetAuthorizationHeader(Token); - -Response = OPI_Tools.Delete(URL, , Headers); - -Return Response; - + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Table); + OPI_TypeConversion.GetLine(Record); + OPI_TypeConversion.GetLine(Comment); + + URL = "https://api.airtable.com/v0/" + Base + "/" + Table + "/" + Record + "/comments/" + Comment; + Headers = GetAuthorizationHeader(Token); + + Response = OPI_Tools.Delete(URL, , Headers); + + Return Response; + EndFunction #EndRegion @@ -624,58 +624,58 @@ EndFunction #Region ServiceProceduresAndFunctions Function GetAuthorizationHeader(Val Token) - -OPI_TypeConversion.GetLine(Token); - -Headers = New Match; -Headers.Insert("Authorization", "Bearer " + Token); - -Return Headers; - + + OPI_TypeConversion.GetLine(Token); + + Headers = New Match; + Headers.Insert("Authorization", "Bearer " + Token); + + Return Headers; + EndFunction Function GenerateTableDescription(Val Name, Val FieldArray, Val Description = "") - -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetCollection(FieldArray); - -TableDescription = New Structure("name,fields", Name, FieldArray); - -OPI_Tools.AddField("description", Description, "String", TableDescription); - -Return TableDescription; - + + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetCollection(FieldArray); + + TableDescription = New Structure("name,fields", Name, FieldArray); + + OPI_Tools.AddField("description", Description, "String", TableDescription); + + Return TableDescription; + EndFunction Function PrimitiveFieldDescription(Val Name, Val Type, Val Options = "") - -FieldStructure = New Structure(); -OPI_Tools.AddField("name" , Name, "String" , FieldStructure); -OPI_Tools.AddField("type" , Type , "String" , FieldStructure); -OPI_Tools.AddField("options", Options , "Collection", FieldStructure); - -Return FieldStructure; + + FieldStructure = New Structure(); + OPI_Tools.AddField("name" , Name, "String" , FieldStructure); + OPI_Tools.AddField("type" , Type , "String" , FieldStructure); + OPI_Tools.AddField("options", Options , "Collection", FieldStructure); + + Return FieldStructure; EndFunction Procedure AddDataDescription(Val Data, Parameters) - -If TypeValue(Data) = Type("Array") Then - -SendArray = New Array; - -For Each RecordDescription In Data Do -SendArray.Add(New Structure("fields", RecordDescription)); -EndDo; - -OPI_Tools.AddField("records", SendArray, "Array", Parameters); - -Else - -OPI_Tools.AddField("fields", Data, "Collection", Parameters); - -EndIf; - + + If TypeValue(Data) = Type("Array") Then + + SendArray = New Array; + + For Each RecordDescription In Data Do + SendArray.Add(New Structure("fields", RecordDescription)); + EndDo; + + OPI_Tools.AddField("records", SendArray, "Array", Parameters); + + Else + + OPI_Tools.AddField("fields", Data, "Collection", Parameters); + + EndIf; + EndProcedure #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Airtable/OPI_Airtable.mdo b/src/en/OPI/src/CommonModules/OPI_Airtable/OPI_Airtable.mdo index 2941163208..a1ecfa6d68 100644 --- a/src/en/OPI/src/CommonModules/OPI_Airtable/OPI_Airtable.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Airtable/OPI_Airtable.mdo @@ -1,11 +1,11 @@  -OPI_Airtable - - -OPI airtable - -true -true -true + OPI_Airtable + + + OPI airtable + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Cryptography/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Cryptography/Module.bsl index 05ff6bd421..a8586b49ca 100644 --- a/src/en/OPI/src/CommonModules/OPI_Cryptography/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Cryptography/Module.bsl @@ -34,75 +34,75 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2019, LLC 1C-Soft -// All rights reserved. This program and accompanying materials are provided +// All rights reserved. This program and accompanying materials are provided // in withоотinетwithтinии with уwithлоinиями лицензии Attribution 4.0 International (CC BY 4.0) // License text available at: // https://creativecommons.org/licenses/by/4.0/legalcode /////////////////////////////////////////////////////////////////////////////////////////////////////// Function HMACSHA256(Val Key, Val Data) Export - -Return HMAC(Key, Data, HashFunction.SHA256, 64); - + + Return HMAC(Key, Data, HashFunction.SHA256, 64); + EndFunction Function Hash(BinaryData, Type) Export - -Hashing = New DataHashing(Type); -Hashing.Add(BinaryData); - -Return Hashing.HashSum; - + + Hashing = New DataHashing(Type); + Hashing.Add(BinaryData); + + Return Hashing.HashSum; + EndFunction Function HMAC(Val Key, Val Data, Type, BlockSize) Export - -Twice = 2; - -If Key.Size() > BlockSize Then -Key = Hash(Key, Type); -EndIf; - -If Key.Size() <= BlockSize Then -Key = GetHexStringFromBinaryData(Key); -Key = Left(Key + RepeatString("00", BlockSize), BlockSize * Twice); -EndIf; - -Key = GetBinaryDataBufferFromBinaryData(GetBinaryDataFromHexString(Key)); - -Ipad = GetBinaryDataBufferFromHexString(RepeatString("36", BlockSize)); -Opad = GetBinaryDataBufferFromHexString(RepeatString("5c", BlockSize)); - -Ipad.WriteBitwiseExclusiveOr(0, Key); -Ikeypad = GetBinaryDataFromBinaryDataBuffer(ipad); - -Opad.WriteBitwiseExclusiveOr(0, Key); -Okeypad = GetBinaryDataFromBinaryDataBuffer(opad); - -Return Hash(ConcatenateBinaryData(okeypad, Hash(ConcatenateBinaryData(ikeypad, Data), Type)), Type); - + + Twice = 2; + + If Key.Size() > BlockSize Then + Key = Hash(Key, Type); + EndIf; + + If Key.Size() <= BlockSize Then + Key = GetHexStringFromBinaryData(Key); + Key = Left(Key + RepeatString("00", BlockSize), BlockSize * Twice); + EndIf; + + Key = GetBinaryDataBufferFromBinaryData(GetBinaryDataFromHexString(Key)); + + Ipad = GetBinaryDataBufferFromHexString(RepeatString("36", BlockSize)); + Opad = GetBinaryDataBufferFromHexString(RepeatString("5c", BlockSize)); + + Ipad.WriteBitwiseExclusiveOr(0, Key); + Ikeypad = GetBinaryDataFromBinaryDataBuffer(ipad); + + Opad.WriteBitwiseExclusiveOr(0, Key); + Okeypad = GetBinaryDataFromBinaryDataBuffer(opad); + + Return Hash(ConcatenateBinaryData(okeypad, Hash(ConcatenateBinaryData(ikeypad, Data), Type)), Type); + EndFunction Function ConcatenateBinaryData(BinaryData1, BinaryData2) Export - -BinaryDataArray = New Array; -BinaryDataArray.Add(BinaryData1); -BinaryDataArray.Add(BinaryData2); - -Return JoinBinaryData(BinaryDataArray); - + + BinaryDataArray = New Array; + BinaryDataArray.Add(BinaryData1); + BinaryDataArray.Add(BinaryData2); + + Return JoinBinaryData(BinaryDataArray); + EndFunction Function RepeatString(String, Quantity) Export + + Parts = New Array(Quantity); + + For To = 1 For Quantity Do + Parts.Add(String); + EndDo; -Parts = New Array(Quantity); - -For To = 1 For Quantity Do -Parts.Add(String); -EndDo; - -Return StrJoin(Parts, ""); - + Return StrJoin(Parts, ""); + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Cryptography/OPI_Cryptography.mdo b/src/en/OPI/src/CommonModules/OPI_Cryptography/OPI_Cryptography.mdo index df230a86fd..c8cd120ec4 100644 --- a/src/en/OPI/src/CommonModules/OPI_Cryptography/OPI_Cryptography.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Cryptography/OPI_Cryptography.mdo @@ -1,11 +1,11 @@  -OPI_Cryptography - -ru -Toриптография (OPI) - -true -true -true + OPI_Cryptography + + ru + Toриптография (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Dropbox/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Dropbox/Module.bsl index 920366021e..01f29be9a2 100644 --- a/src/en/OPI/src/CommonModules/OPI_Dropbox/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Dropbox/Module.bsl @@ -37,128 +37,128 @@ // Get authorization link // Generates an authorization link for browser transition -// +// // Parameters: // AppKey - String - Application key - appkey -// +// // Return value: // String - URL for browser transition Function GetAuthorizationLink(Val AppKey) Export - -OPI_TypeConversion.GetLine(AppKey); -Return "https://www.dropbox.com/oauth2/authorize?client_id=" -+ AppKey -+ "&response_type=code&token_access_type=offline"; - + + OPI_TypeConversion.GetLine(AppKey); + Return "https://www.dropbox.com/oauth2/authorize?client_id=" + + AppKey + + "&response_type=code&token_access_type=offline"; + EndFunction // Get token // Gets token based on the code from the GetAuthorizationLink page -// +// // Parameters: // AppKey - String - Application key - appkey // AppSecret - String - Application secret - appsecret // Code - String - Code from the authorization page - code -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function GetToken(Val AppKey, Val AppSecret, Val Code) Export + + URL = "https://api.dropbox.com/oauth2/token"; + DataType = "application/x-www-form-urlencoded; charset=utf-8"; + + Parameters = New Structure; + OPI_Tools.AddField("code" , Code , "String", Parameters); + OPI_Tools.AddField("grant_type", "authorization_code", "String", Parameters); + + URLStructure = OPI_Tools.SplitURL(URL); + Server = URLStructure["Server"]; + Address = URLStructure["Address"]; + + Request = OPI_Tools.CreateRequest(Address, , DataType); + Connection = OPI_Tools.CreateConnection(Server, AppKey, AppSecret); -URL = "https://api.dropbox.com/oauth2/token"; -DataType = "application/x-www-form-urlencoded; charset=utf-8"; - -Parameters = New Structure; -OPI_Tools.AddField("code" , Code , "String", Parameters); -OPI_Tools.AddField("grant_type", "authorization_code", "String", Parameters); - -URLStructure = OPI_Tools.SplitURL(URL); -Server = URLStructure["Server"]; -Address = URLStructure["Address"]; - -Request = OPI_Tools.CreateRequest(Address, , DataType); -Connection = OPI_Tools.CreateConnection(Server, AppKey, AppSecret); - -ParameterString = OPI_Tools.RequestParametersToString(Parameters); -Data = Right(ParameterString, StrLength(ParameterString) - 1); - -Request.SetBodyFromString(Data); - -Response = Connection.CallHTTPMethod("POST", Request); -OPI_Tools.ProcessResponse(Response); - -Return Response; + ParameterString = OPI_Tools.RequestParametersToString(Parameters); + Data = Right(ParameterString, StrLength(ParameterString) - 1); + Request.SetBodyFromString(Data); + + Response = Connection.CallHTTPMethod("POST", Request); + OPI_Tools.ProcessResponse(Response); + + Return Response; + EndFunction // Refresh token // Gets a new token based on the refresh token -// +// // Parameters: // AppKey - String - Application key - appkey // AppSecret - String - Application secret - appsecret // RefreshToken - String - Refresh token - refresh -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function RefreshToken(Val AppKey, Val AppSecret, Val RefreshToken) Export - -String_ = "String"; -URL = "https://api.dropbox.com/oauth2/token"; - -Parameters = New Structure; -OPI_Tools.AddField("refresh_token", RefreshToken , String_, Parameters); -OPI_Tools.AddField("grant_type" , "refresh_token" , String_, Parameters); -OPI_Tools.AddField("client_id" , AppKey , String_, Parameters); -OPI_Tools.AddField("client_secret", AppSecret, String_, Parameters); - -Response = OPI_Tools.Post(URL, Parameters, , False); - -Return Response; - + + String_ = "String"; + URL = "https://api.dropbox.com/oauth2/token"; + + Parameters = New Structure; + OPI_Tools.AddField("refresh_token", RefreshToken , String_, Parameters); + OPI_Tools.AddField("grant_type" , "refresh_token" , String_, Parameters); + OPI_Tools.AddField("client_id" , AppKey , String_, Parameters); + OPI_Tools.AddField("client_secret", AppSecret, String_, Parameters); + + Response = OPI_Tools.Post(URL, Parameters, , False); + + Return Response; + EndFunction // Get account information // Gets account information -// +// // Parameters: // Token - String - Token - token // Account - String - Account ID. Current token account if not filled - account -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function GetAccountInformation(Val Token, Val Account = "") Export - -If ValueIsFilled(Account) Then -Result = GetAccount(Token, Account); -Else -Result = GetOwnAccount(Token); -EndIf; - -Return Result; - + + If ValueIsFilled(Account) Then + Result = GetAccount(Token, Account); + Else + Result = GetOwnAccount(Token); + EndIf; + + Return Result; + EndFunction // Get space usage data // Gets information on the amount of used disk space -// +// // Parameters: -// Token - String - Token - token -// +// Token - String - Token - token +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function GetSpaceUsageData(Val Token) Export - -URL = "https://api.dropboxapi.com/2/users/get_space_usage"; -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.PostBinary(URL -, GetBinaryDataFromString("null") -, Headers -, -, "text/plain; charset=dropbox-cors-hack"); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/users/get_space_usage"; + Headers = GetRequestHeaders(Token); + + Response = OPI_Tools.PostBinary(URL + , GetBinaryDataFromString("null") + , Headers + , + , "text/plain; charset=dropbox-cors-hack"); + + Return Response; + EndFunction #EndRegion @@ -167,344 +167,344 @@ EndFunction // Get object information // Gets information about a file or directory -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object - path -// Detailed - Boolean - Adds additional information fields for media files - detail -// +// Detailed - Boolean - Adds additional information fields for media files - detail +// // Return value: -// Key-Value Pair - serialized JSON response from Dropbox +// Key-Value Pair - serialized JSON response from Dropbox Function GetObjectInformation(Val Token, Val Path, Val Detailed = False) Export - -URL = "https://api.dropboxapi.com/2/files/get_metadata"; - -Parameters = New Structure; -OPI_Tools.AddField("path" , Path , "String", Parameters); -OPI_Tools.AddField("include_media_info", Detailed, "Boolean", Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/files/get_metadata"; + + Parameters = New Structure; + OPI_Tools.AddField("path" , Path , "String", Parameters); + OPI_Tools.AddField("include_media_info", Detailed, "Boolean", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Get list of folder files // Gets the list of the first files in the directory or continues getting the next ones when the cursor is specified -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the directory. Optional if the cursor is specified - path // Detailed - Boolean - Adds additional information fields for media files - detail // Cursor - String - Cursor from the previous request to get the next set of files - cursor -// +// // Return value: // HTTPResponse - Get list of folder files Function GetListOfFolderFiles(Val Token, Val Path = "", Val Detailed = False, Val Cursor = "") Export + + If Not ValueIsFilled(Cursor) Then + + URL = "https://api.dropboxapi.com/2/files/list_folder"; + + Parameters = New Structure; + OPI_Tools.AddField("path" , Path , "String", Parameters); + OPI_Tools.AddField("include_media_info", Detailed , "Boolean", Parameters); + + Else + + URL = "https://api.dropboxapi.com/2/files/list_folder/continue"; + + Parameters = New Structure; + OPI_Tools.AddField("cursor", Cursor, "String", Parameters); + + EndIf; + + Headers = GetRequestHeaders(Token); -If Not ValueIsFilled(Cursor) Then - -URL = "https://api.dropboxapi.com/2/files/list_folder"; - -Parameters = New Structure; -OPI_Tools.AddField("path" , Path , "String", Parameters); -OPI_Tools.AddField("include_media_info", Detailed , "Boolean", Parameters); - -Else - -URL = "https://api.dropboxapi.com/2/files/list_folder/continue"; - -Parameters = New Structure; -OPI_Tools.AddField("cursor", Cursor, "String", Parameters); - -EndIf; - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Get preview // Forлучает PDF or HTML преinью объеtoта (тольtoо for тоtoументоin) -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object - path -// +// // Return value: -// BinaryData - document preview +// BinaryData - document preview Function GetPreview(Val Token, Val Path) Export - -URL = "https://content.dropboxapi.com/2/files/get_preview"; -Response = ProcessObject(Token, URL, Path, True); - -Return Response; - + + URL = "https://content.dropboxapi.com/2/files/get_preview"; + Response = ProcessObject(Token, URL, Path, True); + + Return Response; + EndFunction // Upload file // Uploads a file to the cloud drive -// +// // Parameters: // Token - String - Token - token // File - String, BinaryData - Data file for upload - file // Path - String - Save path on Dropbox - path // Overwrite - Boolean - Overwrite file in case of path conflicts - overwrite -// +// // Return value: -// Key-Value Pair - serialized JSON response from Dropbox +// Key-Value Pair - serialized JSON response from Dropbox Function UploadFile(Val Token, Val File, Val Path, Val Overwrite = False) Export - -OPI_TypeConversion.GetBinaryData(File); -OPI_TypeConversion.GetBoolean(Overwrite); -OPI_TypeConversion.GetLine(Path); - -Mode = ?(Overwrite, "overwrite", "add"); -Size = File.Size(); -Boundary = 100000000; - -If Size > Border Then -Response = UploadLargeFile(Token, File, Path, Mode); -Else -Response = UploadSmallFile(Token, File, Path, Mode); -EndIf; - -Return Response; - + + OPI_TypeConversion.GetBinaryData(File); + OPI_TypeConversion.GetBoolean(Overwrite); + OPI_TypeConversion.GetLine(Path); + + Mode = ?(Overwrite, "overwrite", "add"); + Size = File.Size(); + Boundary = 100000000; + + If Size > Border Then + Response = UploadLargeFile(Token, File, Path, Mode); + Else + Response = UploadSmallFile(Token, File, Path, Mode); + EndIf; + + Return Response; + EndFunction // Upload file by URL -// Uploads a file to the cloud drive by fetching it from the specified URL -// +// Uploads a file to the cloud drive by fetching it from the specified URL +// // Parameters: // Token - String - Token - token // FileURL - String - URL source of the file - url // Path - String - Save path on Dropbox - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function UploadFileByURL(Val Token, Val FileURL, Val Path) Export - -URL = "https://api.dropboxapi.com/2/files/save_url"; - -Parameters = New Structure; -OPI_Tools.AddField("path", Path , "String", Parameters); -OPI_Tools.AddField("url" , FileURL , "String", Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/files/save_url"; + + Parameters = New Structure; + OPI_Tools.AddField("path", Path , "String", Parameters); + OPI_Tools.AddField("url" , FileURL , "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Get upload status by URL // Gets the upload status of the file by URL -// +// // Parameters: // Token - String - Token - token -// JobID - String - ID of the asynchronous job from the UploadFileByURL response - job -// +// JobID - String - ID of the asynchronous job from the UploadFileByURL response - job +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function GetUploadStatusByURL(Val Token, Val JobID) Export - -URL = "https://api.dropboxapi.com/2/files/save_url/check_job_status"; - -Parameters = New Structure; -OPI_Tools.AddField("async_job_id", JobID, "String", Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/files/save_url/check_job_status"; + + Parameters = New Structure; + OPI_Tools.AddField("async_job_id", JobID, "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Delete object // Deletes an object from the cloud drive -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object to delete - path // Irrecoverable - String - Delete object without the possibility of recovery - permanently -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function DeleteObject(Val Token, Val Path, Val Irretrievably = False) Export - -OPI_TypeConversion.GetBoolean(Irretrievably); - -If Irretrievably Then -URL = "https://api.dropboxapi.com/2/files/permanently_delete"; -Else -URL = "https://api.dropboxapi.com/2/files/delete_v2"; -EndIf; - -Response = ProcessObject(Token, URL, Path); - -Return Response; + + OPI_TypeConversion.GetBoolean(Irretrievably); + + If Irretrievably Then + URL = "https://api.dropboxapi.com/2/files/permanently_delete"; + Else + URL = "https://api.dropboxapi.com/2/files/delete_v2"; + EndIf; + + Response = ProcessObject(Token, URL, Path); + + Return Response; EndFunction // Copy object // Copies a file or directory to the selected path -// +// // Parameters: // Token - String - Token - token // From - String - Path to the original object - form // To - String - Target path for the new object - to -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function CopyObject(Val Token, Val From, Val To) Export + + URL = "https://api.dropboxapi.com/2/files/copy_v2"; + + Parameters = New Structure; + OPI_Tools.AddField("from_path", From, "String", Parameters); + OPI_Tools.AddField("to_path" , To , "String", Parameters); + + Headers = GetRequestHeaders(Token); -URL = "https://api.dropboxapi.com/2/files/copy_v2"; - -Parameters = New Structure; -OPI_Tools.AddField("from_path", From, "String", Parameters); -OPI_Tools.AddField("to_path" , To , "String", Parameters); - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Move object // Moves an object to the selected path -// +// // Parameters: // Token - String - Token - token // From - String - Path to the original object - form // To - String - Target path for the new object - to -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function MoveObject(Val Token, Val From, Val To) Export -URL = "https://api.dropboxapi.com/2/files/move_v2"; - -Parameters = New Structure; -OPI_Tools.AddField("from_path", From, "String", Parameters); -OPI_Tools.AddField("to_path" , To , "String", Parameters); - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + URL = "https://api.dropboxapi.com/2/files/move_v2"; + + Parameters = New Structure; + OPI_Tools.AddField("from_path", From, "String", Parameters); + OPI_Tools.AddField("to_path" , To , "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Create folder // Creates an empty directory at the selected path -// +// // Parameters: // Token - String - Token - token // Path - String - Target path for creating the directory - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function CreateFolder(Val Token, Val Path) Export - -URL = "https://api.dropboxapi.com/2/files/create_folder_v2"; -Response = ProcessObject(Token, URL, Path); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/files/create_folder_v2"; + Response = ProcessObject(Token, URL, Path); + + Return Response; + EndFunction // Download file // Downloads a file by the specified path or ID -// +// // Parameters: // Token - String - Token - token // Path - String - Path or ID of the file - path -// +// // Return value: // BinaryData - binary data of the file Function DownloadFile(Val Token, Val Path) Export - -URL = "https://content.dropboxapi.com/2/files/download"; -Response = ProcessObject(Token, URL, Path, True); - -Return Response; - + + URL = "https://content.dropboxapi.com/2/files/download"; + Response = ProcessObject(Token, URL, Path, True); + + Return Response; + EndFunction // Download folder // Downloads a zip archive with the contents of the specified directory -// +// // Parameters: // Token - String - Token - token // Path - String - Path or ID of the directory - path -// +// // Return value: // BinaryData - binary data of the zip archive with the contents of the directory Function DownloadFolder(Val Token, Val Path) Export - -URL = "https://content.dropboxapi.com/2/files/download_zip"; -Response = ProcessObject(Token, URL, Path, True); - -Return Response; - + + URL = "https://content.dropboxapi.com/2/files/download_zip"; + Response = ProcessObject(Token, URL, Path, True); + + Return Response; + EndFunction // Get list of object versions // Gets the list of versions (revisions) of the object -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object - path // Quantity - String, Number - Number of the latest versions of the object to display - amount -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function GetObjectVersionList(Val Token, Val Path, Val Quantity = 10) Export - -URL = "https://api.dropboxapi.com/2/files/list_revisions"; - -Parameters = New Structure; -OPI_Tools.AddField("path" , Path , "String", Parameters); -OPI_Tools.AddField("limit", Quantity, "Number" , Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/files/list_revisions"; + + Parameters = New Structure; + OPI_Tools.AddField("path" , Path , "String", Parameters); + OPI_Tools.AddField("limit", Quantity, "Number" , Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Restore object to version // Inоwithwithтаtoinлиinает withоwithтояние объеtoта to необхоdимой inерwithии (реinfromии) -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object - path // Version - String - ID of the version (revision) for restoration - rev -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function RestoreObjectToVersion(Val Token, Val Path, Val Version) Export - -URL = "https://api.dropboxapi.com/2/files/restore"; - -Parameters = New Structure; -OPI_Tools.AddField("path", Path , "String", Parameters); -OPI_Tools.AddField("rev" , Version, "String", Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/files/restore"; + + Parameters = New Structure; + OPI_Tools.AddField("path", Path , "String", Parameters); + OPI_Tools.AddField("rev" , Version, "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction #EndRegion @@ -513,58 +513,58 @@ EndFunction // Get list of tags // Gets the list of tags of the selected files -// +// // Parameters: // Token - String - Token - token // Paths - String, Array of Strings - Path or set of paths to the files - paths -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function GetTagList(Val Token, Val Paths) Export + + URL = "https://api.dropboxapi.com/2/files/tags/get"; + + Parameters = New Structure; + OPI_Tools.AddField("paths", Paths, "Array", Parameters); + + Headers = GetRequestHeaders(Token); -URL = "https://api.dropboxapi.com/2/files/tags/get"; - -Parameters = New Structure; -OPI_Tools.AddField("paths", Paths, "Array", Parameters); - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Add tag // Adds a new text tag to a file or directory -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object for which the tag needs to be created - path // Tag - String - Tag text - tag -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function AddTag(Val Token, Val Path, Val Tag) Export - -Return ProcessTag(Token, Path, Tag); - + + Return ProcessTag(Token, Path, Tag); + EndFunction // Delete tag // Deletes the text tag of a file or directory -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object whose tag needs to be deleted - path // Tag - String - Tag text - tag -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function DeleteTag(Val Token, Val Path, Val Tag) Export - -Return ProcessTag(Token, Path, Tag, True); - + + Return ProcessTag(Token, Path, Tag, True); + EndFunction #EndRegion @@ -573,195 +573,195 @@ EndFunction // Publish folder // Sets the directory to public access mode -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the target directory - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function PublishFolder(Val Token, Val Path) Export - -URL = "https://api.dropboxapi.com/2/sharing/share_folder"; -Response = ProcessObject(Token, URL, Path); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/sharing/share_folder"; + Response = ProcessObject(Token, URL, Path); + + Return Response; + EndFunction // Unpublish folder // Cancels the public access mode for the directory -// +// // Parameters: // Token - String - Token - token // FolderID - String - ID публичного directory (shared folder ID) - folder -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function CancelFolderPublication(Val Token, Val FolderID) Export + + URL = "https://api.dropboxapi.com/2/sharing/unshare_folder"; + + Parameters = New Structure; + OPI_Tools.AddField("shared_folder_id", FolderID, "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); -URL = "https://api.dropboxapi.com/2/sharing/unshare_folder"; - -Parameters = New Structure; -OPI_Tools.AddField("shared_folder_id", FolderID, "String", Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Return Response; EndFunction // Add user to file // Defines access to the file for an external user -// +// // Parameters: // Token - String - Token - token // FileID - String - ID of the file to be accessed - fileid // EmailAddresses - String, Array of Strings - List of email addresses of users being added - emails // ViewOnly - Boolean - Prohibits file editing for the external user - readonly -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function AddUsersToFile(Val Token, Val FileID, Val EmailAddresses, Val ViewOnly = True) Export + + String_ = "String"; + + OPI_TypeConversion.GetArray(EmailAddresses); + OPI_TypeConversion.GetLine(FileID); + OPI_TypeConversion.GetBoolean(ViewOnly); + + If Not StringStartsWith(FileID, "id:") Then + FileID = "id:" + FileID; + EndIf; + + URL = "https://api.dropboxapi.com/2/sharing/add_file_member"; + + ArrayOfUsers = New Array; + + For Each Address In EmailAddresses Do + + UserData = New Match; + OPI_Tools.AddField(".tag" , "email", String_, UserData); + OPI_Tools.AddField("email", Address , String_, UserData); + + ArrayOfUsers.Add(UserData); -String_ = "String"; - -OPI_TypeConversion.GetArray(EmailAddresses); -OPI_TypeConversion.GetLine(FileID); -OPI_TypeConversion.GetBoolean(ViewOnly); - -If Not StringStartsWith(FileID, "id:") Then -FileID = "id:" + FileID; -EndIf; - -URL = "https://api.dropboxapi.com/2/sharing/add_file_member"; - -ArrayOfUsers = New Array; - -For Each Address In EmailAddresses Do - -UserData = New Match; -OPI_Tools.AddField(".tag" , "email", String_, UserData); -OPI_Tools.AddField("email", Address , String_, UserData); - -ArrayOfUsers.Add(UserData); - -EndDo; - -Parameters = New Structure; -OPI_Tools.AddField("file" , FileID , String_, Parameters); -OPI_Tools.AddField("members", ArrayOfUsers , "Array", Parameters); - -Mode = ?(ViewOnly, "viewer", "editor"); - -OPI_Tools.AddField("access_level", Mode , String_, Parameters); - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + EndDo; + + Parameters = New Structure; + OPI_Tools.AddField("file" , FileID , String_, Parameters); + OPI_Tools.AddField("members", ArrayOfUsers , "Array", Parameters); + + Mode = ?(ViewOnly, "viewer", "editor"); + + OPI_Tools.AddField("access_level", Mode , String_, Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Add users to folder // Grants external users access to the directory -// +// // Parameters: // Token - String - Token - token // FolderID - String - ID публичного directory (shared folder ID) - folder // EmailAddresses - String, Array of Strings - List of email addresses of users being added - emails // ViewOnly - Boolean - Prohibits file editing for the external user - readonly -// +// // Return value: // Undefined - empty response Function AddUsersToFolder(Val Token, Val FolderID, Val EmailAddresses, Val ViewOnly = True) Export + + String_ = "String"; + + OPI_TypeConversion.GetArray(EmailAddresses); + OPI_TypeConversion.GetBoolean(ViewOnly); + Mode = ?(ViewOnly, "viewer", "editor"); + + URL = "https://api.dropboxapi.com/2/sharing/add_folder_member"; + + ArrayOfUsers = New Array; + + For Each Address In EmailAddresses Do + + UserData = New Match; + OPI_Tools.AddField(".tag" , "email", String_, UserData); + OPI_Tools.AddField("email", Address , String_, UserData); + + UserStructure = New Structure("member,access_level", UserData, Mode); + + ArrayOfUsers.Add(UserStructure); -String_ = "String"; + EndDo; + + Parameters = New Structure; + OPI_Tools.AddField("shared_folder_id", FolderID , String_, Parameters); + OPI_Tools.AddField("members" , ArrayOfUsers , "Array", Parameters); + + Headers = GetRequestHeaders(Token); -OPI_TypeConversion.GetArray(EmailAddresses); -OPI_TypeConversion.GetBoolean(ViewOnly); -Mode = ?(ViewOnly, "viewer", "editor"); - -URL = "https://api.dropboxapi.com/2/sharing/add_folder_member"; - -ArrayOfUsers = New Array; - -For Each Address In EmailAddresses Do - -UserData = New Match; -OPI_Tools.AddField(".tag" , "email", String_, UserData); -OPI_Tools.AddField("email", Address , String_, UserData); - -UserStructure = New Structure("member,access_level", UserData, Mode); - -ArrayOfUsers.Add(UserStructure); - -EndDo; - -Parameters = New Structure; -OPI_Tools.AddField("shared_folder_id", FolderID , String_, Parameters); -OPI_Tools.AddField("members" , ArrayOfUsers , "Array", Parameters); - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Get asynchronous change status // Gets the status of the asynchronous access change job -// +// // Parameters: // Token - String - Token - token // JobID - String - AsynchronousJobID - job -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function GetAsynchronousChangeStatus(Val Token, Val JobID) Export + + URL = "https://api.dropboxapi.com/2/sharing/check_job_status"; + + Parameters = New Structure; + OPI_Tools.AddField("async_job_id", JobID, "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); -URL = "https://api.dropboxapi.com/2/sharing/check_job_status"; - -Parameters = New Structure; -OPI_Tools.AddField("async_job_id", JobID, "String", Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Return Response; EndFunction // Unpublish file // Prohibits access to the file for external users -// +// // Parameters: // Token - String - Token - token // FileID - String - ID of the file to be accessed - fileid -// +// // Return value: // Key-Value Pair - serialized JSON response from Dropbox Function CancelFilePublication(Val Token, Val FileID) Export + + OPI_TypeConversion.GetLine(FileID); + + If Not StringStartsWith(FileID, "id:") Then + FileID = "id:" + FileID; + EndIf; + + URL = "https://api.dropboxapi.com/2/sharing/unshare_file"; + + Parameters = New Structure; + OPI_Tools.AddField("file", FileID, "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); -OPI_TypeConversion.GetLine(FileID); - -If Not StringStartsWith(FileID, "id:") Then -FileID = "id:" + FileID; -EndIf; - -URL = "https://api.dropboxapi.com/2/sharing/unshare_file"; - -Parameters = New Structure; -OPI_Tools.AddField("file", FileID, "String", Parameters); - -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + Return Response; + EndFunction #EndRegion @@ -771,191 +771,191 @@ EndFunction #Region ServiceProceduresAndFunctions Function ProcessObject(Val Token, Val URL, Val Path, Val InHeaders = False) - -Parameters = New Structure; -OPI_Tools.AddField("path", Path, "String", Parameters); - -If InHeaders Then -Headers = GetRequestHeaders(Token, Parameters); -Response = OPI_Tools.PostBinary(URL, GetBinaryDataFromString(""), Headers); -Else -Headers = GetRequestHeaders(Token); -Response = OPI_Tools.Post(URL, Parameters, Headers); -EndIf; - -Return Response; - + + Parameters = New Structure; + OPI_Tools.AddField("path", Path, "String", Parameters); + + If InHeaders Then + Headers = GetRequestHeaders(Token, Parameters); + Response = OPI_Tools.PostBinary(URL, GetBinaryDataFromString(""), Headers); + Else + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + EndIf; + + Return Response; + EndFunction Function ProcessTag(Val Token, Val Path, Val Tag, Val ThisIsDeletion = False) -If ThisIsDeletion Then -URL = "https://api.dropboxapi.com/2/files/tags/remove"; -Else -URL = "https://api.dropboxapi.com/2/files/tags/add"; -EndIf; - -Parameters = New Structure; -OPI_Tools.AddField("path" , Path, "String", Parameters); -OPI_Tools.AddField("tag_text" , Tag , "String", Parameters); - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + If ThisIsDeletion Then + URL = "https://api.dropboxapi.com/2/files/tags/remove"; + Else + URL = "https://api.dropboxapi.com/2/files/tags/add"; + EndIf; + + Parameters = New Structure; + OPI_Tools.AddField("path" , Path, "String", Parameters); + OPI_Tools.AddField("tag_text" , Tag , "String", Parameters); + + Headers = GetRequestHeaders(Token); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction Function GetRequestHeaders(Val Token, Val Parameters = "") + + OPI_TypeConversion.GetLine(Token); + + Headers = New Match; + Headers.Insert("Authorization" , "Bearer " + Token); + + If ValueIsFilled(Parameters) Then + + JSON = OPI_Tools.JSONString(Parameters, "No"); + JSON = StringReplace(JSON, Symbols.VK + Symbols.PS, ""); -OPI_TypeConversion.GetLine(Token); - -Headers = New Match; -Headers.Insert("Authorization" , "Bearer " + Token); - -If ValueIsFilled(Parameters) Then - -JSON = OPI_Tools.JSONString(Parameters, "No"); -JSON = StringReplace(JSON, Symbols.VK + Symbols.PS, ""); - -Headers.Insert("Dropbox-API-Arg", JSON); - -EndIf; - -Return Headers; - + Headers.Insert("Dropbox-API-Arg", JSON); + + EndIf; + + Return Headers; + EndFunction Function UploadLargeFile(Val Token, Val File, Val Path, Val Mode) + + URL = "https://content.dropboxapi.com/2/files/upload_session/append_v2"; -URL = "https://content.dropboxapi.com/2/files/upload_session/append_v2"; - -ChunkSize = 100000000; -CurrentPosition = 0; -BytesRead = 0; -TotalSize = File.Size(); -Session = OpenSession(Token); - -WHile BytesRead < TotalSize Do - -Indent = CurrentPosition; -Cursor = New Structure("offset,session_id", Indent, Session); - -Parameters = New Structure("cursor", Cursor); -Headers = GetRequestHeaders(Token, Parameters); - -ReadingData = New ReadingData(File); -BytesRead = ReadingData.Skip(CurrentPosition); -Result = ReadingData.Read(ChunkSize); -Current data = Result.GetBinaryData(); -CurrentSize = Current data.Size(); -NextPosition = CurrentPosition + CurrentSize; - -If Not ValueIsFilled(Current data) Then -Break; -EndIf; - -Response = OPI_Tools.PostBinary(URL, Current data, Headers); - -CurrentPosition = NextPosition; - -// !OInt KBytes = 1024; -// !OInt MByte = KBytes * KBytes; -// !OInt Notify(OPI_Tools.ProgressInformation(CurrentPosition, TotalSize, "MB", MByte)); - -// !OInt PerformGarbageCollection(); -// !OInt ReleaseObject(Current data); - -EndDo; - -Response = CloseSession(Token, Path, Mode, TotalSize, Session); - -Return Response; + ChunkSize = 100000000; + CurrentPosition = 0; + BytesRead = 0; + TotalSize = File.Size(); + Session = OpenSession(Token); + + WHile BytesRead < TotalSize Do + + Indent = CurrentPosition; + Cursor = New Structure("offset,session_id", Indent, Session); + + Parameters = New Structure("cursor", Cursor); + Headers = GetRequestHeaders(Token, Parameters); + + ReadingData = New ReadingData(File); + BytesRead = ReadingData.Skip(CurrentPosition); + Result = ReadingData.Read(ChunkSize); + Current data = Result.GetBinaryData(); + CurrentSize = Current data.Size(); + NextPosition = CurrentPosition + CurrentSize; + + If Not ValueIsFilled(Current data) Then + Break; + EndIf; + Response = OPI_Tools.PostBinary(URL, Current data, Headers); + + CurrentPosition = NextPosition; + + // !OInt KBytes = 1024; + // !OInt MByte = KBytes * KBytes; + // !OInt Notify(OPI_Tools.ProgressInformation(CurrentPosition, TotalSize, "MB", MByte)); + + // !OInt PerformGarbageCollection(); + // !OInt ReleaseObject(Current data); + + EndDo; + + Response = CloseSession(Token, Path, Mode, TotalSize, Session); + + Return Response; + EndFunction Function UploadSmallFile(Val Token, Val File, Val Path, Val Mode) + + Boolean_ = "Boolean"; + String_ = "String"; + URL = "https://content.dropboxapi.com/2/files/upload"; + + Parameters = New Structure; + + OPI_Tools.AddField("autorename" , False , Boolean_, Parameters); + OPI_Tools.AddField("mode" , Mode, String_, Parameters); + OPI_Tools.AddField("mute" , False , Boolean_, Parameters); + OPI_Tools.AddField("path" , Path , String_, Parameters); + OPI_Tools.AddField("strict_conflict", False , Boolean_, Parameters); + + Headers = GetRequestHeaders(Token, Parameters); -Boolean_ = "Boolean"; -String_ = "String"; -URL = "https://content.dropboxapi.com/2/files/upload"; - -Parameters = New Structure; - -OPI_Tools.AddField("autorename" , False , Boolean_, Parameters); -OPI_Tools.AddField("mode" , Mode, String_, Parameters); -OPI_Tools.AddField("mute" , False , Boolean_, Parameters); -OPI_Tools.AddField("path" , Path , String_, Parameters); -OPI_Tools.AddField("strict_conflict", False , Boolean_, Parameters); - -Headers = GetRequestHeaders(Token, Parameters); - -Response = OPI_Tools.PostBinary(URL, File, Headers); - -Return Response; - + Response = OPI_Tools.PostBinary(URL, File, Headers); + + Return Response; + EndFunction Function OpenSession(Val Token) - -SessionId = "session_id"; -URL = "https://content.dropboxapi.com/2/files/upload_session/start"; -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.PostBinary(URL, GetBinaryDataFromString(""), Headers); - -Return Response[SessionId]; - + + SessionId = "session_id"; + URL = "https://content.dropboxapi.com/2/files/upload_session/start"; + Headers = GetRequestHeaders(Token); + + Response = OPI_Tools.PostBinary(URL, GetBinaryDataFromString(""), Headers); + + Return Response[SessionId]; + EndFunction Function CloseSession(Val Token, Val Path, Val Mode, Val TotalSize, Val Session) -URL = "https://content.dropboxapi.com/2/files/upload_session/finish"; - -Commit = New Structure(); -OPI_Tools.AddField("mode", Mode, "String", Commit); -OPI_Tools.AddField("path", Path, "String", Commit); - -Cursor = New Structure("offset,session_id", TotalSize, Session); - -Parameters = New Structure("commit,cursor", Commit, Cursor); -Headers = GetRequestHeaders(Token, Parameters); - -Response = OPI_Tools.PostBinary(URL, GetBinaryDataFromString(""), Headers); - -Return Response; - + URL = "https://content.dropboxapi.com/2/files/upload_session/finish"; + + Commit = New Structure(); + OPI_Tools.AddField("mode", Mode, "String", Commit); + OPI_Tools.AddField("path", Path, "String", Commit); + + Cursor = New Structure("offset,session_id", TotalSize, Session); + + Parameters = New Structure("commit,cursor", Commit, Cursor); + Headers = GetRequestHeaders(Token, Parameters); + + Response = OPI_Tools.PostBinary(URL, GetBinaryDataFromString(""), Headers); + + Return Response; + EndFunction Function GetAccount(Val Token, Val Account) + + URL = "https://api.dropboxapi.com/2/users/get_account"; + + Parameters = New Structure; + OPI_Tools.AddField("account_id", Account, "String", Parameters); + + Headers = GetRequestHeaders(Token); -URL = "https://api.dropboxapi.com/2/users/get_account"; - -Parameters = New Structure; -OPI_Tools.AddField("account_id", Account, "String", Parameters); - -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction Function GetOwnAccount(Val Token) - -URL = "https://api.dropboxapi.com/2/users/get_current_account"; -Headers = GetRequestHeaders(Token); - -Response = OPI_Tools.PostBinary(URL -, GetBinaryDataFromString("null") -, Headers -, -, "text/plain; charset=dropbox-cors-hack"); - -Return Response; - + + URL = "https://api.dropboxapi.com/2/users/get_current_account"; + Headers = GetRequestHeaders(Token); + + Response = OPI_Tools.PostBinary(URL + , GetBinaryDataFromString("null") + , Headers + , + , "text/plain; charset=dropbox-cors-hack"); + + Return Response; + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Dropbox/OPI_Dropbox.mdo b/src/en/OPI/src/CommonModules/OPI_Dropbox/OPI_Dropbox.mdo index 6f0576f573..fb078b30c9 100644 --- a/src/en/OPI/src/CommonModules/OPI_Dropbox/OPI_Dropbox.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Dropbox/OPI_Dropbox.mdo @@ -1,15 +1,15 @@  -OPI_Dropbox - - -OPI dropbox - - -ru -Drop box - -true -true -true + OPI_Dropbox + + + OPI dropbox + + + ru + Drop box + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_GetTestData/Module.bsl b/src/en/OPI/src/CommonModules/OPI_GetTestData/Module.bsl index 774b2bca0a..029db056ea 100644 --- a/src/en/OPI/src/CommonModules/OPI_GetTestData/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_GetTestData/Module.bsl @@ -42,429 +42,429 @@ #Region ServiceProgramInterface Function GetTestingSectionMapping() Export - -StandardDependencies = "[Decode, Build]"; -GoogleDependencies = "Testing-GoogleWorkspace"; - -Sections = New Structure; -Sections.Insert("Telegram" , StandardDependencies); -Sections.Insert("VK" , StandardDependencies); -Sections.Insert("Viber" , StandardDependencies); -Sections.Insert("Twitter" , StandardDependencies); -Sections.Insert("YandexDisk" , StandardDependencies); -Sections.Insert("GoogleWorkspace", StandardDependencies); -Sections.Insert("GoogleCalendar" , GoogleDependencies); -Sections.Insert("GoogleDrive" , GoogleDependencies); -Sections.Insert("GoogleSheets" , GoogleDependencies); -Sections.Insert("Notion" , StandardDependencies); -Sections.Insert("Slack" , StandardDependencies); -Sections.Insert("Airtable" , StandardDependencies); -Sections.Insert("Dropbox" , StandardDependencies); - -Return Sections; - + + StandardDependencies = "[Decode, Build]"; + GoogleDependencies = "Testing-GoogleWorkspace"; + + Sections = New Structure; + Sections.Insert("Telegram" , StandardDependencies); + Sections.Insert("VK" , StandardDependencies); + Sections.Insert("Viber" , StandardDependencies); + Sections.Insert("Twitter" , StandardDependencies); + Sections.Insert("YandexDisk" , StandardDependencies); + Sections.Insert("GoogleWorkspace", StandardDependencies); + Sections.Insert("GoogleCalendar" , GoogleDependencies); + Sections.Insert("GoogleDrive" , GoogleDependencies); + Sections.Insert("GoogleSheets" , GoogleDependencies); + Sections.Insert("Notion" , StandardDependencies); + Sections.Insert("Slack" , StandardDependencies); + Sections.Insert("Airtable" , StandardDependencies); + Sections.Insert("Dropbox" , StandardDependencies); + + Return Sections; + EndFunction Function GetTestTable() Export - -Telegram = "Telegram"; -VK = "VK"; -YDisk = "YandexDisk"; -Calendar = "GoogleCalendar"; -Twitter = "Twitter"; -Viber = "Viber"; -Drive = "GoogleDrive"; -VSpace = "GoogleWorkspace"; -Notion = "Notion"; -Slack = "Slack"; -Tables = "GoogleSheets"; -AirT = "Airtable"; -Dropbox = "Dropbox"; - -TestTable = New ValueTable; -TestTable.Columns.Add("Method"); -TestTable.Columns.Add("Synonym"); -TestTable.Columns.Add("Section"); - -NewTest(TestTable, "Telegram_GetBotInfo" , "Get bot information" , Telegram); -NewTest(TestTable, "Telegram_GetUpdates" , "Get updates" , Telegram); -NewTest(TestTable, "Telegram_SetWebhook" , "Set Webhook" , Telegram); -NewTest(TestTable, "Telegram_SendTextMessage" , "Send text message" , Telegram); -NewTest(TestTable, "Telegram_SendImage" , "Send image" , Telegram); -NewTest(TestTable, "Telegram_SendVideo" , "Send video" , Telegram); -NewTest(TestTable, "Telegram_SendAudio" , "Send audio" , Telegram); -NewTest(TestTable, "Telegram_SendDocument" , "Send document" , Telegram); -NewTest(TestTable, "Telegram_SendGIF" , "Send GIF" , Telegram); -NewTest(TestTable, "Telegram_SendMediaGroup" , "Send media group" , Telegram); -NewTest(TestTable, "Telegram_SendLocation" , "Send location" , Telegram); -NewTest(TestTable, "Telegram_SendContact" , "Send contact" , Telegram); -NewTest(TestTable, "Telegram_SendPoll" , "Send poll" , Telegram); -NewTest(TestTable, "Telegram_ForwardMessage" , "Forward message" , Telegram); -NewTest(TestTable, "Telegram_BanUnban" , "Ban/Unban" , Telegram); -NewTest(TestTable, "Telegram_CreateInvitationLink" , "Create invitation link" , Telegram); -NewTest(TestTable, "Telegram_PinUnpinMessage" , "Pin/Unpin message" , Telegram); -NewTest(TestTable, "Telegram_GetMemberCount" , "Get participant count" , Telegram); -NewTest(TestTable, "Telegram_GetForumAvatarsList", "Get forum avatars list", Telegram); -NewTest(TestTable, "Telegram_CreateDeleteForumTopic" , "Create/Delete forum topic" , Telegram); -NewTest(TestTable, "Telegram_ChangeMainTopicName" , "Change main topic name" , Telegram); -NewTest(TestTable, "Telegram_HideShowMainTopic" , "Hide/Show main topic" , Telegram); - -NewTest(TestTable, "VK_CreateTokenLink" , "Create token retrieval link", VK); -NewTest(TestTable, "VK_CreateDeletePost" , "Create/Delete post" , VK); -NewTest(TestTable, "VK_CreateCompositePost" , "Create/Delete composite post" , VK); -NewTest(TestTable, "VK_CreatePoll" , "Create poll" , VK); -NewTest(TestTable, "VK_SaveDeleteImage" , "Add/Delete image" , VK); -NewTest(TestTable, "VK_CreateStory" , "Create story" , VK); -NewTest(TestTable, "VK_DiscussionMethods" , "Actions with discussions" , VK); -NewTest(TestTable, "VK_LikeRepostComment" , "Like/Repost/Comment" , VK); -NewTest(TestTable, "VK_GetStatistics" , "Get statistics" , VK); -NewTest(TestTable, "VK_GetPostStatistics" , "Get post statistics" , VK); -NewTest(TestTable, "VK_CreateAdCampaign" , "Create advertising campaign" , VK); -NewTest(TestTable, "VK_SendMessage" , "Send message" , VK); -NewTest(TestTable, "VK_GetProductCategories" , "Get product categories" , VK); -NewTest(TestTable, "VK_CreateProductSelection" , "Create product and selection" , VK); -NewTest(TestTable, "VK_CreateProductWithProperties" , "Create product with properties" , VK); -NewTest(TestTable, "VK_GetProductList" , "Get product list" , VK); -NewTest(TestTable, "VK_GetSelectionList" , "Get selection list" , VK); -NewTest(TestTable, "VK_GetPropertyList" , "Get property list" , VK); -NewTest(TestTable, "VK_GetOrderList" , "Get order list" , VK); -NewTest(TestTable, "VK_UploadVideo" , "Upload video" , VK); - -NewTest(TestTable, "YDisk_GetDiskInfo" , "Get disk information" , YDisk); -NewTest(TestTable, "YDisk_CreateFolder" , "Create folder" , YDisk); -NewTest(TestTable, "YDisk_UploadByUrlAndGetObject", "Upload by URL and get" , YDisk); -NewTest(TestTable, "YDisk_UploadDeleteFile" , "Upload/Delete file" , YDisk); -NewTest(TestTable, "YDisk_CreateObjectCopy" , "Create object copy" , YDisk); -NewTest(TestTable, "YDisk_GetDownloadLink" , "Get download link" , YDisk); -NewTest(TestTable, "YDisk_GetFileList" , "Get list of files" , YDisk); -NewTest(TestTable, "YDisk_MoveObject" , "Move object" , YDisk); -NewTest(TestTable, "YDisk_PublicObjectActions" , "Actions with public objects", YDisk); -NewTest(TestTable, "YDisk_GetPublishedList" , "Get published list" , YDisk); - -NewTest(TestTable, "GV_GetAuthorizationLink" , "Get authorization link" , VSpace); -NewTest(TestTable, "GV_GetToken" , "Get token" , VSpace); -NewTest(TestTable, "GV_UpdateToken" , "Refresh token" , VSpace); - -NewTest(TestTable, "GC_GetCalendarList" , "Get list of calendars" , Calendar); -NewTest(TestTable, "GC_CreateDeleteCalendar" , "Create/Delete calendar" , Calendar); -NewTest(TestTable, "GC_CreateDeleteEvent" , "Create/Delete event" , Calendar); -NewTest(TestTable, "GC_GetEventList" , "Get list of events" , Calendar); - -NewTest(TestTable, "GD_GetCatalogList" , "Get list of directories" , Drive); -NewTest(TestTable, "GD_UploadDeleteFile" , "Upload/Delete file" , Drive); -NewTest(TestTable, "GD_CreateDeleteComment" , "Create/Delete Comment" , Drive); -NewTest(TestTable, "GD_CreateCatalog" , "Create/Delete catalog" , Drive); - -NewTest(TestTable, "GT_CreateTable" , "Create table" , Tables); -NewTest(TestTable, "GT_GetTable" , "Get table" , Tables); -NewTest(TestTable, "GT_FillClearCells" , "Fill/Clear cells" , Tables); - -NewTest(TestTable, "Twitter_GetAuthorizationLink" , "Get authorization link" , Twitter); -NewTest(TestTable, "Twitter_UpdateToken" , "Refresh token" , Twitter); -NewTest(TestTable, "Twitter_CreateTextTweet" , "Text tweet" , Twitter); -NewTest(TestTable, "Twitter_CreateTweetWithImage" , "Tweet with image" , Twitter); -NewTest(TestTable, "Twitter_CreateTweetWithVideo" , "Tweet with video" , Twitter); -NewTest(TestTable, "Twitter_CreateTweetWithGif" , "Tweet with gif" , Twitter); -NewTest(TestTable, "Twitter_CreateTweetWithPoll" , "Tweet with poll" , Twitter); - -NewTest(TestTable, "Viber_GetChannelInfo" , "Get channel info" , Viber); -NewTest(TestTable, "Viber_GetUserData" , "Get user data" , Viber); -NewTest(TestTable, "Viber_GetOnlineUsers" , "Get online users" , Viber); -NewTest(TestTable, "Viber_SendTextMessage" , "Send text message" , Viber); -NewTest(TestTable, "Viber_SendImage" , "Send image" , Viber); -NewTest(TestTable, "Viber_SendFile" , "SendFile" , Viber); -NewTest(TestTable, "Viber_SendContact" , "Send contact" , Viber); -NewTest(TestTable, "Viber_SendLocation" , "SendLocation" , Viber); -NewTest(TestTable, "Viber_SendLink" , "SendLink" , Viber); - -NewTest(TestTable, "Notion_CreatePage" , "Create page" , Notion); -NewTest(TestTable, "Notion_CreateEditDatabase" , "Create/Edit database" , Notion); -NewTest(TestTable, "Notion_GetPageInfo" , "Get page info" , Notion); -NewTest(TestTable, "Notion_GetDatabaseInfo" , "Get database info" , Notion); -NewTest(TestTable, "Notion_CreatePageInDatabase" , "Create page in database" , Notion); -NewTest(TestTable, "Notion_EditPageProperties" , "Edit page properties" , Notion); -NewTest(TestTable, "Notion_CreateDeleteBlock" , "Create/Delete block" , Notion); -NewTest(TestTable, "Notion_GetUsers" , "Get users" , Notion); -NewTest(TestTable, "Notion_GetUserData" , "Get user data" , Notion); - -NewTest(TestTable, "Slack_GetBotInfo" , "Get bot information" , Slack); -NewTest(TestTable, "Slack_GetUserList" , "Get user list" , Slack); -NewTest(TestTable, "Slack_GetRegionList" , "Get region list" , Slack); -NewTest(TestTable, "Slack_SendDeleteMessage" , "Send/Delete message" , Slack); -NewTest(TestTable, "Slack_SendDeleteEphemeral" , "Send/Delete ephemeral" , Slack); -NewTest(TestTable, "Slack_GetScheduledMessages" , "Get scheduled messages" , Slack); -NewTest(TestTable, "Slack_CreateArchiveChannel" , "Create/Archive channel" , Slack); -NewTest(TestTable, "Slack_GetChannelList" , "Get channel list" , Slack); -NewTest(TestTable, "Slack_OpenCloseDialog" , "Open/Close dialog" , Slack); -NewTest(TestTable, "Slack_GetFileList" , "Get list of files" , Slack); -NewTest(TestTable, "Slack_UploadDeleteFile" , "Upload/Delete file" , Slack); -NewTest(TestTable, "Slack_GetExternalFileList" , "Get external file list" , Slack); -NewTest(TestTable, "Slack_UploadDeleteExternalFile" , "Upload/Delete external file" , Slack); - -NewTest(TestTable, "AT_CreateDatabase" , "Create/Edit database" , AirT); -NewTest(TestTable, "AT_CreateTable" , "Create/Edit table" , AirT); -NewTest(TestTable, "AT_CreateField" , "Create/Edit field" , AirT); -NewTest(TestTable, "AT_CreateDeleteRecords" , "Create/Delete records" , AirT); - -NewTest(TestTable, "Dropbox_GetUpdateToken" , "Get/Update token" , Dropbox); -NewTest(TestTable, "Dropbox_UploadFile" , "Upload file" , Dropbox); -NewTest(TestTable, "Dropbox_UploadFileByURL" , "Upload file by URL" , Dropbox); -NewTest(TestTable, "Dropbox_CreateFolder" , "Create folder" , Dropbox); -NewTest(TestTable, "Dropbox_CreateDeleteTag" , "Create/Delete tag" , Dropbox); -NewTest(TestTable, "Dropbox_GetAccount" , "Get account data" , Dropbox); -NewTest(TestTable, "Dropbox_AccessManagement" , "Access management" , Dropbox); - -Return TestTable; - -EndFunction + + Telegram = "Telegram"; + VK = "VK"; + YDisk = "YandexDisk"; + Calendar = "GoogleCalendar"; + Twitter = "Twitter"; + Viber = "Viber"; + Drive = "GoogleDrive"; + VSpace = "GoogleWorkspace"; + Notion = "Notion"; + Slack = "Slack"; + Tables = "GoogleSheets"; + AirT = "Airtable"; + Dropbox = "Dropbox"; + + TestTable = New ValueTable; + TestTable.Columns.Add("Method"); + TestTable.Columns.Add("Synonym"); + TestTable.Columns.Add("Section"); + + NewTest(TestTable, "Telegram_GetBotInfo" , "Get bot information" , Telegram); + NewTest(TestTable, "Telegram_GetUpdates" , "Get updates" , Telegram); + NewTest(TestTable, "Telegram_SetWebhook" , "Set Webhook" , Telegram); + NewTest(TestTable, "Telegram_SendTextMessage" , "Send text message" , Telegram); + NewTest(TestTable, "Telegram_SendImage" , "Send image" , Telegram); + NewTest(TestTable, "Telegram_SendVideo" , "Send video" , Telegram); + NewTest(TestTable, "Telegram_SendAudio" , "Send audio" , Telegram); + NewTest(TestTable, "Telegram_SendDocument" , "Send document" , Telegram); + NewTest(TestTable, "Telegram_SendGIF" , "Send GIF" , Telegram); + NewTest(TestTable, "Telegram_SendMediaGroup" , "Send media group" , Telegram); + NewTest(TestTable, "Telegram_SendLocation" , "Send location" , Telegram); + NewTest(TestTable, "Telegram_SendContact" , "Send contact" , Telegram); + NewTest(TestTable, "Telegram_SendPoll" , "Send poll" , Telegram); + NewTest(TestTable, "Telegram_ForwardMessage" , "Forward message" , Telegram); + NewTest(TestTable, "Telegram_BanUnban" , "Ban/Unban" , Telegram); + NewTest(TestTable, "Telegram_CreateInvitationLink" , "Create invitation link" , Telegram); + NewTest(TestTable, "Telegram_PinUnpinMessage" , "Pin/Unpin message" , Telegram); + NewTest(TestTable, "Telegram_GetMemberCount" , "Get participant count" , Telegram); + NewTest(TestTable, "Telegram_GetForumAvatarsList", "Get forum avatars list", Telegram); + NewTest(TestTable, "Telegram_CreateDeleteForumTopic" , "Create/Delete forum topic" , Telegram); + NewTest(TestTable, "Telegram_ChangeMainTopicName" , "Change main topic name" , Telegram); + NewTest(TestTable, "Telegram_HideShowMainTopic" , "Hide/Show main topic" , Telegram); + + NewTest(TestTable, "VK_CreateTokenLink" , "Create token retrieval link", VK); + NewTest(TestTable, "VK_CreateDeletePost" , "Create/Delete post" , VK); + NewTest(TestTable, "VK_CreateCompositePost" , "Create/Delete composite post" , VK); + NewTest(TestTable, "VK_CreatePoll" , "Create poll" , VK); + NewTest(TestTable, "VK_SaveDeleteImage" , "Add/Delete image" , VK); + NewTest(TestTable, "VK_CreateStory" , "Create story" , VK); + NewTest(TestTable, "VK_DiscussionMethods" , "Actions with discussions" , VK); + NewTest(TestTable, "VK_LikeRepostComment" , "Like/Repost/Comment" , VK); + NewTest(TestTable, "VK_GetStatistics" , "Get statistics" , VK); + NewTest(TestTable, "VK_GetPostStatistics" , "Get post statistics" , VK); + NewTest(TestTable, "VK_CreateAdCampaign" , "Create advertising campaign" , VK); + NewTest(TestTable, "VK_SendMessage" , "Send message" , VK); + NewTest(TestTable, "VK_GetProductCategories" , "Get product categories" , VK); + NewTest(TestTable, "VK_CreateProductSelection" , "Create product and selection" , VK); + NewTest(TestTable, "VK_CreateProductWithProperties" , "Create product with properties" , VK); + NewTest(TestTable, "VK_GetProductList" , "Get product list" , VK); + NewTest(TestTable, "VK_GetSelectionList" , "Get selection list" , VK); + NewTest(TestTable, "VK_GetPropertyList" , "Get property list" , VK); + NewTest(TestTable, "VK_GetOrderList" , "Get order list" , VK); + NewTest(TestTable, "VK_UploadVideo" , "Upload video" , VK); + + NewTest(TestTable, "YDisk_GetDiskInfo" , "Get disk information" , YDisk); + NewTest(TestTable, "YDisk_CreateFolder" , "Create folder" , YDisk); + NewTest(TestTable, "YDisk_UploadByUrlAndGetObject", "Upload by URL and get" , YDisk); + NewTest(TestTable, "YDisk_UploadDeleteFile" , "Upload/Delete file" , YDisk); + NewTest(TestTable, "YDisk_CreateObjectCopy" , "Create object copy" , YDisk); + NewTest(TestTable, "YDisk_GetDownloadLink" , "Get download link" , YDisk); + NewTest(TestTable, "YDisk_GetFileList" , "Get list of files" , YDisk); + NewTest(TestTable, "YDisk_MoveObject" , "Move object" , YDisk); + NewTest(TestTable, "YDisk_PublicObjectActions" , "Actions with public objects", YDisk); + NewTest(TestTable, "YDisk_GetPublishedList" , "Get published list" , YDisk); + + NewTest(TestTable, "GV_GetAuthorizationLink" , "Get authorization link" , VSpace); + NewTest(TestTable, "GV_GetToken" , "Get token" , VSpace); + NewTest(TestTable, "GV_UpdateToken" , "Refresh token" , VSpace); + + NewTest(TestTable, "GC_GetCalendarList" , "Get list of calendars" , Calendar); + NewTest(TestTable, "GC_CreateDeleteCalendar" , "Create/Delete calendar" , Calendar); + NewTest(TestTable, "GC_CreateDeleteEvent" , "Create/Delete event" , Calendar); + NewTest(TestTable, "GC_GetEventList" , "Get list of events" , Calendar); + + NewTest(TestTable, "GD_GetCatalogList" , "Get list of directories" , Drive); + NewTest(TestTable, "GD_UploadDeleteFile" , "Upload/Delete file" , Drive); + NewTest(TestTable, "GD_CreateDeleteComment" , "Create/Delete Comment" , Drive); + NewTest(TestTable, "GD_CreateCatalog" , "Create/Delete catalog" , Drive); + + NewTest(TestTable, "GT_CreateTable" , "Create table" , Tables); + NewTest(TestTable, "GT_GetTable" , "Get table" , Tables); + NewTest(TestTable, "GT_FillClearCells" , "Fill/Clear cells" , Tables); + + NewTest(TestTable, "Twitter_GetAuthorizationLink" , "Get authorization link" , Twitter); + NewTest(TestTable, "Twitter_UpdateToken" , "Refresh token" , Twitter); + NewTest(TestTable, "Twitter_CreateTextTweet" , "Text tweet" , Twitter); + NewTest(TestTable, "Twitter_CreateTweetWithImage" , "Tweet with image" , Twitter); + NewTest(TestTable, "Twitter_CreateTweetWithVideo" , "Tweet with video" , Twitter); + NewTest(TestTable, "Twitter_CreateTweetWithGif" , "Tweet with gif" , Twitter); + NewTest(TestTable, "Twitter_CreateTweetWithPoll" , "Tweet with poll" , Twitter); + + NewTest(TestTable, "Viber_GetChannelInfo" , "Get channel info" , Viber); + NewTest(TestTable, "Viber_GetUserData" , "Get user data" , Viber); + NewTest(TestTable, "Viber_GetOnlineUsers" , "Get online users" , Viber); + NewTest(TestTable, "Viber_SendTextMessage" , "Send text message" , Viber); + NewTest(TestTable, "Viber_SendImage" , "Send image" , Viber); + NewTest(TestTable, "Viber_SendFile" , "SendFile" , Viber); + NewTest(TestTable, "Viber_SendContact" , "Send contact" , Viber); + NewTest(TestTable, "Viber_SendLocation" , "SendLocation" , Viber); + NewTest(TestTable, "Viber_SendLink" , "SendLink" , Viber); + + NewTest(TestTable, "Notion_CreatePage" , "Create page" , Notion); + NewTest(TestTable, "Notion_CreateEditDatabase" , "Create/Edit database" , Notion); + NewTest(TestTable, "Notion_GetPageInfo" , "Get page info" , Notion); + NewTest(TestTable, "Notion_GetDatabaseInfo" , "Get database info" , Notion); + NewTest(TestTable, "Notion_CreatePageInDatabase" , "Create page in database" , Notion); + NewTest(TestTable, "Notion_EditPageProperties" , "Edit page properties" , Notion); + NewTest(TestTable, "Notion_CreateDeleteBlock" , "Create/Delete block" , Notion); + NewTest(TestTable, "Notion_GetUsers" , "Get users" , Notion); + NewTest(TestTable, "Notion_GetUserData" , "Get user data" , Notion); + + NewTest(TestTable, "Slack_GetBotInfo" , "Get bot information" , Slack); + NewTest(TestTable, "Slack_GetUserList" , "Get user list" , Slack); + NewTest(TestTable, "Slack_GetRegionList" , "Get region list" , Slack); + NewTest(TestTable, "Slack_SendDeleteMessage" , "Send/Delete message" , Slack); + NewTest(TestTable, "Slack_SendDeleteEphemeral" , "Send/Delete ephemeral" , Slack); + NewTest(TestTable, "Slack_GetScheduledMessages" , "Get scheduled messages" , Slack); + NewTest(TestTable, "Slack_CreateArchiveChannel" , "Create/Archive channel" , Slack); + NewTest(TestTable, "Slack_GetChannelList" , "Get channel list" , Slack); + NewTest(TestTable, "Slack_OpenCloseDialog" , "Open/Close dialog" , Slack); + NewTest(TestTable, "Slack_GetFileList" , "Get list of files" , Slack); + NewTest(TestTable, "Slack_UploadDeleteFile" , "Upload/Delete file" , Slack); + NewTest(TestTable, "Slack_GetExternalFileList" , "Get external file list" , Slack); + NewTest(TestTable, "Slack_UploadDeleteExternalFile" , "Upload/Delete external file" , Slack); + + NewTest(TestTable, "AT_CreateDatabase" , "Create/Edit database" , AirT); + NewTest(TestTable, "AT_CreateTable" , "Create/Edit table" , AirT); + NewTest(TestTable, "AT_CreateField" , "Create/Edit field" , AirT); + NewTest(TestTable, "AT_CreateDeleteRecords" , "Create/Delete records" , AirT); + + NewTest(TestTable, "Dropbox_GetUpdateToken" , "Get/Update token" , Dropbox); + NewTest(TestTable, "Dropbox_UploadFile" , "Upload file" , Dropbox); + NewTest(TestTable, "Dropbox_UploadFileByURL" , "Upload file by URL" , Dropbox); + NewTest(TestTable, "Dropbox_CreateFolder" , "Create folder" , Dropbox); + NewTest(TestTable, "Dropbox_CreateDeleteTag" , "Create/Delete tag" , Dropbox); + NewTest(TestTable, "Dropbox_GetAccount" , "Get account data" , Dropbox); + NewTest(TestTable, "Dropbox_AccessManagement" , "Access management" , Dropbox); + + Return TestTable; + +EndFunction Function ExpectsThat(Value) Export - -Try - -Module = GetCommonModule("UTest"); -Awaiting = TypeValue(Module) = Type("CommonModule"); -Return Module.ExpectsThat(Value); - -Except -Return Awaiting.What(Value); -EndTry; - + + Try + + Module = GetCommonModule("UTest"); + Awaiting = TypeValue(Module) = Type("CommonModule"); + Return Module.ExpectsThat(Value); + + Except + Return Awaiting.What(Value); + EndTry; + EndFunction Function FormYAXTests() Export - -Module = GetCommonModule("UTTests"); -Sections = GetTestingSectionMapping(); -TestTable = GetTestTable(); - -For Each Section In Sections Do - -CurrentSection = Section.Key; -Filter = New Structure("Section", CurrentSection); -SectionTests = TestTable.FindLines(Filter); - -Set = Module.AddTestSet(CurrentSection); - -For Each Test In SectionTests Do -Set.AddServerTest(Test.Method, Test.Synonym); -EndDo; - -EndDo; - -Return ""; - + + Module = GetCommonModule("UTTests"); + Sections = GetTestingSectionMapping(); + TestTable = GetTestTable(); + + For Each Section In Sections Do + + CurrentSection = Section.Key; + Filter = New Structure("Section", CurrentSection); + SectionTests = TestTable.FindLines(Filter); + + Set = Module.AddTestSet(CurrentSection); + + For Each Test In SectionTests Do + Set.AddServerTest(Test.Method, Test.Synonym); + EndDo; + + EndDo; + + Return ""; + EndFunction Function FormAssertsTests() Export - -TestTable = GetTestTable(); -ArrayOfTests = New Array; - -For Each Test In TestTable Do -ArrayOfTests.Add(Test.Method); -EndDo; - -Return ArrayOfTests; - + + TestTable = GetTestTable(); + ArrayOfTests = New Array; + + For Each Test In TestTable Do + ArrayOfTests.Add(Test.Method); + EndDo; + + Return ArrayOfTests; + EndFunction -Function GetParameter(Parameter) Export +Function GetParameter(Parameter) Export -Path = DataFilePath(); -Return GetValueFromFile(Parameter, Path); + Path = DataFilePath(); + Return GetValueFromFile(Parameter, Path); EndFunction Function GetBinary(Parameter) Export - -Path = DataFilePath(); -LocalParameter = Parameter + "Local"; -MainValue = GetValueFromFile(Parameter , Path); -LocalValue = GetValueFromFile(LocalParameter, Path); - -LocalFile = New File(LocalValue); - -If LocalFile.Exists() Then -Value = New BinaryData(LocalValue); -Else -Value = MainValue; -EndIf; - -If TypeValue(Value) = Type("String") Then -Value = GetFilePath(Value, LocalParameter); -EndIf; - -Return Value; - + + Path = DataFilePath(); + LocalParameter = Parameter + "Local"; + MainValue = GetValueFromFile(Parameter , Path); + LocalValue = GetValueFromFile(LocalParameter, Path); + + LocalFile = New File(LocalValue); + + If LocalFile.Exists() Then + Value = New BinaryData(LocalValue); + Else + Value = MainValue; + EndIf; + + If TypeValue(Value) = Type("String") Then + Value = GetFilePath(Value, LocalParameter); + EndIf; + + Return Value; + EndFunction Function GetFilePath(Val Path, LocalParameter, Val SaveLocally = True) Export - -If StrFind(Path, "http") > 0 -Or StrFind(Path, "www") > 0 Then - -AndVF = GetTempFileName(); -CopyFile(Path, AndVF); -Path = AndVF; -Binary = New BinaryData(Path); - -If SaveLocally Then -WriteParameter(LocalParameter, AndVF); -Else -DeleteFiles(AndVF); -EndIf; - -Else - -Binary = New BinaryData(Path); - -EndIf; - -Return Binary; - + + If StrFind(Path, "http") > 0 + Or StrFind(Path, "www") > 0 Then + + AndVF = GetTempFileName(); + CopyFile(Path, AndVF); + Path = AndVF; + Binary = New BinaryData(Path); + + If SaveLocally Then + WriteParameter(LocalParameter, AndVF); + Else + DeleteFiles(AndVF); + EndIf; + + Else + + Binary = New BinaryData(Path); + + EndIf; + + Return Binary; + EndFunction Procedure ParameterToCollection(Parameter, Collection) Export -Value = GetParameter(Parameter); -Collection.Insert(Parameter, Value); - + Value = GetParameter(Parameter); + Collection.Insert(Parameter, Value); + EndProcedure Procedure BinaryToCollection(Parameter, Collection) Export -Value = GetBinary(Parameter); -Collection.Insert(Parameter, Value); - + Value = GetBinary(Parameter); + Collection.Insert(Parameter, Value); + EndProcedure Procedure WriteParameter(Parameter, Value) Export - -Path = DataFilePath(); -WriteParameterToFile(Parameter, Value, Path); - + + Path = DataFilePath(); + WriteParameterToFile(Parameter, Value, Path); + EndProcedure Procedure WriteLog(Val Result, Val Method, Val Library = "") Export - -Header = String(OPI_Tools.GetCurrentDate()) + " | " + Method; - -Try -Data = OPI_Tools.JSONString(Result); -Except -Data = "Not JSON: " + String(Result); -EndTry; - -Data = " " + Data; - -Notify(Header); -Notify(Symbols.PS); -Notify(Data); -Notify(Symbols.PS); -Notify("---------------------------------"); -Notify(Symbols.PS); - -If ValueIsFilled(Library) Then -WriteLogFile(Data, Method, Library); -EndIf; - + + Header = String(OPI_Tools.GetCurrentDate()) + " | " + Method; + + Try + Data = OPI_Tools.JSONString(Result); + Except + Data = "Not JSON: " + String(Result); + EndTry; + + Data = " " + Data; + + Notify(Header); + Notify(Symbols.PS); + Notify(Data); + Notify(Symbols.PS); + Notify("---------------------------------"); + Notify(Symbols.PS); + + If ValueIsFilled(Library) Then + WriteLogFile(Data, Method, Library); + EndIf; + EndProcedure #EndRegion #Region ServiceProceduresAndFunctions -Function GetValueFromFile(Parameter, Path) - -Values = OPI_Tools.ReadJSONFile(Path); -Return ?(Values.Property(Parameter), Values[Parameter], ""); - +Function GetValueFromFile(Parameter, Path) + + Values = OPI_Tools.ReadJSONFile(Path); + Return ?(Values.Property(Parameter), Values[Parameter], ""); + EndFunction Function DataFilePath() - -Path = ""; -PossiblePaths = New Array; -PossiblePaths.Add("./data.json"); -PossiblePaths.Add("C:\GDrive\My Drive\data.json"); -PossiblePaths.Add("D:\GD\My Drive\data.json"); - -For Each PossiblePath In PossiblePaths Do - -RepositoryFile = New File(PossiblePath); - -If RepositoryFile.Exists() Then -Path = PossiblePath; -EndIf; - -EndDo; - -Return Path; - + + Path = ""; + PossiblePaths = New Array; + PossiblePaths.Add("./data.json"); + PossiblePaths.Add("C:\GDrive\My Drive\data.json"); + PossiblePaths.Add("D:\GD\My Drive\data.json"); + + For Each PossiblePath In PossiblePaths Do + + RepositoryFile = New File(PossiblePath); + + If RepositoryFile.Exists() Then + Path = PossiblePath; + EndIf; + + EndDo; + + Return Path; + EndFunction Function GetCommonModule(Val Name) -SetSafeMode(True); -Module = Calculate(Name); -SetSafeMode(False); -Return Module; + SetSafeMode(True); + Module = Calculate(Name); + SetSafeMode(False); + Return Module; EndFunction Procedure NewTest(ValueTable, Val Method, Val Synonym, Val Section) - -NewTest = ValueTable.Add(); -NewTest.Method = Method; -NewTest.Synonym = Synonym; -NewTest.Section = Section; - + + NewTest = ValueTable.Add(); + NewTest.Method = Method; + NewTest.Synonym = Synonym; + NewTest.Section = Section; + EndProcedure Procedure WriteParameterToFile(Val Parameter, Val Value, Val Path) + + Values = OPI_Tools.ReadJSONFile(Path); + Values.Insert(Parameter, Value); -Values = OPI_Tools.ReadJSONFile(Path); -Values.Insert(Parameter, Value); - -Record = New WritingJSON; -JSONWriteParameters = New JSONWriteParameters(JSONLineBreak.Auto, Symbols.Tab); -Record.OpenFile(Path, , , JSONWriteParameters); -WriteJSON(Record, Values); -Record.Close(); + Record = New WritingJSON; + JSONWriteParameters = New JSONWriteParameters(JSONLineBreak.Auto, Symbols.Tab); + Record.OpenFile(Path, , , JSONWriteParameters); + WriteJSON(Record, Values); + Record.Close(); EndProcedure Procedure WriteLogFile(Val Data, Val Method, Val Library) - -Try - -LogPath = "./docs/results"; -LibraryLogPath = LogPath + "/" + Library; - -LogDirectory = New File(LogPath); - -If Not LogDirectory.Exists() Then -CreateDirectory(LogPath); -EndIf; - -LibraryLogCatalog = New File(LibraryLogPath); - -If Not LibraryLogCatalog.Exists() Then -CreateDirectory(LibraryLogPath); -EndIf; - -FilePath = LibraryLogPath + "/" + Method + ".log"; -LogFile = New File(FilePath); - -If Not LogFile.Exists() Then -LogDocument = New TextDocument; -LogDocument.SetText(Data); -LogDocument.Write(FilePath); -EndIf; - -Except -Notify("Failed to write log file!: " + ErrorDescription()); -EndTry; - + + Try + + LogPath = "./docs/results"; + LibraryLogPath = LogPath + "/" + Library; + + LogDirectory = New File(LogPath); + + If Not LogDirectory.Exists() Then + CreateDirectory(LogPath); + EndIf; + + LibraryLogCatalog = New File(LibraryLogPath); + + If Not LibraryLogCatalog.Exists() Then + CreateDirectory(LibraryLogPath); + EndIf; + + FilePath = LibraryLogPath + "/" + Method + ".log"; + LogFile = New File(FilePath); + + If Not LogFile.Exists() Then + LogDocument = New TextDocument; + LogDocument.SetText(Data); + LogDocument.Write(FilePath); + EndIf; + + Except + Notify("Failed to write log file!: " + ErrorDescription()); + EndTry; + EndProcedure #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_GetTestData/OPI_GetTestData.mdo b/src/en/OPI/src/CommonModules/OPI_GetTestData/OPI_GetTestData.mdo index 5ed1a42c7a..43d6390f03 100644 --- a/src/en/OPI/src/CommonModules/OPI_GetTestData/OPI_GetTestData.mdo +++ b/src/en/OPI/src/CommonModules/OPI_GetTestData/OPI_GetTestData.mdo @@ -1,11 +1,11 @@  -OPI_GetTestData - - -OPI test data retrieval - -true -true -true + OPI_GetTestData + + + OPI test data retrieval + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/Module.bsl b/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/Module.bsl index e7f34d6321..a3db49cd3f 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/Module.bsl @@ -38,132 +38,132 @@ // Create calendar // Creates an empty calendar -// +// // Parameters: // Token - String - Token - token // Name - String - Name of the created calendar - title -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function CreateCalendar(Val Token, Val Name) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Name); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars"; - -Parameters = New Structure; -Parameters.Insert("summary" , Name); -Parameters.Insert("timeZone", "Europe/Moscow"); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Name); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars"; + + Parameters = New Structure; + Parameters.Insert("summary" , Name); + Parameters.Insert("timeZone", "Europe/Moscow"); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Get calendar // Gets calendar information by ID -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetCalendarMetadata(Val Token, Val Calendar) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars/" + Calendar; -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars/" + Calendar; + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; EndFunction // Edit calendar // Edits properties of an existing calendar -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar // Name - String - New name - title // Description - String - New calendar description - description -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function EditCalendarMetadata(Val Token -, Val Calendar -, Val Name = "" -, Val Description = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetLine(Description); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars/" + Calendar; - -Parameters = New Structure; - -If ValueIsFilled(Name) Then -Parameters.Insert("summary", Name); -EndIf; - -If ValueIsFilled(Description) Then -Parameters.Insert("description", Description); -EndIf; - -Response = OPI_Tools.Patch(URL, Parameters, Headers, True); - -Return Response; + , Val Calendar + , Val Name = "" + , Val Description = "") Export + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetLine(Description); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars/" + Calendar; + + Parameters = New Structure; + + If ValueIsFilled(Name) Then + Parameters.Insert("summary", Name); + EndIf; + + If ValueIsFilled(Description) Then + Parameters.Insert("description", Description); + EndIf; + + Response = OPI_Tools.Patch(URL, Parameters, Headers, True); + + Return Response; EndFunction // Clear primary calendar // Clears the event list of the primary calendar -// +// // Parameters: // Token - String - Token - token -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function ClearMainCalendar(Val Token) Export - -OPI_TypeConversion.GetLine(Token); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars/primary/clear"; -Response = OPI_Tools.Post(URL, , Headers, False); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars/primary/clear"; + Response = OPI_Tools.Post(URL, , Headers, False); + + Return Response; EndFunction // Delete calendar // Deletes a calendar by ID -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function DeleteCalendar(Val Token, Val Calendar) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars/" + Calendar; -Response = OPI_Tools.Delete(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars/" + Calendar; + Response = OPI_Tools.Delete(URL, , Headers); + + Return Response; EndFunction @@ -173,130 +173,130 @@ EndFunction // Get list of calendars // Gets an array of account calendars -// +// // Parameters: // Token - String - Token - token -// +// // Return value: // Key-Value Pair - Array of calendar data mappings Function GetCalendarList(Val Token) Export - -OPI_TypeConversion.GetLine(Token); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -ArrayOfCalendars = New Array; - -GetCalendarsListRecursively(Headers, ArrayOfCalendars); - -Return ArrayOfCalendars; - + + OPI_TypeConversion.GetLine(Token); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + ArrayOfCalendars = New Array; + + GetCalendarsListRecursively(Headers, ArrayOfCalendars); + + Return ArrayOfCalendars; + EndFunction // Add calendar to list // Adds an existing calendar to the user's list -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function AddCalendarToList(Val Token, Val Calendar) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList"; - -Parameters = New Structure; -Parameters.Insert("id", Calendar); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList"; + + Parameters = New Structure; + Parameters.Insert("id", Calendar); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Get list calendar // Gets a calendar from the user's list by ID -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetListCalendar(Val Token, Val Calendar) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList/" + Calendar; -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList/" + Calendar; + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; EndFunction // Remove calendar from list // Removes a calendar from the user's list -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function DeleteCalendarFromList(Val Token, Val Calendar) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList/" + Calendar; -Response = OPI_Tools.Delete(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList/" + Calendar; + Response = OPI_Tools.Delete(URL, , Headers); + + Return Response; EndFunction // Edit list calendar // Edits the properties of a calendar from the user's list -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar // PrimaryColor - String - HEX mainоinного цinета (#ffffff) - primary // SecondaryColor - String - HEX addолнительного цinета (#ffffff) - secondary // Hidden - Boolean - Hidden calendar - hidden -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function EditListCalendar(Val Token -, Val Calendar -, Val PrimaryColor -, Val SecondaryColor -, Val Hidden = False) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); -OPI_TypeConversion.GetLine(PrimaryColor); -OPI_TypeConversion.GetLine(SecondaryColor); -OPI_TypeConversion.GetBoolean(Hidden); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList/" + Calendar + "?colorRgbFormat=true"; - -Parameters = New Match; -Parameters.Insert("hidden" , Hidden); -Parameters.Insert("foregroundColor", PrimaryColor); -Parameters.Insert("backgroundColor", SecondaryColor); - -Response = OPI_Tools.Put(URL, Parameters, Headers); - -Return Response; + , Val Calendar + , Val PrimaryColor + , Val SecondaryColor + , Val Hidden = False) Export + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + OPI_TypeConversion.GetLine(PrimaryColor); + OPI_TypeConversion.GetLine(SecondaryColor); + OPI_TypeConversion.GetBoolean(Hidden); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/users/me/calendarList/" + Calendar + "?colorRgbFormat=true"; + + Parameters = New Match; + Parameters.Insert("hidden" , Hidden); + Parameters.Insert("foregroundColor", PrimaryColor); + Parameters.Insert("backgroundColor", SecondaryColor); + + Response = OPI_Tools.Put(URL, Parameters, Headers); + + Return Response; EndFunction @@ -305,164 +305,164 @@ EndFunction #Region EventManagement // Get event description !NOCLI -// +// // Return value: // Key-Value Pair - Empty event template Function GetEventDescription() Export + + CurrentDate = OPI_Tools.GetCurrentDate(); + Hour = 3600; + Event = New Match; + + Event.Insert("Description" , ""); // Event description + Event.Insert("Title" , "New event"); // Title events + Event.Insert("Venue" , ""); // String description of the venue of the event + Event.Insert("StartDate" , CurrentDate); // Date of start events + Event.Insert("EndDate" , CurrentDate + Hour); // Date of end events + Event.Insert("ArrayOfAttachmentURLs", New Match); // Key - name, Value - URL to file + Event.Insert("SendNotifications" , True); // Indication of sending notifications to participants -CurrentDate = OPI_Tools.GetCurrentDate(); -Hour = 3600; -Event = New Match; - -Event.Insert("Description" , ""); // Event description -Event.Insert("Title" , "New event"); // Title events -Event.Insert("Venue" , ""); // String description of the venue of the event -Event.Insert("StartDate" , CurrentDate); // Date of start events -Event.Insert("EndDate" , CurrentDate + Hour); // Date of end events -Event.Insert("ArrayOfAttachmentURLs", New Match); // Key - name, Value - URL to file -Event.Insert("SendNotifications" , True); // Indication of sending notifications to participants - -Return Event; - + Return Event; + EndFunction // Get list of events // Gets the list of all calendar events -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar -// +// // Return value: // Key-Value Pair - Array of event mappings Function GetEventList(Val Token, Val Calendar) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -ArrayOfEvents = New Array; - -GetEventsListRecursively(Headers, Calendar, ArrayOfEvents); - -Return ArrayOfEvents; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + ArrayOfEvents = New Array; + + GetEventsListRecursively(Headers, Calendar, ArrayOfEvents); + + Return ArrayOfEvents; + EndFunction // Get event // Gets an event by ID -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar // Event - String - Event ID - event -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetEvent(Val Token, Val Calendar, Val Event) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); -OPI_TypeConversion.GetLine(Event); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars/" -+ Calendar -+ "/events/" -+ Event; - -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + OPI_TypeConversion.GetLine(Event); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars/" + + Calendar + + "/events/" + + Event; + + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; EndFunction // Create event // Creates a new event -// +// // Parameters: -// Token - String - Token - token +// Token - String - Token - token // Calendar - String - Calendar ID - calendar // EventDescription - Key-Value Pair - Event description - props -// +// // Return value: // String, Arbitrary, HTTPResponse, BinaryData, Undefined - Google server response -Function CreateEvent(Val Token, Val Calendar, Val EventDescription) Export -Return EventManagement(Token, Calendar, EventDescription); +Function CreateEvent(Val Token, Val Calendar, Val EventDescription) Export + Return EventManagement(Token, Calendar, EventDescription); EndFunction // Move event // Moves an event to another calendar -// +// // Parameters: // Token - String - Token - token // SourceCalendar - String - ID of the source calendar - from // TargetCalendar - String - ID of the target calendar - to // Event - String - ID of the source calendar event - event -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function MoveEvent(Val Token, Val SourceCalendar, Val TargetCalendar, Val Event) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(SourceCalendar); -OPI_TypeConversion.GetLine(TargetCalendar); -OPI_TypeConversion.GetLine(Event); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars/" -+ SourceCalendar -+ "/events/" -+ Event -+ "/move?destination=" -+ TargetCalendar; - -Response = OPI_Tools.Post(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(SourceCalendar); + OPI_TypeConversion.GetLine(TargetCalendar); + OPI_TypeConversion.GetLine(Event); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars/" + + SourceCalendar + + "/events/" + + Event + + "/move?destination=" + + TargetCalendar; + + Response = OPI_Tools.Post(URL, , Headers); + + Return Response; EndFunction // Edit event // Edits an existing event -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar // EventDescription - String - New event description - props // Event - String - Event ID - event -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function EditEvent(Val Token, Val Calendar, Val EventDescription, Val Event) Export -Return EventManagement(Token, Calendar, EventDescription, Event); + Return EventManagement(Token, Calendar, EventDescription, Event); EndFunction // Delete event // Deletes an event by ID -// +// // Parameters: // Token - String - Token - token // Calendar - String - Calendar ID - calendar // Event - String - Event ID - event -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function DeleteEvent(Val Token, Val Calendar, Val Event) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); -OPI_TypeConversion.GetLine(Event); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/calendar/v3/calendars/" -+ Calendar -+ "/events/" -+ Event; - -Response = OPI_Tools.Delete(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + OPI_TypeConversion.GetLine(Event); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/calendar/v3/calendars/" + + Calendar + + "/events/" + + Event; + + Response = OPI_Tools.Delete(URL, , Headers); + + Return Response; EndFunction @@ -473,159 +473,159 @@ EndFunction #Region ServiceProceduresAndFunctions Function ConvertDate(Val Date) - -OPI_TypeConversion.GetDate(Date); - -DateStructure = New Structure; - -If Not TypeValue(Date) = Type("Date") Then -Return Undefined; -EndIf; - -If Date = StartOfDay(Date) Then -DateFormat = "DF=yyyy-MM-dd"; -Field = "date"; -Else -DateFormat = "DF=yyyy-MM-ddTHH:mm:ssZ"; -Field = "dateTime"; -EndIf; - -Date = Format(Date, DateFormat); -DateStructure.Insert(Field , Date); -DateStructure.Insert("timeZone", "Europe/Moscow"); - -Return DateStructure; - + + OPI_TypeConversion.GetDate(Date); + + DateStructure = New Structure; + + If Not TypeValue(Date) = Type("Date") Then + Return Undefined; + EndIf; + + If Date = StartOfDay(Date) Then + DateFormat = "DF=yyyy-MM-dd"; + Field = "date"; + Else + DateFormat = "DF=yyyy-MM-ddTHH:mm:ssZ"; + Field = "dateTime"; + EndIf; + + Date = Format(Date, DateFormat); + DateStructure.Insert(Field , Date); + DateStructure.Insert("timeZone", "Europe/Moscow"); + + Return DateStructure; + EndFunction Function ConvertAttachments(Val Attachments) - -OPI_TypeConversion.GetCollection(Attachments); - -AttachmentsArray = New Array; - -If TypeValue(Attachments) = Type("Match") Or TypeValue(Attachments) = Type("Structure") Then - -For Each Attachment In Attachments Do - -CurrentAttachment = New Structure; -CurrentAttachment.Insert("title" , Attachment.Key); -CurrentAttachment.Insert("fileUrl", Attachment.Value); - -AttachmentsArray.Add(CurrentAttachment); - -EndDo; - -EndIf; - -If AttachmentsArray.Quantity() > 0 Then -Return AttachmentsArray; -Else -Return Undefined; -EndIf; + + OPI_TypeConversion.GetCollection(Attachments); + + AttachmentsArray = New Array; + + If TypeValue(Attachments) = Type("Match") Or TypeValue(Attachments) = Type("Structure") Then + + For Each Attachment In Attachments Do + + CurrentAttachment = New Structure; + CurrentAttachment.Insert("title" , Attachment.Key); + CurrentAttachment.Insert("fileUrl", Attachment.Value); + + AttachmentsArray.Add(CurrentAttachment); + + EndDo; + + EndIf; + + If AttachmentsArray.Quantity() > 0 Then + Return AttachmentsArray; + Else + Return Undefined; + EndIf; EndFunction Function EventManagement(Val Token, Val Calendar, Val EventDescription, Val Event = "") - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Calendar); -OPI_TypeConversion.GetLine(Event); -OPI_TypeConversion.GetCollection(EventDescription); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -Existing = ValueIsFilled(Event); -URL = "https://www.googleapis.com/calendar/v3/calendars/" -+ Calendar -+ "/events" -+ ?(Existing, "/" + Event, ""); - -Date0 = EventDescription["StartDate"]; -Date1 = EventDescription["EndDate"]; -Attachments = EventDescription["ArrayOfAttachmentURLs"]; -Attachments = ConvertAttachments(Attachments); -Notifications = ?(EventDescription["SendNotifications"] = Undefined -, False -, EventDescription["SendNotifications"]); - -Parameters = New Structure; -Parameters.Insert("summary" , EventDescription["Title"]); -Parameters.Insert("description", EventDescription["Description"]); -Parameters.Insert("location" , EventDescription["Venue"]); -Parameters.Insert("start" , ConvertDate(Date0)); -Parameters.Insert("end" , ConvertDate(Date1)); -Parameters.Insert("attachments", Attachments); - -URLParameters = New Structure; -URLParameters.Insert("sendUpdates" , ?(Notifications, "all", "none")); -URLParameters.Insert("supportsAttachments" , ?(ValueIsFilled(Attachments), "true", "false")); - -URL = URL + OPI_Tools.RequestParametersToString(URLParameters); - -OPI_Tools.RemoveEmptyCollectionFields(Parameters); - -If Existing Then -Response = OPI_Tools.Patch(URL, Parameters, Headers, True); -Else -Response = OPI_Tools.Post(URL, Parameters, Headers, True); -EndIf; - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Calendar); + OPI_TypeConversion.GetLine(Event); + OPI_TypeConversion.GetCollection(EventDescription); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + Existing = ValueIsFilled(Event); + URL = "https://www.googleapis.com/calendar/v3/calendars/" + + Calendar + + "/events" + + ?(Existing, "/" + Event, ""); + + Date0 = EventDescription["StartDate"]; + Date1 = EventDescription["EndDate"]; + Attachments = EventDescription["ArrayOfAttachmentURLs"]; + Attachments = ConvertAttachments(Attachments); + Notifications = ?(EventDescription["SendNotifications"] = Undefined + , False + , EventDescription["SendNotifications"]); + + Parameters = New Structure; + Parameters.Insert("summary" , EventDescription["Title"]); + Parameters.Insert("description", EventDescription["Description"]); + Parameters.Insert("location" , EventDescription["Venue"]); + Parameters.Insert("start" , ConvertDate(Date0)); + Parameters.Insert("end" , ConvertDate(Date1)); + Parameters.Insert("attachments", Attachments); + + URLParameters = New Structure; + URLParameters.Insert("sendUpdates" , ?(Notifications, "all", "none")); + URLParameters.Insert("supportsAttachments" , ?(ValueIsFilled(Attachments), "true", "false")); + + URL = URL + OPI_Tools.RequestParametersToString(URLParameters); + + OPI_Tools.RemoveEmptyCollectionFields(Parameters); + + If Existing Then + Response = OPI_Tools.Patch(URL, Parameters, Headers, True); + Else + Response = OPI_Tools.Post(URL, Parameters, Headers, True); + EndIf; + + Return Response; EndFunction -Procedure GetCalendarsListRecursively(Val Headers, ArrayOfCalendars, Page = "") - -Items = "items"; -NPT = "nextPageToken"; -Parameters = New Structure; - -If ValueIsFilled(Page) Then -Parameters.Insert("pageToken", Page); -EndIf; - -Result = OPI_Tools.Get("https://www.googleapis.com/calendar/v3/users/me/calendarList" -, Parameters -, Headers); - -Calendars = Result[Items]; -Page = Result[NPT]; - -For Each Calendar In Calendars Do -ArrayOfCalendars.Add(Calendar); -EndDo; - -If Calendars.Quantity() > 0 And ValueIsFilled(Page) Then -GetCalendarsListRecursively(Headers, ArrayOfCalendars, Page); -EndIf; - +Procedure GetCalendarsListRecursively(Val Headers, ArrayOfCalendars, Page = "") + + Items = "items"; + NPT = "nextPageToken"; + Parameters = New Structure; + + If ValueIsFilled(Page) Then + Parameters.Insert("pageToken", Page); + EndIf; + + Result = OPI_Tools.Get("https://www.googleapis.com/calendar/v3/users/me/calendarList" + , Parameters + , Headers); + + Calendars = Result[Items]; + Page = Result[NPT]; + + For Each Calendar In Calendars Do + ArrayOfCalendars.Add(Calendar); + EndDo; + + If Calendars.Quantity() > 0 And ValueIsFilled(Page) Then + GetCalendarsListRecursively(Headers, ArrayOfCalendars, Page); + EndIf; + EndProcedure -Procedure GetEventsListRecursively(Val Headers, Val Calendar, ArrayOfEvents, Page = "") - -Items = "items"; -NPT = "nextPageToken"; -Parameters = New Structure; - -If ValueIsFilled(Page) Then -Parameters.Insert("pageToken", Page); -EndIf; - -Result = OPI_Tools.Get("https://www.googleapis.com/calendar/v3/calendars/" + Calendar + "/events" -, Parameters -, Headers); - -Events = Result[Items]; -Page = Result[NPT]; - -For Each Event In Events Do -ArrayOfEvents.Add(Event); -EndDo; - -If Events.Quantity() > 0 And ValueIsFilled(Page) Then -GetEventsListRecursively(Headers, ArrayOfEvents, Page); -EndIf; - +Procedure GetEventsListRecursively(Val Headers, Val Calendar, ArrayOfEvents, Page = "") + + Items = "items"; + NPT = "nextPageToken"; + Parameters = New Structure; + + If ValueIsFilled(Page) Then + Parameters.Insert("pageToken", Page); + EndIf; + + Result = OPI_Tools.Get("https://www.googleapis.com/calendar/v3/calendars/" + Calendar + "/events" + , Parameters + , Headers); + + Events = Result[Items]; + Page = Result[NPT]; + + For Each Event In Events Do + ArrayOfEvents.Add(Event); + EndDo; + + If Events.Quantity() > 0 And ValueIsFilled(Page) Then + GetEventsListRecursively(Headers, ArrayOfEvents, Page); + EndIf; + EndProcedure #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/OPI_GoogleCalendar.mdo b/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/OPI_GoogleCalendar.mdo index a6581846e5..aefdff4c4f 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/OPI_GoogleCalendar.mdo +++ b/src/en/OPI/src/CommonModules/OPI_GoogleCalendar/OPI_GoogleCalendar.mdo @@ -1,11 +1,11 @@  -OPI_GoogleCalendar - - -OPI google calendar - -true -true -true + OPI_GoogleCalendar + + + OPI google calendar + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleDrive/Module.bsl b/src/en/OPI/src/CommonModules/OPI_GoogleDrive/Module.bsl index d5b845f13d..1f1fe87a66 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleDrive/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_GoogleDrive/Module.bsl @@ -38,275 +38,275 @@ // Get object information // Gets information about a folder or file by ID -// +// // Parameters: // Token - String - Token - token // Identifier - String - Identifier of the file or folder - object -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetObjectInformation(Val Token, Val Identifier) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Identifier); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + Identifier; - -Parameters = New Structure; -Parameters.Insert("fields", "*"); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Identifier); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + Identifier; + + Parameters = New Structure; + Parameters.Insert("fields", "*"); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; EndFunction // Get list of directories // Gets the list of drive directories -// +// // Parameters: // Token - String - Token - token // NameContains - String - Filter by name - querry // Detailed - Boolean - Adds a list of files to the directory fields - depth -// +// // Return value: // Key-Value Pair - Array of directory mappings Function GetDirectoriesList(Val Token, Val NameContains = "", Val Detailed = False) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(NameContains); -OPI_TypeConversion.GetBoolean(Detailed); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -ArrayOfObjects = New Array; -Filter = New Array; - -Filter.Add("mimeType = 'application/vnd.google-apps.folder'"); - -If ValueIsFilled(NameContains) Then -Filter.Add("name contains '" + NameContains + "'"); -EndIf; - -GetObjectsListRecursively(Headers, ArrayOfObjects, Detailed, Filter); - -If Detailed Then -BreakDownObjectsInDetail(Token, ArrayOfObjects); -EndIf; - -Return ArrayOfObjects; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(NameContains); + OPI_TypeConversion.GetBoolean(Detailed); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + ArrayOfObjects = New Array; + Filter = New Array; + + Filter.Add("mimeType = 'application/vnd.google-apps.folder'"); + + If ValueIsFilled(NameContains) Then + Filter.Add("name contains '" + NameContains + "'"); + EndIf; + + GetObjectsListRecursively(Headers, ArrayOfObjects, Detailed, Filter); + + If Detailed Then + BreakDownObjectsInDetail(Token, ArrayOfObjects); + EndIf; + + Return ArrayOfObjects; + EndFunction // Get list of files // Gets the list of files -// +// // Parameters: // Token - String - Token - token // NameContains - String - Filter by name - querry // Directory - String - Filter by parent directory ID - catalog -// +// // Return value: // Key-Value Pair - Array of file mappings Function GetFilesList(Val Token, Val NameContains = "", Val Directory = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(NameContains); -OPI_TypeConversion.GetLine(Directory); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -ArrayOfObjects = New Array; -Filter = New Array; - -Filter.Add("mimeType != 'application/vnd.google-apps.folder'"); - -If ValueIsFilled(NameContains) Then -Filter.Add("name contains '" + NameContains + "'"); -EndIf; - -If ValueIsFilled(Directory) Then -Filter.Add("'" + Directory + "' in parents"); -EndIf; - -GetObjectsListRecursively(Headers, ArrayOfObjects, , Filter); - -Return ArrayOfObjects; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(NameContains); + OPI_TypeConversion.GetLine(Directory); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + ArrayOfObjects = New Array; + Filter = New Array; + + Filter.Add("mimeType != 'application/vnd.google-apps.folder'"); + + If ValueIsFilled(NameContains) Then + Filter.Add("name contains '" + NameContains + "'"); + EndIf; + + If ValueIsFilled(Directory) Then + Filter.Add("'" + Directory + "' in parents"); + EndIf; + + GetObjectsListRecursively(Headers, ArrayOfObjects, , Filter); + + Return ArrayOfObjects; EndFunction // Upload file // Uploads a file to the drive -// +// // Parameters: // Token - String - Token - token // File - BinaryData,String - File to be uploaded - file // Description - Key-Value Pair - See GetFileDescription - props - JSON description or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function UploadFile(Val Token, Val File, Val Description) Export -Return FileManagement(Token, File, Description); + Return FileManagement(Token, File, Description); EndFunction // Create folder // Creates an empty directory on the drive -// +// // Parameters: // Token - String - Token - token // Name - String - Folder name - title // Parent - String - Parent - catalog -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function CreateFolder(Val Token, Val Name, Val Parent = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetLine(Parent); - -Description = New Match; -Description.Insert("MIME" , "application/vnd.google-apps.folder"); -Description.Insert("Name" , Name); -Description.Insert("Description", ""); -Description.Insert("Parent", ?(ValueIsFilled(Parent), Parent, "root")); - -Return FileManagement(Token, , Description); - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetLine(Parent); + + Description = New Match; + Description.Insert("MIME" , "application/vnd.google-apps.folder"); + Description.Insert("Name" , Name); + Description.Insert("Description", ""); + Description.Insert("Parent", ?(ValueIsFilled(Parent), Parent, "root")); + + Return FileManagement(Token, , Description); + EndFunction // Download file // Gets file by ID -// +// // Parameters: // Token - String - Token - token // Identifier - String - File identifier - object -// SavePath - String - File save path - out -// +// SavePath - String - File save path - out +// // Return value: // BinaryData,String - Binary data or file path when SavePath parameter is specified Function DownloadFile(Val Token, Val Identifier, Val SavePath = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Identifier); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + Identifier; - -Parameters = New Match; -Parameters.Insert("alt", "media"); - -Response = OPI_Tools.Get(URL, Parameters , Headers, SavePath); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Identifier); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + Identifier; + + Parameters = New Match; + Parameters.Insert("alt", "media"); + + Response = OPI_Tools.Get(URL, Parameters , Headers, SavePath); + + Return Response; EndFunction // Copy object // Copies file or directory -// +// // Parameters: // Token - String - Token - token // Identifier - String - Object identifier - object // NewName - String - New object name - title // NewParent - String - New parent directory - catalog -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function CopyObject(Val Token, Val Identifier, Val NewName = "", Val NewParent = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(NewName); -OPI_TypeConversion.GetLine(Identifier); -OPI_TypeConversion.GetLine(NewParent); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + Identifier + "/copy"; - -Parameters = New Structure; - -If ValueIsFilled(NewName) Then -Parameters.Insert("name", NewName); -EndIf; - -If ValueIsFilled(NewParent) Then - -ArrayOfParents = New Array; -ArrayOfParents.Add(NewParent); -Parameters.Insert("parents", ArrayOfParents); - -EndIf; - -Response = OPI_Tools.Post(URL, Parameters , Headers, True); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(NewName); + OPI_TypeConversion.GetLine(Identifier); + OPI_TypeConversion.GetLine(NewParent); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + Identifier + "/copy"; + + Parameters = New Structure; + + If ValueIsFilled(NewName) Then + Parameters.Insert("name", NewName); + EndIf; + + If ValueIsFilled(NewParent) Then + + ArrayOfParents = New Array; + ArrayOfParents.Add(NewParent); + Parameters.Insert("parents", ArrayOfParents); + + EndIf; + + Response = OPI_Tools.Post(URL, Parameters , Headers, True); + + Return Response; EndFunction // Update file // Updates file binary data -// +// // Parameters: // Token - String - Token - token // Identifier - String - Identifier of the object to update - object // File - BinaryData,String - File source for update - file // NewName - String - Nоinое имя file (еwithли необхоdимо) - title -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function UpdateFile(Val Token, Val Identifier, Val File, Val NewName = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Identifier); -OPI_TypeConversion.GetLine(NewName); -OPI_TypeConversion.GetBinaryData(File); - -If ValueIsFilled(NewName) Then -Description = New Match; -Description.Insert("Name", NewName); -Else -Description = ""; -EndIf; - -Return FileManagement(Token, File, Description, Identifier); - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Identifier); + OPI_TypeConversion.GetLine(NewName); + OPI_TypeConversion.GetBinaryData(File); + + If ValueIsFilled(NewName) Then + Description = New Match; + Description.Insert("Name", NewName); + Else + Description = ""; + EndIf; + + Return FileManagement(Token, File, Description, Identifier); + EndFunction // Delete object // Deletes file or directory by ID -// +// // Parameters: // Token - String - Token - token // Identifier - String - Identifier of the object to delete - object -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function DeleteObject(Val Token, Val Identifier) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Identifier); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + Identifier; -Response = OPI_Tools.Delete(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Identifier); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + Identifier; + Response = OPI_Tools.Delete(URL, , Headers); + + Return Response; EndFunction // Get file description !NOCLI -// +// // Return value: // Key-Value Pair - File description Function GetFileDescription() Export - -Description = New Match; -Description.Insert("MIME" , "image/jpeg"); // MIME-type uploading file -Description.Insert("Name" , "New file.jpg"); // File name with extension -Description.Insert("Description" , "This is a new file"); // File description -Description.Insert("Parent" , "root"); // ID directory upload or "root" for upload in root - -Return Description; - + + Description = New Match; + Description.Insert("MIME" , "image/jpeg"); // MIME-type uploading file + Description.Insert("Name" , "New file.jpg"); // File name with extension + Description.Insert("Description" , "This is a new file"); // File description + Description.Insert("Parent" , "root"); // ID directory upload or "root" for upload in root + + Return Description; + EndFunction #EndRegion @@ -315,108 +315,108 @@ EndFunction // Create comment // Creates a comment for a file or directory -// +// // Parameters: // Token - String - Token - token -// Identifier - String - Identifier of the object that needs a comment - object +// Identifier - String - Identifier of the object that needs a comment - object // Comment - String - Comment text - text -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function CreateComment(Val Token, Val Identifier, Val Comment) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Identifier); -OPI_TypeConversion.GetLine(Comment); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + Identifier + "/comments?fields=*"; - -Parameters = New Structure; -Parameters.Insert("content", Comment); - -Response = OPI_Tools.POST(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Identifier); + OPI_TypeConversion.GetLine(Comment); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + Identifier + "/comments?fields=*"; + + Parameters = New Structure; + Parameters.Insert("content", Comment); + + Response = OPI_Tools.POST(URL, Parameters, Headers); + + Return Response; EndFunction // Get comment // Gets comment by ID -// +// // Parameters: // Token - String - Token - token // ObjectID - String - Identifier of the file or directory where the comment is located - object // CommentID - String - Comment identifier - comment -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetComment(Val Token, Val ObjectID, Val CommentID) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ObjectID); -OPI_TypeConversion.GetLine(CommentID); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + ObjectID + "/comments/" + CommentID; - -Parameters = New Structure; -Parameters.Insert("fields", "*"); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ObjectID); + OPI_TypeConversion.GetLine(CommentID); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + ObjectID + "/comments/" + CommentID; + + Parameters = New Structure; + Parameters.Insert("fields", "*"); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; EndFunction // Get list of comments // Gets the list of all comments of the object -// +// // Parameters: // Token - String - Token - token // ObjectID - String - Object identifier - object -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetCommentList(Val Token, Val ObjectID) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ObjectID); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + ObjectID + "/comments"; - -Parameters = New Structure; -Parameters.Insert("fields", "*"); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ObjectID); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + ObjectID + "/comments"; + + Parameters = New Structure; + Parameters.Insert("fields", "*"); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; EndFunction // Delete comment // Deletes comment by ID -// +// // Parameters: // Token - String - Token - token // ObjectID - String - Identifier of the file or directory where the comment is located - object // CommentID - String - Comment identifier - comment -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function DeleteComment(Val Token, Val ObjectID, Val CommentID) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ObjectID); -OPI_TypeConversion.GetLine(CommentID); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://www.googleapis.com/drive/v3/files/" + ObjectID + "/comments/" + CommentID; - -Response = OPI_Tools.Delete(URL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ObjectID); + OPI_TypeConversion.GetLine(CommentID); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://www.googleapis.com/drive/v3/files/" + ObjectID + "/comments/" + CommentID; + + Response = OPI_Tools.Delete(URL, , Headers); + + Return Response; EndFunction @@ -426,294 +426,294 @@ EndFunction #Region ServiceProceduresAndFunctions -Procedure GetObjectsListRecursively(Val Headers, ArrayOfObjects, Detailed = False, Filter = "", Page = "") - -URL = "https://www.googleapis.com/drive/v3/files"; -Files = "files"; -NPT = "nextPageToken"; -Parameters = New Structure; -Parameters.Insert("fields", "*"); - -If ValueIsFilled(Page) Then -Parameters.Insert("pageToken", Page); -EndIf; - -If ValueIsFilled(Filter) And TypeValue(Filter) = Type("Array") Then -FilterString = StrJoin(Filter, " and "); -Parameters.Insert("q", FilterString); -EndIf; - -Result = OPI_Tools.Get(URL, Parameters, Headers); - -Objects = Result[Files]; -Page = Result[NPT]; - -For Each CurrentObject In Objects Do -ArrayOfObjects.Add(CurrentObject); -EndDo; - -If Objects.Quantity() > 0 And ValueIsFilled(Page) Then -GetObjectsListRecursively(Headers, ArrayOfObjects, Detailed, Filter, Page); -EndIf; - +Procedure GetObjectsListRecursively(Val Headers, ArrayOfObjects, Detailed = False, Filter = "", Page = "") + + URL = "https://www.googleapis.com/drive/v3/files"; + Files = "files"; + NPT = "nextPageToken"; + Parameters = New Structure; + Parameters.Insert("fields", "*"); + + If ValueIsFilled(Page) Then + Parameters.Insert("pageToken", Page); + EndIf; + + If ValueIsFilled(Filter) And TypeValue(Filter) = Type("Array") Then + FilterString = StrJoin(Filter, " and "); + Parameters.Insert("q", FilterString); + EndIf; + + Result = OPI_Tools.Get(URL, Parameters, Headers); + + Objects = Result[Files]; + Page = Result[NPT]; + + For Each CurrentObject In Objects Do + ArrayOfObjects.Add(CurrentObject); + EndDo; + + If Objects.Quantity() > 0 And ValueIsFilled(Page) Then + GetObjectsListRecursively(Headers, ArrayOfObjects, Detailed, Filter, Page); + EndIf; + EndProcedure -Procedure BreakDownObjectsInDetail(Val Token, ArrayOfObjects) - -For Each CurrentObject In ArrayOfObjects Do - -ArrayOfFiles = New Array; -CurrentID = CurrentObject["id"]; - -Result = GetFilesList(Token, , CurrentID); - -For Each File In Result Do -ArrayOfFiles.Add(File); -EndDo; - -CurrentObject.Insert("files", ArrayOfFiles); - -EndDo; - +Procedure BreakDownObjectsInDetail(Val Token, ArrayOfObjects) + + For Each CurrentObject In ArrayOfObjects Do + + ArrayOfFiles = New Array; + CurrentID = CurrentObject["id"]; + + Result = GetFilesList(Token, , CurrentID); + + For Each File In Result Do + ArrayOfFiles.Add(File); + EndDo; + + CurrentObject.Insert("files", ArrayOfFiles); + + EndDo; + EndProcedure Procedure FormFileUploadParameters(Description) + + FormedDescription = New Match; + OPI_Tools.RemoveEmptyCollectionFields(Description); -FormedDescription = New Match; -OPI_Tools.RemoveEmptyCollectionFields(Description); - -FieldMapping = New Match; -FieldMapping.Insert("MIME" , "mimeType"); -FieldMapping.Insert("Name" , "name"); -FieldMapping.Insert("Description" , "description"); -FieldMapping.Insert("Parent" , "parents"); -FieldMapping.Insert("Extension", "fileExtension"); - -For Each Element In Description Do - -If Element.Key = "Parent" Then - -CurrentValue = New Array; -CurrentValue.Add(Element.Value); - -Else - -CurrentValue = Element.Value; - -EndIf; - -FieldName = FieldMapping.Get(Element.Key); -FormedDescription.Insert(FieldName, CurrentValue); - -EndDo; - -Description = FormedDescription; - + FieldMapping = New Match; + FieldMapping.Insert("MIME" , "mimeType"); + FieldMapping.Insert("Name" , "name"); + FieldMapping.Insert("Description" , "description"); + FieldMapping.Insert("Parent" , "parents"); + FieldMapping.Insert("Extension", "fileExtension"); + + For Each Element In Description Do + + If Element.Key = "Parent" Then + + CurrentValue = New Array; + CurrentValue.Add(Element.Value); + + Else + + CurrentValue = Element.Value; + + EndIf; + + FieldName = FieldMapping.Get(Element.Key); + FormedDescription.Insert(FieldName, CurrentValue); + + EndDo; + + Description = FormedDescription; + EndProcedure -Function FileManagement(Val Token, Val File = "", Val Description = "", Val Identifier = "") - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Identifier); - -If ValueIsFilled(Description) Then -OPI_TypeConversion.GetCollection(Description); -EndIf; - -MimeType = "mimeType"; - -If ValueIsFilled(Identifier) Then -MIME = GetObjectInformation(Token, Identifier)[MimeType]; -Else -MIME = Description["MIME"]; -EndIf; - -If Not ValueIsFilled(Description) Then -Description = New Match; -EndIf; - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -FormFileUploadParameters(Description); -JSONDescription = OPI_Tools.JSONString(Description); - -FileMapping = New Match; - -If ValueIsFilled(File) Then - -ChunkSize = 268435457; -Size = OPI_Tools.ConvertDataWithSizeRetrieval(File, ChunkSize); - -FileMapping.Insert(File, MIME); - -If Size < ChunkSize And TypeValue(File) = Type("BinaryData") Then -Response = UploadSmallFile(JSONDescription, FileMapping, Headers, Identifier); -Else -Response = UploadLargeFile(Description, FileMapping, Headers, Identifier); -EndIf; - -Else -Response = UploadSmallFile(JSONDescription, FileMapping, Headers, Identifier); -EndIf; - -Return Response; - +Function FileManagement(Val Token, Val File = "", Val Description = "", Val Identifier = "") + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Identifier); + + If ValueIsFilled(Description) Then + OPI_TypeConversion.GetCollection(Description); + EndIf; + + MimeType = "mimeType"; + + If ValueIsFilled(Identifier) Then + MIME = GetObjectInformation(Token, Identifier)[MimeType]; + Else + MIME = Description["MIME"]; + EndIf; + + If Not ValueIsFilled(Description) Then + Description = New Match; + EndIf; + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + FormFileUploadParameters(Description); + JSONDescription = OPI_Tools.JSONString(Description); + + FileMapping = New Match; + + If ValueIsFilled(File) Then + + ChunkSize = 268435457; + Size = OPI_Tools.ConvertDataWithSizeRetrieval(File, ChunkSize); + + FileMapping.Insert(File, MIME); + + If Size < ChunkSize And TypeValue(File) = Type("BinaryData") Then + Response = UploadSmallFile(JSONDescription, FileMapping, Headers, Identifier); + Else + Response = UploadLargeFile(Description, FileMapping, Headers, Identifier); + EndIf; + + Else + Response = UploadSmallFile(JSONDescription, FileMapping, Headers, Identifier); + EndIf; + + Return Response; + EndFunction Function UploadSmallFile(Val Description, Val FileMapping, Val Headers, Val Identifier = "") + + URL = "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"; + + If ValueIsFilled(Identifier) Then + URL = StringReplace(URL, "/files", "/files/" + Identifier); + Response = OPI_Tools.PatchMultipartRelated(URL, Description, FileMapping, Headers); + Else + Response = OPI_Tools.PostMultipartRelated(URL, Description, FileMapping, Headers); + EndIf; -URL = "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"; - -If ValueIsFilled(Identifier) Then -URL = StringReplace(URL, "/files", "/files/" + Identifier); -Response = OPI_Tools.PatchMultipartRelated(URL, Description, FileMapping, Headers); -Else -Response = OPI_Tools.PostMultipartRelated(URL, Description, FileMapping, Headers); -EndIf; - -Return Response; - + Return Response; + EndFunction Function UploadLargeFile(Val Description, Val FileMapping, Val Headers, Val Identifier = "") - -For Each File In FileMapping Do -Binary = File.Key; -Break; -EndDo; - -URL = "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable"; - -If ValueIsFilled(Identifier) Then -URL = StringReplace(URL, "/files", "/files/" + Identifier); -Response = OPI_Tools.Patch(URL, Description, Headers, True, True); -Else -Response = OPI_Tools.Post(URL, Description, Headers, True, True); -EndIf; - -UploadURL = Response.Headers["Location"]; - -If Not ValueIsFilled(UploadURL) Then -OPI_Tools.ProcessResponse(Response); -Return Response; -EndIf; - -UploadResponse = UploadFileInParts(Binary, UploadURL); -Response = ?(ValueIsFilled(UploadResponse), UploadResponse, Response); - -OPI_Tools.ProcessResponse(Response); -Return Response; - + + For Each File In FileMapping Do + Binary = File.Key; + Break; + EndDo; + + URL = "https://www.googleapis.com/upload/drive/v3/files?uploadType=resumable"; + + If ValueIsFilled(Identifier) Then + URL = StringReplace(URL, "/files", "/files/" + Identifier); + Response = OPI_Tools.Patch(URL, Description, Headers, True, True); + Else + Response = OPI_Tools.Post(URL, Description, Headers, True, True); + EndIf; + + UploadURL = Response.Headers["Location"]; + + If Not ValueIsFilled(UploadURL) Then + OPI_Tools.ProcessResponse(Response); + Return Response; + EndIf; + + UploadResponse = UploadFileInParts(Binary, UploadURL); + Response = ?(ValueIsFilled(UploadResponse), UploadResponse, Response); + + OPI_Tools.ProcessResponse(Response); + Return Response; + EndFunction Function UploadFileInParts(Val Binary, Val UploadURL) - -Response = ""; -ChunkSize = 268435456; -BytesRead = 0; -CurrentPosition = 0; -TotalSize = Binary.Size(); -StrTotalSize = OPI_Tools.NumberToString(TotalSize); -ReadingData = New ReadingData(Binary); -SourceStream = ReadingData.SourceStream(); - -WHile BytesRead < TotalSize Do - -BytesRead = SourceStream.CurrentPosition(); -Result = ReadingData.Read(ChunkSize); -Current data = Result.GetBinaryData(); -CurrentSize = Current data.Size(); -NextPosition = CurrentPosition + CurrentSize - 1; - -If Not ValueIsFilled(Current data) Then -Break; -EndIf; - -StreamHeader = "bytes " -+ OPI_Tools.NumberToString(CurrentPosition) -+ "-" -+ OPI_Tools.NumberToString(NextPosition) -+ "/" -+ StrTotalSize; - -AdditionalHeaders = New Match; -AdditionalHeaders.Insert("Content-Length", OPI_Tools.NumberToString(CurrentSize)); -AdditionalHeaders.Insert("Content-Range" , StreamHeader); -AdditionalHeaders.Insert("Content-Type" , "application/octet-stream"); - -Response = OPI_Tools.Put(UploadURL, Current data, AdditionalHeaders, False, True); - -CheckResult = CheckPartUpload(Response, StrTotalSize, AdditionalHeaders, UploadURL, CurrentPosition); - -If ValueIsFilled(CheckResult) Then -Return CheckResult; -EndIf; - -// !OInt KBytes = 1024; -// !OInt MByte = KBytes * KBytes; -// !OInt Notify(OPI_Tools.ProgressInformation(CurrentPosition, TotalSize, "MB", MByte)); - -// !OInt PerformGarbageCollection(); -// !OInt ReleaseObject(Current data); - -EndDo; - -Return Response; - + + Response = ""; + ChunkSize = 268435456; + BytesRead = 0; + CurrentPosition = 0; + TotalSize = Binary.Size(); + StrTotalSize = OPI_Tools.NumberToString(TotalSize); + ReadingData = New ReadingData(Binary); + SourceStream = ReadingData.SourceStream(); + + WHile BytesRead < TotalSize Do + + BytesRead = SourceStream.CurrentPosition(); + Result = ReadingData.Read(ChunkSize); + Current data = Result.GetBinaryData(); + CurrentSize = Current data.Size(); + NextPosition = CurrentPosition + CurrentSize - 1; + + If Not ValueIsFilled(Current data) Then + Break; + EndIf; + + StreamHeader = "bytes " + + OPI_Tools.NumberToString(CurrentPosition) + + "-" + + OPI_Tools.NumberToString(NextPosition) + + "/" + + StrTotalSize; + + AdditionalHeaders = New Match; + AdditionalHeaders.Insert("Content-Length", OPI_Tools.NumberToString(CurrentSize)); + AdditionalHeaders.Insert("Content-Range" , StreamHeader); + AdditionalHeaders.Insert("Content-Type" , "application/octet-stream"); + + Response = OPI_Tools.Put(UploadURL, Current data, AdditionalHeaders, False, True); + + CheckResult = CheckPartUpload(Response, StrTotalSize, AdditionalHeaders, UploadURL, CurrentPosition); + + If ValueIsFilled(CheckResult) Then + Return CheckResult; + EndIf; + + // !OInt KBytes = 1024; + // !OInt MByte = KBytes * KBytes; + // !OInt Notify(OPI_Tools.ProgressInformation(CurrentPosition, TotalSize, "MB", MByte)); + + // !OInt PerformGarbageCollection(); + // !OInt ReleaseObject(Current data); + + EndDo; + + Return Response; + EndFunction Function CheckPartUpload(Response, StrTotalSize, AdditionalHeaders, UploadURL, CurrentPosition) - -StartOfErrorCodes = 400; -EndOfFailureCodes = 600; -StartOfSuccessCodes = 200; -EndOfSuccessCodes = 300; -Redirection = 308; - -If Response.StatusCode >= StartOfErrorCodes And Response.StatusCode < EndOfFailureCodes Then - -StreamHeader = "bytes */" + StrTotalSize; -AdditionalHeaders.Insert("Content-Range" , StreamHeader); - -CheckResponse = OPI_Tools.Put(UploadURL, "", AdditionalHeaders, False, True); - -If CheckResponse.StatusCode >= StartOfSuccessCodes And CheckResponse.StatusCode < EndOfSuccessCodes Then - -OPI_Tools.ProcessResponse(CheckResponse); -Return CheckResponse; - -ElsIf CheckResponse.StatusCode = Redirection Then - -UploadedData = Response.Headers["Range"]; - -Else - -OPI_Tools.ProcessResponse(Response); -Return Response; - -EndIf; - -Else -UploadedData = Response.Headers["Range"]; -EndIf; - -If Not ValueIsFilled(UploadedData) Then -OPI_Tools.ProcessResponse(Response); -Return Response; -EndIf; - -UploadedData = StringReplace(UploadedData, "bytes=", ""); -ArrayOfInformation = StrSplit(UploadedData, "-", False); -PartsRequired = 2; - -If Not ArrayOfInformation.Quantity() = PartsRequired Then -OPI_Tools.ProcessResponse(Response); -Return Response; -EndIf; - -CurrentPosition = Number(ArrayOfInformation[1]) + 1; - -Return ""; - + + StartOfErrorCodes = 400; + EndOfFailureCodes = 600; + StartOfSuccessCodes = 200; + EndOfSuccessCodes = 300; + Redirection = 308; + + If Response.StatusCode >= StartOfErrorCodes And Response.StatusCode < EndOfFailureCodes Then + + StreamHeader = "bytes */" + StrTotalSize; + AdditionalHeaders.Insert("Content-Range" , StreamHeader); + + CheckResponse = OPI_Tools.Put(UploadURL, "", AdditionalHeaders, False, True); + + If CheckResponse.StatusCode >= StartOfSuccessCodes And CheckResponse.StatusCode < EndOfSuccessCodes Then + + OPI_Tools.ProcessResponse(CheckResponse); + Return CheckResponse; + + ElsIf CheckResponse.StatusCode = Redirection Then + + UploadedData = Response.Headers["Range"]; + + Else + + OPI_Tools.ProcessResponse(Response); + Return Response; + + EndIf; + + Else + UploadedData = Response.Headers["Range"]; + EndIf; + + If Not ValueIsFilled(UploadedData) Then + OPI_Tools.ProcessResponse(Response); + Return Response; + EndIf; + + UploadedData = StringReplace(UploadedData, "bytes=", ""); + ArrayOfInformation = StrSplit(UploadedData, "-", False); + PartsRequired = 2; + + If Not ArrayOfInformation.Quantity() = PartsRequired Then + OPI_Tools.ProcessResponse(Response); + Return Response; + EndIf; + + CurrentPosition = Number(ArrayOfInformation[1]) + 1; + + Return ""; + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleDrive/OPI_GoogleDrive.mdo b/src/en/OPI/src/CommonModules/OPI_GoogleDrive/OPI_GoogleDrive.mdo index 854d38a3a1..1cc27c5aac 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleDrive/OPI_GoogleDrive.mdo +++ b/src/en/OPI/src/CommonModules/OPI_GoogleDrive/OPI_GoogleDrive.mdo @@ -1,11 +1,11 @@  -OPI_GoogleDrive - - -OPI google drive - -true -true -true + OPI_GoogleDrive + + + OPI google drive + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleSheets/Module.bsl b/src/en/OPI/src/CommonModules/OPI_GoogleSheets/Module.bsl index 950e159927..e6f1302e32 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleSheets/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_GoogleSheets/Module.bsl @@ -38,90 +38,90 @@ // CreateBook // Creates a new book -// +// // Parameters: // Token - String - Token - token // Name - String - Name - title // ArrayOfSheetNames - Array of Strings - Array of names to add new sheets to the book - sheets -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function CreateBook(Val Token, Val Name, Val ArrayOfSheetNames) Export - -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetCollection(ArrayOfSheetNames); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets"; - -Properties = New Structure("title" , Name); -Sheets = New Array; - -FillSheetArray(ArrayOfSheetNames, Sheets); - -Parameters = New Structure; -OPI_Tools.AddField("properties", Properties, "Collection", Parameters); -OPI_Tools.AddField("sheets" , Sheets , "Collection", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetCollection(ArrayOfSheetNames); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets"; + + Properties = New Structure("title" , Name); + Sheets = New Array; + + FillSheetArray(ArrayOfSheetNames, Sheets); + + Parameters = New Structure; + OPI_Tools.AddField("properties", Properties, "Collection", Parameters); + OPI_Tools.AddField("sheets" , Sheets , "Collection", Parameters); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // GetBook // Gets information about the book by ID -// +// // Parameters: // Token - String - Token - token // Identifier - String - BookIdentifier - spreadsheet -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetBook(Val Token, Val Identifier) Export -OPI_TypeConversion.GetLine(Identifier); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Identifier; - -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; + OPI_TypeConversion.GetLine(Identifier); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Identifier; + + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; EndFunction // ChangeBookName // Changes the name of the existing book -// +// // Parameters: // Token - String - Token - token // Book - String - BookID - spreadsheet // Name - String - New name - title -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function EditBookTitle(Val Token, Val Book, Val Name) Export - -OPI_TypeConversion.GetLine(Book); -OPI_TypeConversion.GetLine(Name); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate"; - -Change = New Structure("title", Name); -ChangeRequest = New Structure("properties,fields", Change, "title"); -Request = New Structure("updateSpreadsheetProperties", ChangeRequest); - -ArrayOfRequests = New Array; -ArrayOfRequests.Add(Request); - -Parameters = New Structure("requests", ArrayOfRequests); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Book); + OPI_TypeConversion.GetLine(Name); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate"; + + Change = New Structure("title", Name); + ChangeRequest = New Structure("properties,fields", Change, "title"); + Request = New Structure("updateSpreadsheetProperties", ChangeRequest); + + ArrayOfRequests = New Array; + ArrayOfRequests.Add(Request); + + Parameters = New Structure("requests", ArrayOfRequests); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction #EndRegion @@ -130,95 +130,95 @@ EndFunction // AddSheet // Adds a new sheet to the book -// -// +// +// // Parameters: // Token - String - Token - token // Book - String - BookIdentifier - spreadsheet // Name - String - NewSheetName - title -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function AddSheet(Val Token, Val Book, Val Name) Export - -OPI_TypeConversion.GetLine(Book); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate"; -Sheet = CreateSheet(Name); - -Requests = New Array; -Change = New Structure("addSheet", Sheet); -Requests.Add(Change); - -Parameters = New Structure("requests", Requests); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Book); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate"; + Sheet = CreateSheet(Name); + + Requests = New Array; + Change = New Structure("addSheet", Sheet); + Requests.Add(Change); + + Parameters = New Structure("requests", Requests); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // DeleteSheet // Deletes a sheet from the book -// +// // Parameters: // Token - String - Token - token // Book - String - BookIdentifier - spreadsheet // Sheet - String - IdentifierOfSheetToDelete - sheet -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function DeleteSheet(Val Token, Val Book, Val Sheet) Export - -OPI_TypeConversion.GetLine(Book); -OPI_TypeConversion.GetLine(Sheet); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate"; - -Requests = New Array; -Sheet = New Structure("sheetId" , Sheet); -Change = New Structure("deleteSheet", Sheet); -Requests.Add(Change); - -Parameters = New Structure("requests", Requests); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Book); + OPI_TypeConversion.GetLine(Sheet); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + ":batchUpdate"; + + Requests = New Array; + Sheet = New Structure("sheetId" , Sheet); + Change = New Structure("deleteSheet", Sheet); + Requests.Add(Change); + + Parameters = New Structure("requests", Requests); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // CopySheet // Copies a sheet from one book to another -// +// // Parameters: // Token - String - Token - token // From - String - SourceBookID - from // To - String - DestinationBookID - to // Sheet - String - CopiedSheetID - sheet -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function CopySheet(Val Token, Val From, Val To, Val Sheet) Export - -OPI_TypeConversion.GetLine(From); -OPI_TypeConversion.GetLine(To); -OPI_TypeConversion.GetLine(Sheet); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" -+ From -+ "/sheets/" -+ Sheet -+ ":copyTo"; - -Parameters = New Structure("destinationSpreadsheetId", To); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(From); + OPI_TypeConversion.GetLine(To); + OPI_TypeConversion.GetLine(Sheet); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + + From + + "/sheets/" + + Sheet + + ":copyTo"; + + Parameters = New Structure("destinationSpreadsheetId", To); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction #EndRegion @@ -227,105 +227,105 @@ EndFunction // SetCellValues // Sets sheet cell values -// +// // Parameters: // Token - String - Token - token -// Book - String - BookID - spreadsheet +// Book - String - BookID - spreadsheet // ValueMapping - Key-Value Pair - Fill data where the key is the cell name like A1 - data // Sheet - String - Name лиwithта (перinый лиwithт по умолчанию) - sheetname // MajorDimension - String - Main dimension when filling the array range - dim -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function SetCellValues(Val Token -, Val Book -, Val ValueMapping -, Val Sheet = "" -, Val MajorDimension = "COLUMNS") Export - -OPI_TypeConversion.GetLine(Book); -OPI_TypeConversion.GetCollection(ValueMapping); - -If Not TypeValue(ValueMapping) = Type("Structure") -And Not TypeValue(ValueMapping) = Type("Match") Then -Return "Failed to convert the structure of values to a collection"; -EndIf; - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchUpdate"; -Data array = FormCellDataArray(ValueMapping, MajorDimension, Sheet); - -Parameters = New Structure("data,valueInputOption", Data array, "USER_ENTERED"); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + , Val Book + , Val ValueMapping + , Val Sheet = "" + , Val MajorDimension = "COLUMNS") Export + + OPI_TypeConversion.GetLine(Book); + OPI_TypeConversion.GetCollection(ValueMapping); + + If Not TypeValue(ValueMapping) = Type("Structure") + And Not TypeValue(ValueMapping) = Type("Match") Then + Return "Failed to convert the structure of values to a collection"; + EndIf; + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchUpdate"; + Data array = FormCellDataArray(ValueMapping, MajorDimension, Sheet); + Parameters = New Structure("data,valueInputOption", Data array, "USER_ENTERED"); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Clear cells // Clears the value in cells -// +// // Parameters: // Token - String - Token - token // Book - String - BookID - spreadsheet // Cell array - Array of Strings - Array of cells like A1 to be cleared - cells // Sheet - String - Name лиwithта (перinый лиwithт по умолчанию) - sheetname -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function ClearCells(Val Token, Val Book, Val Cell array, Val Sheet = "") Export - -OPI_TypeConversion.GetLine(Book); -OPI_TypeConversion.GetCollection(Cell array); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchClear"; - -FormCellNameArray(Cell array, Sheet); - -Parameters = New Structure("ranges", Cell array); -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Book); + OPI_TypeConversion.GetCollection(Cell array); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchClear"; + + FormCellNameArray(Cell array, Sheet); + + Parameters = New Structure("ranges", Cell array); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Get cell values // Gets cell values of the table -// +// // Parameters: // Token - String - Token - token // Book - String - BookID - spreadsheet // Cell array - Array of Strings - Array ячееto inиdа А1 for получения (inеwithь лиwithт, еwithли не заполнено) - cells // Sheet - String - Name лиwithта (перinый лиwithт по умолчанию) - sheetname -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetCellValues(Val Token, Val Book, Val Cell array = "", Val Sheet = "") Export - -OPI_TypeConversion.GetLine(Book); - -Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); -URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchGet"; - -If ValueIsFilled(Cell array) Then -OPI_TypeConversion.GetCollection(Cell array); -FormCellNameArray(Cell array, Sheet); - -First = True; -For Each Cell In Cell array Do -Delimiter = ?(First, "?", "&"); -URL = URL + Delimiter + "ranges=" + Cell; -First = False; -EndDo; -Else -URL = URL + "?ranges='" + Sheet + "'"; -EndIf; - -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Book); + + Headers = OPI_GoogleWorkspace.GetAuthorizationHeader(Token); + URL = "https://sheets.googleapis.com/v4/spreadsheets/" + Book + "/values:batchGet"; + + If ValueIsFilled(Cell array) Then + OPI_TypeConversion.GetCollection(Cell array); + FormCellNameArray(Cell array, Sheet); + + First = True; + For Each Cell In Cell array Do + Delimiter = ?(First, "?", "&"); + URL = URL + Delimiter + "ranges=" + Cell; + First = False; + EndDo; + Else + URL = URL + "?ranges='" + Sheet + "'"; + EndIf; + + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; + EndFunction #EndRegion @@ -335,75 +335,75 @@ EndFunction #Region ServiceProceduresAndFunctions Procedure FillSheetArray(Val ArrayOfNames, SheetArray) - -For Each SheetName In ArrayOfNames Do - -Sheet = CreateSheet(SheetName); -SheetArray.Add(Sheet); - -EndDo; + + For Each SheetName In ArrayOfNames Do + + Sheet = CreateSheet(SheetName); + SheetArray.Add(Sheet); + + EndDo; EndProcedure Procedure AddSheetName(Cell, Val Sheet) - -If ValueIsFilled(Sheet) Then -Cell = "'" + Sheet + "'!" + Cell; -EndIf; - + + If ValueIsFilled(Sheet) Then + Cell = "'" + Sheet + "'!" + Cell; + EndIf; + EndProcedure Function CreateSheet(Val Name) + + OPI_TypeConversion.GetLine(Name); + + Sheet properties = New Structure("title" , Name); + Sheet = New Structure("properties", Sheet properties); -OPI_TypeConversion.GetLine(Name); - -Sheet properties = New Structure("title" , Name); -Sheet = New Structure("properties", Sheet properties); - -Return Sheet; - + Return Sheet; + EndFunction Function FormCellDataArray(Val ValueStructure, Val MajorDimension, Val Sheet) - -OPI_TypeConversion.GetLine(Sheet); - -Data array = New Array; - -For Each CellData In ValueStructure Do - -CurrentValue = CellData.Value; -Current key = CellData.Key; - -AddSheetName(Current key, Sheet); - -OPI_TypeConversion.GetArray(CurrentValue); - -Current data = New Match; -Current array = New Array; - -Current array.Add(CurrentValue); - -OPI_Tools.AddField("range" , Current key , "String", Current data); -OPI_Tools.AddField("values" , Current array , "Array", Current data); -OPI_Tools.AddField("majorDimension", MajorDimension, "String", Current data); - -Data array.Add(Current data); - -EndDo; - -Return Data array; - + + OPI_TypeConversion.GetLine(Sheet); + + Data array = New Array; + + For Each CellData In ValueStructure Do + + CurrentValue = CellData.Value; + Current key = CellData.Key; + + AddSheetName(Current key, Sheet); + + OPI_TypeConversion.GetArray(CurrentValue); + + Current data = New Match; + Current array = New Array; + + Current array.Add(CurrentValue); + + OPI_Tools.AddField("range" , Current key , "String", Current data); + OPI_Tools.AddField("values" , Current array , "Array", Current data); + OPI_Tools.AddField("majorDimension", MajorDimension, "String", Current data); + + Data array.Add(Current data); + + EndDo; + + Return Data array; + EndFunction Procedure FormCellNameArray(Val ArrayOfNames, Val Sheet) -OPI_TypeConversion.GetLine(Sheet); - -For N = 0 For ArrayOfNames.WithinBoundary() Do -AddSheetName(ArrayOfNames[N], Sheet); -EndDo; - + OPI_TypeConversion.GetLine(Sheet); + + For N = 0 For ArrayOfNames.WithinBoundary() Do + AddSheetName(ArrayOfNames[N], Sheet); + EndDo; + EndProcedure #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleSheets/OPI_GoogleSheets.mdo b/src/en/OPI/src/CommonModules/OPI_GoogleSheets/OPI_GoogleSheets.mdo index e6f8ac0c0d..cf32e69a19 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleSheets/OPI_GoogleSheets.mdo +++ b/src/en/OPI/src/CommonModules/OPI_GoogleSheets/OPI_GoogleSheets.mdo @@ -1,11 +1,11 @@  -OPI_GoogleSheets - - -OPI google sheets - -true -true -true + OPI_GoogleSheets + + + OPI google sheets + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/Module.bsl b/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/Module.bsl index 22b9b2213b..83ed767079 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/Module.bsl @@ -36,98 +36,98 @@ // Generate code retrieval link // Returns URL for browser authorization -// +// // Parameters: // ClientID - String - Client ID - id // Calendar - Boolean - Calendar methods permission - calendar // Drive - Boolean - Drive methods permission - drive // Sheets - Boolean - Sheets methods permission - sheets -// +// // Return value: // String - Code retrieval link Function FormCodeRetrievalLink(Val ClientID -, Val Calendar = True -, Val Drive = True -, Val Sheets = True) Export - -OPI_TypeConversion.GetLine(ClientID); -OPI_TypeConversion.GetBoolean(Calendar); -OPI_TypeConversion.GetBoolean(Sheets); -OPI_TypeConversion.GetBoolean(Drive); - -URL = "https://accounts.google.com/o/oauth2/auth"; - -URLParameters = New Structure; -URLParameters.Insert("response_type", "code"); -URLParameters.Insert("client_id" , ClientID); -URLParameters.Insert("redirect_uri" , "http://localhost"); -URLParameters.Insert("access_type" , "offline"); -URLParameters.Insert("scope" , GetPermissionsList(Calendar, Drive, Sheets)); - -URL = URL + OPI_Tools.RequestParametersToString(URLParameters); - -Return URL; - + , Val Calendar = True + , Val Drive = True + , Val Sheets = True) Export + + OPI_TypeConversion.GetLine(ClientID); + OPI_TypeConversion.GetBoolean(Calendar); + OPI_TypeConversion.GetBoolean(Sheets); + OPI_TypeConversion.GetBoolean(Drive); + + URL = "https://accounts.google.com/o/oauth2/auth"; + + URLParameters = New Structure; + URLParameters.Insert("response_type", "code"); + URLParameters.Insert("client_id" , ClientID); + URLParameters.Insert("redirect_uri" , "http://localhost"); + URLParameters.Insert("access_type" , "offline"); + URLParameters.Insert("scope" , GetPermissionsList(Calendar, Drive, Sheets)); + + URL = URL + OPI_Tools.RequestParametersToString(URLParameters); + + Return URL; + EndFunction // Get token by code // Gets token by code from browser authorization -// +// // Parameters: // ClientID - String - Client ID - id // ClientSecret - String - Client secret - secret // Code - String - Code from browser - code -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function GetTokenByCode(Val ClientID, Val ClientSecret, Val Code) Export - -OPI_TypeConversion.GetLine(ClientID); -OPI_TypeConversion.GetLine(ClientSecret); -OPI_TypeConversion.GetLine(Code); - -URL = "https://accounts.google.com/o/oauth2/token"; - -URLParameters = New Structure; -URLParameters.Insert("grant_type" , "authorization_code"); -URLParameters.Insert("client_id" , ClientID); -URLParameters.Insert("client_secret", ClientSecret); -URLParameters.Insert("redirect_uri" , "http://localhost"); -URLParameters.Insert("code" , Code); - -Response = OPI_Tools.Post(URL, URLParameters, , False); - -Return Response; + + OPI_TypeConversion.GetLine(ClientID); + OPI_TypeConversion.GetLine(ClientSecret); + OPI_TypeConversion.GetLine(Code); + + URL = "https://accounts.google.com/o/oauth2/token"; + + URLParameters = New Structure; + URLParameters.Insert("grant_type" , "authorization_code"); + URLParameters.Insert("client_id" , ClientID); + URLParameters.Insert("client_secret", ClientSecret); + URLParameters.Insert("redirect_uri" , "http://localhost"); + URLParameters.Insert("code" , Code); + + Response = OPI_Tools.Post(URL, URLParameters, , False); + + Return Response; EndFunction // Refresh token // Updates token by Refresh token -// +// // Parameters: // ClientID - String - Client ID - id // ClientSecret - String - Client secret - secret // RefreshToken - String - Refresh token - refresh -// +// // Return value: // Key-Value Pair - serialized JSON response from Google Function RefreshToken(Val ClientID, Val ClientSecret, Val RefreshToken) Export - -OPI_TypeConversion.GetLine(ClientID); -OPI_TypeConversion.GetLine(ClientSecret); -OPI_TypeConversion.GetLine(RefreshToken); - -URL = "https://accounts.google.com/o/oauth2/token"; - -URLParameters = New Structure; -URLParameters.Insert("grant_type" , "refresh_token"); -URLParameters.Insert("client_id" , ClientID); -URLParameters.Insert("client_secret", ClientSecret); -URLParameters.Insert("refresh_token", RefreshToken); - -Response = OPI_Tools.Post(URL, URLParameters, , False); - -Return Response; + + OPI_TypeConversion.GetLine(ClientID); + OPI_TypeConversion.GetLine(ClientSecret); + OPI_TypeConversion.GetLine(RefreshToken); + + URL = "https://accounts.google.com/o/oauth2/token"; + + URLParameters = New Structure; + URLParameters.Insert("grant_type" , "refresh_token"); + URLParameters.Insert("client_id" , ClientID); + URLParameters.Insert("client_secret", ClientSecret); + URLParameters.Insert("refresh_token", RefreshToken); + + Response = OPI_Tools.Post(URL, URLParameters, , False); + + Return Response; EndFunction @@ -136,14 +136,14 @@ EndFunction #Region ServiceProgramInterface Function GetAuthorizationHeader(Val Token) Export - -OPI_TypeConversion.GetLine(Token); - -Headers = New Match; -Headers.Insert("Authorization", "Bearer " + Token); - -Return Headers; - + + OPI_TypeConversion.GetLine(Token); + + Headers = New Match; + Headers.Insert("Authorization", "Bearer " + Token); + + Return Headers; + EndFunction #EndRegion @@ -151,23 +151,23 @@ EndFunction #Region ServiceProceduresAndFunctions Function GetPermissionsList(Calendar, Drive, Sheets) - -Permissions array = New Array; - -If Calendar Then -Permissions array.Add("https://www.googleapis.com/auth/calendar"); -EndIf; - -If Drive Then -Permissions array.Add("https://www.googleapis.com/auth/drive"); -EndIf; - -If Sheets Then -Permissions array.Add("https://www.googleapis.com/auth/spreadsheets"); -EndIf; - -Return StrJoin(Permissions array, " "); - + + Permissions array = New Array; + + If Calendar Then + Permissions array.Add("https://www.googleapis.com/auth/calendar"); + EndIf; + + If Drive Then + Permissions array.Add("https://www.googleapis.com/auth/drive"); + EndIf; + + If Sheets Then + Permissions array.Add("https://www.googleapis.com/auth/spreadsheets"); + EndIf; + + Return StrJoin(Permissions array, " "); + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/OPI_GoogleWorkspace.mdo b/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/OPI_GoogleWorkspace.mdo index a67c47fbb6..7f7001eaea 100644 --- a/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/OPI_GoogleWorkspace.mdo +++ b/src/en/OPI/src/CommonModules/OPI_GoogleWorkspace/OPI_GoogleWorkspace.mdo @@ -1,11 +1,11 @@  -OPI_GoogleWorkspace - - -OPI google workspace - -true -true -true + OPI_GoogleWorkspace + + + OPI google workspace + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Notion/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Notion/Module.bsl index a29adca305..1521fc8656 100644 --- a/src/en/OPI/src/CommonModules/OPI_Notion/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Notion/Module.bsl @@ -42,90 +42,90 @@ // Create page // Creates a child page above another parent page -// +// // Parameters: // Token - String - Token - token // Parent - String - Parent ID - page // Title - String - Page title - title -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function CreatePage(Val Token, Val Parent, Val Title) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Parent); -OPI_TypeConversion.GetLine(Title); - -Headers = CreateRequestHeaders(Token); -Properties = New Structure; -Parameters = New Structure; - -AddPageHeader(Title, Properties); -AddPageParent(Parent, False, Parameters); - -Parameters.Insert("properties", Properties); - -Response = OPI_Tools.Post("https://api.notion.com/v1/pages", Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Parent); + OPI_TypeConversion.GetLine(Title); + + Headers = CreateRequestHeaders(Token); + Properties = New Structure; + Parameters = New Structure; + + AddPageHeader(Title, Properties); + AddPageParent(Parent, False, Parameters); + + Parameters.Insert("properties", Properties); + + Response = OPI_Tools.Post("https://api.notion.com/v1/pages", Parameters, Headers); + + Return Response; + EndFunction // Create page in database // Creates a page in the parent database -// +// // Parameters: -// Token - String - Token - token +// Token - String - Token - token // Parent - String - Parent database ID - base // Data - Key-Value Pair - Properties match - data -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function CreatePageInDatabase(Val Token, Val Parent, Val Data) Export + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Parent); + OPI_TypeConversion.GetCollection(Data); + + Headers = CreateRequestHeaders(Token); + Parameters = New Structure; + + AddPageParent(Parent, True, Parameters); -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Parent); -OPI_TypeConversion.GetCollection(Data); - -Headers = CreateRequestHeaders(Token); -Parameters = New Structure; - -AddPageParent(Parent, True, Parameters); - -Properties = FillDataBySchema(Parent, Data, Token); -Parameters.Insert("properties", Properties); - -Response = OPI_Tools.Post("https://api.notion.com/v1/pages", Parameters, Headers); - -Return Response; - + Properties = FillDataBySchema(Parent, Data, Token); + Parameters.Insert("properties", Properties); + + Response = OPI_Tools.Post("https://api.notion.com/v1/pages", Parameters, Headers); + + Return Response; + EndFunction // Get page // Gets information about the page by ID -// +// // Parameters: // Token - String - Token - token -// Page - String - Page ID - page -// +// Page - String - Page ID - page +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function GetPage(Val Token, Val Page) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Page); - -Headers = CreateRequestHeaders(Token); -ConvertID(Page); - -Response = OPI_Tools.Get("https://api.notion.com/v1/pages/" + Page, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Page); + + Headers = CreateRequestHeaders(Token); + ConvertID(Page); + + Response = OPI_Tools.Get("https://api.notion.com/v1/pages/" + Page, , Headers); + + Return Response; + EndFunction // Edit page properties. -// +// // Parameters: // Token - String - Token - token // Page - String - ID of the page being modified - page @@ -133,65 +133,65 @@ EndFunction // Icon - String - URL of the page icon image - icon // Cover - String - URL of the page cover image - cover // Archived - Boolean - Archive page or нет (boolean) - archive -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function EditPageProperties(Val Token -, Val Page -, Val Data = "" -, Val Icon = "" -, Val Cover = "" -, Val Archived = False) Export + , Val Page + , Val Data = "" + , Val Icon = "" + , Val Cover = "" + , Val Archived = False) Export + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Page); + OPI_TypeConversion.GetLine(Icon); + OPI_TypeConversion.GetLine(Cover); + OPI_TypeConversion.GetBoolean(Archived); + OPI_TypeConversion.GetCollection(Data); + + Headers = CreateRequestHeaders(Token); + Parameters = New Structure; + Files = "files"; + + If ValueIsFilled(Data) + And (TypeValue(Data) = Type("Match") Or TypeValue(Data) = Type("Structure")) Then + Properties = FillDataBySchema(Page, Data, Token, False); + Else + Properties = New Match; + EndIf; + + If ValueIsFilled(Icon) Then + Icon match = New Match; + Icon match.Insert("Icon", Icon); + + Icon object = ConvertValueByType(Files, Icon match); + Icon object = Icon object[Files][0]; + Icon object.Delete("name"); + + Parameters.Insert("icon", Icon object); + EndIf; + + If ValueIsFilled(Cover) Then + Cover match = New Match; + Cover match.Insert("Cover", Cover); -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Page); -OPI_TypeConversion.GetLine(Icon); -OPI_TypeConversion.GetLine(Cover); -OPI_TypeConversion.GetBoolean(Archived); -OPI_TypeConversion.GetCollection(Data); + Cover object = ConvertValueByType(Files, Cover match); + Cover object = Cover object[Files][0]; + Cover object.Delete("name"); -Headers = CreateRequestHeaders(Token); -Parameters = New Structure; -Files = "files"; + Parameters.Insert("cover", Cover object); + EndIf; -If ValueIsFilled(Data) -And (TypeValue(Data) = Type("Match") Or TypeValue(Data) = Type("Structure")) Then -Properties = FillDataBySchema(Page, Data, Token, False); -Else -Properties = New Match; -EndIf; - -If ValueIsFilled(Icon) Then -Icon match = New Match; -Icon match.Insert("Icon", Icon); - -Icon object = ConvertValueByType(Files, Icon match); -Icon object = Icon object[Files][0]; -Icon object.Delete("name"); - -Parameters.Insert("icon", Icon object); -EndIf; - -If ValueIsFilled(Cover) Then -Cover match = New Match; -Cover match.Insert("Cover", Cover); - -Cover object = ConvertValueByType(Files, Cover match); -Cover object = Cover object[Files][0]; -Cover object.Delete("name"); - -Parameters.Insert("cover", Cover object); -EndIf; - -Parameters.Insert("properties", Properties); -Parameters.Insert("archived" , Archived); - -ConvertID(Page); - -Response = OPI_Tools.Patch("https://api.notion.com/v1/pages/" + Page, Parameters, Headers); - -Return Response; + Parameters.Insert("properties", Properties); + Parameters.Insert("archived" , Archived); + + ConvertID(Page); + Response = OPI_Tools.Patch("https://api.notion.com/v1/pages/" + Page, Parameters, Headers); + + Return Response; + EndFunction #EndRegion @@ -200,287 +200,287 @@ EndFunction // Create database // Creates a database -// +// // Parameters: -// Token - String - Token - token +// Token - String - Token - token // Parent - String - Parent page ID - page // Title - String - Database title - title // Properties - Structure Of String - Database properties - props -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function CreateDatabase(Val Token, Val Parent, Val Title, Val Properties = "") Export -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Parent); -OPI_TypeConversion.GetLine(Title); -OPI_TypeConversion.GetCollection(Properties); + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Parent); + OPI_TypeConversion.GetLine(Title); + OPI_TypeConversion.GetCollection(Properties); + + // Example structure/property map + + // Name : title + // Description : rich_text + // InProgress : checkbox + // Quantity : number + // Date : date + // Status : Match + // Аtoтиinный : green + // Inactive : red + // Архиin : yellow + + // All pages created as children must have parent base properties -// Example structure/property map + If Not TypeValue(Properties) = Type("Structure") And Not TypeValue(Properties) = Type("Match") Then + Properties = New Structure("Name", "title"); + EndIf; -// Name : title -// Description : rich_text -// InProgress : checkbox -// Quantity : number -// Date : date -// Status : Match -// Аtoтиinный : green -// Inactive : red -// Архиin : yellow - -// All pages created as children must have parent base properties - -If Not TypeValue(Properties) = Type("Structure") And Not TypeValue(Properties) = Type("Match") Then -Properties = New Structure("Name", "title"); -EndIf; - -Headers = CreateRequestHeaders(Token); -Parameters = New Structure; - -AddDatabaseParent(Parent, False, Parameters); -AddDatabaseHeader(Title, Parameters); -AddDatabaseProperties(Properties, Parameters); - -Response = OPI_Tools.Post("https://api.notion.com/v1/databases", Parameters, Headers); - -Return Response; + Headers = CreateRequestHeaders(Token); + Parameters = New Structure; + + AddDatabaseParent(Parent, False, Parameters); + AddDatabaseHeader(Title, Parameters); + AddDatabaseProperties(Properties, Parameters); + Response = OPI_Tools.Post("https://api.notion.com/v1/databases", Parameters, Headers); + + Return Response; + EndFunction // Get database // Get database information -// +// // Parameters: // Token - String - Token - token // Base - String - Database ID - base -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function GetDatabase(Val Token, Val Base) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Base); - -Headers = CreateRequestHeaders(Token); -ConvertID(Base); - -Response = OPI_Tools.Get("https://api.notion.com/v1/databases/" + Base, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Base); + + Headers = CreateRequestHeaders(Token); + ConvertID(Base); + + Response = OPI_Tools.Get("https://api.notion.com/v1/databases/" + Base, , Headers); + + Return Response; + EndFunction // Edit database properties // Edits properties of an existing database -// +// // Parameters: // Token - String - Token - token // Base - String - Target database ID - base // Properties - Map from KeyAndValue - New or modified database properties - props // Title - String - New database title - title // Description - String - New database description - description -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function EditDatabaseProperties(Val Token, Val Base, Val Properties = "", Val Title = "", Val Description = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Base); -OPI_TypeConversion.GetLine(Title); -OPI_TypeConversion.GetLine(Description); -OPI_TypeConversion.GetCollection(Properties); - -Parameters = New Structure; -Headers = CreateRequestHeaders(Token); -ConvertID(Base); - -If ValueIsFilled(Title) Then -AddDatabaseHeader(Title, Parameters); -EndIf; - -If ValueIsFilled(Description) Then -AddDatabaseDescription(Description, Parameters); -EndIf; - -If TypeValue(Properties) = Type("Structure") Or TypeValue(Properties) = Type("Match") Then -AddDatabaseProperties(Properties, Parameters); -EndIf; - -Response = OPI_Tools.Patch("https://api.notion.com/v1/databases/" + Base, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Base); + OPI_TypeConversion.GetLine(Title); + OPI_TypeConversion.GetLine(Description); + OPI_TypeConversion.GetCollection(Properties); + + Parameters = New Structure; + Headers = CreateRequestHeaders(Token); + ConvertID(Base); + + If ValueIsFilled(Title) Then + AddDatabaseHeader(Title, Parameters); + EndIf; + + If ValueIsFilled(Description) Then + AddDatabaseDescription(Description, Parameters); + EndIf; + + If TypeValue(Properties) = Type("Structure") Or TypeValue(Properties) = Type("Match") Then + AddDatabaseProperties(Properties, Parameters); + EndIf; + + Response = OPI_Tools.Patch("https://api.notion.com/v1/databases/" + Base, Parameters, Headers); + + Return Response; + EndFunction -#EndRegion +#EndRegion #Region BlockWork // Create block // Creates a new block based on an existing block -// +// // Parameters: // Token - String - Token - token // Parent - String - Parent block or page ID - page // Block - String, Map From KeyAndValue - Block ID or block sample itself - block // InsertAfter - String - Block ID after which to insert the new one - prev -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function CreateBlock(Val Token, Val Parent, Val Block, Val InsertAfter = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Parent); -OPI_TypeConversion.GetLine(InsertAfter); -OPI_TypeConversion.GetCollection(Block); - -If TypeValue(Block) = Type("Array") Then -Block = Block[0]; -EndIf; - -Headers = CreateRequestHeaders(Token); -ConvertID(Parent); - -If TypeValue(Block) = Type("String") Then -ConvertID(Block); -Block = ReturnBlock(Token, Block); -EndIf; - -BlockArray = New Array; -BlockArray.Add(Block); - -Parameters = New Match; -Parameters.Insert("children", BlockArray); - -If ValueIsFilled(InsertAfter) Then -Parameters.Insert("after", InsertAfter); -EndIf; - -URL = "https://api.notion.com/v1/blocks/" + Parent + "/children"; -Response = OPI_Tools.Patch(URL, Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Parent); + OPI_TypeConversion.GetLine(InsertAfter); + OPI_TypeConversion.GetCollection(Block); + + If TypeValue(Block) = Type("Array") Then + Block = Block[0]; + EndIf; + + Headers = CreateRequestHeaders(Token); + ConvertID(Parent); + + If TypeValue(Block) = Type("String") Then + ConvertID(Block); + Block = ReturnBlock(Token, Block); + EndIf; + + BlockArray = New Array; + BlockArray.Add(Block); + + Parameters = New Match; + Parameters.Insert("children", BlockArray); + + If ValueIsFilled(InsertAfter) Then + Parameters.Insert("after", InsertAfter); + EndIf; + + URL = "https://api.notion.com/v1/blocks/" + Parent + "/children"; + Response = OPI_Tools.Patch(URL, Parameters, Headers); + + Return Response; + EndFunction // Inернуть блоto. -// +// // Parameters: // Token - String - Token - token // BlockID - String - Block ID - block // OnlyBase - Boolean - True > service fields are deleted, only the block itself remains - core -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function ReturnBlock(Val Token, Val BlockID, Val OnlyBase = True) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(BlockID); -OPI_TypeConversion.GetBoolean(OnlyBase); - -ConvertID(BlockID); - -Headers = CreateRequestHeaders(Token); -Response = OPI_Tools.Get("https://api.notion.com/v1/blocks/" + BlockID, , Headers); - -If OnlyBase Then -RemoveExtraBlockFields(Response); -EndIf; - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(BlockID); + OPI_TypeConversion.GetBoolean(OnlyBase); + + ConvertID(BlockID); + + Headers = CreateRequestHeaders(Token); + Response = OPI_Tools.Get("https://api.notion.com/v1/blocks/" + BlockID, , Headers); + + If OnlyBase Then + RemoveExtraBlockFields(Response); + EndIf; + + Return Response; + EndFunction // Return child blocks // Returns list of child blocks of parent block -// +// // Parameters: // Token - String - Token - token // BlockID - String - Parent block ID - block -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function ReturnChildBlocks(Val Token, Val BlockID) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(BlockID); - -ConvertID(BlockID); - -Headers = CreateRequestHeaders(Token); -Response = OPI_Tools.Get("https://api.notion.com/v1/blocks/" + BlockID + "/children", , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(BlockID); + + ConvertID(BlockID); + + Headers = CreateRequestHeaders(Token); + Response = OPI_Tools.Get("https://api.notion.com/v1/blocks/" + BlockID + "/children", , Headers); + + Return Response; + EndFunction // Delete block // Deletes block by ID -// +// // Parameters: // Token - String - Token - token // BlockID - String - Block ID - block -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function DeleteBlock(Val Token, Val BlockID) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(BlockID); - -ConvertID(BlockID); - -Headers = CreateRequestHeaders(Token); -Response = OPI_Tools.Delete("https://api.notion.com/v1/blocks/" + BlockID, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(BlockID); + + ConvertID(BlockID); + + Headers = CreateRequestHeaders(Token); + Response = OPI_Tools.Delete("https://api.notion.com/v1/blocks/" + BlockID, , Headers); + + Return Response; + EndFunction - + #EndRegion #Region Users // User list // Returns a list of workspace users -// +// // Parameters: // Token - String - Token - token -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function UserList(Val Token) Export -OPI_TypeConversion.GetLine(Token); - -Headers = CreateRequestHeaders(Token); -Response = OPI_Tools.Get("https://api.notion.com/v1/users", , Headers); - -Return Response; - + OPI_TypeConversion.GetLine(Token); + + Headers = CreateRequestHeaders(Token); + Response = OPI_Tools.Get("https://api.notion.com/v1/users", , Headers); + + Return Response; + EndFunction // Get user data // Gets user data by ID -// +// // Parameters: // Token - String - Token - token // UserID - String - Target user ID - user -// +// // Return value: // Key-Value Pair - Serialized JSON response from Notion Function GetUserData(Val Token, Val UserID) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(UserID); - -ConvertID(UserID); - -Headers = CreateRequestHeaders(Token); -Response = OPI_Tools.Get("https://api.notion.com/v1/users/" + UserID, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(UserID); + + ConvertID(UserID); + + Headers = CreateRequestHeaders(Token); + Response = OPI_Tools.Get("https://api.notion.com/v1/users/" + UserID, , Headers); + + Return Response; + EndFunction #EndRegion @@ -490,398 +490,398 @@ EndFunction #Region ServiceProceduresAndFunctions Function CreateRequestHeaders(Val Token) - -OPI_TypeConversion.GetLine(Token); - -Headers = New Match; -Headers.Insert("Authorization" , "Bearer " + Token); -Headers.Insert("Notion-Version", "2022-06-28"); - -Return Headers; - + + OPI_TypeConversion.GetLine(Token); + + Headers = New Match; + Headers.Insert("Authorization" , "Bearer " + Token); + Headers.Insert("Notion-Version", "2022-06-28"); + + Return Headers; + EndFunction Procedure ConvertID(Identifier) - -OPI_TypeConversion.GetLine(Identifier); - -Identifier = StringReplace(Identifier, "-", ""); - + + OPI_TypeConversion.GetLine(Identifier); + + Identifier = StringReplace(Identifier, "-", ""); + EndProcedure Procedure AddPageParent(Val Parent, Val ParentBase, MainStructure) + + OPI_TypeConversion.GetLine(ParentBase); + + ConvertID(Parent); + + IdentifierField = ?(ParentBase, "database_id", "page_id"); + ParentStructure = New Structure(IdentifierField, Parent); -OPI_TypeConversion.GetLine(ParentBase); - -ConvertID(Parent); - -IdentifierField = ?(ParentBase, "database_id", "page_id"); -ParentStructure = New Structure(IdentifierField, Parent); - -MainStructure.Insert("parent", ParentStructure); - + MainStructure.Insert("parent", ParentStructure); + EndProcedure Procedure AddDatabaseParent(Val Parent, Val ParentBase, MainStructure) + + OPI_TypeConversion.GetLine(ParentBase); + + ConvertID(Parent); + + IdentifierField = ?(ParentBase, "database_id", "page_id"); + + ParentStructure = New Structure(); + ParentStructure.Insert("type" , IdentifierField); + ParentStructure.Insert(IdentifierField, Parent); -OPI_TypeConversion.GetLine(ParentBase); - -ConvertID(Parent); - -IdentifierField = ?(ParentBase, "database_id", "page_id"); - -ParentStructure = New Structure(); -ParentStructure.Insert("type" , IdentifierField); -ParentStructure.Insert(IdentifierField, Parent); - -MainStructure.Insert("parent", ParentStructure); - + MainStructure.Insert("parent", ParentStructure); + EndProcedure -Procedure AddPageHeader(Val Title, MainStructure) - -OPI_TypeConversion.GetLine(Title); - -SubordinateStructure = New Structure; -DataStructure = New Structure; -TextStructure = New Structure; -Data array = New Array; -Title = "title"; - -TextStructure.Insert("content", Title); -TextStructure.Insert("link" , Undefined); - -DataStructure.Insert("text", TextStructure); -DataStructure.Insert("type", "text"); - -Data array.Add(DataStructure); - -SubordinateStructure.Insert("id" , Title); -SubordinateStructure.Insert("type" , Title); -SubordinateStructure.Insert(Title , Data array); - -MainStructure.Insert(Title, SubordinateStructure); - +Procedure AddPageHeader(Val Title, MainStructure) + + OPI_TypeConversion.GetLine(Title); + + SubordinateStructure = New Structure; + DataStructure = New Structure; + TextStructure = New Structure; + Data array = New Array; + Title = "title"; + + TextStructure.Insert("content", Title); + TextStructure.Insert("link" , Undefined); + + DataStructure.Insert("text", TextStructure); + DataStructure.Insert("type", "text"); + + Data array.Add(DataStructure); + + SubordinateStructure.Insert("id" , Title); + SubordinateStructure.Insert("type" , Title); + SubordinateStructure.Insert(Title , Data array); + + MainStructure.Insert(Title, SubordinateStructure); + EndProcedure Procedure AddDatabaseHeader(Val Title, MainStructure) - -OPI_TypeConversion.GetLine(Title); - -Title = ConvertHeader(Title); -MainStructure.Insert("title", Title["title"]); - + + OPI_TypeConversion.GetLine(Title); + + Title = ConvertHeader(Title); + MainStructure.Insert("title", Title["title"]); + EndProcedure Procedure AddDatabaseDescription(Val Description, MainStructure) - -OPI_TypeConversion.GetLine(Description); - -Title = ConvertHeader(Description); -MainStructure.Insert("description", Title["title"]); - + + OPI_TypeConversion.GetLine(Description); + + Title = ConvertHeader(Description); + MainStructure.Insert("description", Title["title"]); + EndProcedure Procedure AddDatabaseProperties(Val Properties, MainStructure) - -If Properties.Quantity() = 0 Then -MainStructure.Insert("properties", New Structure); -Return; -EndIf; - -ParameterMap = New Match; - -For Each Property In Properties Do - -If TypeValue(Property.Value) = Type("String") Then - -ParameterMap.Insert(Property.Key, New Structure(Property.Value, New Structure)); - -ElsIf TypeValue(Property.Value) = Type("Structure") -Or TypeValue(Property.Value) = Type("Match") Then - -ValueSelection = FormSelectionValues(Property.Value); -ParameterMap.Insert(Property.Key, New Structure("select", ValueSelection)); - -Else - -ParameterMap.Insert(Property.Key, Property.Value); - -EndIf; - -EndDo; - -MainStructure.Insert("properties", ParameterMap); - + + If Properties.Quantity() = 0 Then + MainStructure.Insert("properties", New Structure); + Return; + EndIf; + + ParameterMap = New Match; + + For Each Property In Properties Do + + If TypeValue(Property.Value) = Type("String") Then + + ParameterMap.Insert(Property.Key, New Structure(Property.Value, New Structure)); + + ElsIf TypeValue(Property.Value) = Type("Structure") + Or TypeValue(Property.Value) = Type("Match") Then + + ValueSelection = FormSelectionValues(Property.Value); + ParameterMap.Insert(Property.Key, New Structure("select", ValueSelection)); + + Else + + ParameterMap.Insert(Property.Key, Property.Value); + + EndIf; + + EndDo; + + MainStructure.Insert("properties", ParameterMap); + EndProcedure Function FormSelectionValues(Val VariantStructure) - -OptionArray = New Array; - -For Each Option In VariantStructure Do - -OptionMap = New Match; -OptionMap.Insert("name" , Option.Key); -OptionMap.Insert("color", Option.Value); - -OptionArray.Add(OptionMap); - -EndDo; - -Return New Structure("options", OptionArray); - + + OptionArray = New Array; + + For Each Option In VariantStructure Do + + OptionMap = New Match; + OptionMap.Insert("name" , Option.Key); + OptionMap.Insert("color", Option.Value); + + OptionArray.Add(OptionMap); + + EndDo; + + Return New Structure("options", OptionArray); + EndFunction Function FillDataBySchema(Val Scheme, Val Data, Val Token, Val ThisIsBase = True) + + If ThisIsBase Then + SchemaData = GetDatabase(Token, Scheme); + Else + SchemaData = GetPage(Token, Scheme); + EndIf; + + BaseFields = SchemaData["properties"]; + Properties = New Match; + + If ValueIsFilled(BaseFields) Then + + For Each Field In BaseFields Do + + FieldData = Field.Value; + FieldType = FieldData["type"]; + + FillableData = Data.Get(Field.Key); + + If FillableData = Undefined Then + Continue; + EndIf; + + ConvertedData = ConvertValueByType(FieldType, FillableData); + + If ConvertedData = Undefined Then + Continue; + EndIf; + + Properties.Insert(FieldData["id"], ConvertedData); + + EndDo; + + EndIf; -If ThisIsBase Then -SchemaData = GetDatabase(Token, Scheme); -Else -SchemaData = GetPage(Token, Scheme); -EndIf; - -BaseFields = SchemaData["properties"]; -Properties = New Match; - -If ValueIsFilled(BaseFields) Then - -For Each Field In BaseFields Do - -FieldData = Field.Value; -FieldType = FieldData["type"]; - -FillableData = Data.Get(Field.Key); - -If FillableData = Undefined Then -Continue; -EndIf; - -ConvertedData = ConvertValueByType(FieldType, FillableData); - -If ConvertedData = Undefined Then -Continue; -EndIf; - -Properties.Insert(FieldData["id"], ConvertedData); - -EndDo; - -EndIf; - -Return Properties; + Return Properties; EndFunction Procedure RemoveExtraBlockFields(Val Block) - -ExtraArray = New Array; -ExtraArray.Add("request_id"); -ExtraArray.Add("archived"); -ExtraArray.Add("created_by"); -ExtraArray.Add("last_edited_time"); -ExtraArray.Add("created_time"); -ExtraArray.Add("has_children"); -ExtraArray.Add("parrent"); -ExtraArray.Add("last_edited_by"); -ExtraArray.Add("id"); - -For Each Field In ExtraArray Do - -If Not Block.Get(Field) = Undefined Then -Block.Delete(Field); -EndIf; - -EndDo; - + + ExtraArray = New Array; + ExtraArray.Add("request_id"); + ExtraArray.Add("archived"); + ExtraArray.Add("created_by"); + ExtraArray.Add("last_edited_time"); + ExtraArray.Add("created_time"); + ExtraArray.Add("has_children"); + ExtraArray.Add("parrent"); + ExtraArray.Add("last_edited_by"); + ExtraArray.Add("id"); + + For Each Field In ExtraArray Do + + If Not Block.Get(Field) = Undefined Then + Block.Delete(Field); + EndIf; + + EndDo; + EndProcedure #Region TypeConversion Function ConvertValueByType(Val Type, Val Value) - -If Type = "title" Then -Return ConvertHeader(Value); -ElsIf Type = "rich_text" Then -Return ConvertText(Value); -ElsIf Type = "number" Then -Return ConvertNumber(Value); -ElsIf Type = "select" Then -Return ConvertSelectionOption(Value); -ElsIf Type = "multi_select" Then -Return ConvertMultipleChoice(Value); -ElsIf Type = "status" Then -Return ConvertStatus(Value); -ElsIf Type = "date" Then -Return ConvertDate(Value); -ElsIf Type = "relation" Then -Return ConvertLink(Value); -ElsIf Type = "people" Then -Return ConvertUsers(Value); -ElsIf Type = "files" Then -Return ConvertFiles(Value); -ElsIf Type = "checkbox" Then -Return ConvertBoolean(Value); -ElsIf Type = "url" Then -Return ConvertLink(Value); -ElsIf Type = "email" Then -Return ConvertEmail(Value); -ElsIf Type = "phone_number" Then -Return ConvertPhone(Value); -Else -Return Undefined; -EndIf; - + + If Type = "title" Then + Return ConvertHeader(Value); + ElsIf Type = "rich_text" Then + Return ConvertText(Value); + ElsIf Type = "number" Then + Return ConvertNumber(Value); + ElsIf Type = "select" Then + Return ConvertSelectionOption(Value); + ElsIf Type = "multi_select" Then + Return ConvertMultipleChoice(Value); + ElsIf Type = "status" Then + Return ConvertStatus(Value); + ElsIf Type = "date" Then + Return ConvertDate(Value); + ElsIf Type = "relation" Then + Return ConvertLink(Value); + ElsIf Type = "people" Then + Return ConvertUsers(Value); + ElsIf Type = "files" Then + Return ConvertFiles(Value); + ElsIf Type = "checkbox" Then + Return ConvertBoolean(Value); + ElsIf Type = "url" Then + Return ConvertLink(Value); + ElsIf Type = "email" Then + Return ConvertEmail(Value); + ElsIf Type = "phone_number" Then + Return ConvertPhone(Value); + Else + Return Undefined; + EndIf; + EndFunction -Function ConvertHeader(Val Title) - -DataStructure = New Structure; -TextStructure = New Structure; -Data array = New Array; - -TextStructure.Insert("content", Title); -TextStructure.Insert("link" , Undefined); - -DataStructure.Insert("type", "text"); -DataStructure.Insert("text", TextStructure); - -Data array.Add(DataStructure); - -Return New Structure("title", Data array); +Function ConvertHeader(Val Title) + + DataStructure = New Structure; + TextStructure = New Structure; + Data array = New Array; + + TextStructure.Insert("content", Title); + TextStructure.Insert("link" , Undefined); + + DataStructure.Insert("type", "text"); + DataStructure.Insert("text", TextStructure); + + Data array.Add(DataStructure); + Return New Structure("title", Data array); + EndFunction Function ConvertText(Val Text) - -TextArray = New Array; -TextStructure = New Structure; - -TextStructure.Insert("type", "text"); -TextStructure.Insert("text", New Structure("content", Text)); - -TextArray.Add(TextStructure); - -Return New Structure("rich_text", TextArray); - + + TextArray = New Array; + TextStructure = New Structure; + + TextStructure.Insert("type", "text"); + TextStructure.Insert("text", New Structure("content", Text)); + + TextArray.Add(TextStructure); + + Return New Structure("rich_text", TextArray); + EndFunction Function ConvertNumber(Val Number) -Return New Structure("number", Number); + Return New Structure("number", Number); EndFunction Function ConvertSelectionOption(Val Option) - -ChoiceStructure = New Structure; -ChoiceStructure.Insert("select", New Structure("name", Option)); - -Return ChoiceStructure; - + + ChoiceStructure = New Structure; + ChoiceStructure.Insert("select", New Structure("name", Option)); + + Return ChoiceStructure; + EndFunction Function ConvertStatus(Val Status) - -StatusStructure = New Structure; -StatusStructure.Insert("status", New Structure("name", Status)); - -Return StatusStructure; - + + StatusStructure = New Structure; + StatusStructure.Insert("status", New Structure("name", Status)); + + Return StatusStructure; + EndFunction Function ConvertMultipleChoice(Val OptionArray) - -ChoiceOptionArray = New Array; - -For Each Option In OptionArray Do -ChoiceOptionArray.Add(New Structure("name", Option)); -EndDo; - -Return New Structure("multi_select", ChoiceOptionArray); - + + ChoiceOptionArray = New Array; + + For Each Option In OptionArray Do + ChoiceOptionArray.Add(New Structure("name", Option)); + EndDo; + + Return New Structure("multi_select", ChoiceOptionArray); + EndFunction Function ConvertDate(Val Date) - -DateStructure = New Structure; - -If Date = StartOfDay(Date) Then -DateFormat = "DF=yyyy-MM-dd"; -Else -DateFormat = "ISO8601Datetime"; -EndIf; - -Date = Format(Date, DateFormat); -DateStructure.Insert("start", Date); - -Return New Structure("date", DateStructure); - + + DateStructure = New Structure; + + If Date = StartOfDay(Date) Then + DateFormat = "DF=yyyy-MM-dd"; + Else + DateFormat = "ISO8601Datetime"; + EndIf; + + Date = Format(Date, DateFormat); + DateStructure.Insert("start", Date); + + Return New Structure("date", DateStructure); + EndFunction -Function ConvertLink(Val Identifier) - -LinkArray = New Array; -LinkArray.Add(New Structure("id", Identifier)); - -Return New Structure("relation", LinkArray); - +Function ConvertLink(Val Identifier) + + LinkArray = New Array; + LinkArray.Add(New Structure("id", Identifier)); + + Return New Structure("relation", LinkArray); + EndFunction Function ConvertUsers(Val IDArray) - -If Not TypeValue(IDArray) = Type("Array") Then -ArrayID_ = New Array; -ArrayID_.Add(IDArray); -IDArray = ArrayID_; -EndIf; - -ArrayOfUsers = New Array; - -For Each Identifier In IDArray Do - -UserStructure = New Structure; -UserStructure.Insert("object", "user"); -UserStructure.Insert("id" , Identifier); -ArrayOfUsers.Add(UserStructure); - -EndDo; - -Return New Structure("people", ArrayOfUsers); - + + If Not TypeValue(IDArray) = Type("Array") Then + ArrayID_ = New Array; + ArrayID_.Add(IDArray); + IDArray = ArrayID_; + EndIf; + + ArrayOfUsers = New Array; + + For Each Identifier In IDArray Do + + UserStructure = New Structure; + UserStructure.Insert("object", "user"); + UserStructure.Insert("id" , Identifier); + ArrayOfUsers.Add(UserStructure); + + EndDo; + + Return New Structure("people", ArrayOfUsers); + EndFunction Function ConvertFiles(Val FileMapping) + + ArrayOfFiles = New Array; + + For Each File In FileMapping Do + + FileStructure = New Structure; + FileStructure.Insert("type" , "external"); + FileStructure.Insert("name" , File.Key); + FileStructure.Insert("external", New Structure("url", File.Value)); + + ArrayOfFiles.Add(FileStructure); + + EndDo; -ArrayOfFiles = New Array; - -For Each File In FileMapping Do - -FileStructure = New Structure; -FileStructure.Insert("type" , "external"); -FileStructure.Insert("name" , File.Key); -FileStructure.Insert("external", New Structure("url", File.Value)); - -ArrayOfFiles.Add(FileStructure); - -EndDo; - -Return New Structure("files", ArrayOfFiles); - + Return New Structure("files", ArrayOfFiles); + EndFunction Function ConvertBoolean(Val Boolean) -Return New Structure("checkbox", Boolean); + Return New Structure("checkbox", Boolean); EndFunction Function ConvertLink(Val URL) -Return New Structure("url", URL); + Return New Structure("url", URL); EndFunction Function ConvertEmail(Val Email) -Return New Structure("email", Email); + Return New Structure("email", Email); EndFunction Function ConvertPhone(Val Phone) -Return New Structure("phone_number", Phone); + Return New Structure("phone_number", Phone); EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Notion/OPI_Notion.mdo b/src/en/OPI/src/CommonModules/OPI_Notion/OPI_Notion.mdo index c77bf35ab6..159dbf1812 100644 --- a/src/en/OPI/src/CommonModules/OPI_Notion/OPI_Notion.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Notion/OPI_Notion.mdo @@ -1,11 +1,11 @@  -OPI_Notion - -ru -Methodы work with Notion (OPI) - -true -true -true + OPI_Notion + + ru + Methodы work with Notion (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Slack/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Slack/Module.bsl index da61e10c33..25be73fcdd 100644 --- a/src/en/OPI/src/CommonModules/OPI_Slack/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Slack/Module.bsl @@ -38,57 +38,57 @@ // Get bot information // Gets basic information about the bot -// +// // Parameters: // Token - String - Bot token - token -// +// // Return value: -// Key-Value Pair - Serialized JSON response from Slack +// Key-Value Pair - Serialized JSON response from Slack Function GetBotInformation(Val Token) Export - -URL = "https://slack.com/api/auth.test"; -Headers = GetAuthorizationHeader(Token); - -Response = OPI_Tools.Get(URL, , Headers); - -Return Response; + + URL = "https://slack.com/api/auth.test"; + Headers = GetAuthorizationHeader(Token); + + Response = OPI_Tools.Get(URL, , Headers); + + Return Response; EndFunction // Get workspace list // Gets a list of workspaces where the bot is connected -// +// // Parameters: // Token - String - Bot token - token // Cursor - String - Pointer from the previous request, if the result rows > 100 - cursor -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetWorkspaceList(Val Token, Val Cursor = "") Export - -URL = "https://slack.com/api/auth.teams.list"; -Response = GeneralDataRetrieval(Token, URL, Cursor); - -Return Response; + + URL = "https://slack.com/api/auth.teams.list"; + Response = GeneralDataRetrieval(Token, URL, Cursor); + + Return Response; EndFunction // Get user list // Gets a list of users in the workspace -// +// // Parameters: // Token - String - Bot token - token // Cursor - String - Pointer from the previous request, if the result rows > 100 - cursor -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetUserList(Val Token, Val Cursor = "") Export - -URL = "https://slack.com/api/users.list"; -Response = GeneralDataRetrieval(Token, URL, Cursor); - -Return Response; - + + URL = "https://slack.com/api/users.list"; + Response = GeneralDataRetrieval(Token, URL, Cursor); + + Return Response; + EndFunction #EndRegion @@ -97,238 +97,238 @@ EndFunction // Send message // Sends a message at a selected hour -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Text - String - Message text - text -// Sending date - Date - Sending date for delayed message - date +// Sending date - Date - Sending date for delayed message - date // Blocks - Array of Structures - Array of block descriptions - blocks - JSON array of block descriptions -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function SendMessage(Val Token, Val Channel, Val Text = "", Val Sending date = "", Val Blocks = "") Export + + String_ = "String"; + HasDate = ValueIsFilled(Sending date); + Headers = GetAuthorizationHeader(Token); + + If ValueIsFilled(Blocks) And TypeValue(Blocks) = Type(String_) Then + OPI_TypeConversion.GetCollection(Blocks); + + If TypeValue(Blocks) = Type("Array") Then + + For N = 0 For Blocks.WithinBoundary() Do + OPI_TypeConversion.GetCollection(Blocks[N]); + EndDo; + + EndIf; -String_ = "String"; -HasDate = ValueIsFilled(Sending date); -Headers = GetAuthorizationHeader(Token); - -If ValueIsFilled(Blocks) And TypeValue(Blocks) = Type(String_) Then -OPI_TypeConversion.GetCollection(Blocks); - -If TypeValue(Blocks) = Type("Array") Then - -For N = 0 For Blocks.WithinBoundary() Do -OPI_TypeConversion.GetCollection(Blocks[N]); -EndDo; - -EndIf; - -EndIf; - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel, String_ , Parameters); -OPI_Tools.AddField("text" , Text, String_ , Parameters); -OPI_Tools.AddField("blocks" , Blocks, "Array" , Parameters); - -If HasDate Then - -URL = "https://slack.com/api/chat.scheduleMessage"; -OPI_Tools.AddField("post_at", Sending date, "Date", Parameters); - -Else - -URL = "https://slack.com/api/chat.postMessage"; - -EndIf; - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + EndIf; + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel, String_ , Parameters); + OPI_Tools.AddField("text" , Text, String_ , Parameters); + OPI_Tools.AddField("blocks" , Blocks, "Array" , Parameters); + If HasDate Then + + URL = "https://slack.com/api/chat.scheduleMessage"; + OPI_Tools.AddField("post_at", Sending date, "Date", Parameters); + + Else + + URL = "https://slack.com/api/chat.postMessage"; + + EndIf; + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Send ephemeral message -// Sends a message that arrives in the channel but is visible +// Sends a message that arrives in the channel but is visible // only to a specific user -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Text - String - Message text - text -// User - String - User ID - user +// User - String - User ID - user // Blocks - Array of Structures - Array of block descriptions - blocks - JSON array of block descriptions -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function SendEphemeralMessage(Val Token -, Val Channel -, Val Text = "" -, Val User = "" -, Val Blocks = "") Export - -String_ = "String"; - -If ValueIsFilled(Blocks) And Not TypeValue(Blocks) = Type(String_) Then -OPI_TypeConversion.GetArray(Blocks); -EndIf; - -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , String_ , Parameters); -OPI_Tools.AddField("text" , Text , String_ , Parameters); -OPI_Tools.AddField("user" , User, String_ , Parameters); -OPI_Tools.AddField("blocks" , Blocks , "Collection", Parameters); - -URL = "https://slack.com/api/chat.postEphemeral"; - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + , Val Channel + , Val Text = "" + , Val User = "" + , Val Blocks = "") Export + + String_ = "String"; + + If ValueIsFilled(Blocks) And Not TypeValue(Blocks) = Type(String_) Then + OPI_TypeConversion.GetArray(Blocks); + EndIf; + + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , String_ , Parameters); + OPI_Tools.AddField("text" , Text , String_ , Parameters); + OPI_Tools.AddField("user" , User, String_ , Parameters); + OPI_Tools.AddField("blocks" , Blocks , "Collection", Parameters); + + URL = "https://slack.com/api/chat.postEphemeral"; + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Edit message // Edits the content of an existing message -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Timestamp - String - Message timestamp - stamp // Text - String - New message text - text // BlockArray - Array of Structures - Array of block descriptions - blocks - JSON array of block descriptions -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function EditMessage(Val Token, Val Channel, Val Timestamp, Val Text = "", Val BlockArray = "") Export - -String_ = "String"; -URL = "https://slack.com/api/chat.update"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , String_ , Parameters); -OPI_Tools.AddField("text" , Text , String_ , Parameters); -OPI_Tools.AddField("ts" , Timestamp , String_ , Parameters); -OPI_Tools.AddField("blocks" , BlockArray, "Collection", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + + String_ = "String"; + URL = "https://slack.com/api/chat.update"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , String_ , Parameters); + OPI_Tools.AddField("text" , Text , String_ , Parameters); + OPI_Tools.AddField("ts" , Timestamp , String_ , Parameters); + OPI_Tools.AddField("blocks" , BlockArray, "Collection", Parameters); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Delete message // Deletes a channel message by timestamp -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Timestamp - String - Timestamp or message ID - stamp // IsDelayed - Boolean - Indicator of deleting a delayed message - issheduled -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function DeleteMessage(Val Token, Val Channel, Val Timestamp, Val IsDelayed = False) Export + + OPI_TypeConversion.GetBoolean(IsDelayed); + + Headers = GetAuthorizationHeader(Token); + + If IsDelayed Then + URL = "https://slack.com/api/chat.deleteScheduledMessage"; + TimestampField = "scheduled_message_id"; + Else + URL = "https://slack.com/api/chat.delete"; + TimestampField = "ts"; + EndIf; + + Parameters = New Structure; + OPI_Tools.AddField("channel" , Channel , "String", Parameters); + OPI_Tools.AddField(TimestampField, Timestamp, "String", Parameters); -OPI_TypeConversion.GetBoolean(IsDelayed); - -Headers = GetAuthorizationHeader(Token); - -If IsDelayed Then -URL = "https://slack.com/api/chat.deleteScheduledMessage"; -TimestampField = "scheduled_message_id"; -Else -URL = "https://slack.com/api/chat.delete"; -TimestampField = "ts"; -EndIf; - -Parameters = New Structure; -OPI_Tools.AddField("channel" , Channel , "String", Parameters); -OPI_Tools.AddField(TimestampField, Timestamp, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Get list of delayed messages // Gets a list of delayed channel messages -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Cursor - String - Pointer from the previous request, if the result rows > 100 - cursor -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetDelayedMessageList(Val Token, Val Channel, Val Cursor = "") Export - -URL = "https://slack.com/api/chat.scheduledMessages.list"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("cursor" , Cursor, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + + URL = "https://slack.com/api/chat.scheduledMessages.list"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("cursor" , Cursor, "String", Parameters); + + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Get message link // Gets a permanent URL to the channel message -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Timestamp - String - Timestamp or message ID - stamp -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetMessageLink(Val Token, Val Channel, Val Timestamp) Export + + URL = "https://slack.com/api/chat.getPermalink"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel" , Channel , "String", Parameters); + OPI_Tools.AddField("message_ts", Timestamp, "String", Parameters); -URL = "https://slack.com/api/chat.getPermalink"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel" , Channel , "String", Parameters); -OPI_Tools.AddField("message_ts", Timestamp, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; EndFunction // Get list of message replies // Gets an array of messages that are replies to the specified -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Timestamp - String - Timestamp or message ID - stamp // Cursor - String - Pointer from the previous request, if the result rows > 100 - cursor -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetMessageReplyList(Val Token, Val Channel, Val Timestamp, Val Cursor = "") Export - -String_ = "String"; -URL = "https://slack.com/api/conversations.replies"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , String_, Parameters); -OPI_Tools.AddField("cursor" , Cursor , String_, Parameters); -OPI_Tools.AddField("ts" , Timestamp, String_, Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; + + String_ = "String"; + URL = "https://slack.com/api/conversations.replies"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , String_, Parameters); + OPI_Tools.AddField("cursor" , Cursor , String_, Parameters); + OPI_Tools.AddField("ts" , Timestamp, String_, Parameters); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; EndFunction @@ -338,289 +338,289 @@ EndFunction // Get channel list // Gets a list of available channels -// +// // Parameters: // Token - String - Bot token - token -// ExcludeArchived - Boolean - Indicator of excluding archived channels - notarchived +// ExcludeArchived - Boolean - Indicator of excluding archived channels - notarchived // Cursor - String - Pointer from the previous request, if the result rows > 100 - cursor -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetChannelList(Val Token, Val ExcludeArchived = False, Val Cursor = "") Export + + URL = "https://slack.com/api/conversations.list"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("exclude_archived", ExcludeArchived, "Boolean", Parameters); + OPI_Tools.AddField("cursor" , Cursor , "String", Parameters); -URL = "https://slack.com/api/conversations.list"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("exclude_archived", ExcludeArchived, "Boolean", Parameters); -OPI_Tools.AddField("cursor" , Cursor , "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Get channel user list // Gets a list of users in the specified channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Cursor - String - Pointer from the previous request, if the result rows > 100 - cursor -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetChannelUserList(Val Token, Val Channel, Val Cursor = "") Export + + URL = "https://slack.com/api/conversations.members"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("cursor" , Cursor, "String", Parameters); -URL = "https://slack.com/api/conversations.members"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("cursor" , Cursor, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; EndFunction // Create channel // Creates a new channel -// +// // Parameters: // Token - String - Bot token - token // Name - String - Channel name - title // Private - Boolean - Create channel as private - private -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function CreateChannel(Val Token, Val Name, Val Private = False) Export + + URL = "https://slack.com/api/conversations.create"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("name" , Name , "String", Parameters); + OPI_Tools.AddField("is_private", Private, "Boolean", Parameters); -URL = "https://slack.com/api/conversations.create"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("name" , Name , "String", Parameters); -OPI_Tools.AddField("is_private", Private, "Boolean", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Archive channel // Archives an active channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function ArchiveChannel(Val Token, Val Channel) Export - -URL = "https://slack.com/api/conversations.archive"; -Response = DialogManagement(Token, Channel, URL); -Return Response; - + + URL = "https://slack.com/api/conversations.archive"; + Response = DialogManagement(Token, Channel, URL); + Return Response; + EndFunction // Get channel // Gets information about the channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetChannel(Val Token, Val Channel) Export - -URL = "https://slack.com/api/conversations.info"; -Response = DialogManagement(Token, Channel, URL, "GET"); -Return Response; + + URL = "https://slack.com/api/conversations.info"; + Response = DialogManagement(Token, Channel, URL, "GET"); + Return Response; EndFunction // Get channel history // Gets information about channel events -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetChannelHistory(Val Token, Val Channel) Export - -URL = "https://slack.com/api/conversations.history"; -Response = DialogManagement(Token, Channel, URL, "GET"); -Return Response; + + URL = "https://slack.com/api/conversations.history"; + Response = DialogManagement(Token, Channel, URL, "GET"); + Return Response; EndFunction // Invite users to channel // Adds specified users to the channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // ArrayOfUsers - Array Of String - User ID Array - users -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function InviteUsersToChannel(Val Token, Val Channel, Val ArrayOfUsers) Export + + URL = "https://slack.com/api/conversations.invite"; + Headers = GetAuthorizationHeader(Token); + + OPI_TypeConversion.GetCollection(ArrayOfUsers); + ArrayOfUsers = StrJoin(ArrayOfUsers, ","); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("users" , ArrayOfUsers, "String", Parameters); -URL = "https://slack.com/api/conversations.invite"; -Headers = GetAuthorizationHeader(Token); - -OPI_TypeConversion.GetCollection(ArrayOfUsers); -ArrayOfUsers = StrJoin(ArrayOfUsers, ","); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("users" , ArrayOfUsers, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Kick user from channel // Removes specified user from channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // User - String - User ID - user -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function KickUserFromChannel(Val Token, Val Channel, Val User) Export + + URL = "https://slack.com/api/conversations.kick"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("user" , User, "String", Parameters); -URL = "https://slack.com/api/conversations.kick"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("user" , User, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Join channel // Adds the current bot to the channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function JoinChannel(Val Token, Val Channel) Export - -URL = "https://slack.com/api/conversations.join"; -Response = DialogManagement(Token, Channel, URL); -Return Response; + + URL = "https://slack.com/api/conversations.join"; + Response = DialogManagement(Token, Channel, URL); + Return Response; EndFunction // Leave channel // Removes the current bot from the channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function LeaveChannel(Val Token, Val Channel) Export - -URL = "https://slack.com/api/conversations.leave"; -Response = DialogManagement(Token, Channel, URL); -Return Response; + + URL = "https://slack.com/api/conversations.leave"; + Response = DialogManagement(Token, Channel, URL); + Return Response; EndFunction // Set channel topic // Sets the channel topic -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Topic - String - Channel topic - theme -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function SetChannelTopic(Val Token, Val Channel, Val Topic) Export + + URL = "https://slack.com/api/conversations.setTopic"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("topic" , Topic , "String", Parameters); -URL = "https://slack.com/api/conversations.setTopic"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("topic" , Topic , "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Set channel purpose // Sets the channel purpose (description) -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Purpose - String - Channel purpose - purpose -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function SetChannelGoal(Val Token, Val Channel, Val Purpose) Export + + URL = "https://slack.com/api/conversations.setPurpose"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("purpose", Purpose , "String", Parameters); -URL = "https://slack.com/api/conversations.setPurpose"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("purpose", Purpose , "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Rename channel // Changes the name of the channel -// +// // Parameters: // Token - String - Bot token - token // Channel - String - Channel ID - channel // Name - String - New channel name - title -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function RenameChannel(Val Token, Val Channel, Val Name) Export + + URL = "https://slack.com/api/conversations.rename"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("name" , Name, "String", Parameters); -URL = "https://slack.com/api/conversations.rename"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("name" , Name, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction @@ -630,45 +630,45 @@ EndFunction // Open dialog // Opens a new dialog with one or more users -// +// // Parameters: // Token - String - Bot token - token // ArrayOfUsers - Array of Strings - User ID Array - users -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function OpenDialog(Val Token, Val ArrayOfUsers) Export + + URL = "https://slack.com/api/conversations.open"; + Headers = GetAuthorizationHeader(Token); + + OPI_TypeConversion.GetCollection(ArrayOfUsers); + ArrayOfUsers = StrJoin(ArrayOfUsers, ","); + + Parameters = New Structure; + OPI_Tools.AddField("users", ArrayOfUsers, "String", Parameters); -URL = "https://slack.com/api/conversations.open"; -Headers = GetAuthorizationHeader(Token); - -OPI_TypeConversion.GetCollection(ArrayOfUsers); -ArrayOfUsers = StrJoin(ArrayOfUsers, ","); - -Parameters = New Structure; -OPI_Tools.AddField("users", ArrayOfUsers, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; EndFunction // Close dialog // Closes an existing dialog -// +// // Parameters: // Token - String - Bot token - token // Dialog - String - Dialog ID - conv -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function CloseDialog(Val Token, Val Dialog) Export - -URL = "https://slack.com/api/conversations.close"; -Response = DialogManagement(Token, Dialog, URL); -Return Response; - + + URL = "https://slack.com/api/conversations.close"; + Response = DialogManagement(Token, Dialog, URL); + Return Response; + EndFunction #EndRegion @@ -677,154 +677,154 @@ EndFunction // Get list of files // Gets a list of files of the bot or channel -// +// // Parameters: // Token - String - Bot token - token -// Channel - String - Channel for selection - channel +// Channel - String - Channel for selection - channel // PageNumber - Number, String - Page number - page -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetFilesList(Val Token, Val Channel = "", Val PageNumber = 1) Export + + URL = "https://slack.com/api/files.list"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("page" , PageNumber, "String", Parameters); -URL = "https://slack.com/api/files.list"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("page" , PageNumber, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Upload file // Uploads a file to Slack servers -// +// // Parameters: // Token - String - Bot token - token // File - String, BinaryData - File for upload - file // FileName - String - File name with extension - filename // Title - String - File name in Slack - title // Channel - String - Channel ID - channel -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function UploadFile(Val Token, Val File, Val FileName, Val Title, Val Channel = "") Export + + OPI_TypeConversion.GetBinaryData(File); + OPI_TypeConversion.GetLine(FileName); + OPI_TypeConversion.GetLine(Title); + + String_ = "String"; + Upload_url = "upload_url"; + File_id = "file_id"; + URL = "https://slack.com/api/files.getUploadURLExternal"; + Headers = GetAuthorizationHeader(Token); + Size = File.Size(); + + Parameters = New Structure; + OPI_Tools.AddField("filename", FileName, String_, Parameters); + OPI_Tools.AddField("length" , Size , String_, Parameters); -OPI_TypeConversion.GetBinaryData(File); -OPI_TypeConversion.GetLine(FileName); -OPI_TypeConversion.GetLine(Title); - -String_ = "String"; -Upload_url = "upload_url"; -File_id = "file_id"; -URL = "https://slack.com/api/files.getUploadURLExternal"; -Headers = GetAuthorizationHeader(Token); -Size = File.Size(); - -Parameters = New Structure; -OPI_Tools.AddField("filename", FileName, String_, Parameters); -OPI_Tools.AddField("length" , Size , String_, Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); -URL = Response[Upload_url]; -Identifier = Response[File_id]; - -If Not ValueIsFilled(URL) Or Not ValueIsFilled(Identifier) Then -Return Response; -EndIf; - -Files = New Match; -Files.Insert(FileName, File); - -Response = OPI_Tools.PostMultipart(URL, , Files, , Headers); -URL = "https://slack.com/api/files.completeUploadExternal"; -SlackFile = New Structure("id, title", Identifier, Title); - -Parameters = New Structure; -OPI_Tools.AddField("filename" , FileName, String_, Parameters); -OPI_Tools.AddField("channel_id", Channel , String_, Parameters); -OPI_Tools.AddField("files" , SlackFile, "Array", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, Headers); - -Return Response; + Response = OPI_Tools.Get(URL, Parameters, Headers); + URL = Response[Upload_url]; + Identifier = Response[File_id]; + + If Not ValueIsFilled(URL) Or Not ValueIsFilled(Identifier) Then + Return Response; + EndIf; + + Files = New Match; + Files.Insert(FileName, File); + + Response = OPI_Tools.PostMultipart(URL, , Files, , Headers); + URL = "https://slack.com/api/files.completeUploadExternal"; + SlackFile = New Structure("id, title", Identifier, Title); + + Parameters = New Structure; + OPI_Tools.AddField("filename" , FileName, String_, Parameters); + OPI_Tools.AddField("channel_id", Channel , String_, Parameters); + OPI_Tools.AddField("files" , SlackFile, "Array", Parameters); + Response = OPI_Tools.Post(URL, Parameters, Headers); + + Return Response; + EndFunction // Get file data // Gets information about the file -// +// // Parameters: // Token - String - Bot token - token // FileID - String - File identifier - fileid -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetFileData(Val Token, Val FileID) Export - -URL = "https://slack.com/api/files.info"; -Response = FileManagement(Token, FileID, URL, "GET"); - -Return Response; - + + URL = "https://slack.com/api/files.info"; + Response = FileManagement(Token, FileID, URL, "GET"); + + Return Response; + EndFunction // Delete file // Deletes a file on Slack -// +// // Parameters: // Token - String - Bot token - token // FileID - String - File identifier - fileid -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function DeleteFile(Val Token, Val FileID) Export - -URL = "https://slack.com/api/files.delete"; -Response = FileManagement(Token, FileID, URL); - -Return Response; - + + URL = "https://slack.com/api/files.delete"; + Response = FileManagement(Token, FileID, URL); + + Return Response; + EndFunction // Make file public // Creates a public URL for the file. Requires user token -// +// // Parameters: // Token - String - User token - token // FileID - String - File identifier - fileid -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function MakeFilePublic(Val Token, Val FileID) Export - -URL = "https://slack.com/api/files.sharedPublicURL"; -Response = FileManagement(Token, FileID, URL); - -Return Response; - + + URL = "https://slack.com/api/files.sharedPublicURL"; + Response = FileManagement(Token, FileID, URL); + + Return Response; + EndFunction // Make file private // Removes the public URL from the file. Requires user token -// +// // Parameters: // Token - String - User token - token // FileID - String - File identifier - fileid -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function MakeFilePrivate(Val Token, Val FileID) Export - -URL = "https://slack.com/api/files.revokePublicURL"; -Response = FileManagement(Token, FileID, URL); - -Return Response; - + + URL = "https://slack.com/api/files.revokePublicURL"; + Response = FileManagement(Token, FileID, URL); + + Return Response; + EndFunction #EndRegion @@ -833,119 +833,119 @@ EndFunction // Get list of external files // Gets a list of external files of a user or channel -// +// // Parameters: // Token - String - Bot token - token -// Channel - String - Channel for selection - channel +// Channel - String - Channel for selection - channel // Cursor - String - Pointer from the previous request, if the result rows > 100 - cursor -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetExternalFileList(Val Token, Val Channel = "", Val Cursor = "") Export + + URL = "https://slack.com/api/files.remote.list"; + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel , "String", Parameters); + OPI_Tools.AddField("cursor" , Cursor, "String", Parameters); -URL = "https://slack.com/api/files.remote.list"; -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel , "String", Parameters); -OPI_Tools.AddField("cursor" , Cursor, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Get external file // Gets information about the external file -// +// // Parameters: // Token - String - Bot token - token // FileID - String - File identifier - fileid -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function GetExternalFile(Val Token, Val FileID) Export - -URL = "https://slack.com/api/files.remote.info"; -Response = ExternalFileManagement(Token, FileID, URL); - -Return Response; - + + URL = "https://slack.com/api/files.remote.info"; + Response = ExternalFileManagement(Token, FileID, URL); + + Return Response; + EndFunction // Add external file // Adds a new external file -// +// // Parameters: // Token - String - Bot token - token // URL - String - URL to external file - url // Title - String - File title for Slack - title -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function AddExternalFile(Val Token, Val URL, Val Title) Export + + String_ = "String"; + URL = "https://slack.com/api/files.remote.add"; + Headers = GetAuthorizationHeader(Token); + UID = String(New UniqueIdentifier()); + + Parameters = New Structure; + OPI_Tools.AddField("external_url", URL , String_, Parameters); + OPI_Tools.AddField("external_id" , UID , String_, Parameters); + OPI_Tools.AddField("title" , Title , String_, Parameters); -String_ = "String"; -URL = "https://slack.com/api/files.remote.add"; -Headers = GetAuthorizationHeader(Token); -UID = String(New UniqueIdentifier()); - -Parameters = New Structure; -OPI_Tools.AddField("external_url", URL , String_, Parameters); -OPI_Tools.AddField("external_id" , UID , String_, Parameters); -OPI_Tools.AddField("title" , Title , String_, Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Send external file // Sends an external file to a list of channels -// +// // Parameters: // Token - String - Bot token - token // FileID - String - File identifier - fileid // ChannelArray - Array Of String - Array of channels for sending - channels -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function SendExternalFile(Val Token, Val FileID, Val ChannelArray) Export + + URL = "https://slack.com/api/files.remote.share"; + Headers = GetAuthorizationHeader(Token); + + OPI_TypeConversion.GetCollection(ChannelArray); + ChannelArray = StrJoin(ChannelArray, ","); + + Parameters = New Structure; + OPI_Tools.AddField("file" , FileID , "String", Parameters); + OPI_Tools.AddField("channels", ChannelArray , "String", Parameters); -URL = "https://slack.com/api/files.remote.share"; -Headers = GetAuthorizationHeader(Token); - -OPI_TypeConversion.GetCollection(ChannelArray); -ChannelArray = StrJoin(ChannelArray, ","); - -Parameters = New Structure; -OPI_Tools.AddField("file" , FileID , "String", Parameters); -OPI_Tools.AddField("channels", ChannelArray , "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction // Delete external file // Deletes an external file from Slack -// +// // Parameters: // Token - String - Bot token - token // FileID - String - File identifier - fileid -// +// // Return value: // Key-Value Pair - Serialized JSON response from Slack Function DeleteExternalFile(Val Token, Val FileID) Export - -URL = "https://slack.com/api/files.remote.remove"; -Response = ExternalFileManagement(Token, FileID, URL); - -Return Response; - + + URL = "https://slack.com/api/files.remote.remove"; + Response = ExternalFileManagement(Token, FileID, URL); + + Return Response; + EndFunction #EndRegion @@ -954,24 +954,24 @@ EndFunction // Generate image block // Generates a block with an image to add to the message block array -// +// // Parameters: // URL - String - Image URL - picture // AlternateText - String - Alternate text of the image - alt -// +// // Return value: // Key-Value Pair - Image block Function GenerateImageBlock(Val URL, Val AlternateText = "") Export - -String_ = "String"; - -Block = New Match; -OPI_Tools.AddField("type" , "image" , String_, Block); -OPI_Tools.AddField("image_url", URL , String_, Block); -OPI_Tools.AddField("alt_text" , AlternateText , String_, Block); - -Return Block; - + + String_ = "String"; + + Block = New Match; + OPI_Tools.AddField("type" , "image" , String_, Block); + OPI_Tools.AddField("image_url", URL , String_, Block); + OPI_Tools.AddField("alt_text" , AlternateText , String_, Block); + + Return Block; + EndFunction #EndRegion @@ -982,74 +982,74 @@ EndFunction Function GetAuthorizationHeader(Val Token) -OPI_TypeConversion.GetLine(Token); - -Headers = New Match; -Headers.Insert("Authorization", "Bearer " + Token); -Return Headers; - + OPI_TypeConversion.GetLine(Token); + + Headers = New Match; + Headers.Insert("Authorization", "Bearer " + Token); + Return Headers; + EndFunction Function DialogManagement(Val Token, Val Channel, Val URL, Val RequestType = "POST") + + Headers = GetAuthorizationHeader(Token); + RequestType = inReg(RequestType); + + Parameters = New Structure; + OPI_Tools.AddField("channel", Channel, "String", Parameters); -Headers = GetAuthorizationHeader(Token); -RequestType = inReg(RequestType); - -Parameters = New Structure; -OPI_Tools.AddField("channel", Channel, "String", Parameters); - -If RequestType = "POST" Then -Response = OPI_Tools.Post(URL, Parameters, Headers); -Else -Response = OPI_Tools.Get(URL, Parameters, Headers); -EndIf; - -Return Response; - + If RequestType = "POST" Then + Response = OPI_Tools.Post(URL, Parameters, Headers); + Else + Response = OPI_Tools.Get(URL, Parameters, Headers); + EndIf; + + Return Response; + EndFunction Function FileManagement(Val Token, Val FileID, Val URL, Val RequestType = "POST") + + Headers = GetAuthorizationHeader(Token); + RequestType = inReg(RequestType); + + Parameters = New Structure; + OPI_Tools.AddField("file", FileID , "String", Parameters); -Headers = GetAuthorizationHeader(Token); -RequestType = inReg(RequestType); + If RequestType = "POST" Then + Response = OPI_Tools.Post(URL, Parameters, Headers); + Else + Response = OPI_Tools.Get(URL, Parameters, Headers); + EndIf; -Parameters = New Structure; -OPI_Tools.AddField("file", FileID , "String", Parameters); - -If RequestType = "POST" Then -Response = OPI_Tools.Post(URL, Parameters, Headers); -Else -Response = OPI_Tools.Get(URL, Parameters, Headers); -EndIf; - -Return Response; + Return Response; EndFunction Function GeneralDataRetrieval(Val Token, Val URL, Val Cursor) - -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("cursor", Cursor, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("cursor", Cursor, "String", Parameters); + + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction Function ExternalFileManagement(Val Token, Val FileID, Val URL) + + Headers = GetAuthorizationHeader(Token); + + Parameters = New Structure; + OPI_Tools.AddField("file", FileID , "String", Parameters); -Headers = GetAuthorizationHeader(Token); - -Parameters = New Structure; -OPI_Tools.AddField("file", FileID , "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters, Headers); - -Return Response; - + Response = OPI_Tools.Get(URL, Parameters, Headers); + + Return Response; + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Slack/OPI_Slack.mdo b/src/en/OPI/src/CommonModules/OPI_Slack/OPI_Slack.mdo index fcf5becb55..c81e3953ae 100644 --- a/src/en/OPI/src/CommonModules/OPI_Slack/OPI_Slack.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Slack/OPI_Slack.mdo @@ -1,11 +1,11 @@  -OPI_Slack - -ru -Slack - -true -true -true + OPI_Slack + + ru + Slack + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Telegram/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Telegram/Module.bsl index 25327323c4..e2fdef264d 100644 --- a/src/en/OPI/src/CommonModules/OPI_Telegram/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Telegram/Module.bsl @@ -41,20 +41,20 @@ // Get bot information // Inыполняет запроwith /getMe, inозinращающий базоinую информацию о боте: имя, id, inозможноwithть dобаinлять бота in группы и т.d. -// +// // Parameters: // Token - String - Bot token - token -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function GetBotInformation(Val Token) Export -OPI_TypeConversion.GetLine(Token); - -URL = "api.telegram.org/bot" + Token + "/getMe"; -Response = OPI_Tools.Get(URL); - -Return Response; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/getMe"; + Response = OPI_Tools.Get(URL); + + Return Response; EndFunction @@ -65,164 +65,164 @@ EndFunction // Token - String - Bot token - token // Timeout - String, Number - Waiting time for new events - timeout // Offset - String, Number - Offset in the list of received messages - offset -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function GetUpdates(Val Token, Val Timeout = 0, Val Offset = "") Export -OPI_TypeConversion.GetLine(Token); - -URL = "api.telegram.org/bot" + Token + "/getUpdates"; - -Parameters = New Structure; -OPI_Tools.AddField("timeout", Timeout , "String", Parameters); -OPI_Tools.AddField("offset" , Offset, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters); -Return Response; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/getUpdates"; + + Parameters = New Structure; + OPI_Tools.AddField("timeout", Timeout , "String", Parameters); + OPI_Tools.AddField("offset" , Offset, "String", Parameters); + + Response = OPI_Tools.Get(URL, Parameters); + Return Response; EndFunction // Set Webhook -// Set webhook URL for bot event handling in webhook mode -// +// Set webhook URL for bot event handling in webhook mode +// // Parameters: // Token - String - Bot token - token // URL - String - Address processing запроwithоin от Telegram (with https:) - url -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SetWebhook(Val Token, Val URL) Export -OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Token); + + Parameters = New Structure; + OPI_Tools.AddField("url", URL, "String", Parameters); -Parameters = New Structure; -OPI_Tools.AddField("url", URL, "String", Parameters); - -URL = "api.telegram.org/bot" + Token + "/setWebHook"; -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + URL = "api.telegram.org/bot" + Token + "/setWebHook"; + Response = OPI_Tools.Get(URL, Parameters); + + Return Response; EndFunction // Delete webhook // Deletes the bot event handler URL for webhook operation -// +// // Parameters: // Token - String - Bot token - token -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function DeleteWebhook(Val Token) Export -OPI_TypeConversion.GetLine(Token); - -URL = "api.telegram.org/bot" + Token + "/deleteWebHook"; -Response = OPI_Tools.Get(URL); - -Return Response; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/deleteWebHook"; + Response = OPI_Tools.Get(URL); + + Return Response; EndFunction // Download file // Download file from Telegram servers -// +// // Parameters: // Token - String - Token - token // FileID - String - File ID for downloading - fileid -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function DownloadFile(Val Token, Val FileID) Export -Result = "result"; - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(FileID); - -Parameters = New Structure("file_id", FileID); - -URL = "api.telegram.org/bot" + Token + "/getFile"; -Response = OPI_Tools.Get(URL, Parameters); - -Path = Response[Result]["file_path"]; - -If Not ValueIsFilled(Path) Then -Return Response; -EndIf; - -URL = "api.telegram.org/file/bot" + Token + "/" + Path; -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Result = "result"; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(FileID); + + Parameters = New Structure("file_id", FileID); + URL = "api.telegram.org/bot" + Token + "/getFile"; + Response = OPI_Tools.Get(URL, Parameters); + + Path = Response[Result]["file_path"]; + + If Not ValueIsFilled(Path) Then + Return Response; + EndIf; + + URL = "api.telegram.org/file/bot" + Token + "/" + Path; + Response = OPI_Tools.Get(URL, Parameters); + + Return Response; + EndFunction // Process Telegram Mini App data // Processes TMA data and determines its validity -// +// // Parameters: // DataString - String - Query from Telegram.WebApp.initData // Token - String - Bot token -// +// // Return value: // Map from String - Map of data with the result of verification in the passed field Function ProcessTMAData(Val DataString, Val Token) Export -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(DataString); + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(DataString); + + DataString = DecodeString(DataString, StringEncodingMethod.URLencoding); + DataStructure = OPI_Tools.RequestParametersToMatch(DataString); + Key = "WebAppData"; + Hash = ""; + BinaryKey = GetBinaryDataFromString(Key); -DataString = DecodeString(DataString, StringEncodingMethod.URLencoding); -DataStructure = OPI_Tools.RequestParametersToMatch(DataString); -Key = "WebAppData"; -Hash = ""; -BinaryKey = GetBinaryDataFromString(Key); + Result = OPI_Cryptography.HMACSHA256(BinaryKey, GetBinaryDataFromString(Token)); -Result = OPI_Cryptography.HMACSHA256(BinaryKey, GetBinaryDataFromString(Token)); + TValue = New ValueTable; + TValue.Columns.Add("Key"); + TValue.Columns.Add("Value"); -TValue = New ValueTable; -TValue.Columns.Add("Key"); -TValue.Columns.Add("Value"); + For Each Data In DataStructure Do -For Each Data In DataStructure Do + NewLine = TValue.Add(); + NewLine.Key = Data.Key; + NewLine.Value = Data.Value; -NewLine = TValue.Add(); -NewLine.Key = Data.Key; -NewLine.Value = Data.Value; + EndDo; -EndDo; + TValue.Sort("Key"); -TValue.Sort("Key"); + ReturnMapping = New Match; + DCS = ""; -ReturnMapping = New Match; -DCS = ""; + For Each DataString In TValue Do -For Each DataString In TValue Do + If DataString.Key <> "hash" Then + DCS = DCS + DataString.Key + "=" + DataString.Value + Symbols.PS; + ReturnMapping.Insert(DataString.Key, DataString.Value); + Else + Hash = DataString.Value; + EndIf; -If DataString.Key <> "hash" Then -DCS = DCS + DataString.Key + "=" + DataString.Value + Symbols.PS; -ReturnMapping.Insert(DataString.Key, DataString.Value); -Else -Hash = DataString.Value; -EndIf; + EndDo; -EndDo; + DCS = Left(DCS, StrLength(DCS) - 1); + Signature = OPI_Cryptography.HMACSHA256(Result, GetBinaryDataFromString(DCS)); -DCS = Left(DCS, StrLength(DCS) - 1); -Signature = OPI_Cryptography.HMACSHA256(Result, GetBinaryDataFromString(DCS)); + Final = GetHexStringFromBinaryData(Signature); -Final = GetHexStringFromBinaryData(Signature); + If Final = inReg(Hash) Then + Response = True; + Else + Response = False; + EndIf; -If Final = inReg(Hash) Then -Response = True; -Else -Response = False; -EndIf; + ReturnMapping.Insert("passed", Response); -ReturnMapping.Insert("passed", Response); - -Return ReturnMapping; + Return ReturnMapping; EndFunction @@ -232,42 +232,42 @@ EndFunction // Send text message // Sends a text message to a chat or channel -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat // Text - String - Message text - text // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json // Markup - String - View processing textа (HTML, Markdown, MarkdownV2) - parsemode -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendTextMessage(Val Token -, Val ChatID -, Val Text -, Val Keyboard = "" -, Val Markup = "Markdown") Export + , Val ChatID + , Val Text + , Val Keyboard = "" + , Val Markup = "Markdown") Export -OPI_TypeConversion.GetLine(Token); -OPI_Tools.ReplaceSpecialCharacters(Text, Markup); + OPI_TypeConversion.GetLine(Token); + OPI_Tools.ReplaceSpecialCharacters(Text, Markup); + + Parameters = New Structure; + OPI_Tools.AddField("parse_mode" , Markup , "String" , Parameters); + OPI_Tools.AddField("text" , Text , "String" , Parameters); + OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); + + AddChatIdentifier(ChatID, Parameters); + + URL = "api.telegram.org/bot" + Token + "/sendMessage"; + Response = OPI_Tools.Get(URL, Parameters); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode" , Markup , "String" , Parameters); -OPI_Tools.AddField("text" , Text , "String" , Parameters); -OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); - -AddChatIdentifier(ChatID, Parameters); - -URL = "api.telegram.org/bot" + Token + "/sendMessage"; -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Send image // Sends an image to a chat or channel -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat @@ -275,23 +275,23 @@ EndFunction // Image - BinaryData,String - Image file - picture // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json // Markup - String - View processing textа (HTML, Markdown, MarkdownV2) - parsemode -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendImage(Val Token -, Val ChatID -, Val Text -, Val Image -, Val Keyboard = "" -, Val Markup = "Markdown") Export + , Val ChatID + , Val Text + , Val Image + , Val Keyboard = "" + , Val Markup = "Markdown") Export -Return SendFile(Token, ChatID, Text, Image, "photo", Keyboard, Markup); + Return SendFile(Token, ChatID, Text, Image, "photo", Keyboard, Markup); EndFunction // Send video // Sends a video to a chat or channel -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat @@ -299,23 +299,23 @@ EndFunction // Video - BinaryData,String - Video file - video // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json // Markup - String - View processing textа (HTML, Markdown, MarkdownV2) - parsemode -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendVideo(Val Token -, Val ChatID -, Val Text -, Val Video -, Val Keyboard = "" -, Val Markup = "Markdown") Export + , Val ChatID + , Val Text + , Val Video + , Val Keyboard = "" + , Val Markup = "Markdown") Export -Return SendFile(Token, ChatID, Text, Video, "video", Keyboard, Markup); + Return SendFile(Token, ChatID, Text, Video, "video", Keyboard, Markup); EndFunction // Send audio // Sends an audio file to a chat or channel -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat @@ -323,23 +323,23 @@ EndFunction // Audio - BinaryData,String - Audio file - audio // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json // Markup - String - View processing textа (HTML, Markdown, MarkdownV2) - parsemode -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendAudio(Val Token -, Val ChatID -, Val Text -, Val Audio -, Val Keyboard = "" -, Val Markup = "Markdown") Export + , Val ChatID + , Val Text + , Val Audio + , Val Keyboard = "" + , Val Markup = "Markdown") Export -Return SendFile(Token, ChatID, Text, Audio, "audio", Keyboard, Markup); + Return SendFile(Token, ChatID, Text, Audio, "audio", Keyboard, Markup); EndFunction // Send document // Sends a document to a chat or channel -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat @@ -347,23 +347,23 @@ EndFunction // Document - BinaryData,String - Document file - doc // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json // Markup - String - View processing textа (HTML, Markdown, MarkdownV2) - parsemode -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendDocument(Val Token -, Val ChatID -, Val Text -, Val Document -, Val Keyboard = "" -, Val Markup = "Markdown") Export + , Val ChatID + , Val Text + , Val Document + , Val Keyboard = "" + , Val Markup = "Markdown") Export -Return SendFile(Token, ChatID, Text, Document, "document", Keyboard, Markup); + Return SendFile(Token, ChatID, Text, Document, "document", Keyboard, Markup); EndFunction // Send GIF // Sends a GIF to a chat or channel -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat @@ -371,23 +371,23 @@ EndFunction // GIF - BinaryData,String - GIF file - gif // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json // Markup - String - View processing textа (HTML, Markdown, MarkdownV2) - parsemode -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendGif(Val Token -, Val ChatID -, Val Text -, Val GIF -, Val Keyboard = "" -, Val Markup = "Markdown") Export + , Val ChatID + , Val Text + , Val GIF + , Val Keyboard = "" + , Val Markup = "Markdown") Export -Return SendFile(Token, ChatID, Text, GIF, "animation", Keyboard, Markup); + Return SendFile(Token, ChatID, Text, GIF, "animation", Keyboard, Markup); EndFunction // Send media group // Sends a set of files to a chat or channel. Media types: audio, document, photo, video -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat @@ -395,85 +395,85 @@ EndFunction // FileMapping - Map from String - File collection - media - File JSON or path to .json // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json // Markup - String - View processing textа (HTML, Markdown, MarkdownV2) - parsemode -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendMediaGroup(Val Token -, Val ChatID -, Val Text -, Val FileMapping -, Val Keyboard = "" -, Val Markup = "Markdown") Export + , Val ChatID + , Val Text + , Val FileMapping + , Val Keyboard = "" + , Val Markup = "Markdown") Export + + // FileMapping + // Key - File, Value - Type + // Types: audio, document, photo, video + // Different types cannot be mixed! -// FileMapping -// Key - File, Value - Type -// Types: audio, document, photo, video -// Different types cannot be mixed! + String_ = "String"; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ChatID); + OPI_TypeConversion.GetCollection(FileMapping); + + OPI_Tools.ReplaceSpecialCharacters(Text, Markup); -String_ = "String"; + URL = "api.telegram.org/bot" + Token + "/sendMediaGroup"; + FileStructure = New Structure; + Media = New Array; + Parameters = New Structure; + + AddChatIdentifier(ChatID, Parameters); + FormMediaArray(FileMapping, Text, FileStructure, Media); + + OPI_Tools.AddField("parse_mode" , Markup , String_ , Parameters); + OPI_Tools.AddField("caption" , Text , String_ , Parameters); + OPI_Tools.AddField("media" , Media , String_ , Parameters); + OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ChatID); -OPI_TypeConversion.GetCollection(FileMapping); + Response = OPI_Tools.PostMultipart(URL, Parameters, FileStructure, "mixed"); -OPI_Tools.ReplaceSpecialCharacters(Text, Markup); - -URL = "api.telegram.org/bot" + Token + "/sendMediaGroup"; -FileStructure = New Structure; -Media = New Array; -Parameters = New Structure; - -AddChatIdentifier(ChatID, Parameters); -FormMediaArray(FileMapping, Text, FileStructure, Media); - -OPI_Tools.AddField("parse_mode" , Markup , String_ , Parameters); -OPI_Tools.AddField("caption" , Text , String_ , Parameters); -OPI_Tools.AddField("media" , Media , String_ , Parameters); -OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); - -Response = OPI_Tools.PostMultipart(URL, Parameters, FileStructure, "mixed"); - -Return Response; + Return Response; EndFunction // Send location // Sends location by geographic latitude and longitude to a chat or channel -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat // Latitude - String, Number - Geographic latitude - lat // Longitude - String, Number - Geographic longitude - long // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendLocation(Val Token, Val ChatID, Val Latitude, Val Longitude, Val Keyboard = "") Export -String_ = "String"; -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ChatID); + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ChatID); + + URL = "api.telegram.org/bot" + Token + "/sendLocation"; + + Parameters = New Structure; + OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); + OPI_Tools.AddField("latitude" , Latitude , String_ , Parameters); + OPI_Tools.AddField("longitude" , Longitude , String_ , Parameters); + OPI_Tools.AddField("reply_markup", Keyboard , "FileString", Parameters); + + AddChatIdentifier(ChatID, Parameters); -URL = "api.telegram.org/bot" + Token + "/sendLocation"; + Response = OPI_Tools.Get(URL, Parameters); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); -OPI_Tools.AddField("latitude" , Latitude , String_ , Parameters); -OPI_Tools.AddField("longitude" , Longitude , String_ , Parameters); -OPI_Tools.AddField("reply_markup", Keyboard , "FileString", Parameters); - -AddChatIdentifier(ChatID, Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Send contact // Sends a contact with name and phone number -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat @@ -481,133 +481,133 @@ EndFunction // Last name - String - Contact last name - surname // Phone - String - Contact phone number - phone // Keyboard - String - See GenerateKeyboardFromArray - keyboard - Keyboard JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendContact(Val Token, Val ChatID, Val Name, Val Last name, Val Phone, Val Keyboard = "") Export -String_ = "String"; -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ChatID); + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ChatID); + + URL = "api.telegram.org/bot" + Token + "/sendContact"; -URL = "api.telegram.org/bot" + Token + "/sendContact"; + Parameters = New Structure; + OPI_Tools.AddField("parse_mode" , "Markdown", String_ , Parameters); + OPI_Tools.AddField("first_name" , Name , String_ , Parameters); + OPI_Tools.AddField("last_name" , Last name , String_ , Parameters); + OPI_Tools.AddField("phone_number", Phone , String_ , Parameters); + OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); + + AddChatIdentifier(ChatID, Parameters); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode" , "Markdown", String_ , Parameters); -OPI_Tools.AddField("first_name" , Name , String_ , Parameters); -OPI_Tools.AddField("last_name" , Last name , String_ , Parameters); -OPI_Tools.AddField("phone_number", Phone , String_ , Parameters); -OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); + Response = OPI_Tools.Get(URL, Parameters); -AddChatIdentifier(ChatID, Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Send poll // Sends a poll with answer options -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat // Question - String - Poll question - question // AnswersArray - Array of Strings - Array of answer options - options // Anonymous - Boolean - Poll anonymity - anonymous -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function SendPoll(Val Token, Val ChatID, Val Question, Val AnswersArray, Val Anonymous = True) Export -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ChatID); -OPI_TypeConversion.GetCollection(AnswersArray); + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ChatID); + OPI_TypeConversion.GetCollection(AnswersArray); -OPI_TypeConversion.GetBoolean(Anonymous); + OPI_TypeConversion.GetBoolean(Anonymous); + + URL = "api.telegram.org/bot" + Token + "/sendPoll"; -URL = "api.telegram.org/bot" + Token + "/sendPoll"; + Parameters = New Structure; + OPI_Tools.AddField("parse_mode", "Markdown" , "String" , Parameters); + OPI_Tools.AddField("question" , Question , "String" , Parameters); + OPI_Tools.AddField("options" , AnswersArray, "FileString", Parameters); + + Parameters.Insert("is_anonymous", ?(Anonymous, 1, 0)); + AddChatIdentifier(ChatID, Parameters); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode", "Markdown" , "String" , Parameters); -OPI_Tools.AddField("question" , Question , "String" , Parameters); -OPI_Tools.AddField("options" , AnswersArray, "FileString", Parameters); + Response = OPI_Tools.Get(URL, Parameters); -Parameters.Insert("is_anonymous", ?(Anonymous, 1, 0)); -AddChatIdentifier(ChatID, Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Forward message // Forwards a message between chats or within a chat -// +// // Parameters: // Token - String - Bot token - token // OriginalID - String, Number - Original message ID - message // FromID - String, Number - Chat ID of the original message - from // ToID - String, Number - Target chat ID or ChatID*TopicID - to -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function ForwardMessage(Val Token, Val OriginalID, Val FromID, Val ToID) Export -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(OriginalID); -OPI_TypeConversion.GetLine(FromID); -OPI_TypeConversion.GetLine(ToID); + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(OriginalID); + OPI_TypeConversion.GetLine(FromID); + OPI_TypeConversion.GetLine(ToID); + + URL = "api.telegram.org/bot" + Token + "/forwardMessage"; + + Parameters = New Structure; + OPI_Tools.AddField("from_chat_id", FromID , "String", Parameters); + OPI_Tools.AddField("message_id" , OriginalID, "String", Parameters); -URL = "api.telegram.org/bot" + Token + "/forwardMessage"; + AddChatIdentifier(ToID, Parameters); + + Response = OPI_Tools.Get(URL, Parameters); -Parameters = New Structure; -OPI_Tools.AddField("from_chat_id", FromID , "String", Parameters); -OPI_Tools.AddField("message_id" , OriginalID, "String", Parameters); - -AddChatIdentifier(ToID, Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Generate keyboard from array of buttons // Generates a simple JSON keyboard from an array of buttons for a message or bottom panel -// +// // Parameters: -// ButtonArray - Array of Strings - Array of buttons - buttons +// ButtonArray - Array of Strings - Array of buttons - buttons // UnderMessage - Boolean - Keyboard under the message or on the bottom panel - under // OneByOne - Boolean - True > buttons are displayed in a column, False > in a row - column -// +// // Return value: // String - Keyboard JSON Function FormKeyboardFromButtonArray(Val ButtonArray -, Val UnderMessage = False -, Val OneByOne = True) Export + , Val UnderMessage = False + , Val OneByOne = True) Export -OPI_TypeConversion.GetBoolean(UnderMessage); -OPI_TypeConversion.GetBoolean(OneByOne); -OPI_TypeConversion.GetCollection(ButtonArray); + OPI_TypeConversion.GetBoolean(UnderMessage); + OPI_TypeConversion.GetBoolean(OneByOne); + OPI_TypeConversion.GetCollection(ButtonArray); + + If OneByOne Then + Strings = CreateTallKeyboard(ButtonArray); + Else + Strings = CreateLongKeyboard(ButtonArray); + EndIf; -If OneByOne Then -Strings = CreateTallKeyboard(ButtonArray); -Else -Strings = CreateLongKeyboard(ButtonArray); -EndIf; + If UnderMessage Then + ParameterStructure = New Structure("inline_keyboard,rows", Strings, 1); + Else + ParameterStructure = New Structure("keyboard,resize_keyboard", Strings, True); + EndIf; -If UnderMessage Then -ParameterStructure = New Structure("inline_keyboard,rows", Strings, 1); -Else -ParameterStructure = New Structure("keyboard,resize_keyboard", Strings, True); -EndIf; + Keyboard = OPI_Tools.JSONString(ParameterStructure); -Keyboard = OPI_Tools.JSONString(ParameterStructure); - -Return Keyboard; + Return Keyboard; EndFunction @@ -617,176 +617,176 @@ EndFunction // Ban // Bans a user in the selected chat -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat // UserID - String, Number - Target user ID - user -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function Ban(Val Token, Val ChatID, Val UserID) Export -String_ = "String"; -OPI_TypeConversion.GetLine(Token); + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/banChatMember"; -URL = "api.telegram.org/bot" + Token + "/banChatMember"; + Parameters = New Structure; + OPI_Tools.AddField("parse_mode", "Markdown" , String_, Parameters); + OPI_Tools.AddField("chat_id" , ChatID , String_, Parameters); + OPI_Tools.AddField("user_id" , UserID, String_, Parameters); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode", "Markdown" , String_, Parameters); -OPI_Tools.AddField("chat_id" , ChatID , String_, Parameters); -OPI_Tools.AddField("user_id" , UserID, String_, Parameters); + Response = OPI_Tools.Get(URL, Parameters); -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Unban // Unbans a previously banned user -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat // UserID - String, Number - Target user ID - user -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function Unban(Val Token, Val ChatID, Val UserID) Export -String_ = "String"; -OPI_TypeConversion.GetLine(Token); + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/unbanChatMember"; -URL = "api.telegram.org/bot" + Token + "/unbanChatMember"; + Parameters = New Structure; + OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); + OPI_Tools.AddField("chat_id" , ChatID , String_ , Parameters); + OPI_Tools.AddField("user_id" , UserID, String_ , Parameters); + OPI_Tools.AddField("only_if_banned", False , "Boolean", Parameters); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); -OPI_Tools.AddField("chat_id" , ChatID , String_ , Parameters); -OPI_Tools.AddField("user_id" , UserID, String_ , Parameters); -OPI_Tools.AddField("only_if_banned", False , "Boolean", Parameters); + Response = OPI_Tools.Get(URL, Parameters); -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Create invitation link // Creates a link for joining a closed chat -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID or ChatID*TopicID - chat // Title - String - Invitation title - title // ExpirationDate - Date - Date of end жfromни withwithылtoи (withoutwithрочно, еwithли не уtoазано) - expire // UserLimit - Number - Limit пользоinателей (беwithtoонечно, еwithли не уtoазано) - limit -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function CreateInvitationLink(Val Token -, Val ChatID -, Val Title = "" -, Val ExpirationDate = "" -, Val UserLimit = 0) Export + , Val ChatID + , Val Title = "" + , Val ExpirationDate = "" + , Val UserLimit = 0) Export -String_ = "String"; -OPI_TypeConversion.GetLine(Token); + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/createChatInviteLink"; + + Parameters = New Structure; + OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); + OPI_Tools.AddField("chat_id" , ChatID , String_ , Parameters); + OPI_Tools.AddField("name" , Title , String_ , Parameters); + OPI_Tools.AddField("member_limit" , UserLimit, String_ , Parameters); + OPI_Tools.AddField("expire_date" , ExpirationDate , "Date" , Parameters); + + Response = OPI_Tools.Get(URL, Parameters); -URL = "api.telegram.org/bot" + Token + "/createChatInviteLink"; - -Parameters = New Structure; -OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); -OPI_Tools.AddField("chat_id" , ChatID , String_ , Parameters); -OPI_Tools.AddField("name" , Title , String_ , Parameters); -OPI_Tools.AddField("member_limit" , UserLimit, String_ , Parameters); -OPI_Tools.AddField("expire_date" , ExpirationDate , "Date" , Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Pin message // Pins a message in the chat header -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Target chat ID - chat // MessageID - String, Number - Target message ID - message -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function PinMessage(Val Token, Val ChatID, Val MessageID) Export + + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/pinChatMessage"; + + Parameters = New Structure; + OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); + OPI_Tools.AddField("chat_id" , ChatID , String_ , Parameters); + OPI_Tools.AddField("message_id" , MessageID, String_ , Parameters); + OPI_Tools.AddField("disable_notification", False , "Boolean", Parameters); -String_ = "String"; -OPI_TypeConversion.GetLine(Token); + Response = OPI_Tools.Get(URL, Parameters); -URL = "api.telegram.org/bot" + Token + "/pinChatMessage"; - -Parameters = New Structure; -OPI_Tools.AddField("parse_mode" , "Markdown" , String_ , Parameters); -OPI_Tools.AddField("chat_id" , ChatID , String_ , Parameters); -OPI_Tools.AddField("message_id" , MessageID, String_ , Parameters); -OPI_Tools.AddField("disable_notification", False , "Boolean", Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Unpin message // Unpins a message in the chat header -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID - chat // MessageID - String, Number - Target message ID - message -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function UnpinMessage(Val Token, Val ChatID, Val MessageID) Export + + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/unpinChatMessage"; + + Parameters = New Structure; + OPI_Tools.AddField("parse_mode", "Markdown" , String_, Parameters); + OPI_Tools.AddField("chat_id" , ChatID , String_, Parameters); + OPI_Tools.AddField("message_id", MessageID, String_, Parameters); -String_ = "String"; -OPI_TypeConversion.GetLine(Token); + Response = OPI_Tools.Get(URL, Parameters); -URL = "api.telegram.org/bot" + Token + "/unpinChatMessage"; - -Parameters = New Structure; -OPI_Tools.AddField("parse_mode", "Markdown" , String_, Parameters); -OPI_Tools.AddField("chat_id" , ChatID , String_, Parameters); -OPI_Tools.AddField("message_id", MessageID, String_, Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction // Get participant count // Gets the total number of chat participants -// +// // Parameters: // Token - String - Bot token - token // ChatID - String, Number - Target chat ID - chat -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function GetParticipantCount(Val Token, Val ChatID) Export -OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/getChatMemberCount"; + + Parameters = New Structure; + OPI_Tools.AddField("parse_mode", "Markdown" , "String", Parameters); + OPI_Tools.AddField("chat_id" , ChatID , "String", Parameters); -URL = "api.telegram.org/bot" + Token + "/getChatMemberCount"; + Response = OPI_Tools.Get(URL, Parameters); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode", "Markdown" , "String", Parameters); -OPI_Tools.AddField("chat_id" , ChatID , "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + Return Response; EndFunction @@ -796,195 +796,195 @@ EndFunction // Get avatar icon list // Gets the mapping of Emoji IDs for setting as forum theme icons -// +// // Parameters: // Token - String - Token - token -// +// // Return value: // Key-Value Pair - Key > ID, Value > Emoji Function GetAvatarIconList(Val Token) Export - -OPI_TypeConversion.GetLine(Token); - -Result = "result"; -URL = "api.telegram.org/bot" + Token + "/getForumTopicIconStickers"; -Response = OPI_Tools.Get(URL); -Icons = Response[Result]; - -If Not ValueIsFilled(Icons) Then -Return Response; -EndIf; - -Collection = New Match; - -For Each Icon In Icons Do -Collection.Insert(Icon["custom_emoji_id"], Icon["emoji"]); -EndDo; - -Return Collection; + + OPI_TypeConversion.GetLine(Token); + + Result = "result"; + URL = "api.telegram.org/bot" + Token + "/getForumTopicIconStickers"; + Response = OPI_Tools.Get(URL); + Icons = Response[Result]; + + If Not ValueIsFilled(Icons) Then + Return Response; + EndIf; + + Collection = New Match; + + For Each Icon In Icons Do + Collection.Insert(Icon["custom_emoji_id"], Icon["emoji"]); + EndDo; + + Return Collection; EndFunction // Create forum thread // Creates a new thread in the group with theme functionality enabled -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread creation chat ID - forum // Title - String - Thread title - title // IconID - String - See GetAvatarIconList - icon -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function CreateForumThread(Val Token, Val ChatID, Val Title, Val IconID = "") Export -Return ForumTopicManagement(Token, ChatID, Title, IconID); + Return ForumTopicManagement(Token, ChatID, Title, IconID); EndFunction // Edit forum thread // Creates a new thread in the group with theme functionality enabled -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread creation chat ID - forum // ThreadID - String, Number - Thread ID - topic // Title - String - New title - title // IconID - String - See GetAvatarIconList - icon -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function EditForumTopic(Val Token -, Val ChatID -, Val ThreadID -, Val Title = Undefined -, Val IconID = Undefined) Export - -Return ForumTopicManagement(Token, ChatID, Title, IconID, ThreadID); + , Val ChatID + , Val ThreadID + , Val Title = Undefined + , Val IconID = Undefined) Export + + Return ForumTopicManagement(Token, ChatID, Title, IconID, ThreadID); EndFunction // Close forum thread // Closes the thread for new messages -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread chat ID - forum // ThreadID - String, Number - Thread ID - topic -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function CloseForumThread(Val Token, Val ChatID, Val ThreadID = "") Export -Return ManageForumThreadState(Token, ChatID, 2, ThreadID); + Return ManageForumThreadState(Token, ChatID, 2, ThreadID); EndFunction // Open forum thread // Reopens a previously closed forum thread -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread chat ID - forum // ThreadID - String, Number - Thread ID - topic -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function OpenForumThread(Val Token, Val ChatID, Val ThreadID = "") Export -Return ManageForumThreadState(Token, ChatID, 1, ThreadID); + Return ManageForumThreadState(Token, ChatID, 1, ThreadID); EndFunction // Delete forum thread // Deletes a forum thread -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread chat ID - forum // ThreadID - String, Number - Thread ID - topic -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function DeleteForumTopic(Val Token, Val ChatID, Val ThreadID) Export -Return ManageForumThreadState(Token, ChatID, 3, ThreadID); + Return ManageForumThreadState(Token, ChatID, 3, ThreadID); EndFunction // Hide main forum thread // Hides the main forum thread -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread chat ID - forum -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function HideMainForumTopic(Val Token, Val ChatID) Export -Return ManageMainTopicVisibility(Token, ChatID, True); + Return ManageMainTopicVisibility(Token, ChatID, True); EndFunction // Show main forum thread // Shows a previously hidden main forum thread -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread chat ID - forum -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function ShowMainForumTopic(Val Token, Val ChatID) Export -Return ManageMainTopicVisibility(Token, ChatID, False); + Return ManageMainTopicVisibility(Token, ChatID, False); EndFunction // Edit main forum thread name // Edits the name of the main forum thread -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread chat ID - forum // Title - String - New main thread name - title -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function EditMainForumTopicName(Val Token, Val ChatID, Val Title) Export - -OPI_TypeConversion.GetLine(Token); - -URL = "api.telegram.org/bot" + Token + "/editGeneralForumTopic"; - -Parameters = New Structure; -OPI_Tools.AddField("chat_id", ChatID , "String", Parameters); -OPI_Tools.AddField("name" , Title, "String", Parameters); - -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + + URL = "api.telegram.org/bot" + Token + "/editGeneralForumTopic"; + + Parameters = New Structure; + OPI_Tools.AddField("chat_id", ChatID , "String", Parameters); + OPI_Tools.AddField("name" , Title, "String", Parameters); + + Response = OPI_Tools.Get(URL, Parameters); + + Return Response; EndFunction // Clear thread's pinned messages list // Clears the list of pinned messages in the forum thread -// +// // Parameters: // Token - String - Token - token // ChatID - String, Number - Thread chat ID - forum // ThreadID - String, Number - Thread ID. Main if not filled - topic -// +// // Return value: // Key-Value Pair - Serialized JSON response from Telegram Function ClearThreadPinnedMessagesList(Val Token, Val ChatID, Val ThreadID = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ChatID); -OPI_TypeConversion.GetLine(ThreadID); - -Parameters = New Structure; -OPI_Tools.AddField("chat_id" , ChatID, "String", Parameters); -OPI_Tools.AddField("message_thread_id", ThreadID, "String", Parameters); - -If ValueIsFilled(ThreadID) Then -Method = "/unpinAllForumTopicMessages"; -Else -Method = "/unpinAllGeneralForumTopicMessages"; -EndIf; - -URL = "api.telegram.org/bot" + Token + Method; -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ChatID); + OPI_TypeConversion.GetLine(ThreadID); + + Parameters = New Structure; + OPI_Tools.AddField("chat_id" , ChatID, "String", Parameters); + OPI_Tools.AddField("message_thread_id", ThreadID, "String", Parameters); + + If ValueIsFilled(ThreadID) Then + Method = "/unpinAllForumTopicMessages"; + Else + Method = "/unpinAllGeneralForumTopicMessages"; + EndIf; + + URL = "api.telegram.org/bot" + Token + Method; + Response = OPI_Tools.Get(URL, Parameters); + + Return Response; EndFunction @@ -996,258 +996,258 @@ EndFunction Function SendFile(Val Token, Val ChatID, Val Text, Val File, Val View, Val Keyboard, Val Markup) -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(ChatID); -OPI_TypeConversion.GetLine(View); + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(ChatID); + OPI_TypeConversion.GetLine(View); -Extension = ""; -Method = ""; + Extension = ""; + Method = ""; + + DetermineSendMethod(View, Method, Extension); + ConvertFileData(File, Extension, View); + OPI_Tools.ReplaceSpecialCharacters(Text, Markup); + + Parameters = New Structure; + OPI_Tools.AddField("parse_mode" , Markup , "String" , Parameters); + OPI_Tools.AddField("caption" , Text , "String" , Parameters); + OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); + + AddChatIdentifier(ChatID, Parameters); -DetermineSendMethod(View, Method, Extension); -ConvertFileData(File, Extension, View); -OPI_Tools.ReplaceSpecialCharacters(Text, Markup); + FileStructure = New Structure; + FileStructure.Insert(View + Extension, File); -Parameters = New Structure; -OPI_Tools.AddField("parse_mode" , Markup , "String" , Parameters); -OPI_Tools.AddField("caption" , Text , "String" , Parameters); -OPI_Tools.AddField("reply_markup", Keyboard, "FileString", Parameters); + URL = "api.telegram.org/bot" + Token + Method; + Response = OPI_Tools.PostMultipart(URL, Parameters, FileStructure, "mixed"); -AddChatIdentifier(ChatID, Parameters); - -FileStructure = New Structure; -FileStructure.Insert(View + Extension, File); - -URL = "api.telegram.org/bot" + Token + Method; -Response = OPI_Tools.PostMultipart(URL, Parameters, FileStructure, "mixed"); - -Return Response; + Return Response; EndFunction Function ForumTopicManagement(Val Token -, Val ChatID -, Val Title = Undefined -, Val IconID = Undefined -, Val ThreadID = "") - -String_ = "String"; -OPI_TypeConversion.GetLine(Token); - -Parameters = New Structure; -OPI_Tools.AddField("name" , Title, String_, Parameters); -OPI_Tools.AddField("chat_id" , ChatID , String_, Parameters); -OPI_Tools.AddField("icon_custom_emoji_id", IconID , String_, Parameters); -OPI_Tools.AddField("message_thread_id" , ThreadID , String_, Parameters); - -If ValueIsFilled(ThreadID) Then -Method = "/editForumTopic"; -Else -Method = "/createForumTopic"; -EndIf; - -OPI_Tools.RemoveEmptyCollectionFields(Parameters); -Response = OPI_Tools.Get("api.telegram.org/bot" + Token + Method, Parameters); - -Return Response; + , Val ChatID + , Val Title = Undefined + , Val IconID = Undefined + , Val ThreadID = "") + + String_ = "String"; + OPI_TypeConversion.GetLine(Token); + + Parameters = New Structure; + OPI_Tools.AddField("name" , Title, String_, Parameters); + OPI_Tools.AddField("chat_id" , ChatID , String_, Parameters); + OPI_Tools.AddField("icon_custom_emoji_id", IconID , String_, Parameters); + OPI_Tools.AddField("message_thread_id" , ThreadID , String_, Parameters); + + If ValueIsFilled(ThreadID) Then + Method = "/editForumTopic"; + Else + Method = "/createForumTopic"; + EndIf; + + OPI_Tools.RemoveEmptyCollectionFields(Parameters); + Response = OPI_Tools.Get("api.telegram.org/bot" + Token + Method, Parameters); + + Return Response; EndFunction -Function ManageForumThreadState(Val Token, Val ChatID, Val Status, Val ThreadID = "") - -OPI_TypeConversion.GetLine(Token); - -If ValueIsFilled(ThreadID) Then -Forum = "Forum"; -Else -Forum = "GeneralForum"; -EndIf; - -Method = DetermineForumManagementMethod(Status, Forum); - -Parameters = New Structure; -OPI_Tools.AddField("chat_id" , ChatID, "String", Parameters); -OPI_Tools.AddField("message_thread_id", ThreadID, "String", Parameters); - -URL = "api.telegram.org/bot" + Token + Method; -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; +Function ManageForumThreadState(Val Token, Val ChatID, Val Status, Val ThreadID = "") + + OPI_TypeConversion.GetLine(Token); + + If ValueIsFilled(ThreadID) Then + Forum = "Forum"; + Else + Forum = "GeneralForum"; + EndIf; + + Method = DetermineForumManagementMethod(Status, Forum); + + Parameters = New Structure; + OPI_Tools.AddField("chat_id" , ChatID, "String", Parameters); + OPI_Tools.AddField("message_thread_id", ThreadID, "String", Parameters); + + URL = "api.telegram.org/bot" + Token + Method; + Response = OPI_Tools.Get(URL, Parameters); + Return Response; + EndFunction Function ManageMainTopicVisibility(Val Token, Val ChatID, Val Hide) + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetBoolean(Hide); -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetBoolean(Hide); + If Hide Then + Method = "/hideGeneralForumTopic"; + Else + Method = "/unhideGeneralForumTopic"; + EndIf; + + Parameters = New Structure; + OPI_Tools.AddField("chat_id", ChatID, "String", Parameters); + + URL = "api.telegram.org/bot" + Token + Method; + Response = OPI_Tools.Get(URL, Parameters); + + Return Response; -If Hide Then -Method = "/hideGeneralForumTopic"; -Else -Method = "/unhideGeneralForumTopic"; -EndIf; +EndFunction -Parameters = New Structure; -OPI_Tools.AddField("chat_id", ChatID, "String", Parameters); - -URL = "api.telegram.org/bot" + Token + Method; -Response = OPI_Tools.Get(URL, Parameters); - -Return Response; - -EndFunction - -Function DetermineForumManagementMethod(Val Status, Val Forum) - -Open = 1; -Close = 2; -Delete = 3; - -If Status = Open Then -Method = "/reopen" + Forum + "Topic"; -ElsIf Status = Close Then -Method = "/close" + Forum + "Topic"; -ElsIf Status = Delete Then -Method = "/deleteForumTopic"; -Else -Raise "Incorrect forum management status"; -EndIf; - -Return Method; +Function DetermineForumManagementMethod(Val Status, Val Forum) + + Open = 1; + Close = 2; + Delete = 3; + + If Status = Open Then + Method = "/reopen" + Forum + "Topic"; + ElsIf Status = Close Then + Method = "/close" + Forum + "Topic"; + ElsIf Status = Delete Then + Method = "/deleteForumTopic"; + Else + Raise "Incorrect forum management status"; + EndIf; + + Return Method; EndFunction Function CreateTallKeyboard(Val ButtonArray) + + Strings = New Array; + + For Each Button In ButtonArray Do + Buttons = New Array; + Button = OPI_Tools.NumberToString(Button); + Buttons.Add(New Structure("text,callback_data", Button, Button)); + Strings.Add(Buttons); + EndDo; -Strings = New Array; - -For Each Button In ButtonArray Do -Buttons = New Array; -Button = OPI_Tools.NumberToString(Button); -Buttons.Add(New Structure("text,callback_data", Button, Button)); -Strings.Add(Buttons); -EndDo; - -Return Strings; - + Return Strings; + EndFunction Function CreateLongKeyboard(Val ButtonArray) - -Strings = New Array; -Buttons = New Array; - -For Each Button In ButtonArray Do -Button = OPI_Tools.NumberToString(Button); -Buttons.Add(New Structure("text,callback_data", Button, Button)); -EndDo; - -Strings.Add(Buttons); - -Return Strings; + + Strings = New Array; + Buttons = New Array; + + For Each Button In ButtonArray Do + Button = OPI_Tools.NumberToString(Button); + Buttons.Add(New Structure("text,callback_data", Button, Button)); + EndDo; + + Strings.Add(Buttons); + + Return Strings; EndFunction Procedure FormMediaArray(Val FileMapping, Val Text, FileStructure, Media) + + Counter = 0; + + OPI_TypeConversion.GetCollection(FileMapping); + OPI_TypeConversion.GetLine(Text); + + If TypeValue(FileMapping) <> Type("Match") Then + // !OInt Raise("Failed to Retrieve Information from JSON media!"); + Return; + EndIf; + + For Each CurrentFile In FileMapping Do + + If Not TypeValue(CurrentFile.Key) = Type("BinaryData") Then + + Binary = CurrentFile.Key; + OPI_TypeConversion.GetBinaryData(Binary); + + ThisFile = New File(CurrentFile.Key); + MediaName = CurrentFile.Value + + String(Counter) + + ?(CurrentFile.Value = "document", ThisFile.Extension, ""); + + FullMediaName = StringReplace(MediaName, ".", "___"); + + Else + Binary = CurrentFile.Key; + MediaName = CurrentFile.Value + String(Counter); + FullMediaName = MediaName; + EndIf; + + FileStructure.Insert(FullMediaName, Binary); + + MediaStructure = New Structure; + MediaStructure.Insert("type" , CurrentFile.Value); + MediaStructure.Insert("media", "attach://" + MediaName); + + If Counter = 0 Then + MediaStructure.Insert("caption", Text); + EndIf; + + Media.Add(MediaStructure); + + Counter = Counter + 1; + + EndDo; -Counter = 0; - -OPI_TypeConversion.GetCollection(FileMapping); -OPI_TypeConversion.GetLine(Text); - -If TypeValue(FileMapping) <> Type("Match") Then -// !OInt Raise("Failed to Retrieve Information from JSON media!"); -Return; -EndIf; - -For Each CurrentFile In FileMapping Do - -If Not TypeValue(CurrentFile.Key) = Type("BinaryData") Then - -Binary = CurrentFile.Key; -OPI_TypeConversion.GetBinaryData(Binary); - -ThisFile = New File(CurrentFile.Key); -MediaName = CurrentFile.Value -+ String(Counter) -+ ?(CurrentFile.Value = "document", ThisFile.Extension, ""); - -FullMediaName = StringReplace(MediaName, ".", "___"); - -Else -Binary = CurrentFile.Key; -MediaName = CurrentFile.Value + String(Counter); -FullMediaName = MediaName; -EndIf; - -FileStructure.Insert(FullMediaName, Binary); - -MediaStructure = New Structure; -MediaStructure.Insert("type" , CurrentFile.Value); -MediaStructure.Insert("media", "attach://" + MediaName); - -If Counter = 0 Then -MediaStructure.Insert("caption", Text); -EndIf; - -Media.Add(MediaStructure); - -Counter = Counter + 1; - -EndDo; - -Media = OPI_Tools.JSONString(Media); - + Media = OPI_Tools.JSONString(Media); + EndProcedure Procedure AddChatIdentifier(Val ChatID, Parameters) - -ChatID = OPI_Tools.NumberToString(ChatID); -ChatArray = StrSplit(ChatID, "*", False); - -If ChatArray.Quantity() > 1 Then - -ChatID = ChatArray[0]; -ThreadID = ChatArray[1]; - -Parameters.Insert("message_thread_id", ThreadID); - -EndIf; - -Parameters.Insert("chat_id", ChatID); + + ChatID = OPI_Tools.NumberToString(ChatID); + ChatArray = StrSplit(ChatID, "*", False); + + If ChatArray.Quantity() > 1 Then + + ChatID = ChatArray[0]; + ThreadID = ChatArray[1]; + + Parameters.Insert("message_thread_id", ThreadID); + + EndIf; + + Parameters.Insert("chat_id", ChatID); EndProcedure Procedure DetermineSendMethod(Val View, Method, Extension) - -If View = "photo" Then -Method = "/sendPhoto"; -ElsIf View = "video" Then -Method = "/sendVideo"; -ElsIf View = "audio" Then -Method = "/sendAudio"; -ElsIf View = "document" Then -Method = "/sendDocument"; -ElsIf View = "animation" Then -Method = "/sendAnimation"; -Extension = ".gif"; -Else -Raise "Incorrect sending view"; -EndIf; + + If View = "photo" Then + Method = "/sendPhoto"; + ElsIf View = "video" Then + Method = "/sendVideo"; + ElsIf View = "audio" Then + Method = "/sendAudio"; + ElsIf View = "document" Then + Method = "/sendDocument"; + ElsIf View = "animation" Then + Method = "/sendAnimation"; + Extension = ".gif"; + Else + Raise "Incorrect sending view"; + EndIf; EndProcedure Procedure ConvertFileData(File, Extension, View) + + If Not TypeValue(File) = Type("BinaryData") Then + + CurrentFile = New File(File); + Extension = ?(View = "document", CurrentFile.Extension, Extension); + OPI_TypeConversion.GetBinaryData(File); + + EndIf; -If Not TypeValue(File) = Type("BinaryData") Then - -CurrentFile = New File(File); -Extension = ?(View = "document", CurrentFile.Extension, Extension); -OPI_TypeConversion.GetBinaryData(File); - -EndIf; - -Extension = StringReplace(Extension, ".", "___"); - + Extension = StringReplace(Extension, ".", "___"); + EndProcedure #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Telegram/OPI_Telegram.mdo b/src/en/OPI/src/CommonModules/OPI_Telegram/OPI_Telegram.mdo index 46dccc11b8..51643d7cc5 100644 --- a/src/en/OPI/src/CommonModules/OPI_Telegram/OPI_Telegram.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Telegram/OPI_Telegram.mdo @@ -1,11 +1,11 @@  -OPI_Telegram - -ru -Methodы интеграции with Telegram (OPI) - -true -true -true + OPI_Telegram + + ru + Methodы интеграции with Telegram (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Tests/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Tests/Module.bsl index ff1efd2cb9..3b8357b928 100644 --- a/src/en/OPI/src/CommonModules/OPI_Tests/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Tests/Module.bsl @@ -46,7 +46,7 @@ Procedure ExecutableScripts() Export -OPI_GetTestData.FormYAXTests(); + OPI_GetTestData.FormYAXTests(); EndProcedure @@ -54,7 +54,7 @@ EndProcedure Function GetTestList(UnitTesting) Export -Return OPI_GetTestData.FormAssertsTests(); + Return OPI_GetTestData.FormAssertsTests(); EndFunction @@ -63,268 +63,268 @@ EndFunction #Region Telegram Procedure Telegram_GetBotInfo() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); - -Telegram_GetBotInformation(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); + + Telegram_GetBotInformation(TestParameters); + EndProcedure Procedure Telegram_GetUpdates() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); - -Telegram_DeleteWebhook(TestParameters); -Telegram_GetUpdates(TestParameters); - + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); + + Telegram_DeleteWebhook(TestParameters); + Telegram_GetUpdates(TestParameters); + EndProcedure Procedure Telegram_SetWebhook() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_URL" , TestParameters); - -Telegram_SetWebhook(TestParameters); -Telegram_DeleteWebhook(TestParameters); + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_URL" , TestParameters); + Telegram_SetWebhook(TestParameters); + Telegram_DeleteWebhook(TestParameters); + EndProcedure Procedure Telegram_SendTextMessage() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); - -Telegram_SendTextMessage(TestParameters); - + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + + Telegram_SendTextMessage(TestParameters); + EndProcedure Procedure Telegram_SendImage() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); -OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); - -Telegram_SendPicture(TestParameters); -Telegram_DownloadFile(TestParameters); + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); + + Telegram_SendPicture(TestParameters); + Telegram_DownloadFile(TestParameters); EndProcedure Procedure Telegram_SendVideo() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); -OPI_GetTestData.ParameterToCollection("Video" , TestParameters); - -Telegram_SendVideo(TestParameters); -Telegram_DownloadFile(TestParameters); + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + OPI_GetTestData.ParameterToCollection("Video" , TestParameters); + + Telegram_SendVideo(TestParameters); + Telegram_DownloadFile(TestParameters); EndProcedure Procedure Telegram_SendAudio() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); -OPI_GetTestData.ParameterToCollection("Audio" , TestParameters); - -Telegram_SendAudio(TestParameters); -Telegram_DownloadFile(TestParameters); + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + OPI_GetTestData.ParameterToCollection("Audio" , TestParameters); + + Telegram_SendAudio(TestParameters); + Telegram_DownloadFile(TestParameters); EndProcedure Procedure Telegram_SendDocument() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); -OPI_GetTestData.ParameterToCollection("Document" , TestParameters); - -Telegram_SendDocument(TestParameters); + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + OPI_GetTestData.ParameterToCollection("Document" , TestParameters); + + Telegram_SendDocument(TestParameters); EndProcedure Procedure Telegram_SendGIF() Export -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); -OPI_GetTestData.ParameterToCollection("GIF" , TestParameters); - -Telegram_SendGif(TestParameters); + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + OPI_GetTestData.ParameterToCollection("GIF" , TestParameters); + + Telegram_SendGif(TestParameters); EndProcedure Procedure Telegram_SendMediaGroup() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); -OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); -OPI_GetTestData.ParameterToCollection("Video" , TestParameters); - -Telegram_SendMediaGroup(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); + OPI_GetTestData.ParameterToCollection("Video" , TestParameters); + + Telegram_SendMediaGroup(TestParameters); EndProcedure Procedure Telegram_SendLocation() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("Long" , TestParameters); -OPI_GetTestData.ParameterToCollection("Lat" , TestParameters); - -Telegram_SendLocation(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("Long" , TestParameters); + OPI_GetTestData.ParameterToCollection("Lat" , TestParameters); + + Telegram_SendLocation(TestParameters); EndProcedure Procedure Telegram_SendContact() Export + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + OPI_GetTestData.ParameterToCollection("Name" , TestParameters); + OPI_GetTestData.ParameterToCollection("Surname" , TestParameters); + OPI_GetTestData.ParameterToCollection("Phone" , TestParameters); -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); -OPI_GetTestData.ParameterToCollection("Name" , TestParameters); -OPI_GetTestData.ParameterToCollection("Surname" , TestParameters); -OPI_GetTestData.ParameterToCollection("Phone" , TestParameters); - -Telegram_SendContact(TestParameters); + Telegram_SendContact(TestParameters); EndProcedure Procedure Telegram_SendPoll() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); - -Telegram_SendPoll(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + + Telegram_SendPoll(TestParameters); EndProcedure Procedure Telegram_ForwardMessage() Export + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelMessageID", TestParameters); -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelMessageID", TestParameters); - -Telegram_ForwardMessage(TestParameters); - + Telegram_ForwardMessage(TestParameters); + EndProcedure Procedure Telegram_BanUnban() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID" , TestParameters); - -Telegram_Ban(TestParameters); -Telegram_Unban(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChatID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID" , TestParameters); + + Telegram_Ban(TestParameters); + Telegram_Unban(TestParameters); + EndProcedure Procedure Telegram_CreateInvitationLink() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); - -Telegram_CreateInviteLink(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + + Telegram_CreateInviteLink(TestParameters); EndProcedure Procedure Telegram_PinUnpinMessage() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelMessageID", TestParameters); - -Telegram_PinMessage(TestParameters); -Telegram_UnpinMessage(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelMessageID", TestParameters); + + Telegram_PinMessage(TestParameters); + Telegram_UnpinMessage(TestParameters); EndProcedure Procedure Telegram_GetMemberCount() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); - -Telegram_GetParticipantCount(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ChannelID", TestParameters); + + Telegram_GetParticipantCount(TestParameters); EndProcedure Procedure Telegram_GetForumAvatarsList() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); - -Telegram_GetForumAvatarList(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token", TestParameters); + + Telegram_GetForumAvatarList(TestParameters); + EndProcedure Procedure Telegram_CreateDeleteForumTopic() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ForumID", TestParameters); -OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); -OPI_GetTestData.ParameterToCollection("String" , TestParameters); - -Telegram_CreateForumTopic(TestParameters); -Telegram_EditForumTopic(TestParameters); -Telegram_CloseForumTopic(TestParameters); -Telegram_OpenForumTopic(TestParameters); -Telegram_ClearPinnedMessagesList(TestParameters); -Telegram_DeleteForumTopic(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ForumID", TestParameters); + OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); + OPI_GetTestData.ParameterToCollection("String" , TestParameters); + + Telegram_CreateForumTopic(TestParameters); + Telegram_EditForumTopic(TestParameters); + Telegram_CloseForumTopic(TestParameters); + Telegram_OpenForumTopic(TestParameters); + Telegram_ClearPinnedMessagesList(TestParameters); + Telegram_DeleteForumTopic(TestParameters); EndProcedure Procedure Telegram_HideShowMainTopic() Export + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ForumID", TestParameters); -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ForumID", TestParameters); - -Telegram_HideMainForumTopic(TestParameters); -Telegram_ShowMainForumTopic(TestParameters); + Telegram_HideMainForumTopic(TestParameters); + Telegram_ShowMainForumTopic(TestParameters); EndProcedure Procedure Telegram_ChangeMainTopicName() Export + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Telegram_ForumID", TestParameters); -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Telegram_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Telegram_ForumID", TestParameters); - -Telegram_ChangeMainTopicName(TestParameters); - + Telegram_ChangeMainTopicName(TestParameters); + EndProcedure #EndRegion @@ -332,654 +332,654 @@ EndProcedure #Region VK Procedure VK_CreateTokenLink() Export + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("VK_AppID", TestParameters); -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("VK_AppID", TestParameters); - -VK_CreateTokenRetrievalLink(TestParameters); - + VK_CreateTokenRetrievalLink(TestParameters); + EndProcedure Procedure VK_CreateDeletePost() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); -OPI_GetTestData.ParameterToCollection("Picture2", TestParameters); - -VK_CreatePost(TestParameters); -VK_DeletePost(TestParameters); + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); + OPI_GetTestData.ParameterToCollection("Picture2", TestParameters); + + VK_CreatePost(TestParameters); + VK_DeletePost(TestParameters); EndProcedure Procedure VK_CreateCompositePost() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); -OPI_GetTestData.ParameterToCollection("Video" , TestParameters); - -VK_CreateCompositePost(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); + OPI_GetTestData.ParameterToCollection("Video" , TestParameters); + + VK_CreateCompositePost(TestParameters); + EndProcedure Procedure VK_CreatePoll() Export - -VK_CreatePoll(); - + + VK_CreatePoll(); + EndProcedure Procedure VK_SaveDeleteImage() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); - -VK_CreateAlbum(TestParameters); -VK_SavePictureToAlbum(TestParameters); -VK_DeleteImage(TestParameters); -VK_DeleteAlbum(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); + + VK_CreateAlbum(TestParameters); + VK_SavePictureToAlbum(TestParameters); + VK_DeleteImage(TestParameters); + VK_DeleteAlbum(TestParameters); + EndProcedure Procedure VK_CreateStory() Export - -TestParameters = New Match; -OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); - -VK_CreateStory(TestParameters); - + + TestParameters = New Match; + OPI_GetTestData.ParameterToCollection("Picture" , TestParameters); + + VK_CreateStory(TestParameters); + EndProcedure Procedure VK_DiscussionMethods() Export - -TestParameters = New Structure; -Parameters = GetVKParameters(); - -VK_CreateDiscussion(TestParameters); -VK_CloseDiscussion(TestParameters); -VK_OpenDiscussion(TestParameters); -VK_PostToDiscussion(TestParameters); - -OPI_VK.CloseDiscussion(TestParameters["VK_ConvID"], True, Parameters); - -OPI_Tools.Pause(5); - + + TestParameters = New Structure; + Parameters = GetVKParameters(); + + VK_CreateDiscussion(TestParameters); + VK_CloseDiscussion(TestParameters); + VK_OpenDiscussion(TestParameters); + VK_PostToDiscussion(TestParameters); + + OPI_VK.CloseDiscussion(TestParameters["VK_ConvID"], True, Parameters); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_LikeRepostComment() Export - -Parameters = GetVKParameters(); -Text = "Post from autotest"; -Message = "Message from autotest"; -TypeMatch = Type("Match"); -TypeNumber = Type("Number"); -Response = "response"; - -Result = OPI_VK.CreatePost(Text, New Array, , , Parameters); - -PostID = Result[Response]["post_id"]; -Result = OPI_VK.LikePost(PostID, , Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "LikePost"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); -OPI_GetTestData.ExpectsThat(Result[Response]["likes"]).HasType(TypeNumber).Filled(); - -ExternalPost = 2571; -ExternalWall = -218704372; - -Result = OPI_VK.MakeRepost(ExternalPost, ExternalWall, , , Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "MakeRepost"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); -OPI_GetTestData.ExpectsThat(Result[Response]["success"]).HasType(TypeNumber).Equal(1); -OPI_GetTestData.ExpectsThat(Result[Response]["wall_repost_count"]).HasType(TypeNumber).Equal(1); - -Result = OPI_VK.WriteComment(PostID, Parameters["owner_id"], Message, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "WriteComment"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); -OPI_GetTestData.ExpectsThat(Result[Response]["comment_id"]).HasType(TypeNumber).Filled(); - -OPI_VK.DeletePost(PostID, Parameters); -OPI_VK.DeletePost(Result[Response]["post_id"], Parameters); - -OPI_Tools.Pause(5); + + Parameters = GetVKParameters(); + Text = "Post from autotest"; + Message = "Message from autotest"; + TypeMatch = Type("Match"); + TypeNumber = Type("Number"); + Response = "response"; + + Result = OPI_VK.CreatePost(Text, New Array, , , Parameters); + + PostID = Result[Response]["post_id"]; + Result = OPI_VK.LikePost(PostID, , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "LikePost"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); + OPI_GetTestData.ExpectsThat(Result[Response]["likes"]).HasType(TypeNumber).Filled(); + + ExternalPost = 2571; + ExternalWall = -218704372; + + Result = OPI_VK.MakeRepost(ExternalPost, ExternalWall, , , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "MakeRepost"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); + OPI_GetTestData.ExpectsThat(Result[Response]["success"]).HasType(TypeNumber).Equal(1); + OPI_GetTestData.ExpectsThat(Result[Response]["wall_repost_count"]).HasType(TypeNumber).Equal(1); + + Result = OPI_VK.WriteComment(PostID, Parameters["owner_id"], Message, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "WriteComment"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); + OPI_GetTestData.ExpectsThat(Result[Response]["comment_id"]).HasType(TypeNumber).Filled(); + + OPI_VK.DeletePost(PostID, Parameters); + OPI_VK.DeletePost(Result[Response]["post_id"], Parameters); + + OPI_Tools.Pause(5); EndProcedure Procedure VK_GetStatistics() Export - -CurrentDate = OPI_Tools.GetCurrentDate(); -Parameters = GetVKParameters(); -Date0 = StartOfDay(CurrentDate); -Date1 = EndOfDay(Date0); -TypeMatch = Type("Match"); - -Result = OPI_VK.GetStatistics(Date0, Date1, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetStatistics"); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); -OPI_GetTestData.ExpectsThat(Result["response"][0]["visitors"]).HasType(TypeMatch).Filled(); -OPI_GetTestData.ExpectsThat(Result["response"][0]["reach"]).HasType(TypeMatch).Filled(); - -OPI_Tools.Pause(5); + + CurrentDate = OPI_Tools.GetCurrentDate(); + Parameters = GetVKParameters(); + Date0 = StartOfDay(CurrentDate); + Date1 = EndOfDay(Date0); + TypeMatch = Type("Match"); + + Result = OPI_VK.GetStatistics(Date0, Date1, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetStatistics"); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch).Filled(); + OPI_GetTestData.ExpectsThat(Result["response"][0]["visitors"]).HasType(TypeMatch).Filled(); + OPI_GetTestData.ExpectsThat(Result["response"][0]["reach"]).HasType(TypeMatch).Filled(); + + OPI_Tools.Pause(5); EndProcedure Procedure VK_GetPostStatistics() Export + + Parameters = GetVKParameters(); + + ArrayOfPosts = New Array; + ArrayOfPosts.Add(214); + ArrayOfPosts.Add(215); + + Result = OPI_VK.GetPostStatistics(ArrayOfPosts, Parameters); -Parameters = GetVKParameters(); - -ArrayOfPosts = New Array; -ArrayOfPosts.Add(214); -ArrayOfPosts.Add(215); - -Result = OPI_VK.GetPostStatistics(ArrayOfPosts, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetPostStatistics"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Array").HasLength(2); - -OPI_Tools.Pause(5); + // !OInt OPI_GetTestData.WriteLog(Result, "GetPostStatistics"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Array").HasLength(2); + + OPI_Tools.Pause(5); EndProcedure Procedure VK_CreateAdCampaign() Export - -Parameters = GetVKParameters(); -CabinetID = OPI_GetTestData.GetParameter("VK_AdsCabinetID"); -Name = "TestCampaign"; -TypeMatch = Type("Match"); -TypeNumber = Type("Number"); -Response = "response"; -UID = "id"; - -Result = OPI_VK.CreateAdvertisingCampaign(CabinetID, Name, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateAdvertisingCampaign"); - -Result = Result[Response][0]; - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result["error_code"]).HasType(TypeNumber).Equal(602); -OPI_GetTestData.ExpectsThat(Result[UID]).HasType(TypeNumber).Filled(); - -CampaignID = Result[UID]; -CategoryID = 126; -Limit = 150; - -Result = OPI_VK.CreatePost(Name, New Array, , , Parameters); -PostID = Result[Response]["post_id"]; - -Result = OPI_VK.CreateAd(CampaignID -, Limit -, CategoryID -, PostID -, CabinetID -, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateAd"); - -Result = Result[Response][0]; - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result["error_code"]).HasType(TypeNumber).Equal(602); -OPI_GetTestData.ExpectsThat(Result[UID]).HasType(TypeNumber).Filled(); - -AnnouncementID = Result[UID]; -Result = OPI_VK.PauseAdvertisingAd(CabinetID, AnnouncementID, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "PauseAdvertisingAd"); - -Result = Result[Response][0]; - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[UID]).HasType(TypeNumber).Filled(); - -OPI_VK.DeletePost(PostID, Parameters); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + CabinetID = OPI_GetTestData.GetParameter("VK_AdsCabinetID"); + Name = "TestCampaign"; + TypeMatch = Type("Match"); + TypeNumber = Type("Number"); + Response = "response"; + UID = "id"; + + Result = OPI_VK.CreateAdvertisingCampaign(CabinetID, Name, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateAdvertisingCampaign"); + + Result = Result[Response][0]; + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result["error_code"]).HasType(TypeNumber).Equal(602); + OPI_GetTestData.ExpectsThat(Result[UID]).HasType(TypeNumber).Filled(); + + CampaignID = Result[UID]; + CategoryID = 126; + Limit = 150; + + Result = OPI_VK.CreatePost(Name, New Array, , , Parameters); + PostID = Result[Response]["post_id"]; + + Result = OPI_VK.CreateAd(CampaignID + , Limit + , CategoryID + , PostID + , CabinetID + , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateAd"); + + Result = Result[Response][0]; + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result["error_code"]).HasType(TypeNumber).Equal(602); + OPI_GetTestData.ExpectsThat(Result[UID]).HasType(TypeNumber).Filled(); + + AnnouncementID = Result[UID]; + Result = OPI_VK.PauseAdvertisingAd(CabinetID, AnnouncementID, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "PauseAdvertisingAd"); + + Result = Result[Response][0]; + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[UID]).HasType(TypeNumber).Filled(); + + OPI_VK.DeletePost(PostID, Parameters); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_SendMessage() Export - -Parameters = GetVKParameters(); -User = OPI_GetTestData.GetParameter("VK_UserID"); -Token = OPI_GetTestData.GetParameter("VK_CommunityToken"); -Text = "Message from autotest"; - -ButtonArray = New Array; -ButtonArray.Add("Button 1"); -ButtonArray.Add("Button 2"); - -Keyboard = OPI_VK.FormKeyboard(ButtonArray); -Result = OPI_VK.WriteMessage(Text, User, Token, Keyboard, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "WriteMessage"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match"); -OPI_GetTestData.ExpectsThat(Result["response"]).HasType("Number").Filled(); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + User = OPI_GetTestData.GetParameter("VK_UserID"); + Token = OPI_GetTestData.GetParameter("VK_CommunityToken"); + Text = "Message from autotest"; + + ButtonArray = New Array; + ButtonArray.Add("Button 1"); + ButtonArray.Add("Button 2"); + + Keyboard = OPI_VK.FormKeyboard(ButtonArray); + Result = OPI_VK.WriteMessage(Text, User, Token, Keyboard, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "WriteMessage"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match"); + OPI_GetTestData.ExpectsThat(Result["response"]).HasType("Number").Filled(); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_GetProductCategories() Export - -Parameters = GetVKParameters(); -Result = OPI_VK.GetProductCategoryList(Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetProductCategoryList"); - -OPI_GetTestData.ExpectsThat(Result) -.HasType("Match") -.Filled(); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + Result = OPI_VK.GetProductCategoryList(Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetProductCategoryList"); + + OPI_GetTestData.ExpectsThat(Result) + .HasType("Match") + .Filled(); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_CreateProductSelection() Export + + Parameters = GetVKParameters(); + TypeMatch = Type("Match"); + TypeNumber = Type("Number"); + Response = "response"; + Image = OPI_GetTestData.GetBinary("Picture"); + AndVF = GetTempFileName("png"); + Image.Write(AndVF); + + Result = OPI_VK.CreateProductCollection("TestCollection" + , Image + , True + , False + , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateProductCollection"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]["albums_count"]).HasType(TypeNumber).Filled(); + OPI_GetTestData.ExpectsThat(Result[Response]["market_album_id"]).HasType(TypeNumber).Filled(); + + SelectionID = Result[Response]["market_album_id"]; + + Result = OPI_VK.EditProductCollection("EditedCollection", SelectionID, , , , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditProductCollection"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]).HasType(TypeNumber).Equal(1); + + ImageArray = New Array; + ImageArray.Add(OPI_GetTestData.GetBinary("Picture")); + ImageArray.Add(OPI_GetTestData.GetBinary("Picture2")); + + Product = New Match(); + Product.Insert("Name" , "TestProduct"); + Product.Insert("Description" , "Product description"); + Product.Insert("Category" , "20173"); + Product.Insert("Price" , 1); + Product.Insert("OldPrice" , 15); + Product.Insert("MainPhoto" , Image); + Product.Insert("URL" , "https://github.com/Bayselonarrend/OpenIntegrations"); + Product.Insert("AdditionalPhotos" , ImageArray); + Product.Insert("MainInGroup" , True); + Product.Insert("Width" , 20); + Product.Insert("Height" , 30); + Product.Insert("Depth" , 40); + Product.Insert("Weight" , 100); + Product.Insert("SKU" , "12345"); + Product.Insert("AvailableBalance" , "10"); + + Result = OPI_VK.AddProduct(Product, SelectionID, Parameters); // Adding product + + // !OInt OPI_GetTestData.WriteLog(Result, "AddProduct"); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]["market_item_id"]).HasType(TypeNumber).Filled(); + + ProductID = Result[Response]["market_item_id"]; + + Product = New Match; + Product.Insert("Name", "EditedTestProduct"); + + Result = OPI_VK.EditProduct(ProductID, Product, , Parameters); // Change product + + // !OInt OPI_GetTestData.WriteLog(Result, "EditProduct"); + + Check_VKTrue(Result); + + Result = OPI_VK.AddProductToSelection(ProductID, SelectionID, Parameters); // Adding in selection + + // !OInt OPI_GetTestData.WriteLog(Result, "AddProductToSelection"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]).HasType(TypeNumber).Filled(); + + Result = OPI_VK.RemoveProductFromSelection(ProductID, SelectionID, Parameters); // Deletes from selections + + // !OInt OPI_GetTestData.WriteLog(Result, "RemoveProductFromSelection"); + + OPI_Tools.Pause(5); + Check_VKTrue(Result); + + Result = OPI_VK.DeleteProduct(ProductID, Parameters); // Deletion product + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteProduct"); + + OPI_Tools.Pause(5); + Check_VKTrue(Result); + + Result = OPI_VK.DeleteSelection(SelectionID, Parameters); // Removal selections + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteSelection"); + + OPI_Tools.Pause(5); + Check_VKTrue(Result); -Parameters = GetVKParameters(); -TypeMatch = Type("Match"); -TypeNumber = Type("Number"); -Response = "response"; -Image = OPI_GetTestData.GetBinary("Picture"); -AndVF = GetTempFileName("png"); -Image.Write(AndVF); - -Result = OPI_VK.CreateProductCollection("TestCollection" -, Image -, True -, False -, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateProductCollection"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]["albums_count"]).HasType(TypeNumber).Filled(); -OPI_GetTestData.ExpectsThat(Result[Response]["market_album_id"]).HasType(TypeNumber).Filled(); - -SelectionID = Result[Response]["market_album_id"]; - -Result = OPI_VK.EditProductCollection("EditedCollection", SelectionID, , , , Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditProductCollection"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]).HasType(TypeNumber).Equal(1); - -ImageArray = New Array; -ImageArray.Add(OPI_GetTestData.GetBinary("Picture")); -ImageArray.Add(OPI_GetTestData.GetBinary("Picture2")); - -Product = New Match(); -Product.Insert("Name" , "TestProduct"); -Product.Insert("Description" , "Product description"); -Product.Insert("Category" , "20173"); -Product.Insert("Price" , 1); -Product.Insert("OldPrice" , 15); -Product.Insert("MainPhoto" , Image); -Product.Insert("URL" , "https://github.com/Bayselonarrend/OpenIntegrations"); -Product.Insert("AdditionalPhotos" , ImageArray); -Product.Insert("MainInGroup" , True); -Product.Insert("Width" , 20); -Product.Insert("Height" , 30); -Product.Insert("Depth" , 40); -Product.Insert("Weight" , 100); -Product.Insert("SKU" , "12345"); -Product.Insert("AvailableBalance" , "10"); - -Result = OPI_VK.AddProduct(Product, SelectionID, Parameters); // Adding product - -// !OInt OPI_GetTestData.WriteLog(Result, "AddProduct"); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]["market_item_id"]).HasType(TypeNumber).Filled(); - -ProductID = Result[Response]["market_item_id"]; - -Product = New Match; -Product.Insert("Name", "EditedTestProduct"); - -Result = OPI_VK.EditProduct(ProductID, Product, , Parameters); // Change product - -// !OInt OPI_GetTestData.WriteLog(Result, "EditProduct"); - -Check_VKTrue(Result); - -Result = OPI_VK.AddProductToSelection(ProductID, SelectionID, Parameters); // Adding in selection - -// !OInt OPI_GetTestData.WriteLog(Result, "AddProductToSelection"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]).HasType(TypeNumber).Filled(); - -Result = OPI_VK.RemoveProductFromSelection(ProductID, SelectionID, Parameters); // Deletes from selections - -// !OInt OPI_GetTestData.WriteLog(Result, "RemoveProductFromSelection"); - -OPI_Tools.Pause(5); -Check_VKTrue(Result); - -Result = OPI_VK.DeleteProduct(ProductID, Parameters); // Deletion product - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteProduct"); - -OPI_Tools.Pause(5); -Check_VKTrue(Result); - -Result = OPI_VK.DeleteSelection(SelectionID, Parameters); // Removal selections - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteSelection"); - -OPI_Tools.Pause(5); -Check_VKTrue(Result); - -DeleteFiles(AndVF); - -OPI_Tools.Pause(5); - + DeleteFiles(AndVF); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_CreateProductWithProperties() Export + + Parameters = GetVKParameters(); + TypeMatch = Type("Match"); + TypeNumber = Type("Number"); + MII = "market_item_id"; + Response = "response"; + Yellow = "Yellow"; + Red = "Red"; + Image = OPI_GetTestData.GetBinary("Picture"); + AndVF = GetTempFileName("png"); + Image.Write(AndVF); + + OptionArray = New Array; + OptionArray.Add(Yellow); + OptionArray.Add("Blue"); + OptionArray.Add(Red); + + Result = OPI_VK.CreateProductProperty("Color", Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateProductProperty"); + + OPI_Tools.Pause(5); + + Property = Result[Response]["property_id"]; + Property = OPI_Tools.NumberToString(Property); + + PropertyMatch = New Match; + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]["property_id"]).HasType(TypeNumber).Filled(); + + Result = OPI_VK.EditProductProperty("Color (fromм.)", Property, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditProductProperty"); + + OPI_Tools.Pause(5); + + Check_VKTrue(Result); + + For Each Option In OptionArray Do + + Result = OPI_VK.AddProductPropertyVariant(Option, Property, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "AddProductPropertyVariant"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]["variant_id"]).HasType(TypeNumber).Filled(); + + VariantID = Result[Response]["variant_id"]; + PropertyMatch.Insert(Option, VariantID); + + Result = OPI_VK.EditProductPropertyVariant(Option + String(New UniqueIdentifier()) + , Property + , VariantID + , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditProductPropertyVariant"); + + Check_VKTrue(Result); + + EndDo; + + ImageArray = New Array; + ImageArray.Add(AndVF); + ImageArray.Add(Image); + + Product = New Match(); + Product.Insert("Name" , "TestProduct (" + Yellow + ")"); + Product.Insert("Description" , "Product description"); + Product.Insert("Category" , "20173"); + Product.Insert("Price" , 1); + Product.Insert("OldPrice" , 15); + Product.Insert("MainPhoto" , Image); + Product.Insert("URL" , "https://github.com/Bayselonarrend/OpenIntegrations"); + Product.Insert("AdditionalPhotos" , ImageArray); + Product.Insert("MainInGroup" , True); + Product.Insert("GroupNumber" , Undefined); + Product.Insert("Width" , 20); + Product.Insert("Height" , 30); + Product.Insert("Depth" , 40); + Product.Insert("Weight" , 100); + Product.Insert("SKU" , 12345); + Product.Insert("AvailableBalance" , "10"); + Product.Insert("PropertyValues" , PropertyMatch[Yellow]); + + Result = OPI_VK.AddProduct(Product, , Parameters); // Adding product + + // !OInt OPI_GetTestData.WriteLog(Result, "AddProduct"); + + OPI_Tools.Pause(5); + + YellowID = Result[Response]["market_item_id"]; + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response][MII]).HasType(TypeNumber).Filled(); + + Product.Insert("Name" , "TestProduct (" + Red + ")"); + Product.Insert("PropertyValues", PropertyMatch[Red]); -Parameters = GetVKParameters(); -TypeMatch = Type("Match"); -TypeNumber = Type("Number"); -MII = "market_item_id"; -Response = "response"; -Yellow = "Yellow"; -Red = "Red"; -Image = OPI_GetTestData.GetBinary("Picture"); -AndVF = GetTempFileName("png"); -Image.Write(AndVF); - -OptionArray = New Array; -OptionArray.Add(Yellow); -OptionArray.Add("Blue"); -OptionArray.Add(Red); - -Result = OPI_VK.CreateProductProperty("Color", Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateProductProperty"); - -OPI_Tools.Pause(5); - -Property = Result[Response]["property_id"]; -Property = OPI_Tools.NumberToString(Property); - -PropertyMatch = New Match; - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]["property_id"]).HasType(TypeNumber).Filled(); - -Result = OPI_VK.EditProductProperty("Color (fromм.)", Property, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditProductProperty"); - -OPI_Tools.Pause(5); - -Check_VKTrue(Result); - -For Each Option In OptionArray Do - -Result = OPI_VK.AddProductPropertyVariant(Option, Property, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "AddProductPropertyVariant"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]["variant_id"]).HasType(TypeNumber).Filled(); - -VariantID = Result[Response]["variant_id"]; -PropertyMatch.Insert(Option, VariantID); - -Result = OPI_VK.EditProductPropertyVariant(Option + String(New UniqueIdentifier()) -, Property -, VariantID -, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditProductPropertyVariant"); - -Check_VKTrue(Result); - -EndDo; - -ImageArray = New Array; -ImageArray.Add(AndVF); -ImageArray.Add(Image); - -Product = New Match(); -Product.Insert("Name" , "TestProduct (" + Yellow + ")"); -Product.Insert("Description" , "Product description"); -Product.Insert("Category" , "20173"); -Product.Insert("Price" , 1); -Product.Insert("OldPrice" , 15); -Product.Insert("MainPhoto" , Image); -Product.Insert("URL" , "https://github.com/Bayselonarrend/OpenIntegrations"); -Product.Insert("AdditionalPhotos" , ImageArray); -Product.Insert("MainInGroup" , True); -Product.Insert("GroupNumber" , Undefined); -Product.Insert("Width" , 20); -Product.Insert("Height" , 30); -Product.Insert("Depth" , 40); -Product.Insert("Weight" , 100); -Product.Insert("SKU" , 12345); -Product.Insert("AvailableBalance" , "10"); -Product.Insert("PropertyValues" , PropertyMatch[Yellow]); - -Result = OPI_VK.AddProduct(Product, , Parameters); // Adding product - -// !OInt OPI_GetTestData.WriteLog(Result, "AddProduct"); - -OPI_Tools.Pause(5); - -YellowID = Result[Response]["market_item_id"]; - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response][MII]).HasType(TypeNumber).Filled(); - -Product.Insert("Name" , "TestProduct (" + Red + ")"); -Product.Insert("PropertyValues", PropertyMatch[Red]); - -Result = OPI_VK.AddProduct(Product, , Parameters); // Adding product - -// !OInt OPI_GetTestData.WriteLog(Result, "AddProduct"); - -OPI_Tools.Pause(5); - -RedID = Result[Response][MII]; - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response][MII]).HasType(TypeNumber).Filled(); - -Array of products = New Array; -Array of products.Add(YellowID); -Array of products.Add(RedID); - -Result = OPI_VK.GetProductsByID(Array of products, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetProductsByID"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]["items"]).HasType("Array").HasLength(2); - -Result = OPI_VK.GroupProducts(Array of products, , Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GroupProducts"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Response]["item_group_id"]).HasType(TypeNumber).Filled(); - -OPI_VK.DeleteProduct(YellowID , Parameters); -OPI_VK.DeleteProduct(RedID, Parameters); - -For Each Option In PropertyMatch Do - -Deletion = OPI_VK.DeleteProductPropertyVariant(Option.Value, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteProductPropertyVariant"); - -OPI_Tools.Pause(5); -Check_VKTrue(Deletion); - -EndDo; - -Deletion = OPI_VK.DeleteProductProperty(Property, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteProductProperty"); - -OPI_Tools.Pause(5); - -Check_VKTrue(Deletion); - -DeleteFiles(AndVF); + Result = OPI_VK.AddProduct(Product, , Parameters); // Adding product + + // !OInt OPI_GetTestData.WriteLog(Result, "AddProduct"); + + OPI_Tools.Pause(5); + + RedID = Result[Response][MII]; + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response][MII]).HasType(TypeNumber).Filled(); + + Array of products = New Array; + Array of products.Add(YellowID); + Array of products.Add(RedID); + + Result = OPI_VK.GetProductsByID(Array of products, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetProductsByID"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]["items"]).HasType("Array").HasLength(2); + + Result = OPI_VK.GroupProducts(Array of products, , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GroupProducts"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Response]["item_group_id"]).HasType(TypeNumber).Filled(); + + OPI_VK.DeleteProduct(YellowID , Parameters); + OPI_VK.DeleteProduct(RedID, Parameters); + + For Each Option In PropertyMatch Do + + Deletion = OPI_VK.DeleteProductPropertyVariant(Option.Value, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteProductPropertyVariant"); + + OPI_Tools.Pause(5); + Check_VKTrue(Deletion); + + EndDo; + + Deletion = OPI_VK.DeleteProductProperty(Property, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteProductProperty"); + + OPI_Tools.Pause(5); + + Check_VKTrue(Deletion); + DeleteFiles(AndVF); + EndProcedure Procedure VK_GetProductList() Export - -Parameters = GetVKParameters(); -Image = OPI_GetTestData.GetBinary("Picture"); - -ImageArray = New Array; -ImageArray.Add(Image); - -Product = New Match(); -Product.Insert("Name" , "TestProduct2"); -Product.Insert("Description" , "Product description"); -Product.Insert("Category" , "20173"); -Product.Insert("Price" , 1); -Product.Insert("OldPrice" , 15); -Product.Insert("MainPhoto" , Image); -Product.Insert("URL" , "https://github.com/Bayselonarrend/OpenIntegrations"); -Product.Insert("AdditionalPhotos" , ImageArray); -Product.Insert("MainInGroup" , True); -Product.Insert("GroupNumber" , Undefined); -Product.Insert("Width" , 20); -Product.Insert("Height" , 30); -Product.Insert("Depth" , 40); -Product.Insert("Weight" , 100); -Product.Insert("SKU" , 12345); -Product.Insert("AvailableBalance" , "10"); - -Result = OPI_VK.AddProduct(Product, , Parameters); -ProductID = Result["response"]["market_item_id"]; -OPI_Tools.Pause(5); - -Result = OPI_VK.GetProductList(, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetProductList"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result) -.HasType("Array").Filled(); - -OPI_VK.DeleteProduct(ProductID, Parameters); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + Image = OPI_GetTestData.GetBinary("Picture"); + + ImageArray = New Array; + ImageArray.Add(Image); + + Product = New Match(); + Product.Insert("Name" , "TestProduct2"); + Product.Insert("Description" , "Product description"); + Product.Insert("Category" , "20173"); + Product.Insert("Price" , 1); + Product.Insert("OldPrice" , 15); + Product.Insert("MainPhoto" , Image); + Product.Insert("URL" , "https://github.com/Bayselonarrend/OpenIntegrations"); + Product.Insert("AdditionalPhotos" , ImageArray); + Product.Insert("MainInGroup" , True); + Product.Insert("GroupNumber" , Undefined); + Product.Insert("Width" , 20); + Product.Insert("Height" , 30); + Product.Insert("Depth" , 40); + Product.Insert("Weight" , 100); + Product.Insert("SKU" , 12345); + Product.Insert("AvailableBalance" , "10"); + + Result = OPI_VK.AddProduct(Product, , Parameters); + ProductID = Result["response"]["market_item_id"]; + OPI_Tools.Pause(5); + + Result = OPI_VK.GetProductList(, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetProductList"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result) + .HasType("Array").Filled(); + + OPI_VK.DeleteProduct(ProductID, Parameters); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_GetSelectionList() Export - -Parameters = GetVKParameters(); -Image = OPI_GetTestData.GetBinary("Picture"); -Result = OPI_VK.CreateProductCollection("TestCollection" -, Image -, True -, False -, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateProductCollection"); - -SelectionID = Result["response"]["market_album_id"]; -Result = OPI_VK.GetSelectionList(Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetSelectionList"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result) -.HasType("Array").Filled(); - -OPI_VK.DeleteSelection(SelectionID, Parameters); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + Image = OPI_GetTestData.GetBinary("Picture"); + Result = OPI_VK.CreateProductCollection("TestCollection" + , Image + , True + , False + , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateProductCollection"); + + SelectionID = Result["response"]["market_album_id"]; + Result = OPI_VK.GetSelectionList(Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetSelectionList"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result) + .HasType("Array").Filled(); + + OPI_VK.DeleteSelection(SelectionID, Parameters); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_GetPropertyList() Export - -Parameters = GetVKParameters(); -Result = OPI_VK.GetPropertyList(Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetPropertyList"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result) -.HasType("Array").Filled(); - -OPI_Tools.Pause(5); + + Parameters = GetVKParameters(); + Result = OPI_VK.GetPropertyList(Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetPropertyList"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result) + .HasType("Array").Filled(); + + OPI_Tools.Pause(5); EndProcedure Procedure VK_GetOrderList() Export - -Parameters = GetVKParameters(); -Result = OPI_VK.GetOrderList(Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetOrderList"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result) -.HasType("Array").Filled(); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + Result = OPI_VK.GetOrderList(Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetOrderList"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result) + .HasType("Array").Filled(); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_UploadVideo() Export - -Parameters = GetVKParameters(); -Video = OPI_GetTestData.GetParameter("Video"); -Name = "NewVideo"; -Description = "Video description"; - -Result = OPI_VK.UploadVideoToServer(Video, Name, Description, , Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetOrderList"); - -OPI_GetTestData.ExpectsThat(Result["video_id"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["video_hash"]).Filled(); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + Video = OPI_GetTestData.GetParameter("Video"); + Name = "NewVideo"; + Description = "Video description"; + + Result = OPI_VK.UploadVideoToServer(Video, Name, Description, , Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetOrderList"); + + OPI_GetTestData.ExpectsThat(Result["video_id"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["video_hash"]).Filled(); + + OPI_Tools.Pause(5); + EndProcedure #EndRegion @@ -987,282 +987,282 @@ EndProcedure #Region YandexDisk Procedure YDisk_GetDiskInfo() Export - -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Match = "Match"; - -Result = OPI_YandexDisk.GetDiskInformation(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetDiskInformation"); - -OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); -OPI_GetTestData.ExpectsThat(Result["system_folders"]).HasType(Match); -OPI_GetTestData.ExpectsThat(Result["user"]).HasType(Match); - -OPI_Tools.Pause(5); - + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Match = "Match"; + + Result = OPI_YandexDisk.GetDiskInformation(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetDiskInformation"); + + OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); + OPI_GetTestData.ExpectsThat(Result["system_folders"]).HasType(Match); + OPI_GetTestData.ExpectsThat(Result["user"]).HasType(Match); + + OPI_Tools.Pause(5); + EndProcedure Procedure YDisk_CreateFolder() Export - -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Path = "/" + String(New UniqueIdentifier); - -Result = OPI_YandexDisk.CreateFolder(Token, Path); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateFolder"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["type"]).Equal("dir"); -OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + Path); - -OPI_YandexDisk.DeleteObject(Token, Path, False); - -OPI_Tools.Pause(5); - + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Path = "/" + String(New UniqueIdentifier); + + Result = OPI_YandexDisk.CreateFolder(Token, Path); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateFolder"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["type"]).Equal("dir"); + OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + Path); + + OPI_YandexDisk.DeleteObject(Token, Path, False); + + OPI_Tools.Pause(5); + EndProcedure Procedure YDisk_UploadByUrlAndGetObject() Export + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Path = "/" + String(New UniqueIdentifier) + ".png"; + URL = "https://raw.githubusercontent.com/Bayselonarrend/OpenIntegrations/main/Media/logo.png"; -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Path = "/" + String(New UniqueIdentifier) + ".png"; -URL = "https://raw.githubusercontent.com/Bayselonarrend/OpenIntegrations/main/Media/logo.png"; - -OPI_YandexDisk.UploadFileByURL(Token, Path, URL); -OPI_Tools.Pause(5); - -Result = OPI_YandexDisk.GetObject(Token, Path); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetObject"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); -OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + Path); - -OPI_YandexDisk.DeleteObject(Token, Path, False); - -OPI_Tools.Pause(5); + OPI_YandexDisk.UploadFileByURL(Token, Path, URL); + OPI_Tools.Pause(5); + + Result = OPI_YandexDisk.GetObject(Token, Path); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetObject"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); + OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + Path); + OPI_YandexDisk.DeleteObject(Token, Path, False); + + OPI_Tools.Pause(5); + EndProcedure Procedure YDisk_UploadDeleteFile() Export + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Path = "/" + String(New UniqueIdentifier) + ".png"; + Image = OPI_GetTestData.GetBinary("Picture"); + AndVF = GetTempFileName("png"); + Image.Write(AndVF); -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Path = "/" + String(New UniqueIdentifier) + ".png"; -Image = OPI_GetTestData.GetBinary("Picture"); -AndVF = GetTempFileName("png"); -Image.Write(AndVF); - -Result = OPI_YandexDisk.UploadFile(Token, Path, Image, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); - -Check_Empty(Result); -OPI_Tools.Pause(5); - -Result = OPI_YandexDisk.DeleteObject(Token, Path, False); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject"); - -Check_Empty(Result); - -Result = OPI_YandexDisk.UploadFile(Token, Path, AndVF, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); - -Check_Empty(Result); -OPI_Tools.Pause(5); - -Result = OPI_YandexDisk.DeleteObject(Token, Path, False); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject"); - -Check_Empty(Result); - -DeleteFiles(AndVF); - -OPI_Tools.Pause(5); + Result = OPI_YandexDisk.UploadFile(Token, Path, Image, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); + + Check_Empty(Result); + OPI_Tools.Pause(5); + + Result = OPI_YandexDisk.DeleteObject(Token, Path, False); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject"); + + Check_Empty(Result); + + Result = OPI_YandexDisk.UploadFile(Token, Path, AndVF, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); + + Check_Empty(Result); + OPI_Tools.Pause(5); + + Result = OPI_YandexDisk.DeleteObject(Token, Path, False); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject"); + + Check_Empty(Result); + DeleteFiles(AndVF); + + OPI_Tools.Pause(5); + EndProcedure Procedure YDisk_CreateObjectCopy() Export + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + OriginalPath = "/" + String(New UniqueIdentifier) + ".png"; + CopyPath = "/" + String(New UniqueIdentifier) + ".png"; + URL = "https://raw.githubusercontent.com/Bayselonarrend/" + + "OpenIntegrations/main/Media/logo.png"; -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -OriginalPath = "/" + String(New UniqueIdentifier) + ".png"; -CopyPath = "/" + String(New UniqueIdentifier) + ".png"; -URL = "https://raw.githubusercontent.com/Bayselonarrend/" -+ "OpenIntegrations/main/Media/logo.png"; - -OPI_YandexDisk.UploadFileByURL(Token, OriginalPath, URL); -OPI_Tools.Pause(5); - -Result = OPI_YandexDisk.CreateObjectCopy(Token, OriginalPath, CopyPath, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateObjectCopy"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); -OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + CopyPath); - -OPI_YandexDisk.DeleteObject(Token, OriginalPath, False); -OPI_YandexDisk.DeleteObject(Token, CopyPath, False); - -OPI_Tools.Pause(5); + OPI_YandexDisk.UploadFileByURL(Token, OriginalPath, URL); + OPI_Tools.Pause(5); + + Result = OPI_YandexDisk.CreateObjectCopy(Token, OriginalPath, CopyPath, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateObjectCopy"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); + OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + CopyPath); + OPI_YandexDisk.DeleteObject(Token, OriginalPath, False); + OPI_YandexDisk.DeleteObject(Token, CopyPath, False); + + OPI_Tools.Pause(5); + EndProcedure Procedure YDisk_GetDownloadLink() Export + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Path = "/" + String(New UniqueIdentifier) + ".png"; + URL = "https://raw.githubusercontent.com/Bayselonarrend/OpenIntegrations/main/Media/logo.png"; -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Path = "/" + String(New UniqueIdentifier) + ".png"; -URL = "https://raw.githubusercontent.com/Bayselonarrend/OpenIntegrations/main/Media/logo.png"; + OPI_YandexDisk.UploadFileByURL(Token, Path, URL); + OPI_Tools.Pause(5); + + Result = OPI_YandexDisk.GetDownloadLink(Token, Path); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetDownloadLink"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["method"]).Equal("GET"); + OPI_GetTestData.ExpectsThat(Result["href"]).HasType("String").Filled(); + + URL = Result["href"]; + + Result = OPI_YandexDisk.DownloadFile(Token, Path); + + OPI_GetTestData.ExpectsThat(Result).HasType("BinaryData").Filled(); -OPI_YandexDisk.UploadFileByURL(Token, Path, URL); -OPI_Tools.Pause(5); - -Result = OPI_YandexDisk.GetDownloadLink(Token, Path); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetDownloadLink"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["method"]).Equal("GET"); -OPI_GetTestData.ExpectsThat(Result["href"]).HasType("String").Filled(); - -URL = Result["href"]; - -Result = OPI_YandexDisk.DownloadFile(Token, Path); - -OPI_GetTestData.ExpectsThat(Result).HasType("BinaryData").Filled(); - -OPI_YandexDisk.DeleteObject(Token, Path, False); + OPI_YandexDisk.DeleteObject(Token, Path, False); EndProcedure Procedure YDisk_GetFileList() Export - -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Quantity = 2; -Indent = 1; - -Result = OPI_YandexDisk.GetFilesList(Token, Quantity, Indent, "image"); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetFilesList"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["limit"]).Equal(Quantity); -OPI_GetTestData.ExpectsThat(Result["offset"]).Equal(Indent); -OPI_GetTestData.ExpectsThat(Result["items"]).HasType("Array"); - -OPI_Tools.Pause(5); - + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Quantity = 2; + Indent = 1; + + Result = OPI_YandexDisk.GetFilesList(Token, Quantity, Indent, "image"); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetFilesList"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["limit"]).Equal(Quantity); + OPI_GetTestData.ExpectsThat(Result["offset"]).Equal(Indent); + OPI_GetTestData.ExpectsThat(Result["items"]).HasType("Array"); + + OPI_Tools.Pause(5); + EndProcedure Procedure YDisk_MoveObject() Export + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + OriginalPath = "/" + String(New UniqueIdentifier) + ".png"; + CopyPath = "/" + String(New UniqueIdentifier) + ".png"; + URL = "https://raw.githubusercontent.com/Bayselonarrend/" + + "OpenIntegrations/main/Media/logo.png"; -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -OriginalPath = "/" + String(New UniqueIdentifier) + ".png"; -CopyPath = "/" + String(New UniqueIdentifier) + ".png"; -URL = "https://raw.githubusercontent.com/Bayselonarrend/" -+ "OpenIntegrations/main/Media/logo.png"; - -OPI_YandexDisk.UploadFileByURL(Token, OriginalPath, URL); -OPI_Tools.Pause(15); - -Result = OPI_YandexDisk.MoveObject(Token, OriginalPath, CopyPath, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "MoveObject"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); -OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + CopyPath); - -OPI_YandexDisk.DeleteObject(Token, OriginalPath, False); -OPI_YandexDisk.DeleteObject(Token, CopyPath, False); - -OPI_Tools.Pause(5); + OPI_YandexDisk.UploadFileByURL(Token, OriginalPath, URL); + OPI_Tools.Pause(15); + + Result = OPI_YandexDisk.MoveObject(Token, OriginalPath, CopyPath, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "MoveObject"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); + OPI_GetTestData.ExpectsThat(Result["path"]).Equal("disk:" + CopyPath); + OPI_YandexDisk.DeleteObject(Token, OriginalPath, False); + OPI_YandexDisk.DeleteObject(Token, CopyPath, False); + + OPI_Tools.Pause(5); + EndProcedure Procedure YDisk_PublicObjectActions() Export - -PUrl = "public_url"; -Match = "Match"; -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Path = "/" + String(New UniqueIdentifier) + ".png"; -URL = "https://raw.githubusercontent.com/Bayselonarrend/OpenIntegrations/main/Media/logo.png"; - -OPI_YandexDisk.UploadFileByURL(Token, Path, URL); -OPI_Tools.Pause(5); - -ResultArray = New Array; - -ResultArray.Add(OPI_YandexDisk.PublishObject(Token, Path)); -PublicURL = ResultArray[0][PUrl]; - -Result = OPI_YandexDisk.GetDownloadLinkForPublicObject(Token, PublicURL); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetDownloadLinkForPublicObject"); - -OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); -OPI_GetTestData.ExpectsThat(Result["method"]).Equal("GET"); -OPI_GetTestData.ExpectsThat(Result["href"]).HasType("String").Filled(); - -Result = OPI_YandexDisk.GetPublicObject(Token, PublicURL); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetPublicObject"); - -OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); -OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); -OPI_GetTestData.ExpectsThat(Result["path"]).Equal("/"); - -ResultArray.Add(OPI_YandexDisk.SavePublicObjectToDisk(Token, PublicURL)); - -ResultArray.Add(OPI_YandexDisk.CancelObjectPublication(Token, Path)); - -Counter = 0; -For Each Result In ResultArray Do - -// !OInt OPI_GetTestData.WriteLog(Result, "PublicationChange"); - -OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); -OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); -OPI_GetTestData.ExpectsThat(Result["path"]).Filled(); - -If Counter = 0 Then -OPI_GetTestData.ExpectsThat(Result[PUrl]).HasType("String").Filled(); -Else -OPI_GetTestData.ExpectsThat(Result[PUrl]).HasType("Undefined"); -EndIf; - -Counter = Counter + 1; - -EndDo; - -OPI_YandexDisk.DeleteObject(Token, Path, False); - -OPI_Tools.Pause(5); + + PUrl = "public_url"; + Match = "Match"; + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Path = "/" + String(New UniqueIdentifier) + ".png"; + URL = "https://raw.githubusercontent.com/Bayselonarrend/OpenIntegrations/main/Media/logo.png"; + + OPI_YandexDisk.UploadFileByURL(Token, Path, URL); + OPI_Tools.Pause(5); + + ResultArray = New Array; + + ResultArray.Add(OPI_YandexDisk.PublishObject(Token, Path)); + PublicURL = ResultArray[0][PUrl]; + + Result = OPI_YandexDisk.GetDownloadLinkForPublicObject(Token, PublicURL); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetDownloadLinkForPublicObject"); + + OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); + OPI_GetTestData.ExpectsThat(Result["method"]).Equal("GET"); + OPI_GetTestData.ExpectsThat(Result["href"]).HasType("String").Filled(); + + Result = OPI_YandexDisk.GetPublicObject(Token, PublicURL); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetPublicObject"); + + OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); + OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); + OPI_GetTestData.ExpectsThat(Result["path"]).Equal("/"); + + ResultArray.Add(OPI_YandexDisk.SavePublicObjectToDisk(Token, PublicURL)); + + ResultArray.Add(OPI_YandexDisk.CancelObjectPublication(Token, Path)); + + Counter = 0; + For Each Result In ResultArray Do + + // !OInt OPI_GetTestData.WriteLog(Result, "PublicationChange"); + + OPI_GetTestData.ExpectsThat(Result).HasType(Match).Filled(); + OPI_GetTestData.ExpectsThat(Result["type"]).Equal("file"); + OPI_GetTestData.ExpectsThat(Result["path"]).Filled(); + + If Counter = 0 Then + OPI_GetTestData.ExpectsThat(Result[PUrl]).HasType("String").Filled(); + Else + OPI_GetTestData.ExpectsThat(Result[PUrl]).HasType("Undefined"); + EndIf; + + Counter = Counter + 1; + + EndDo; + + OPI_YandexDisk.DeleteObject(Token, Path, False); + + OPI_Tools.Pause(5); EndProcedure Procedure YDisk_GetPublishedList() Export - -Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); -Quantity = 2; -Indent = 1; - -Result = OPI_YandexDisk.GetPublishedObjectsList(Token, Quantity, Indent); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetPublishedObjectsList"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["limit"]).Equal(Quantity); -OPI_GetTestData.ExpectsThat(Result["offset"]).Equal(Indent); -OPI_GetTestData.ExpectsThat(Result["items"]).HasType("Array"); - -OPI_Tools.Pause(5); - + + Token = OPI_GetTestData.GetParameter("YandexDisk_Token"); + Quantity = 2; + Indent = 1; + + Result = OPI_YandexDisk.GetPublishedObjectsList(Token, Quantity, Indent); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetPublishedObjectsList"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["limit"]).Equal(Quantity); + OPI_GetTestData.ExpectsThat(Result["offset"]).Equal(Indent); + OPI_GetTestData.ExpectsThat(Result["items"]).HasType("Array"); + + OPI_Tools.Pause(5); + EndProcedure #EndRegion @@ -1270,211 +1270,211 @@ EndProcedure #Region Viber Procedure Viber_GetChannelInfo() Export + + Token = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + Result = OPI_Viber.GetChannelInformation(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetChannelInformation"); + + Check_ViberOk(Result); -Token = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -Result = OPI_Viber.GetChannelInformation(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetChannelInformation"); - -Check_ViberOk(Result); - -OPI_Tools.Pause(5); + OPI_Tools.Pause(5); EndProcedure Procedure Viber_GetUserData() Export - -Token = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -User = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); -Result = OPI_Viber.GetUserData(Token, User); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetUserData"); - -OPI_GetTestData.ExpectsThat(Result["chat_hostname"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["status_message"]).Filled(); -OPI_Tools.Pause(5); + + Token = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + User = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); + Result = OPI_Viber.GetUserData(Token, User); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetUserData"); + + OPI_GetTestData.ExpectsThat(Result["chat_hostname"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["status_message"]).Filled(); + OPI_Tools.Pause(5); EndProcedure Procedure Viber_GetOnlineUsers() Export - -Token = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -User = OPI_GetTestData.GetParameter("Viber_UserID"); -Result = OPI_Viber.GetOnlineUsers(Token, User); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetOnlineUsers"); - -OPI_GetTestData.ExpectsThat(Result["users"]).HasType("Array"); -Check_ViberOk(Result); - -OPI_Tools.Pause(5); + + Token = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + User = OPI_GetTestData.GetParameter("Viber_UserID"); + Result = OPI_Viber.GetOnlineUsers(Token, User); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetOnlineUsers"); + + OPI_GetTestData.ExpectsThat(Result["users"]).HasType("Array"); + Check_ViberOk(Result); + + OPI_Tools.Pause(5); EndProcedure Procedure Viber_SendTextMessage() Export - -Text = "TestMessage"; -ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -BotToken = OPI_GetTestData.GetParameter("Viber_Token"); -User = OPI_GetTestData.GetParameter("Viber_UserID"); -Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); - -ButtonArray = New Array; -ButtonArray.Add("Button 1"); -ButtonArray.Add("Button 2"); -ButtonArray.Add("Button 3"); - -Keyboard = OPI_Viber.CreateKeyboardFromArrayButton(ButtonArray); - -Result = OPI_Viber.SendTextMessage(BotToken, Text, User, False, Keyboard); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -Result = OPI_Viber.SendTextMessage(ChannelToken, Text, Administrator, True, Keyboard); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -OPI_Tools.Pause(5); - + + Text = "TestMessage"; + ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + BotToken = OPI_GetTestData.GetParameter("Viber_Token"); + User = OPI_GetTestData.GetParameter("Viber_UserID"); + Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); + + ButtonArray = New Array; + ButtonArray.Add("Button 1"); + ButtonArray.Add("Button 2"); + ButtonArray.Add("Button 3"); + + Keyboard = OPI_Viber.CreateKeyboardFromArrayButton(ButtonArray); + + Result = OPI_Viber.SendTextMessage(BotToken, Text, User, False, Keyboard); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + Result = OPI_Viber.SendTextMessage(ChannelToken, Text, Administrator, True, Keyboard); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Viber_SendImage() Export -Text = "TestMessage"; -Image = OPI_GetTestData.GetParameter("Picture"); -ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -BotToken = OPI_GetTestData.GetParameter("Viber_Token"); -User = OPI_GetTestData.GetParameter("Viber_UserID"); -Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); - -Result = OPI_Viber.SendImage(BotToken, Image, User, False, Text); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendImage"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -Result = OPI_Viber.SendImage(ChannelToken, Image, Administrator, True, Text); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendImage"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -OPI_Tools.Pause(5); - + Text = "TestMessage"; + Image = OPI_GetTestData.GetParameter("Picture"); + ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + BotToken = OPI_GetTestData.GetParameter("Viber_Token"); + User = OPI_GetTestData.GetParameter("Viber_UserID"); + Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); + + Result = OPI_Viber.SendImage(BotToken, Image, User, False, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendImage"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + Result = OPI_Viber.SendImage(ChannelToken, Image, Administrator, True, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendImage"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Viber_SendFile() Export - -Document = OPI_GetTestData.GetParameter("Document"); -ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -BotToken = OPI_GetTestData.GetParameter("Viber_Token"); -User = OPI_GetTestData.GetParameter("Viber_UserID"); -Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); - -Result = OPI_Viber.SendFile(BotToken, Document, User, False, "docx"); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendFile"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -Result = OPI_Viber.SendFile(ChannelToken, Document, Administrator, True, "docx"); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendFile"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -OPI_Tools.Pause(5); - + + Document = OPI_GetTestData.GetParameter("Document"); + ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + BotToken = OPI_GetTestData.GetParameter("Viber_Token"); + User = OPI_GetTestData.GetParameter("Viber_UserID"); + Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); + + Result = OPI_Viber.SendFile(BotToken, Document, User, False, "docx"); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendFile"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + Result = OPI_Viber.SendFile(ChannelToken, Document, Administrator, True, "docx"); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendFile"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Viber_SendContact() Export - -Name = "Petr Petrov"; -Phone = "+123456789"; -ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -BotToken = OPI_GetTestData.GetParameter("Viber_Token"); -User = OPI_GetTestData.GetParameter("Viber_UserID"); -Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); - -Result = OPI_Viber.SendContact(BotToken, Name, Phone, User, False); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendContact"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -Result = OPI_Viber.SendContact(ChannelToken, Name, Phone, Administrator, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendContact"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -OPI_Tools.Pause(5); - + + Name = "Petr Petrov"; + Phone = "+123456789"; + ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + BotToken = OPI_GetTestData.GetParameter("Viber_Token"); + User = OPI_GetTestData.GetParameter("Viber_UserID"); + Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); + + Result = OPI_Viber.SendContact(BotToken, Name, Phone, User, False); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendContact"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + Result = OPI_Viber.SendContact(ChannelToken, Name, Phone, Administrator, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendContact"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Viber_SendLocation() Export -Latitude = "48.87373649724122"; -Longitude = "2.2954639195323967"; -ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -BotToken = OPI_GetTestData.GetParameter("Viber_Token"); -User = OPI_GetTestData.GetParameter("Viber_UserID"); -Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); - -Result = OPI_Viber.SendLocation(BotToken, Latitude, Longitude, User, False); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendLocation"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -Result = OPI_Viber.SendLocation(ChannelToken, Latitude, Longitude, Administrator, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendLocation"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -OPI_Tools.Pause(5); - + Latitude = "48.87373649724122"; + Longitude = "2.2954639195323967"; + ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + BotToken = OPI_GetTestData.GetParameter("Viber_Token"); + User = OPI_GetTestData.GetParameter("Viber_UserID"); + Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); + + Result = OPI_Viber.SendLocation(BotToken, Latitude, Longitude, User, False); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendLocation"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + Result = OPI_Viber.SendLocation(ChannelToken, Latitude, Longitude, Administrator, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendLocation"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Viber_SendLink() Export -URL = "https://github.com/Bayselonarrend/OpenIntegrations"; -ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); -BotToken = OPI_GetTestData.GetParameter("Viber_Token"); -User = OPI_GetTestData.GetParameter("Viber_UserID"); -Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); - -Result = OPI_Viber.SendLink(BotToken, URL, User, False); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendLink"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -Result = OPI_Viber.SendLink(ChannelToken, URL, Administrator, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendLink"); - -OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); -Check_ViberOk(Result); - -OPI_Tools.Pause(5); - + URL = "https://github.com/Bayselonarrend/OpenIntegrations"; + ChannelToken = OPI_GetTestData.GetParameter("Viber_ChannelToken"); + BotToken = OPI_GetTestData.GetParameter("Viber_Token"); + User = OPI_GetTestData.GetParameter("Viber_UserID"); + Administrator = OPI_GetTestData.GetParameter("Viber_ChannelAdminID"); + + Result = OPI_Viber.SendLink(BotToken, URL, User, False); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendLink"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + Result = OPI_Viber.SendLink(ChannelToken, URL, Administrator, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendLink"); + + OPI_GetTestData.ExpectsThat(Result["message_token"]).Filled(); + Check_ViberOk(Result); + + OPI_Tools.Pause(5); + EndProcedure #EndRegion @@ -1482,54 +1482,54 @@ EndProcedure #Region GoogleWorkspace Procedure GV_GetAuthorizationLink() Export - -ClientID = OPI_GetTestData.GetParameter("Google_ClientID"); -Result = OPI_GoogleWorkspace.FormCodeRetrievalLink(ClientID); - -OPI_GetTestData.ExpectsThat(Result) -.HasType("String") -.Filled(); - -OPI_GetTestData.WriteParameter("Google_Link", Result); - -OPI_Tools.Pause(5); - + + ClientID = OPI_GetTestData.GetParameter("Google_ClientID"); + Result = OPI_GoogleWorkspace.FormCodeRetrievalLink(ClientID); + + OPI_GetTestData.ExpectsThat(Result) + .HasType("String") + .Filled(); + + OPI_GetTestData.WriteParameter("Google_Link", Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure GV_GetToken() Export - -ClientID = OPI_GetTestData.GetParameter("Google_ClientID"); -ClientSecret = OPI_GetTestData.GetParameter("Google_ClientSecret"); -Code = OPI_GetTestData.GetParameter("Google_Code"); - -Result = OPI_GoogleWorkspace.GetTokenByCode(ClientID, ClientSecret, Code); - -If ValueIsFilled(Result["access_token"]) -And ValueIsFilled(Result["refresh_token"]) Then - -OPI_GetTestData.WriteParameter("Google_Token" , Result["access_token"]); -OPI_GetTestData.WriteParameter("Google_Refresh", Result["refresh_token"]); - -EndIf; - -OPI_Tools.Pause(5); - + + ClientID = OPI_GetTestData.GetParameter("Google_ClientID"); + ClientSecret = OPI_GetTestData.GetParameter("Google_ClientSecret"); + Code = OPI_GetTestData.GetParameter("Google_Code"); + + Result = OPI_GoogleWorkspace.GetTokenByCode(ClientID, ClientSecret, Code); + + If ValueIsFilled(Result["access_token"]) + And ValueIsFilled(Result["refresh_token"]) Then + + OPI_GetTestData.WriteParameter("Google_Token" , Result["access_token"]); + OPI_GetTestData.WriteParameter("Google_Refresh", Result["refresh_token"]); + + EndIf; + + OPI_Tools.Pause(5); + EndProcedure Procedure GV_UpdateToken() Export - -ClientID = OPI_GetTestData.GetParameter("Google_ClientID"); -ClientSecret = OPI_GetTestData.GetParameter("Google_ClientSecret"); -RefreshToken = OPI_GetTestData.GetParameter("Google_Refresh"); - -Result = OPI_GoogleWorkspace.RefreshToken(ClientID, ClientSecret, RefreshToken); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match"); -OPI_GetTestData.ExpectsThat(Result["access_token"]).Filled(); - -OPI_GetTestData.WriteParameter("Google_Token", Result["access_token"]); - -OPI_Tools.Pause(5); + + ClientID = OPI_GetTestData.GetParameter("Google_ClientID"); + ClientSecret = OPI_GetTestData.GetParameter("Google_ClientSecret"); + RefreshToken = OPI_GetTestData.GetParameter("Google_Refresh"); + + Result = OPI_GoogleWorkspace.RefreshToken(ClientID, ClientSecret, RefreshToken); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match"); + OPI_GetTestData.ExpectsThat(Result["access_token"]).Filled(); + + OPI_GetTestData.WriteParameter("Google_Token", Result["access_token"]); + + OPI_Tools.Pause(5); EndProcedure @@ -1538,181 +1538,181 @@ EndProcedure #Region GoogleCalendar Procedure GC_GetCalendarList() Export + + Token = OPI_GetTestData.GetParameter("Google_Token"); + Result = OPI_GoogleCalendar.GetCalendarList(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetCalendarList"); + + OPI_GetTestData.ExpectsThat(Result) + .HasType("Array"); -Token = OPI_GetTestData.GetParameter("Google_Token"); -Result = OPI_GoogleCalendar.GetCalendarList(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetCalendarList"); - -OPI_GetTestData.ExpectsThat(Result) -.HasType("Array"); - -OPI_Tools.Pause(5); - + OPI_Tools.Pause(5); + EndProcedure Procedure GC_CreateDeleteCalendar() Export + + Token = OPI_GetTestData.GetParameter("Google_Token"); + Name = "TestCalendar"; + Description = "TestDescription"; + EditedName = Name + " (fromм.)"; + TypeMatch = Type("Match"); + TypeString = Type("String"); + Summary = "summary"; + Black = "#000000"; + Yellow = "#ffd800"; + + Result = OPI_GoogleCalendar.CreateCalendar(Token, Name); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateCalendar"); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Summary]).Equal(Name); + OPI_GetTestData.ExpectsThat(Result["id"]).HasType(TypeString).Filled(); + + Calendar = Result["id"]; + + Result = OPI_GoogleCalendar.EditCalendarMetadata(Token + , Calendar + , EditedName + , Description); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditCalendarMetadata"); + + Check_GKObject(Result, EditedName, Description); + + Result = OPI_GoogleCalendar.GetCalendarMetadata(Token, Calendar); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetCalendarMetadata"); + + Check_GKObject(Result, EditedName, Description); -Token = OPI_GetTestData.GetParameter("Google_Token"); -Name = "TestCalendar"; -Description = "TestDescription"; -EditedName = Name + " (fromм.)"; -TypeMatch = Type("Match"); -TypeString = Type("String"); -Summary = "summary"; -Black = "#000000"; -Yellow = "#ffd800"; - -Result = OPI_GoogleCalendar.CreateCalendar(Token, Name); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateCalendar"); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Summary]).Equal(Name); -OPI_GetTestData.ExpectsThat(Result["id"]).HasType(TypeString).Filled(); - -Calendar = Result["id"]; - -Result = OPI_GoogleCalendar.EditCalendarMetadata(Token -, Calendar -, EditedName -, Description); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditCalendarMetadata"); - -Check_GKObject(Result, EditedName, Description); - -Result = OPI_GoogleCalendar.GetCalendarMetadata(Token, Calendar); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetCalendarMetadata"); - -Check_GKObject(Result, EditedName, Description); - -Result = OPI_GoogleCalendar.AddCalendarToList(Token, Calendar); - -// !OInt OPI_GetTestData.WriteLog(Result, "AddCalendarToList"); - -Check_GKObject(Result, EditedName, Description); - -Result = OPI_GoogleCalendar.EditListCalendar(Token, Calendar, Black, Yellow, False); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditListCalendar"); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Summary]).Equal(EditedName); -OPI_GetTestData.ExpectsThat(Result["foregroundColor"]).Equal(Black); -OPI_GetTestData.ExpectsThat(Result["backgroundColor"]).Equal(Yellow); - -Result = OPI_GoogleCalendar.GetListCalendar(Token, Calendar); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetListCalendar"); - -OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); -OPI_GetTestData.ExpectsThat(Result[Summary]).Equal(EditedName); -OPI_GetTestData.ExpectsThat(Result["foregroundColor"]).Equal(Black); -OPI_GetTestData.ExpectsThat(Result["backgroundColor"]).Equal(Yellow); - -Result = OPI_GoogleCalendar.ClearMainCalendar(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "ClearMainCalendar"); - -Check_Empty(Result); - -Result = OPI_GoogleCalendar.DeleteCalendarFromList(Token, Calendar); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteCalendarFromList"); - -Check_Empty(Result); - -Result = OPI_GoogleCalendar.DeleteCalendar(Token, Calendar); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteCalendar"); - -Check_Empty(Result); - -OPI_Tools.Pause(5); + Result = OPI_GoogleCalendar.AddCalendarToList(Token, Calendar); + + // !OInt OPI_GetTestData.WriteLog(Result, "AddCalendarToList"); + + Check_GKObject(Result, EditedName, Description); + + Result = OPI_GoogleCalendar.EditListCalendar(Token, Calendar, Black, Yellow, False); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditListCalendar"); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Summary]).Equal(EditedName); + OPI_GetTestData.ExpectsThat(Result["foregroundColor"]).Equal(Black); + OPI_GetTestData.ExpectsThat(Result["backgroundColor"]).Equal(Yellow); + + Result = OPI_GoogleCalendar.GetListCalendar(Token, Calendar); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetListCalendar"); + + OPI_GetTestData.ExpectsThat(Result).HasType(TypeMatch); + OPI_GetTestData.ExpectsThat(Result[Summary]).Equal(EditedName); + OPI_GetTestData.ExpectsThat(Result["foregroundColor"]).Equal(Black); + OPI_GetTestData.ExpectsThat(Result["backgroundColor"]).Equal(Yellow); + Result = OPI_GoogleCalendar.ClearMainCalendar(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "ClearMainCalendar"); + + Check_Empty(Result); + + Result = OPI_GoogleCalendar.DeleteCalendarFromList(Token, Calendar); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteCalendarFromList"); + + Check_Empty(Result); + + Result = OPI_GoogleCalendar.DeleteCalendar(Token, Calendar); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteCalendar"); + + Check_Empty(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure GC_CreateDeleteEvent() Export + + CurrentDate = OPI_Tools.GetCurrentDate(); + Token = OPI_GetTestData.GetParameter("Google_Token"); + Calendar = OPI_GetTestData.GetParameter("Google_CalendarID"); + Name = "New event"; + Description = "TestEventDescription"; + EditedDescription = "TestEventDescription (fromм.)"; + UID = "id"; + Hour = 3600; -CurrentDate = OPI_Tools.GetCurrentDate(); -Token = OPI_GetTestData.GetParameter("Google_Token"); -Calendar = OPI_GetTestData.GetParameter("Google_CalendarID"); -Name = "New event"; -Description = "TestEventDescription"; -EditedDescription = "TestEventDescription (fromм.)"; -UID = "id"; -Hour = 3600; + Attachments = New Match; + + Attachments.Insert("Image1" + , "https://opi.neocities.org/assets/images/logo_long-e8fdcca6ff8b32e679ea49a1ccdd3eac.png"); + Attachments.Insert("Image2" + , "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/Media/logo.png?v1"); + + EventMatch = New Match; + EventMatch.Insert("Description" , Description); + EventMatch.Insert("Title" , Name); + EventMatch.Insert("Venue" , "InOffice"); + EventMatch.Insert("StartDate" , CurrentDate); + EventMatch.Insert("EndDate" , EventMatch["StartDate"] + Hour); + EventMatch.Insert("ArrayOfAttachmentURLs" , Attachments); + EventMatch.Insert("SendNotifications" , True); + + Result = OPI_GoogleCalendar.CreateEvent(Token, Calendar, EventMatch); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateEvent"); + + Event = Result[UID]; + + Check_GKObject(Result, Name, Description); + + EventMatch = New Match; + EventMatch.Insert("Description", EditedDescription); + + Result = OPI_GoogleCalendar.EditEvent(Token, Calendar, EventMatch, Event); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditEvent"); + + Check_GKObject(Result, Name, EditedDescription); + + Result = OPI_GoogleCalendar.GetEvent(Token, Calendar, Event); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetEvent"); + + Check_GKObject(Result, Name, EditedDescription); -Attachments = New Match; - -Attachments.Insert("Image1" -, "https://opi.neocities.org/assets/images/logo_long-e8fdcca6ff8b32e679ea49a1ccdd3eac.png"); -Attachments.Insert("Image2" -, "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/Media/logo.png?v1"); - -EventMatch = New Match; -EventMatch.Insert("Description" , Description); -EventMatch.Insert("Title" , Name); -EventMatch.Insert("Venue" , "InOffice"); -EventMatch.Insert("StartDate" , CurrentDate); -EventMatch.Insert("EndDate" , EventMatch["StartDate"] + Hour); -EventMatch.Insert("ArrayOfAttachmentURLs" , Attachments); -EventMatch.Insert("SendNotifications" , True); - -Result = OPI_GoogleCalendar.CreateEvent(Token, Calendar, EventMatch); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateEvent"); - -Event = Result[UID]; - -Check_GKObject(Result, Name, Description); - -EventMatch = New Match; -EventMatch.Insert("Description", EditedDescription); - -Result = OPI_GoogleCalendar.EditEvent(Token, Calendar, EventMatch, Event); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditEvent"); - -Check_GKObject(Result, Name, EditedDescription); - -Result = OPI_GoogleCalendar.GetEvent(Token, Calendar, Event); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetEvent"); - -Check_GKObject(Result, Name, EditedDescription); - -Result = OPI_GoogleCalendar.MoveEvent(Token, Calendar, Calendar, Event); - -// !OInt OPI_GetTestData.WriteLog(Result, "MoveEvent"); - -Check_GKObject(Result, Name, EditedDescription); - -Result = OPI_GoogleCalendar.DeleteEvent(Token, Calendar, Event); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteEvent"); - -Check_Empty(Result); - -OPI_Tools.Pause(5); + Result = OPI_GoogleCalendar.MoveEvent(Token, Calendar, Calendar, Event); + + // !OInt OPI_GetTestData.WriteLog(Result, "MoveEvent"); + + Check_GKObject(Result, Name, EditedDescription); + + Result = OPI_GoogleCalendar.DeleteEvent(Token, Calendar, Event); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteEvent"); + + Check_Empty(Result); + + OPI_Tools.Pause(5); EndProcedure Procedure GC_GetEventList() Export + + Token = OPI_GetTestData.GetParameter("Google_Token"); + Calendar = OPI_GetTestData.GetParameter("Google_CalendarID"); -Token = OPI_GetTestData.GetParameter("Google_Token"); -Calendar = OPI_GetTestData.GetParameter("Google_CalendarID"); - -Result = OPI_GoogleCalendar.GetEventList(Token, Calendar); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetEventList"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Array"); - -OPI_Tools.Pause(5); - + Result = OPI_GoogleCalendar.GetEventList(Token, Calendar); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetEventList"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Array"); + + OPI_Tools.Pause(5); + EndProcedure #EndRegion @@ -1720,198 +1720,198 @@ EndProcedure #Region GoogleDrive Procedure GD_GetCatalogList() Export - -MimeType = "mimeType"; -Name = "name"; -Name = "TestFolder"; -Token = OPI_GetTestData.GetParameter("Google_Token"); -Result = OPI_GoogleDrive.GetDirectoriesList(Token, Name, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetDirectoriesList"); - -Result = Result[0]; - -OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); -OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal("application/vnd.google-apps.folder"); -OPI_GetTestData.ExpectsThat(Result[Name]).Filled(); - -OPI_Tools.Pause(5); -Identifier = Result["id"]; - -OPI_GetTestData.WriteParameter("GD_Catalog", Identifier); - -Result = OPI_GoogleDrive.GetObjectInformation(Token, Identifier); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetObjectInformation"); - -OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal("application/vnd.google-apps.folder"); -OPI_GetTestData.ExpectsThat(Result[Name]).Filled(); - -OPI_Tools.Pause(5); + + MimeType = "mimeType"; + Name = "name"; + Name = "TestFolder"; + Token = OPI_GetTestData.GetParameter("Google_Token"); + Result = OPI_GoogleDrive.GetDirectoriesList(Token, Name, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetDirectoriesList"); + + Result = Result[0]; + + OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); + OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal("application/vnd.google-apps.folder"); + OPI_GetTestData.ExpectsThat(Result[Name]).Filled(); + + OPI_Tools.Pause(5); + Identifier = Result["id"]; + + OPI_GetTestData.WriteParameter("GD_Catalog", Identifier); + + Result = OPI_GoogleDrive.GetObjectInformation(Token, Identifier); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetObjectInformation"); + + OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal("application/vnd.google-apps.folder"); + OPI_GetTestData.ExpectsThat(Result[Name]).Filled(); + + OPI_Tools.Pause(5); EndProcedure Procedure GD_UploadDeleteFile() Export + + ExtraBytes = 2; + + Kind = "kind"; + Content = "content"; + MIME = "MIME"; + MimeType = "mimeType"; + Name = "name"; + Id_ = "id"; + + ArrayOfDeletions = New Array; + Token = OPI_GetTestData.GetParameter("Google_Token"); + Image = OPI_GetTestData.GetBinary("Picture"); + ReplacementImage = OPI_GetTestData.GetBinary("Picture2"); + Directory = OPI_GetTestData.GetParameter("GD_Catalog"); + + Description = OPI_GoogleDrive.GetFileDescription(); + Description.Insert("Parent", Directory); + + Result = OPI_GoogleDrive.UploadFile(Token, Image, Description); + + // !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); + + OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal(Description[MIME]); + OPI_GetTestData.ExpectsThat(Result[Name]).Equal(Description["Name"]); -ExtraBytes = 2; - -Kind = "kind"; -Content = "content"; -MIME = "MIME"; -MimeType = "mimeType"; -Name = "name"; -Id_ = "id"; - -ArrayOfDeletions = New Array; -Token = OPI_GetTestData.GetParameter("Google_Token"); -Image = OPI_GetTestData.GetBinary("Picture"); -ReplacementImage = OPI_GetTestData.GetBinary("Picture2"); -Directory = OPI_GetTestData.GetParameter("GD_Catalog"); - -Description = OPI_GoogleDrive.GetFileDescription(); -Description.Insert("Parent", Directory); - -Result = OPI_GoogleDrive.UploadFile(Token, Image, Description); - -// !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); - -OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal(Description[MIME]); -OPI_GetTestData.ExpectsThat(Result[Name]).Equal(Description["Name"]); - -Identifier = Result[Id_]; -ArrayOfDeletions.Add(Identifier); - -NewName = "CopiedFile.jpeg"; -Result = OPI_GoogleDrive.CopyObject(Token, Identifier, NewName, "root"); - -// !OInt OPI_GetTestData.WriteLog(Result, "CopyObject"); - -OPI_Tools.Pause(5); - -OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal(Description[MIME]); -OPI_GetTestData.ExpectsThat(Result[Name]).Equal(NewName); - -ArrayOfDeletions.Add(Result[Id_]); - -Result = OPI_GoogleDrive.DownloadFile(Token, Identifier); - -// !OInt OPI_GetTestData.WriteLog(Result, "DownloadFile"); - -OPI_GetTestData.ExpectsThat(Result.Size()).Equal(Image.Size() + ExtraBytes); -OPI_Tools.Pause(5); - -NewName = "UpdatedFile.jpg"; -Result = OPI_GoogleDrive.UpdateFile(Token, Identifier, ReplacementImage, NewName); - -// !OInt OPI_GetTestData.WriteLog(Result, "UpdateFile"); - -OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal(Description[MIME]); -OPI_GetTestData.ExpectsThat(Result[Name]).Equal(NewName); - -OPI_Tools.Pause(5); - -Comment = "Yo"; -Result = OPI_GoogleDrive.CreateComment(Token, Identifier, Comment); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateComment"); - -OPI_GetTestData.ExpectsThat(Result[Content]).Equal(Comment); -OPI_GetTestData.ExpectsThat(Result[Kind]).Equal("drive#comment"); - -OPI_Tools.Pause(5); - -For Each Deletable In ArrayOfDeletions Do -Result = OPI_GoogleDrive.DeleteObject(Token, Deletable); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject"); - -OPI_GetTestData.ExpectsThat(ValueIsFilled(Result)).Equal(False); -OPI_Tools.Pause(2); -EndDo; - -OPI_Tools.Pause(5); + Identifier = Result[Id_]; + ArrayOfDeletions.Add(Identifier); + + NewName = "CopiedFile.jpeg"; + Result = OPI_GoogleDrive.CopyObject(Token, Identifier, NewName, "root"); + + // !OInt OPI_GetTestData.WriteLog(Result, "CopyObject"); + + OPI_Tools.Pause(5); + + OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal(Description[MIME]); + OPI_GetTestData.ExpectsThat(Result[Name]).Equal(NewName); + + ArrayOfDeletions.Add(Result[Id_]); + + Result = OPI_GoogleDrive.DownloadFile(Token, Identifier); + + // !OInt OPI_GetTestData.WriteLog(Result, "DownloadFile"); + + OPI_GetTestData.ExpectsThat(Result.Size()).Equal(Image.Size() + ExtraBytes); + OPI_Tools.Pause(5); + + NewName = "UpdatedFile.jpg"; + Result = OPI_GoogleDrive.UpdateFile(Token, Identifier, ReplacementImage, NewName); + + // !OInt OPI_GetTestData.WriteLog(Result, "UpdateFile"); + + OPI_GetTestData.ExpectsThat(Result[MimeType]).Equal(Description[MIME]); + OPI_GetTestData.ExpectsThat(Result[Name]).Equal(NewName); + OPI_Tools.Pause(5); + + Comment = "Yo"; + Result = OPI_GoogleDrive.CreateComment(Token, Identifier, Comment); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateComment"); + + OPI_GetTestData.ExpectsThat(Result[Content]).Equal(Comment); + OPI_GetTestData.ExpectsThat(Result[Kind]).Equal("drive#comment"); + + OPI_Tools.Pause(5); + + For Each Deletable In ArrayOfDeletions Do + Result = OPI_GoogleDrive.DeleteObject(Token, Deletable); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject"); + + OPI_GetTestData.ExpectsThat(ValueIsFilled(Result)).Equal(False); + OPI_Tools.Pause(2); + EndDo; + + OPI_Tools.Pause(5); + EndProcedure Procedure GD_CreateDeleteComment() Export + + Kind = "kind"; + Content = "content"; + Id_ = "id"; + Comments = "comments"; + Token = OPI_GetTestData.GetParameter("Google_Token"); + Directory = OPI_GetTestData.GetParameter("GD_Catalog"); + Image = OPI_GetTestData.GetBinary("Picture"); + + Description = OPI_GoogleDrive.GetFileDescription(); + Description.Insert("Parent", Directory); + + Result = OPI_GoogleDrive.UploadFile(Token, Image, Description); + Identifier = Result[Id_]; + + Comment = "NewComment"; + ResultArray = New Array; + Result = OPI_GoogleDrive.CreateComment(Token, Identifier, Comment); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateComment"); + + CommentID = Result[Id_]; + + ResultArray.Add(Result); + + Result = OPI_GoogleDrive.GetComment(Token, Identifier, CommentID); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetComment"); + + ResultArray.Add(Result); + + Result = OPI_GoogleDrive.GetCommentList(Token, Identifier); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetCommentList"); + + Comments = Result[Comments]; + CommentObject = Comments[Comments.WithinBoundary()]; + + ResultArray.Add(CommentObject); + + For Each Result In ResultArray Do + OPI_GetTestData.ExpectsThat(Result[Content]).Equal(Comment); + OPI_GetTestData.ExpectsThat(Result[Kind]).Equal("drive#comment"); + EndDo; + + Result = OPI_GoogleDrive.DeleteComment(Token, Identifier, CommentID); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteComment"); + + OPI_GetTestData.ExpectsThat(ValueIsFilled(Result)).Equal(False); -Kind = "kind"; -Content = "content"; -Id_ = "id"; -Comments = "comments"; -Token = OPI_GetTestData.GetParameter("Google_Token"); -Directory = OPI_GetTestData.GetParameter("GD_Catalog"); -Image = OPI_GetTestData.GetBinary("Picture"); - -Description = OPI_GoogleDrive.GetFileDescription(); -Description.Insert("Parent", Directory); - -Result = OPI_GoogleDrive.UploadFile(Token, Image, Description); -Identifier = Result[Id_]; - -Comment = "NewComment"; -ResultArray = New Array; -Result = OPI_GoogleDrive.CreateComment(Token, Identifier, Comment); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateComment"); - -CommentID = Result[Id_]; - -ResultArray.Add(Result); - -Result = OPI_GoogleDrive.GetComment(Token, Identifier, CommentID); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetComment"); - -ResultArray.Add(Result); - -Result = OPI_GoogleDrive.GetCommentList(Token, Identifier); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetCommentList"); - -Comments = Result[Comments]; -CommentObject = Comments[Comments.WithinBoundary()]; - -ResultArray.Add(CommentObject); - -For Each Result In ResultArray Do -OPI_GetTestData.ExpectsThat(Result[Content]).Equal(Comment); -OPI_GetTestData.ExpectsThat(Result[Kind]).Equal("drive#comment"); -EndDo; - -Result = OPI_GoogleDrive.DeleteComment(Token, Identifier, CommentID); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteComment"); - -OPI_GetTestData.ExpectsThat(ValueIsFilled(Result)).Equal(False); - -OPI_GoogleDrive.DeleteObject(Token, Identifier); - + OPI_GoogleDrive.DeleteObject(Token, Identifier); + EndProcedure Procedure GD_CreateCatalog() Export - -Name = "name"; -Name = "TestFolder"; -Token = OPI_GetTestData.GetParameter("Google_Token"); -Directory = OPI_GetTestData.GetParameter("GD_Catalog"); - -ResultArray = New Array; - -ResultArray.Add(OPI_GoogleDrive.CreateFolder(Token, Name)); -ResultArray.Add(OPI_GoogleDrive.CreateFolder(Token, Name, Directory)); - -For Each Result In ResultArray Do - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateFolder"); - -CatalogID = Result["id"]; - -OPI_GetTestData.ExpectsThat(Result[Name]).Equal(Name); - -OPI_GoogleDrive.DeleteObject(Token, CatalogID); - -EndDo; + + Name = "name"; + Name = "TestFolder"; + Token = OPI_GetTestData.GetParameter("Google_Token"); + Directory = OPI_GetTestData.GetParameter("GD_Catalog"); + + ResultArray = New Array; + + ResultArray.Add(OPI_GoogleDrive.CreateFolder(Token, Name)); + ResultArray.Add(OPI_GoogleDrive.CreateFolder(Token, Name, Directory)); + + For Each Result In ResultArray Do + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateFolder"); + + CatalogID = Result["id"]; + + OPI_GetTestData.ExpectsThat(Result[Name]).Equal(Name); + + OPI_GoogleDrive.DeleteObject(Token, CatalogID); + + EndDo; EndProcedure @@ -1920,136 +1920,136 @@ EndProcedure #Region GoogleSheets Procedure GT_CreateTable() Export + + Token = OPI_GetTestData.GetParameter("Google_Token"); + Name = "TestTable"; + + SheetArray = New Array; + SheetArray.Add("Sheet1"); + SheetArray.Add("Sheet2"); + + Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateBook"); + + OPI_GetTestData.ExpectsThat(Result["properties"]["title"]).Equal(Name); -Token = OPI_GetTestData.GetParameter("Google_Token"); -Name = "TestTable"; + For N = 0 For SheetArray.WithinBoundary() Do + + SheetName = Result["sheets"][N]["properties"]["title"]; + OPI_GetTestData.ExpectsThat(SheetName).Equal(SheetArray[N]); + Sheet = Result["sheets"][N]["properties"]["sheetId"]; + Sheet = OPI_Tools.NumberToString(Sheet); + + EndDo; + + Book = Result["spreadsheetId"]; + + OPI_GetTestData.WriteParameter("GS_Spreadsheet", Book); + OPI_GetTestData.WriteParameter("GS_Sheet" , Sheet); + + Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray); + Book2 = Result["spreadsheetId"]; + + Result = OPI_GoogleSheets.CopySheet(Token, Book, Book2, Sheet); + + // !OInt OPI_GetTestData.WriteLog(Result, "CopySheet"); -SheetArray = New Array; -SheetArray.Add("Sheet1"); -SheetArray.Add("Sheet2"); + OPI_GetTestData.ExpectsThat(Result["title"]).Equal(SheetName + " (toопия)"); + + Name = "TestSheet"; + + Result = OPI_GoogleSheets.AddSheet(Token, Book, Name); + + // !OInt OPI_GetTestData.WriteLog(Result, "AddSheet"); -Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateBook"); - -OPI_GetTestData.ExpectsThat(Result["properties"]["title"]).Equal(Name); - -For N = 0 For SheetArray.WithinBoundary() Do - -SheetName = Result["sheets"][N]["properties"]["title"]; -OPI_GetTestData.ExpectsThat(SheetName).Equal(SheetArray[N]); -Sheet = Result["sheets"][N]["properties"]["sheetId"]; -Sheet = OPI_Tools.NumberToString(Sheet); - -EndDo; - -Book = Result["spreadsheetId"]; - -OPI_GetTestData.WriteParameter("GS_Spreadsheet", Book); -OPI_GetTestData.WriteParameter("GS_Sheet" , Sheet); - -Result = OPI_GoogleSheets.CreateBook(Token, Name, SheetArray); -Book2 = Result["spreadsheetId"]; - -Result = OPI_GoogleSheets.CopySheet(Token, Book, Book2, Sheet); - -// !OInt OPI_GetTestData.WriteLog(Result, "CopySheet"); - -OPI_GetTestData.ExpectsThat(Result["title"]).Equal(SheetName + " (toопия)"); - -Name = "TestSheet"; - -Result = OPI_GoogleSheets.AddSheet(Token, Book, Name); - -// !OInt OPI_GetTestData.WriteLog(Result, "AddSheet"); - -NewSheet = Result["replies"][0]["addSheet"]["properties"]["sheetId"]; -NewSheet = OPI_Tools.NumberToString(NewSheet); - -OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); - -Result = OPI_GoogleSheets.DeleteSheet(Token, Book, NewSheet); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteSheet"); - -OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); - -Name = "TestTable (fromм.)"; - -Result = OPI_GoogleSheets.EditBookTitle(Token, Book, Name); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditBookTitle"); - -OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + NewSheet = Result["replies"][0]["addSheet"]["properties"]["sheetId"]; + NewSheet = OPI_Tools.NumberToString(NewSheet); + + OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + Result = OPI_GoogleSheets.DeleteSheet(Token, Book, NewSheet); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteSheet"); + + OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + + Name = "TestTable (fromм.)"; + + Result = OPI_GoogleSheets.EditBookTitle(Token, Book, Name); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditBookTitle"); + + OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + EndProcedure Procedure GT_GetTable() Export + + Token = OPI_GetTestData.GetParameter("Google_Token"); + Book = OPI_GetTestData.GetParameter("GS_Spreadsheet"); + Name = "TestTable (fromм.)"; -Token = OPI_GetTestData.GetParameter("Google_Token"); -Book = OPI_GetTestData.GetParameter("GS_Spreadsheet"); -Name = "TestTable (fromм.)"; - -Result = OPI_GoogleSheets.GetBook(Token, Book); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetTable"); - -OPI_GetTestData.ExpectsThat(Result["properties"]["title"]).Equal(Name); + Result = OPI_GoogleSheets.GetBook(Token, Book); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetTable"); + + OPI_GetTestData.ExpectsThat(Result["properties"]["title"]).Equal(Name); EndProcedure Procedure GT_FillClearCells() Export + + Token = OPI_GetTestData.GetParameter("Google_Token"); + Book = OPI_GetTestData.GetParameter("GS_Spreadsheet"); + Sheet = "Sheet2"; -Token = OPI_GetTestData.GetParameter("Google_Token"); -Book = OPI_GetTestData.GetParameter("GS_Spreadsheet"); -Sheet = "Sheet2"; + CellStructure = New Match; + CellStructure.Insert("A1", "ThisIsA1"); + CellStructure.Insert("A2", "ThisIsA2"); + CellStructure.Insert("B2", "ThisIsB2"); + CellStructure.Insert("B3", "ThisIsB3"); + CellStructure.Insert("A3", "ThisIsA3"); + CellStructure.Insert("A4", "ThisIsA4"); + CellStructure.Insert("B1", "ThisIsB1"); + CellStructure.Insert("B4", "ThisIsB4"); + + Cell array = New Array; + Cell array.Add("B2"); + Cell array.Add("A3"); + Cell array.Add("B4"); -CellStructure = New Match; -CellStructure.Insert("A1", "ThisIsA1"); -CellStructure.Insert("A2", "ThisIsA2"); -CellStructure.Insert("B2", "ThisIsB2"); -CellStructure.Insert("B3", "ThisIsB3"); -CellStructure.Insert("A3", "ThisIsA3"); -CellStructure.Insert("A4", "ThisIsA4"); -CellStructure.Insert("B1", "ThisIsB1"); -CellStructure.Insert("B4", "ThisIsB4"); + Result = OPI_GoogleSheets.SetCellValues(Token, Book, CellStructure, Sheet); + + // !OInt OPI_GetTestData.WriteLog(Result, "SetCellValues"); + + OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + OPI_GetTestData.ExpectsThat(Result["totalUpdatedCells"]).Equal(CellStructure.Quantity()); + + Result = OPI_GoogleSheets.GetCellValues(Token, Book, Cell array, Sheet); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetCellValues"); + + OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + OPI_GetTestData.ExpectsThat(Result["valueRanges"].Quantity()).Equal(Cell array.Quantity()); + + Result = OPI_GoogleSheets.GetCellValues(Token, Book, , Sheet); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetCellValues"); + + OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + + Cell array = New Array; + Cell array.Add("B2"); + Cell array.Add("A3"); + Cell array.Add("B4"); -Cell array = New Array; -Cell array.Add("B2"); -Cell array.Add("A3"); -Cell array.Add("B4"); - -Result = OPI_GoogleSheets.SetCellValues(Token, Book, CellStructure, Sheet); - -// !OInt OPI_GetTestData.WriteLog(Result, "SetCellValues"); - -OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); -OPI_GetTestData.ExpectsThat(Result["totalUpdatedCells"]).Equal(CellStructure.Quantity()); - -Result = OPI_GoogleSheets.GetCellValues(Token, Book, Cell array, Sheet); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetCellValues"); - -OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); -OPI_GetTestData.ExpectsThat(Result["valueRanges"].Quantity()).Equal(Cell array.Quantity()); - -Result = OPI_GoogleSheets.GetCellValues(Token, Book, , Sheet); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetCellValues"); - -OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); - -Cell array = New Array; -Cell array.Add("B2"); -Cell array.Add("A3"); -Cell array.Add("B4"); - -Result = OPI_GoogleSheets.ClearCells(Token, Book, Cell array, Sheet); - -// !OInt OPI_GetTestData.WriteLog(Result, "ClearCells"); - -OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); -OPI_GetTestData.ExpectsThat(Result["clearedRanges"].Quantity()).Equal(Cell array.Quantity()); + Result = OPI_GoogleSheets.ClearCells(Token, Book, Cell array, Sheet); + + // !OInt OPI_GetTestData.WriteLog(Result, "ClearCells"); + + OPI_GetTestData.ExpectsThat(Result["spreadsheetId"]).Equal(Book); + OPI_GetTestData.ExpectsThat(Result["clearedRanges"].Quantity()).Equal(Cell array.Quantity()); EndProcedure @@ -2058,151 +2058,151 @@ EndProcedure #Region Twitter Procedure Twitter_GetAuthorizationLink() Export - -Parameters = GetTwitterParameters(); -Result = OPI_Twitter.GetAuthorizationLink(Parameters); - -OPI_GetTestData.ExpectsThat(Result).HasType("String").Filled(); - -OPI_GetTestData.WriteParameter("Twitter_URL", Result); - -OPI_Tools.Pause(5); - + + Parameters = GetTwitterParameters(); + Result = OPI_Twitter.GetAuthorizationLink(Parameters); + + OPI_GetTestData.ExpectsThat(Result).HasType("String").Filled(); + + OPI_GetTestData.WriteParameter("Twitter_URL", Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Twitter_UpdateToken() Export - -Parameters = GetTwitterParameters(); -Result = OPI_Twitter.RefreshToken(Parameters); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["access_token"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["refresh_token"]).Filled(); - -Refresh = Result["refresh_token"]; -Token = Result["access_token"]; - -If ValueIsFilled(Refresh) And Not Refresh = "null" Then -OPI_GetTestData.WriteParameter("Twitter_Refresh", Refresh); -EndIf; - -If ValueIsFilled(Token) And Not Token = "null" Then -OPI_GetTestData.WriteParameter("Twitter_Token" , Token); -EndIf; - -OPI_Tools.Pause(5); - + + Parameters = GetTwitterParameters(); + Result = OPI_Twitter.RefreshToken(Parameters); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["access_token"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["refresh_token"]).Filled(); + + Refresh = Result["refresh_token"]; + Token = Result["access_token"]; + + If ValueIsFilled(Refresh) And Not Refresh = "null" Then + OPI_GetTestData.WriteParameter("Twitter_Refresh", Refresh); + EndIf; + + If ValueIsFilled(Token) And Not Token = "null" Then + OPI_GetTestData.WriteParameter("Twitter_Token" , Token); + EndIf; + + OPI_Tools.Pause(5); + EndProcedure Procedure Twitter_CreateTextTweet() Export - -Parameters = GetTwitterParameters(); -Text = "TestTweet" + String(New UniqueIdentifier); - -Result = OPI_Twitter.CreateTextTweet(Text, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateTextTweet"); - -Check_TwitterText(Result, Text); - -OPI_Tools.Pause(5); - + + Parameters = GetTwitterParameters(); + Text = "TestTweet" + String(New UniqueIdentifier); + + Result = OPI_Twitter.CreateTextTweet(Text, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateTextTweet"); + + Check_TwitterText(Result, Text); + + OPI_Tools.Pause(5); + EndProcedure Procedure Twitter_CreateTweetWithImage() Export - -Parameters = GetTwitterParameters(); -Text = "TestTweet" + String(New UniqueIdentifier); -Image = OPI_GetTestData.GetBinary("Picture"); -AndVF = GetTempFileName("png"); -Image.Write(AndVF); - -Result = OPI_Twitter.Create image tweet(Text, Image, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "Create image tweet"); - -Check_TwitterText(Result, Text); - -Result = OPI_Twitter.Create image tweet(Text, AndVF, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "Create image tweet"); - -Check_TwitterText(Result, Text); - -DeleteFiles(AndVF); - -OPI_Tools.Pause(20); - + + Parameters = GetTwitterParameters(); + Text = "TestTweet" + String(New UniqueIdentifier); + Image = OPI_GetTestData.GetBinary("Picture"); + AndVF = GetTempFileName("png"); + Image.Write(AndVF); + + Result = OPI_Twitter.Create image tweet(Text, Image, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "Create image tweet"); + + Check_TwitterText(Result, Text); + + Result = OPI_Twitter.Create image tweet(Text, AndVF, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "Create image tweet"); + + Check_TwitterText(Result, Text); + + DeleteFiles(AndVF); + + OPI_Tools.Pause(20); + EndProcedure Procedure Twitter_CreateTweetWithVideo() Export - -Parameters = GetTwitterParameters(); -Text = "TestTweet" + String(New UniqueIdentifier); -Video = OPI_GetTestData.GetBinary("Video"); -AndVF = GetTempFileName("mp4"); -Video.Write(AndVF); - -Result = OPI_Twitter.CreateVideoTweet(Text, Video, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateVideoTweet"); - -Check_TwitterText(Result, Text); - -Result = OPI_Twitter.CreateVideoTweet(Text, AndVF, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateVideoTweet"); - -Check_TwitterText(Result, Text); - -DeleteFiles(AndVF); - -OPI_Tools.Pause(20); - + + Parameters = GetTwitterParameters(); + Text = "TestTweet" + String(New UniqueIdentifier); + Video = OPI_GetTestData.GetBinary("Video"); + AndVF = GetTempFileName("mp4"); + Video.Write(AndVF); + + Result = OPI_Twitter.CreateVideoTweet(Text, Video, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateVideoTweet"); + + Check_TwitterText(Result, Text); + + Result = OPI_Twitter.CreateVideoTweet(Text, AndVF, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateVideoTweet"); + + Check_TwitterText(Result, Text); + + DeleteFiles(AndVF); + + OPI_Tools.Pause(20); + EndProcedure Procedure Twitter_CreateTweetWithGif() Export - -Parameters = GetTwitterParameters(); -Text = "TestTweet" + String(New UniqueIdentifier); -GIF = OPI_GetTestData.GetBinary("GIF"); -AndVF = GetTempFileName("gif"); -GIF.Write(AndVF); - -Result = OPI_Twitter.CreateGifTweet(Text, GIF, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateGifTweet"); - -Check_TwitterText(Result, Text); - -Result = OPI_Twitter.CreateGifTweet(Text, AndVF, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateGifTweet"); - -Check_TwitterText(Result, Text); - -DeleteFiles(AndVF); - -OPI_Tools.Pause(20); - + + Parameters = GetTwitterParameters(); + Text = "TestTweet" + String(New UniqueIdentifier); + GIF = OPI_GetTestData.GetBinary("GIF"); + AndVF = GetTempFileName("gif"); + GIF.Write(AndVF); + + Result = OPI_Twitter.CreateGifTweet(Text, GIF, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateGifTweet"); + + Check_TwitterText(Result, Text); + + Result = OPI_Twitter.CreateGifTweet(Text, AndVF, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateGifTweet"); + + Check_TwitterText(Result, Text); + + DeleteFiles(AndVF); + + OPI_Tools.Pause(20); + EndProcedure Procedure Twitter_CreateTweetWithPoll() Export - -Parameters = GetTwitterParameters(); -Text = "TestTweet" + String(New UniqueIdentifier); -AnswersArray = New Array; -AnswersArray.Add("Option 1"); -AnswersArray.Add("Option 2"); - -Result = OPI_Twitter.CreatePollTweet(Text, AnswersArray, 60, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePollTweet"); - -Check_TwitterText(Result, Text); - -OPI_Tools.Pause(20); - + + Parameters = GetTwitterParameters(); + Text = "TestTweet" + String(New UniqueIdentifier); + AnswersArray = New Array; + AnswersArray.Add("Option 1"); + AnswersArray.Add("Option 2"); + + Result = OPI_Twitter.CreatePollTweet(Text, AnswersArray, 60, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePollTweet"); + + Check_TwitterText(Result, Text); + + OPI_Tools.Pause(20); + EndProcedure #EndRegion @@ -2210,203 +2210,203 @@ EndProcedure #Region Notion Procedure Notion_CreatePage() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Parent = OPI_GetTestData.GetParameter("Notion_Parent"); -Title = "TestTitle"; - -Result = OPI_Notion.CreatePage(Token, Parent, Title); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePage"); - -Check_NotionObject(Result); + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Parent = OPI_GetTestData.GetParameter("Notion_Parent"); + Title = "TestTitle"; + + Result = OPI_Notion.CreatePage(Token, Parent, Title); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePage"); + + Check_NotionObject(Result); EndProcedure Procedure Notion_CreateEditDatabase() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Parent = OPI_GetTestData.GetParameter("Notion_Parent"); -Title = "TestTitle"; - -Properties = New Match; -Properties.Insert("Name" , "title"); -Properties.Insert("Description" , "rich_text"); -Properties.Insert("Number" , "number"); -Properties.Insert("Status" , "status"); -Properties.Insert("CreationDate" , "date"); -Properties.Insert("Image" , "files"); -Properties.Insert("Active" , "checkbox"); -Properties.Insert("Website" , "url"); -Properties.Insert("Email" , "email"); -Properties.Insert("Phone" , "phone_number"); -Properties.Insert("User" , "people"); - -ValueSelection = New Match; -ValueSelection.Insert("New", "green"); -ValueSelection.Insert("InProgress", "yellow"); -ValueSelection.Insert("Remote", "red"); -Properties.Insert("Status", ValueSelection); - -Result = OPI_Notion.CreateDatabase(Token, Parent, Title, Properties); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateDatabase"); - -Check_NotionObject(Result, "database"); - -Base = Result["id"]; -Title = "TestTitle"; -Description = "TestDescription"; - -Properties = New Match; -Properties.Insert("Email", "rich_text"); // Type fields "Email" will changed with email to text -Properties.Insert("Website"); // Field "Website" will deleted - -Result = OPI_Notion.EditDatabaseProperties(Token, Base, Properties, Title, Description); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditDatabaseProperties"); - -Check_NotionObject(Result, "database"); + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Parent = OPI_GetTestData.GetParameter("Notion_Parent"); + Title = "TestTitle"; + + Properties = New Match; + Properties.Insert("Name" , "title"); + Properties.Insert("Description" , "rich_text"); + Properties.Insert("Number" , "number"); + Properties.Insert("Status" , "status"); + Properties.Insert("CreationDate" , "date"); + Properties.Insert("Image" , "files"); + Properties.Insert("Active" , "checkbox"); + Properties.Insert("Website" , "url"); + Properties.Insert("Email" , "email"); + Properties.Insert("Phone" , "phone_number"); + Properties.Insert("User" , "people"); + + ValueSelection = New Match; + ValueSelection.Insert("New", "green"); + ValueSelection.Insert("InProgress", "yellow"); + ValueSelection.Insert("Remote", "red"); + Properties.Insert("Status", ValueSelection); + + Result = OPI_Notion.CreateDatabase(Token, Parent, Title, Properties); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateDatabase"); + + Check_NotionObject(Result, "database"); + + Base = Result["id"]; + Title = "TestTitle"; + Description = "TestDescription"; + + Properties = New Match; + Properties.Insert("Email", "rich_text"); // Type fields "Email" will changed with email to text + Properties.Insert("Website"); // Field "Website" will deleted + + Result = OPI_Notion.EditDatabaseProperties(Token, Base, Properties, Title, Description); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditDatabaseProperties"); + + Check_NotionObject(Result, "database"); EndProcedure Procedure Notion_GetPageInfo() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Page = OPI_GetTestData.GetParameter("Notion_Page"); - -Result = OPI_Notion.GetPage(Token, Page); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetPage"); - -Check_NotionObject(Result); - + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Page = OPI_GetTestData.GetParameter("Notion_Page"); + + Result = OPI_Notion.GetPage(Token, Page); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetPage"); + + Check_NotionObject(Result); + EndProcedure Procedure Notion_GetDatabaseInfo() Export -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Base = OPI_GetTestData.GetParameter("Notion_Base"); - -Result = OPI_Notion.GetDatabase(Token, Base); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetDatabase"); - -Check_NotionObject(Result, "database"); - + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Base = OPI_GetTestData.GetParameter("Notion_Base"); + + Result = OPI_Notion.GetDatabase(Token, Base); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetDatabase"); + + Check_NotionObject(Result, "database"); + EndProcedure Procedure Notion_CreatePageInDatabase() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Base = OPI_GetTestData.GetParameter("Notion_Base"); - -Image = New Match; -Image.Insert("Logo", OPI_GetTestData.GetParameter("Picture")); - -Properties = New Match; -Properties.Insert("Name" , "LLC Vector"); -Properties.Insert("Description" , "OurFirstClient"); -Properties.Insert("Number" , 1); -Properties.Insert("Status" , "Regular"); -Properties.Insert("CreationDate" , OPI_Tools.GetCurrentDate()); -Properties.Insert("Image" , Image); -Properties.Insert("Active" , True); -Properties.Insert("Website" , "https://vector.ru"); -Properties.Insert("Email" , "mail@vector.ru"); -Properties.Insert("Phone" , "88005553535"); -Properties.Insert("Status" , "New"); - -Result = OPI_Notion.CreatePageInDatabase(Token, Base, Properties); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePageInDatabase"); - -Check_NotionObject(Result); - -Parent = StringReplace(Result["parent"]["database_id"], "-", ""); -OPI_GetTestData.ExpectsThat(Parent).Equal(Base); - + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Base = OPI_GetTestData.GetParameter("Notion_Base"); + + Image = New Match; + Image.Insert("Logo", OPI_GetTestData.GetParameter("Picture")); + + Properties = New Match; + Properties.Insert("Name" , "LLC Vector"); + Properties.Insert("Description" , "OurFirstClient"); + Properties.Insert("Number" , 1); + Properties.Insert("Status" , "Regular"); + Properties.Insert("CreationDate" , OPI_Tools.GetCurrentDate()); + Properties.Insert("Image" , Image); + Properties.Insert("Active" , True); + Properties.Insert("Website" , "https://vector.ru"); + Properties.Insert("Email" , "mail@vector.ru"); + Properties.Insert("Phone" , "88005553535"); + Properties.Insert("Status" , "New"); + + Result = OPI_Notion.CreatePageInDatabase(Token, Base, Properties); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePageInDatabase"); + + Check_NotionObject(Result); + + Parent = StringReplace(Result["parent"]["database_id"], "-", ""); + OPI_GetTestData.ExpectsThat(Parent).Equal(Base); + EndProcedure Procedure Notion_EditPageProperties() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Page = OPI_GetTestData.GetParameter("Notion_Page"); -Icon = OPI_GetTestData.GetParameter("Picture"); -Cover = OPI_GetTestData.GetParameter("Picture2"); -Archive = False; - -Properties = New Match; -Properties.Insert("Active" , False); -Properties.Insert("Email" , "vector@mail.ru"); - -Result = OPI_Notion.EditPageProperties(Token -, Page -, Properties -, Icon -, Cover -, Archive); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditPageProperties"); - -Check_NotionObject(Result); - + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Page = OPI_GetTestData.GetParameter("Notion_Page"); + Icon = OPI_GetTestData.GetParameter("Picture"); + Cover = OPI_GetTestData.GetParameter("Picture2"); + Archive = False; + + Properties = New Match; + Properties.Insert("Active" , False); + Properties.Insert("Email" , "vector@mail.ru"); + + Result = OPI_Notion.EditPageProperties(Token + , Page + , Properties + , Icon + , Cover + , Archive); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditPageProperties"); + + Check_NotionObject(Result); + EndProcedure Procedure Notion_CreateDeleteBlock() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Parent = OPI_GetTestData.GetParameter("Notion_Parent"); -Block = OPI_GetTestData.GetParameter("Notion_Block"); - -Result = OPI_Notion.ReturnBlock(Token, Block); - -// !OInt OPI_GetTestData.WriteLog(Result, "ReturnBlock"); - -Check_NotionObject(Result, "block"); - -Result = OPI_Notion.CreateBlock(Token, Parent, Result); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateBlock"); - -Check_NotionObject(Result, "list"); - -Block = Result["results"][0]["id"]; -Result = OPI_Notion.ReturnChildBlocks(Token, Block); - -// !OInt OPI_GetTestData.WriteLog(Result, "ReturnChildBlocks"); - -Check_NotionObject(Result, "list"); - -Result = OPI_Notion.DeleteBlock(Token, Block); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteBlock"); - -Check_NotionObject(Result, "block"); - + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Parent = OPI_GetTestData.GetParameter("Notion_Parent"); + Block = OPI_GetTestData.GetParameter("Notion_Block"); + + Result = OPI_Notion.ReturnBlock(Token, Block); + + // !OInt OPI_GetTestData.WriteLog(Result, "ReturnBlock"); + + Check_NotionObject(Result, "block"); + + Result = OPI_Notion.CreateBlock(Token, Parent, Result); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateBlock"); + + Check_NotionObject(Result, "list"); + + Block = Result["results"][0]["id"]; + Result = OPI_Notion.ReturnChildBlocks(Token, Block); + + // !OInt OPI_GetTestData.WriteLog(Result, "ReturnChildBlocks"); + + Check_NotionObject(Result, "list"); + + Result = OPI_Notion.DeleteBlock(Token, Block); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteBlock"); + + Check_NotionObject(Result, "block"); + EndProcedure Procedure Notion_GetUsers() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -Result = OPI_Notion.UserList(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "UserList"); - -Check_NotionObject(Result, "list"); - + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + Result = OPI_Notion.UserList(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "UserList"); + + Check_NotionObject(Result, "list"); + EndProcedure Procedure Notion_GetUserData() Export - -Token = OPI_GetTestData.GetParameter("Notion_Token"); -User = OPI_GetTestData.GetParameter("Notion_User"); -Result = OPI_Notion.GetUserData(Token, User); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetUserData"); - -Check_NotionObject(Result, "user"); - + + Token = OPI_GetTestData.GetParameter("Notion_Token"); + User = OPI_GetTestData.GetParameter("Notion_User"); + Result = OPI_Notion.GetUserData(Token, User); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetUserData"); + + Check_NotionObject(Result, "user"); + EndProcedure #EndRegion @@ -2414,496 +2414,496 @@ EndProcedure #Region Slack Procedure Slack_GetBotInfo() Export - -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Result = OPI_Slack.GetBotInformation(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetBotInformation"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["bot_id"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["user_id"]).Filled(); - + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Result = OPI_Slack.GetBotInformation(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetBotInformation"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["bot_id"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["user_id"]).Filled(); + EndProcedure Procedure Slack_GetUserList() Export - -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Result = OPI_Slack.GetUserList(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetUserList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["members"]).HasType("Array"); - + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Result = OPI_Slack.GetUserList(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetUserList"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["members"]).HasType("Array"); + EndProcedure Procedure Slack_GetRegionList() Export - -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Result = OPI_Slack.GetWorkspaceList(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetWorkspaceList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["teams"]).HasType("Array"); - + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Result = OPI_Slack.GetWorkspaceList(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetWorkspaceList"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["teams"]).HasType("Array"); + EndProcedure Procedure Slack_SendDeleteMessage() Export -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Channel = OPI_GetTestData.GetParameter("Slack_Channel"); -Text = "TestMessage1"; -Text2 = "TestMessage2"; -Tags = New Array; -Image = "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/Media/logo.png?v1"; + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Channel = OPI_GetTestData.GetParameter("Slack_Channel"); + Text = "TestMessage1"; + Text2 = "TestMessage2"; + Tags = New Array; + Image = "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/Media/logo.png?v1"; + + Result = OPI_Slack.SendMessage(Token, Channel, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMessage"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["message"]["text"]).Equal(Text); + + Timestamp = Result["ts"]; + + Result = OPI_Slack.EditMessage(Token, Channel, Timestamp, Text2); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditMessage"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["message"]["text"]).Equal(Text2); + + Result = OPI_Slack.GetMessageReplyList(Token, Channel, Timestamp); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetMessageReplyList"); + + OPI_GetTestData.ExpectsThat(Result["messages"]).HasType("Array"); + + Result = OPI_Slack.GetMessageLink(Token, Channel, Timestamp); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetMessageLink"); + + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["permalink"]).Filled(); + + Check_SlackOk(Result); + + Tags.Add(Timestamp); + + BlockArray = New Array; + Block = OPI_Slack.GenerateImageBlock(Image, "Yo"); + BlockArray.Add(Block); + + Result = OPI_Slack.SendMessage(Token, Channel, Text, , BlockArray); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (toартинtoа)"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); + + Tags.Add(Result["ts"]); + + Block = OPI_Slack.GenerateImageBlock(Image, "Yo"); + JSONBlock = OPI_Tools.JSONString(Block); + + AndVF = GetTempFileName("json"); + + TextDocument = New TextDocument(); + TextDocument.SetText(JSONBlock); + TextDocument.Write(AndVF); + + Result = OPI_Slack.SendMessage(Token, Channel, Text, , AndVF); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (json)"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); + + Tags.Add(Result["ts"]); + + Blocks = "['" + AndVF + "','" + AndVF + "']"; + Result = OPI_Slack.SendMessage(Token, Channel, Text, , Blocks); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (json маwithwithиin)"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); + + Tags.Add(Result["ts"]); -Result = OPI_Slack.SendMessage(Token, Channel, Text); + DeleteFiles(AndVF); + + For Each Timestamp In Tags Do + + Result = OPI_Slack.DeleteMessage(Token, Channel, Timestamp); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteMessage"); -// !OInt OPI_GetTestData.WriteLog(Result, "SendMessage"); + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); + + EndDo; + + Hour = 3600; + Day = 24; + Sending = OPI_Tools.GetCurrentDate() + (Day * Hour); + Result = OPI_Slack.SendMessage(Token, Channel, Text, Sending); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (отложенное)"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); + OPI_GetTestData.ExpectsThat(Result["scheduled_message_id"]).Filled(); + + Timestamp = Result["scheduled_message_id"]; + Result = OPI_Slack.DeleteMessage(Token, Channel, Timestamp, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteMessage"); -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["message"]["text"]).Equal(Text); - -Timestamp = Result["ts"]; - -Result = OPI_Slack.EditMessage(Token, Channel, Timestamp, Text2); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditMessage"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["message"]["text"]).Equal(Text2); - -Result = OPI_Slack.GetMessageReplyList(Token, Channel, Timestamp); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetMessageReplyList"); - -OPI_GetTestData.ExpectsThat(Result["messages"]).HasType("Array"); - -Result = OPI_Slack.GetMessageLink(Token, Channel, Timestamp); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetMessageLink"); - -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["permalink"]).Filled(); - -Check_SlackOk(Result); - -Tags.Add(Timestamp); - -BlockArray = New Array; -Block = OPI_Slack.GenerateImageBlock(Image, "Yo"); -BlockArray.Add(Block); - -Result = OPI_Slack.SendMessage(Token, Channel, Text, , BlockArray); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (toартинtoа)"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); - -Tags.Add(Result["ts"]); - -Block = OPI_Slack.GenerateImageBlock(Image, "Yo"); -JSONBlock = OPI_Tools.JSONString(Block); - -AndVF = GetTempFileName("json"); - -TextDocument = New TextDocument(); -TextDocument.SetText(JSONBlock); -TextDocument.Write(AndVF); - -Result = OPI_Slack.SendMessage(Token, Channel, Text, , AndVF); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (json)"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); - -Tags.Add(Result["ts"]); - -Blocks = "['" + AndVF + "','" + AndVF + "']"; -Result = OPI_Slack.SendMessage(Token, Channel, Text, , Blocks); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (json маwithwithиin)"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); - -Tags.Add(Result["ts"]); - -DeleteFiles(AndVF); - -For Each Timestamp In Tags Do - -Result = OPI_Slack.DeleteMessage(Token, Channel, Timestamp); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteMessage"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["ts"]).Filled(); - -EndDo; - -Hour = 3600; -Day = 24; -Sending = OPI_Tools.GetCurrentDate() + (Day * Hour); -Result = OPI_Slack.SendMessage(Token, Channel, Text, Sending); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendMessage (отложенное)"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).Equal(Channel); -OPI_GetTestData.ExpectsThat(Result["scheduled_message_id"]).Filled(); - -Timestamp = Result["scheduled_message_id"]; -Result = OPI_Slack.DeleteMessage(Token, Channel, Timestamp, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteMessage"); - -Check_SlackOk(Result); + Check_SlackOk(Result); EndProcedure Procedure Slack_SendDeleteEphemeral() Export - -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Channel = OPI_GetTestData.GetParameter("Slack_Channel"); -User = OPI_GetTestData.GetParameter("Slack_User"); -Image = "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/Media/logo.png?v1"; -Text = "TestMessage1"; - -Block = OPI_Slack.GenerateImageBlock(Image, "Yo"); -Result = OPI_Slack.SendEphemeralMessage(Token, Channel, Text, User, Block); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendMessage"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["message_ts"]).Filled(); - + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Channel = OPI_GetTestData.GetParameter("Slack_Channel"); + User = OPI_GetTestData.GetParameter("Slack_User"); + Image = "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/Media/logo.png?v1"; + Text = "TestMessage1"; + + Block = OPI_Slack.GenerateImageBlock(Image, "Yo"); + Result = OPI_Slack.SendEphemeralMessage(Token, Channel, Text, User, Block); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMessage"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["message_ts"]).Filled(); + EndProcedure Procedure Slack_GetScheduledMessages() Export - -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Channel = OPI_GetTestData.GetParameter("Slack_Channel"); - -Result = OPI_Slack.GetDelayedMessageList(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetDelayedMessageList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["scheduled_messages"]).HasType("Array"); - + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Channel = OPI_GetTestData.GetParameter("Slack_Channel"); + + Result = OPI_Slack.GetDelayedMessageList(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetDelayedMessageList"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["scheduled_messages"]).HasType("Array"); + EndProcedure Procedure Slack_CreateArchiveChannel() Export + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + User = OPI_GetTestData.GetParameter("Slack_User"); + Name = "testconv" + String(New UniqueIdentifier); + Topic = "TestTopic"; + Purpose = "TestGoal"; + + #Region CreateChannel + Result = OPI_Slack.CreateChannel(Token, Name); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateChannel"); + + Data = Result["channel"]; + Channel = Data["id"]; -Token = OPI_GetTestData.GetParameter("Slack_Token"); -User = OPI_GetTestData.GetParameter("Slack_User"); -Name = "testconv" + String(New UniqueIdentifier); -Topic = "TestTopic"; -Purpose = "TestGoal"; + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); + #EndRegion -#Region CreateChannel -Result = OPI_Slack.CreateChannel(Token, Name); + #Region SetChannelTopic + Result = OPI_Slack.SetChannelTopic(Token, Channel, Topic); + + // !OInt OPI_GetTestData.WriteLog(Result, "SetChannelTopic"); + + Data = Result["channel"]; + Channel = Data["id"]; -// !OInt OPI_GetTestData.WriteLog(Result, "CreateChannel"); + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); + OPI_GetTestData.ExpectsThat(Data["topic"]["value"]).Equal(Topic); + #EndRegion + + #Region SetChannelGoal + Result = OPI_Slack.SetChannelGoal(Token, Channel, Purpose); + + // !OInt OPI_GetTestData.WriteLog(Result, "SetChannelGoal"); + + Check_SlackOk(Result); + #EndRegion + + #Region GetChannel + Result = OPI_Slack.GetChannel(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetChannel"); + + Data = Result["channel"]; + Channel = Data["id"]; -Data = Result["channel"]; -Channel = Data["id"]; + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); + #EndRegion + + #Region InviteUsersToChannel + Result = OPI_Slack.InviteUsersToChannel(Token, Channel, User); + + // !OInt OPI_GetTestData.WriteLog(Result, "InviteUsersToChannel"); + + Data = Result["channel"]; + Channel = Data["id"]; -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); -#EndRegion + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); + #EndRegion + + #Region KickUserFromChannel + Result = OPI_Slack.KickUserFromChannel(Token, Channel, User); + + // !OInt OPI_GetTestData.WriteLog(Result, "KickUserFromChannel"); + + Check_SlackOk(Result); + #EndRegion + + #Region GetChannelHistory + Result = OPI_Slack.GetChannelHistory(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetChannelHistory"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["messages"]).HasType("Array"); + #EndRegion + + #Region GetChannelUserList + Result = OPI_Slack.GetChannelUserList(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetChannelUserList"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["members"]).HasType("Array"); + #EndRegion -#Region SetChannelTopic -Result = OPI_Slack.SetChannelTopic(Token, Channel, Topic); + #Region LeaveChannel + Result = OPI_Slack.LeaveChannel(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "LeaveChannel"); + + Check_SlackOk(Result); + #EndRegion + + #Region JoinChannel + Result = OPI_Slack.JoinChannel(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "JoinChannel"); + + Data = Result["channel"]; + Channel = Data["id"]; -// !OInt OPI_GetTestData.WriteLog(Result, "SetChannelTopic"); - -Data = Result["channel"]; -Channel = Data["id"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); -OPI_GetTestData.ExpectsThat(Data["topic"]["value"]).Equal(Topic); -#EndRegion - -#Region SetChannelGoal -Result = OPI_Slack.SetChannelGoal(Token, Channel, Purpose); - -// !OInt OPI_GetTestData.WriteLog(Result, "SetChannelGoal"); - -Check_SlackOk(Result); -#EndRegion - -#Region GetChannel -Result = OPI_Slack.GetChannel(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetChannel"); - -Data = Result["channel"]; -Channel = Data["id"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); -#EndRegion - -#Region InviteUsersToChannel -Result = OPI_Slack.InviteUsersToChannel(Token, Channel, User); - -// !OInt OPI_GetTestData.WriteLog(Result, "InviteUsersToChannel"); - -Data = Result["channel"]; -Channel = Data["id"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); -#EndRegion - -#Region KickUserFromChannel -Result = OPI_Slack.KickUserFromChannel(Token, Channel, User); - -// !OInt OPI_GetTestData.WriteLog(Result, "KickUserFromChannel"); - -Check_SlackOk(Result); -#EndRegion - -#Region GetChannelHistory -Result = OPI_Slack.GetChannelHistory(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetChannelHistory"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["messages"]).HasType("Array"); -#EndRegion - -#Region GetChannelUserList -Result = OPI_Slack.GetChannelUserList(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetChannelUserList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["members"]).HasType("Array"); -#EndRegion - -#Region LeaveChannel -Result = OPI_Slack.LeaveChannel(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "LeaveChannel"); - -Check_SlackOk(Result); -#EndRegion - -#Region JoinChannel -Result = OPI_Slack.JoinChannel(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "JoinChannel"); - -Data = Result["channel"]; -Channel = Data["id"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); -#EndRegion - -#Region RenameChannel -NewName = "testconv" + String(New UniqueIdentifier); -Result = OPI_Slack.RenameChannel(Token, Channel, NewName); - -// !OInt OPI_GetTestData.WriteLog(Result, "RenameChannel"); - -Data = Result["channel"]; -Channel = Data["id"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Data["name"]).Equal(NewName); -#EndRegion - -#Region ArchiveChannel -Result = OPI_Slack.ArchiveChannel(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "ArchiveChannel"); - -Check_SlackOk(Result); -#EndRegion + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Data["name"]).Equal(Name); + #EndRegion + + #Region RenameChannel + NewName = "testconv" + String(New UniqueIdentifier); + Result = OPI_Slack.RenameChannel(Token, Channel, NewName); + + // !OInt OPI_GetTestData.WriteLog(Result, "RenameChannel"); + + Data = Result["channel"]; + Channel = Data["id"]; + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Data["name"]).Equal(NewName); + #EndRegion + + #Region ArchiveChannel + Result = OPI_Slack.ArchiveChannel(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "ArchiveChannel"); + + Check_SlackOk(Result); + #EndRegion + EndProcedure Procedure Slack_GetChannelList() Export + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + + Result = OPI_Slack.GetChannelList(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetChannelList"); -Token = OPI_GetTestData.GetParameter("Slack_Token"); - -Result = OPI_Slack.GetChannelList(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetChannelList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channels"]).HasType("Array"); - + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channels"]).HasType("Array"); + EndProcedure Procedure Slack_OpenCloseDialog() Export + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + User = OPI_GetTestData.GetParameter("Slack_User"); + Text = "Yo, dude"; + + Result = OPI_Slack.OpenDialog(Token, User); + + // !OInt OPI_GetTestData.WriteLog(Result, "OpenDialog"); -Token = OPI_GetTestData.GetParameter("Slack_Token"); -User = OPI_GetTestData.GetParameter("Slack_User"); -Text = "Yo, dude"; + Dialog = Result["channel"]["id"]; + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["channel"]).HasType("Match"); + OPI_GetTestData.ExpectsThat(Dialog).Filled(); + + Result = OPI_Slack.SendMessage(Token, Dialog, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMessage"); + + Check_SlackOk(Result); -Result = OPI_Slack.OpenDialog(Token, User); + Result = OPI_Slack.CloseDialog(Token, Dialog); + + // !OInt OPI_GetTestData.WriteLog(Result, "CloseDialog"); -// !OInt OPI_GetTestData.WriteLog(Result, "OpenDialog"); - -Dialog = Result["channel"]["id"]; -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["channel"]).HasType("Match"); -OPI_GetTestData.ExpectsThat(Dialog).Filled(); - -Result = OPI_Slack.SendMessage(Token, Dialog, Text); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendMessage"); - -Check_SlackOk(Result); - -Result = OPI_Slack.CloseDialog(Token, Dialog); - -// !OInt OPI_GetTestData.WriteLog(Result, "CloseDialog"); - -Check_SlackOk(Result); + Check_SlackOk(Result); EndProcedure Procedure Slack_GetFileList() Export + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Channel = OPI_GetTestData.GetParameter("Slack_Channel"); + + Result = OPI_Slack.GetFilesList(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetFilesList"); -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Channel = OPI_GetTestData.GetParameter("Slack_Channel"); - -Result = OPI_Slack.GetFilesList(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetFilesList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); EndProcedure Procedure Slack_UploadDeleteFile() Export + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + File = OPI_GetTestData.GetBinary("Document"); + Channel = OPI_GetTestData.GetParameter("Slack_Channel"); + ArrayOfFiles = New Array; + FileName = "megadoc.docx"; + Title = "NewFile"; + + Result = OPI_Slack.UploadFile(Token, File, FileName, Title); + + // !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); -Token = OPI_GetTestData.GetParameter("Slack_Token"); -File = OPI_GetTestData.GetBinary("Document"); -Channel = OPI_GetTestData.GetParameter("Slack_Channel"); -ArrayOfFiles = New Array; -FileName = "megadoc.docx"; -Title = "NewFile"; + UploadedFile = Result["files"][0]; + ArrayOfFiles.Add(UploadedFile["id"]); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(UploadedFile["name"]).Equal(FileName); + + Result = OPI_Slack.UploadFile(Token, File, FileName, Title, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "UploadFile (in toаtoл)"); -Result = OPI_Slack.UploadFile(Token, File, FileName, Title); - -// !OInt OPI_GetTestData.WriteLog(Result, "UploadFile"); - -UploadedFile = Result["files"][0]; -ArrayOfFiles.Add(UploadedFile["id"]); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(UploadedFile["name"]).Equal(FileName); - -Result = OPI_Slack.UploadFile(Token, File, FileName, Title, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "UploadFile (in toаtoл)"); - -UploadedFile = Result["files"][0]; -ArrayOfFiles.Add(UploadedFile["id"]); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(UploadedFile["name"]).Equal(FileName); - -Result = OPI_Slack.GetFileData(Token, UploadedFile["id"]); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetFile"); - -UploadedFile = Result["file"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(UploadedFile["name"]).Equal(FileName); - -For Each UploadedFile In ArrayOfFiles Do - -Result = OPI_Slack.DeleteFile(Token, UploadedFile); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteFile"); - -Check_SlackOk(Result); - -EndDo; + UploadedFile = Result["files"][0]; + ArrayOfFiles.Add(UploadedFile["id"]); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(UploadedFile["name"]).Equal(FileName); + + Result = OPI_Slack.GetFileData(Token, UploadedFile["id"]); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetFile"); + + UploadedFile = Result["file"]; + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(UploadedFile["name"]).Equal(FileName); + + For Each UploadedFile In ArrayOfFiles Do + + Result = OPI_Slack.DeleteFile(Token, UploadedFile); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteFile"); + + Check_SlackOk(Result); + + EndDo; EndProcedure Procedure Slack_GetExternalFileList() Export - -Token = OPI_GetTestData.GetParameter("Slack_Token"); -Channel = OPI_GetTestData.GetParameter("Slack_Channel"); - -Result = OPI_Slack.GetExternalFileList(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetExternalFileList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); - -Result = OPI_Slack.GetExternalFileList(Token, Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetExternalFileList"); - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); - + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + Channel = OPI_GetTestData.GetParameter("Slack_Channel"); + + Result = OPI_Slack.GetExternalFileList(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetExternalFileList"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); + + Result = OPI_Slack.GetExternalFileList(Token, Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetExternalFileList"); + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(Result["files"]).HasType("Array"); + EndProcedure Procedure Slack_UploadDeleteExternalFile() Export - -Token = OPI_GetTestData.GetParameter("Slack_Token"); -File = OPI_GetTestData.GetParameter("Document"); -Channel = OPI_GetTestData.GetParameter("Slack_Channel"); -Title = "NewFile"; - -Result = OPI_Slack.AddExternalFile(Token, File, Title); - -// !OInt OPI_GetTestData.WriteLog(Result, "AddExternalFile"); - -UploadedFile = Result["file"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(UploadedFile["title"]).Equal(Title); - -Result = OPI_Slack.GetExternalFile(Token, UploadedFile["id"]); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetExternalFile"); - -UploadedFile = Result["file"]; - -Check_SlackOk(Result); -OPI_GetTestData.ExpectsThat(UploadedFile["title"]).Equal(Title); - -Result = OPI_Slack.SendExternalFile(Token, UploadedFile["id"], Channel); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendExternalFile"); - -Check_SlackOk(Result); - -Result = OPI_Slack.DeleteExternalFile(Token, UploadedFile["id"]); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendExternalFile"); - -Check_SlackOk(Result); - + + Token = OPI_GetTestData.GetParameter("Slack_Token"); + File = OPI_GetTestData.GetParameter("Document"); + Channel = OPI_GetTestData.GetParameter("Slack_Channel"); + Title = "NewFile"; + + Result = OPI_Slack.AddExternalFile(Token, File, Title); + + // !OInt OPI_GetTestData.WriteLog(Result, "AddExternalFile"); + + UploadedFile = Result["file"]; + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(UploadedFile["title"]).Equal(Title); + + Result = OPI_Slack.GetExternalFile(Token, UploadedFile["id"]); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetExternalFile"); + + UploadedFile = Result["file"]; + + Check_SlackOk(Result); + OPI_GetTestData.ExpectsThat(UploadedFile["title"]).Equal(Title); + + Result = OPI_Slack.SendExternalFile(Token, UploadedFile["id"], Channel); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendExternalFile"); + + Check_SlackOk(Result); + + Result = OPI_Slack.DeleteExternalFile(Token, UploadedFile["id"]); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendExternalFile"); + + Check_SlackOk(Result); + EndProcedure #EndRegion @@ -2911,222 +2911,222 @@ EndProcedure #Region Airtable Procedure AT_CreateDatabase() Export + + Token = OPI_GetTestData.GetParameter("Airtable_Token"); + Region = OPI_GetTestData.GetParameter("Airtable_Workspace"); + Name = "TestDatabase"; + + FieldArray = New Array; + FieldArray.Add(OPI_Airtable.GetNumberField("Number")); + FieldArray.Add(OPI_Airtable.GetStringField("String")); + + TableName = "TestTable"; + + TableMapping = New Match; + TableMapping.Insert(TableName, FieldArray); + + Result = OPI_Airtable.CreateDatabase(Token, Region, Name, TableMapping); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateDatabase"); + + OPI_GetTestData.ExpectsThat(Result["id"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["tables"][0]["name"]).Equal(TableName); + + Base = Result["id"]; + OPI_GetTestData.WriteParameter("Airtable_Base", Base); + + Result = OPI_Airtable.GetDatabaseTables(Token, Base); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetDatabaseTables"); + + OPI_GetTestData.ExpectsThat(Result["tables"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["tables"]).HasType("Array"); -Token = OPI_GetTestData.GetParameter("Airtable_Token"); -Region = OPI_GetTestData.GetParameter("Airtable_Workspace"); -Name = "TestDatabase"; - -FieldArray = New Array; -FieldArray.Add(OPI_Airtable.GetNumberField("Number")); -FieldArray.Add(OPI_Airtable.GetStringField("String")); - -TableName = "TestTable"; - -TableMapping = New Match; -TableMapping.Insert(TableName, FieldArray); - -Result = OPI_Airtable.CreateDatabase(Token, Region, Name, TableMapping); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateDatabase"); - -OPI_GetTestData.ExpectsThat(Result["id"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["tables"][0]["name"]).Equal(TableName); - -Base = Result["id"]; -OPI_GetTestData.WriteParameter("Airtable_Base", Base); - -Result = OPI_Airtable.GetDatabaseTables(Token, Base); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetDatabaseTables"); - -OPI_GetTestData.ExpectsThat(Result["tables"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["tables"]).HasType("Array"); - -Result = OPI_Airtable.GetListOfBases(Token); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetListOfBases"); - -OPI_GetTestData.ExpectsThat(Result["bases"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["bases"]).HasType("Array"); - + Result = OPI_Airtable.GetListOfBases(Token); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetListOfBases"); + + OPI_GetTestData.ExpectsThat(Result["bases"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["bases"]).HasType("Array"); + EndProcedure Procedure AT_CreateTable() Export - -Token = OPI_GetTestData.GetParameter("Airtable_Token"); -Base = OPI_GetTestData.GetParameter("Airtable_Base"); - -FieldArray = New Array; -FieldArray.Add(OPI_Airtable.GetNumberField("Number")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[0], "GetNumberField"); - -FieldArray.Add(OPI_Airtable.GetStringField("String")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[1], "GetStringField"); - -FieldArray.Add(OPI_Airtable.GetAttachmentField("Attachment")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[2], "GetAttachmentField"); - -FieldArray.Add(OPI_Airtable.GetCheckboxField("Checkbox")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[3], "GetCheckboxField"); - -FieldArray.Add(OPI_Airtable.GetDateField("Date")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[4], "GetDateField"); - -FieldArray.Add(OPI_Airtable.GetPhoneField("Phone")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[5], "GetPhoneField"); - -FieldArray.Add(OPI_Airtable.GetEmailField("Email")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[6], "GetEmailField"); - -FieldArray.Add(OPI_Airtable.GetLinkField("Link")); -// !OInt OPI_GetTestData.WriteLog(FieldArray[7], "GetLinkField"); - -TableName = "TestTable2"; -Description = "NewTable"; - -Result = OPI_Airtable.CreateTable(Token, Base, TableName, FieldArray, Description); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateTable"); - -OPI_GetTestData.ExpectsThat(Result["name"]).Equal(TableName); -OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); - -Table = Result["id"]; -TableName = "TestTable2 (fromм.)"; -Description = "NewTable (fromм.)"; - -OPI_GetTestData.WriteParameter("Airtable_Table", Table); - -Result = OPI_Airtable.ModifyTable(Token, Base, Table, TableName, Description); - -// !OInt OPI_GetTestData.WriteLog(Result, "ModifyTable"); - -OPI_GetTestData.ExpectsThat(Result["name"]).Equal(TableName); -OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); + + Token = OPI_GetTestData.GetParameter("Airtable_Token"); + Base = OPI_GetTestData.GetParameter("Airtable_Base"); + + FieldArray = New Array; + FieldArray.Add(OPI_Airtable.GetNumberField("Number")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[0], "GetNumberField"); + + FieldArray.Add(OPI_Airtable.GetStringField("String")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[1], "GetStringField"); + + FieldArray.Add(OPI_Airtable.GetAttachmentField("Attachment")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[2], "GetAttachmentField"); + + FieldArray.Add(OPI_Airtable.GetCheckboxField("Checkbox")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[3], "GetCheckboxField"); + + FieldArray.Add(OPI_Airtable.GetDateField("Date")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[4], "GetDateField"); + + FieldArray.Add(OPI_Airtable.GetPhoneField("Phone")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[5], "GetPhoneField"); + + FieldArray.Add(OPI_Airtable.GetEmailField("Email")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[6], "GetEmailField"); + + FieldArray.Add(OPI_Airtable.GetLinkField("Link")); + // !OInt OPI_GetTestData.WriteLog(FieldArray[7], "GetLinkField"); + + TableName = "TestTable2"; + Description = "NewTable"; + + Result = OPI_Airtable.CreateTable(Token, Base, TableName, FieldArray, Description); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateTable"); + + OPI_GetTestData.ExpectsThat(Result["name"]).Equal(TableName); + OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); + + Table = Result["id"]; + TableName = "TestTable2 (fromм.)"; + Description = "NewTable (fromм.)"; + + OPI_GetTestData.WriteParameter("Airtable_Table", Table); + + Result = OPI_Airtable.ModifyTable(Token, Base, Table, TableName, Description); + + // !OInt OPI_GetTestData.WriteLog(Result, "ModifyTable"); + + OPI_GetTestData.ExpectsThat(Result["name"]).Equal(TableName); + OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); EndProcedure Procedure AT_CreateField() Export - -Token = OPI_GetTestData.GetParameter("Airtable_Token"); -Base = OPI_GetTestData.GetParameter("Airtable_Base"); -Table = OPI_GetTestData.GetParameter("Airtable_Table"); -Name = String(New UniqueIdentifier); - -Field = OPI_Airtable.GetNumberField(Name); - -Result = OPI_Airtable.CreateField(Token, Base, Table, Field); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateField"); - -OPI_GetTestData.ExpectsThat(Result["name"]).Equal(Name); - -Field = Result["id"]; -Name = Name + "(fromм.)"; -Description = "New description"; - -Result = OPI_Airtable.ModifyField(Token, Base, Table, Field, Name, Description); - -// !OInt OPI_GetTestData.WriteLog(Result, "ModifyField"); - -OPI_GetTestData.ExpectsThat(Result["name"]).Equal(Name); -OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); - + + Token = OPI_GetTestData.GetParameter("Airtable_Token"); + Base = OPI_GetTestData.GetParameter("Airtable_Base"); + Table = OPI_GetTestData.GetParameter("Airtable_Table"); + Name = String(New UniqueIdentifier); + + Field = OPI_Airtable.GetNumberField(Name); + + Result = OPI_Airtable.CreateField(Token, Base, Table, Field); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateField"); + + OPI_GetTestData.ExpectsThat(Result["name"]).Equal(Name); + + Field = Result["id"]; + Name = Name + "(fromм.)"; + Description = "New description"; + + Result = OPI_Airtable.ModifyField(Token, Base, Table, Field, Name, Description); + + // !OInt OPI_GetTestData.WriteLog(Result, "ModifyField"); + + OPI_GetTestData.ExpectsThat(Result["name"]).Equal(Name); + OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); + EndProcedure Procedure AT_CreateDeleteRecords() Export -Token = OPI_GetTestData.GetParameter("Airtable_Token"); -Base = OPI_GetTestData.GetParameter("Airtable_Base"); -Table = OPI_GetTestData.GetParameter("Airtable_Table"); - -Numeric = 10; -StringType = "Hello"; - -RowDescription1 = New Structure("Number,String", Numeric, StringType); -RowDescription2 = New Structure("Number,String", Numeric, StringType); - -ArrayOfDeletions = New Array; -ArrayOfDescriptions = New Array; -ArrayOfDescriptions.Add(RowDescription1); -ArrayOfDescriptions.Add(RowDescription2); - -Result = OPI_Airtable.CreatePosts(Token, Base, Table, ArrayOfDescriptions); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePosts"); - -OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); -OPI_GetTestData.ExpectsThat(Result["records"].Quantity()).Equal(2); - -For Each Record In Result["records"] Do -ArrayOfDeletions.Add(Record["id"]); -EndDo; - -Result = OPI_Airtable.CreatePosts(Token, Base, Table, RowDescription1); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePosts (оdto)"); - -SingleRecord = Result["id"]; -OPI_GetTestData.ExpectsThat(SingleRecord).Filled(); -OPI_GetTestData.ExpectsThat(Result["createdTime"]).Filled(); -OPI_GetTestData.ExpectsThat(Result["fields"]["Number"]).Equal(Numeric); -OPI_GetTestData.ExpectsThat(ShortLP(Result["fields"]["String"])).Equal(StringType); - -Result = OPI_Airtable.GetRecord(Token, Base, Table, SingleRecord); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetRecord"); - -OPI_GetTestData.ExpectsThat(Result["id"]).Equal(SingleRecord); - -Text = "TestComment"; -Result = OPI_Airtable.CreateComment(Token, Base, Table, SingleRecord, Text); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateComment"); - -OPI_GetTestData.ExpectsThat(Result["text"]).Equal(Text); - -Comment = Result["id"]; -Text = "TestComment (fromм.)"; -Result = OPI_Airtable.EditComment(Token, Base, Table, SingleRecord, Comment, Text); - -// !OInt OPI_GetTestData.WriteLog(Result, "EditComment"); - -OPI_GetTestData.ExpectsThat(Result["text"]).Equal(Text); - -Result = OPI_Airtable.GetComments(Token, Base, Table, SingleRecord); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetComments"); - -OPI_GetTestData.ExpectsThat(Result["comments"]).HasType("Array"); - -Result = OPI_Airtable.DeleteComment(Token, Base, Table, SingleRecord, Comment); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteComment"); - -OPI_GetTestData.ExpectsThat(Result["deleted"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["id"]).Equal(Comment); - -Result = OPI_Airtable.GetListOfRecords(Token, Base, Table); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetListOfRecords"); - -OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); -OPI_GetTestData.ExpectsThat(Result["records"]).Filled(); - -Result = OPI_Airtable.DeletePosts(Token, Base, Table, ArrayOfDeletions); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeletePosts"); - -OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); -OPI_GetTestData.ExpectsThat(Result["records"]).Filled(); - -Result = OPI_Airtable.DeletePosts(Token, Base, Table, SingleRecord); - -// !OInt OPI_GetTestData.WriteLog(Result, "DeletePosts (оdto)"); - -OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); -OPI_GetTestData.ExpectsThat(Result["records"]).Filled(); + Token = OPI_GetTestData.GetParameter("Airtable_Token"); + Base = OPI_GetTestData.GetParameter("Airtable_Base"); + Table = OPI_GetTestData.GetParameter("Airtable_Table"); + + Numeric = 10; + StringType = "Hello"; + + RowDescription1 = New Structure("Number,String", Numeric, StringType); + RowDescription2 = New Structure("Number,String", Numeric, StringType); + + ArrayOfDeletions = New Array; + ArrayOfDescriptions = New Array; + ArrayOfDescriptions.Add(RowDescription1); + ArrayOfDescriptions.Add(RowDescription2); + + Result = OPI_Airtable.CreatePosts(Token, Base, Table, ArrayOfDescriptions); + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePosts"); + + OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); + OPI_GetTestData.ExpectsThat(Result["records"].Quantity()).Equal(2); + + For Each Record In Result["records"] Do + ArrayOfDeletions.Add(Record["id"]); + EndDo; + + Result = OPI_Airtable.CreatePosts(Token, Base, Table, RowDescription1); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePosts (оdto)"); + + SingleRecord = Result["id"]; + OPI_GetTestData.ExpectsThat(SingleRecord).Filled(); + OPI_GetTestData.ExpectsThat(Result["createdTime"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["fields"]["Number"]).Equal(Numeric); + OPI_GetTestData.ExpectsThat(ShortLP(Result["fields"]["String"])).Equal(StringType); + + Result = OPI_Airtable.GetRecord(Token, Base, Table, SingleRecord); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetRecord"); + + OPI_GetTestData.ExpectsThat(Result["id"]).Equal(SingleRecord); + + Text = "TestComment"; + Result = OPI_Airtable.CreateComment(Token, Base, Table, SingleRecord, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateComment"); + + OPI_GetTestData.ExpectsThat(Result["text"]).Equal(Text); + + Comment = Result["id"]; + Text = "TestComment (fromм.)"; + Result = OPI_Airtable.EditComment(Token, Base, Table, SingleRecord, Comment, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "EditComment"); + + OPI_GetTestData.ExpectsThat(Result["text"]).Equal(Text); + + Result = OPI_Airtable.GetComments(Token, Base, Table, SingleRecord); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetComments"); + + OPI_GetTestData.ExpectsThat(Result["comments"]).HasType("Array"); + + Result = OPI_Airtable.DeleteComment(Token, Base, Table, SingleRecord, Comment); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteComment"); + + OPI_GetTestData.ExpectsThat(Result["deleted"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["id"]).Equal(Comment); + + Result = OPI_Airtable.GetListOfRecords(Token, Base, Table); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetListOfRecords"); + + OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); + OPI_GetTestData.ExpectsThat(Result["records"]).Filled(); + + Result = OPI_Airtable.DeletePosts(Token, Base, Table, ArrayOfDeletions); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeletePosts"); + + OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); + OPI_GetTestData.ExpectsThat(Result["records"]).Filled(); + + Result = OPI_Airtable.DeletePosts(Token, Base, Table, SingleRecord); + + // !OInt OPI_GetTestData.WriteLog(Result, "DeletePosts (оdto)"); + + OPI_GetTestData.ExpectsThat(Result["records"]).HasType("Array"); + OPI_GetTestData.ExpectsThat(Result["records"]).Filled(); + EndProcedure #EndRegion @@ -3134,105 +3134,105 @@ EndProcedure #Region Dropbox Procedure Dropbox_GetUpdateToken() Export + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Appkey" , TestParameters); + OPI_GetTestData.ParameterToCollection("Dropbox_Appsecret", TestParameters); + + Dropbox_GetAuthorizationLink(TestParameters); + + OPI_GetTestData.ParameterToCollection("Dropbox_Code", TestParameters); -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Appkey" , TestParameters); -OPI_GetTestData.ParameterToCollection("Dropbox_Appsecret", TestParameters); - -Dropbox_GetAuthorizationLink(TestParameters); - -OPI_GetTestData.ParameterToCollection("Dropbox_Code", TestParameters); - -Dropbox_GetToken(TestParameters); - -OPI_GetTestData.ParameterToCollection("Dropbox_Refresh", TestParameters); - -Dropbox_UpdateToken(TestParameters); - + Dropbox_GetToken(TestParameters); + + OPI_GetTestData.ParameterToCollection("Dropbox_Refresh", TestParameters); + + Dropbox_UpdateToken(TestParameters); + EndProcedure Procedure Dropbox_UploadFile() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); -OPI_GetTestData.ParameterToCollection("Picture", TestParameters); - -Dropbox_UploadFile(TestParameters); -Dropbox_GetObjectInformation(TestParameters); -Dropbox_GetObjectVersionList(TestParameters); -Dropbox_RestoreObjectToVersion(TestParameters); -Dropbox_GetPreview(TestParameters); -Dropbox_DownloadFile(TestParameters); -Dropbox_MoveObject(TestParameters); -Dropbox_CopyObject(TestParameters); -Dropbox_DeleteObject(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); + OPI_GetTestData.ParameterToCollection("Picture", TestParameters); + + Dropbox_UploadFile(TestParameters); + Dropbox_GetObjectInformation(TestParameters); + Dropbox_GetObjectVersionList(TestParameters); + Dropbox_RestoreObjectToVersion(TestParameters); + Dropbox_GetPreview(TestParameters); + Dropbox_DownloadFile(TestParameters); + Dropbox_MoveObject(TestParameters); + Dropbox_CopyObject(TestParameters); + Dropbox_DeleteObject(TestParameters); + EndProcedure Procedure Dropbox_CreateFolder() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); - -Dropbox_CreateFolder(TestParameters); -Dropbox_DownloadFolder(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); + + Dropbox_CreateFolder(TestParameters); + Dropbox_DownloadFolder(TestParameters); + EndProcedure Procedure Dropbox_GetFolderFileList() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); - -Dropbox_GetFolderFileList(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); + + Dropbox_GetFolderFileList(TestParameters); + EndProcedure Procedure Dropbox_UploadFileByURL() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); -OPI_GetTestData.ParameterToCollection("Document", TestParameters); - -Dropbox_UploadFileByURL(TestParameters); -Dropbox_GetUploadStatusByURL(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); + OPI_GetTestData.ParameterToCollection("Document", TestParameters); + + Dropbox_UploadFileByURL(TestParameters); + Dropbox_GetUploadStatusByURL(TestParameters); + EndProcedure Procedure Dropbox_CreateDeleteTag() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); - -Dropbox_AddTag(TestParameters); -Dropbox_GetTagList(TestParameters); -Dropbox_DeleteTag(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); + + Dropbox_AddTag(TestParameters); + Dropbox_GetTagList(TestParameters); + Dropbox_DeleteTag(TestParameters); + EndProcedure Procedure Dropbox_GetAccount() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); - -Dropbox_GetAccountInformation(TestParameters); -Dropbox_GetSpaceUsageData(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Token", TestParameters); + + Dropbox_GetAccountInformation(TestParameters); + Dropbox_GetSpaceUsageData(TestParameters); + EndProcedure Procedure Dropbox_AccessManagement() Export - -TestParameters = New Structure; -OPI_GetTestData.ParameterToCollection("Dropbox_Token" , TestParameters); -OPI_GetTestData.ParameterToCollection("Dropbox_OtherUser", TestParameters); -OPI_GetTestData.ParameterToCollection("Dropbox_FileID" , TestParameters); - -Dropbox_AddUsersToFile(TestParameters); -Dropbox_PublishFolder(TestParameters); -Dropbox_AddUsersToFolder(TestParameters); -Dropbox_CancelFolderPublication(TestParameters); -Dropbox_CancelFilePublication(TestParameters); - + + TestParameters = New Structure; + OPI_GetTestData.ParameterToCollection("Dropbox_Token" , TestParameters); + OPI_GetTestData.ParameterToCollection("Dropbox_OtherUser", TestParameters); + OPI_GetTestData.ParameterToCollection("Dropbox_FileID" , TestParameters); + + Dropbox_AddUsersToFile(TestParameters); + Dropbox_PublishFolder(TestParameters); + Dropbox_AddUsersToFolder(TestParameters); + Dropbox_CancelFolderPublication(TestParameters); + Dropbox_CancelFilePublication(TestParameters); + EndProcedure #EndRegion @@ -3243,376 +3243,376 @@ EndProcedure #Region ServiceProceduresAndFunctions -Function GetVKParameters() - -Parameters = New Structure; -GroupNumber = OPI_GetTestData.GetParameter("VK_GroupID"); - -Parameters.Insert("access_token" , OPI_GetTestData.GetParameter("VK_Token")); -Parameters.Insert("owner_id" , "-" + GroupNumber); -Parameters.Insert("app_id" , OPI_GetTestData.GetParameter("VK_AppID")); -Parameters.Insert("group_id" , GroupNumber); - -Return Parameters; - +Function GetVKParameters() + + Parameters = New Structure; + GroupNumber = OPI_GetTestData.GetParameter("VK_GroupID"); + + Parameters.Insert("access_token" , OPI_GetTestData.GetParameter("VK_Token")); + Parameters.Insert("owner_id" , "-" + GroupNumber); + Parameters.Insert("app_id" , OPI_GetTestData.GetParameter("VK_AppID")); + Parameters.Insert("group_id" , GroupNumber); + + Return Parameters; + EndFunction -Function GetTwitterParameters() - -Parameters = New Match; - -Parameters.Insert("redirect_uri" , OPI_GetTestData.GetParameter("Twitter_Redirect")); -Parameters.Insert("client_id" , OPI_GetTestData.GetParameter("Twitter_ClinetID")); -Parameters.Insert("client_secret" , OPI_GetTestData.GetParameter("Twitter_ClientSecret")); -Parameters.Insert("access_token" , OPI_GetTestData.GetParameter("Twitter_Token")); -Parameters.Insert("refresh_token" , OPI_GetTestData.GetParameter("Twitter_Refresh")); -Parameters.Insert("oauth_token" , OPI_GetTestData.GetParameter("Twitter_OAuthToken")); -Parameters.Insert("oauth_token_secret" , OPI_GetTestData.GetParameter("Twitter_OAuthSecret")); - -Parameters.Insert("oauth_consumer_key" -, OPI_GetTestData.GetParameter("Twitter_OAuthConsumerKey")); -Parameters.Insert("oauth_consumer_secret" -, OPI_GetTestData.GetParameter("Twitter_OAuthConsumerSecret")); - -Return Parameters; +Function GetTwitterParameters() + + Parameters = New Match; + + Parameters.Insert("redirect_uri" , OPI_GetTestData.GetParameter("Twitter_Redirect")); + Parameters.Insert("client_id" , OPI_GetTestData.GetParameter("Twitter_ClinetID")); + Parameters.Insert("client_secret" , OPI_GetTestData.GetParameter("Twitter_ClientSecret")); + Parameters.Insert("access_token" , OPI_GetTestData.GetParameter("Twitter_Token")); + Parameters.Insert("refresh_token" , OPI_GetTestData.GetParameter("Twitter_Refresh")); + Parameters.Insert("oauth_token" , OPI_GetTestData.GetParameter("Twitter_OAuthToken")); + Parameters.Insert("oauth_token_secret" , OPI_GetTestData.GetParameter("Twitter_OAuthSecret")); + + Parameters.Insert("oauth_consumer_key" + , OPI_GetTestData.GetParameter("Twitter_OAuthConsumerKey")); + Parameters.Insert("oauth_consumer_secret" + , OPI_GetTestData.GetParameter("Twitter_OAuthConsumerSecret")); + Return Parameters; + EndFunction #Region Checks -Procedure Check_Empty(Val Result) -OPI_GetTestData.ExpectsThat(ValueIsFilled(Result)).Equal(False); +Procedure Check_Empty(Val Result) + OPI_GetTestData.ExpectsThat(ValueIsFilled(Result)).Equal(False); EndProcedure Procedure Check_BinaryData(Val Result, Val Size = Undefined) - -MinimumSize = 500000; - -OPI_GetTestData.ExpectsThat(Result).HasType("BinaryData"); - -If Not Size = Undefined Then -OPI_GetTestData.ExpectsThat(Result.Size()).Equal(Size); -Else -OPI_GetTestData.ExpectsThat(Result.Size() > MinimumSize).Equal(True); -EndIf; - + + MinimumSize = 500000; + + OPI_GetTestData.ExpectsThat(Result).HasType("BinaryData"); + + If Not Size = Undefined Then + OPI_GetTestData.ExpectsThat(Result.Size()).Equal(Size); + Else + OPI_GetTestData.ExpectsThat(Result.Size() > MinimumSize).Equal(True); + EndIf; + EndProcedure Procedure Check_TelegramTrue(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]).Equal(True); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]).Equal(True); + EndProcedure Procedure Check_TelegramBotInformation(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["username"]).Filled(); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["username"]).Filled(); + EndProcedure Procedure Check_TelegramArray(Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match") .Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]).HasType("Array"); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match") .Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]).HasType("Array"); + EndProcedure Procedure Check_TelegramWebhookSetup(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["description"]).Equal("Webhook was set"); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["description"]).Equal("Webhook was set"); + EndProcedure Procedure Check_TelegramWebhookDeletion(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["description"]).Filled(); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["description"]).Filled(); + EndProcedure Procedure Check_TelegramMessage(Val Result, Val Text) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["text"]).Equal(Text); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["text"]).Equal(Text); + EndProcedure Procedure Check_TelegramImage(Val Result, Val Text) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match") .Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); -OPI_GetTestData.ExpectsThat(Result["result"]["photo"]).HasType("Array"); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match") .Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); + OPI_GetTestData.ExpectsThat(Result["result"]["photo"]).HasType("Array"); + EndProcedure Procedure Check_TelegramVideo(Val Result, Val Text) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); -OPI_GetTestData.ExpectsThat(Result["result"]["video"]["mime_type"]).Equal("video/mp4"); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); + OPI_GetTestData.ExpectsThat(Result["result"]["video"]["mime_type"]).Equal("video/mp4"); + EndProcedure Procedure Check_TelegramAudio(Val Result, Val Text) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); -OPI_GetTestData.ExpectsThat(Result["result"]["audio"]["mime_type"]).Equal("audio/mpeg"); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); + OPI_GetTestData.ExpectsThat(Result["result"]["audio"]["mime_type"]).Equal("audio/mpeg"); + EndProcedure Procedure Check_TelegramDocument(Val Result, Val Text) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); -OPI_GetTestData.ExpectsThat(Result["result"]["document"]).HasType("Match").Filled(); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["caption"]).Equal(Text); + OPI_GetTestData.ExpectsThat(Result["result"]["document"]).HasType("Match").Filled(); + EndProcedure Procedure Check_TelegramGif(Val Result, Val Text) -Result = "result"; - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result[Result]["caption"]).Equal(Text); -OPI_GetTestData.ExpectsThat(Result[Result]["document"]).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result[Result]["animation"]["mime_type"]).Equal("video/mp4"); - + Result = "result"; + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result[Result]["caption"]).Equal(Text); + OPI_GetTestData.ExpectsThat(Result[Result]["document"]).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result[Result]["animation"]["mime_type"]).Equal("video/mp4"); + EndProcedure Procedure Check_TelegramMediaGroup(Val Result) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]).HasType("Array"); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]).HasType("Array"); + EndProcedure Procedure Check_TelegramLocation(Val Result) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["location"]).HasType("Match").Filled(); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["location"]).HasType("Match").Filled(); + EndProcedure Procedure Check_TelegramContact(Val Result, Val Name) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["contact"]).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["result"]["contact"]["first_name"]).Equal(Name); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["contact"]).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["result"]["contact"]["first_name"]).Equal(Name); + EndProcedure Procedure Check_TelegramPoll(Val Result, Val Question) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["poll"]).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["result"]["poll"]["question"]).Equal(Question); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["poll"]).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["result"]["poll"]["question"]).Equal(Question); + EndProcedure Procedure Check_TelegramForward(Val Result, Val MessageID) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["forward_origin"]["message_id"]).Equal(Number(MessageID)); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["forward_origin"]["message_id"]).Equal(Number(MessageID)); + EndProcedure Procedure Check_TelegramBan(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["description"]).Equal("Bad Request: can't remove chat owner"); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["description"]).Equal("Bad Request: can't remove chat owner"); + EndProcedure Procedure Check_TelegramInvitation(Val Result, Val Title, Val UnixExpiration) -Result = "result"; -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result[Result]["member_limit"]).Equal(200); -OPI_GetTestData.ExpectsThat(Result[Result]["name"]).Equal(Title); -OPI_GetTestData.ExpectsThat(Result[Result]["expire_date"]).Equal(Number(UnixExpiration)); - + Result = "result"; + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result[Result]["member_limit"]).Equal(200); + OPI_GetTestData.ExpectsThat(Result[Result]["name"]).Equal(Title); + OPI_GetTestData.ExpectsThat(Result[Result]["expire_date"]).Equal(Number(UnixExpiration)); + EndProcedure Procedure Check_TelegramNumber(Val Result) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]).HasType("Number"); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]).HasType("Number"); + EndProcedure Procedure Check_TelegramCreateTopic(Val Result, Val Name, Icon) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); -OPI_GetTestData.ExpectsThat(Result["result"]["name"]).Equal(Name); -OPI_GetTestData.ExpectsThat(Result["result"]["icon_custom_emoji_id"]).Equal(Icon); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + OPI_GetTestData.ExpectsThat(Result["result"]["name"]).Equal(Name); + OPI_GetTestData.ExpectsThat(Result["result"]["icon_custom_emoji_id"]).Equal(Icon); + EndProcedure Procedure Check_VKPost(Val Result) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["response"]["post_id"]).HasType("Number").Filled(); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["response"]["post_id"]).HasType("Number").Filled(); + EndProcedure Procedure Check_VKTrue(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["response"]).HasType("Number").Equal(1); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["response"]).HasType("Number").Equal(1); + EndProcedure Procedure Check_VKAlbum(Val Result, Val Description) -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["response"]["description"]).Equal(Description); - + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["response"]["description"]).Equal(Description); + EndProcedure Procedure Check_VKAlbumPicture(Val Result, Val ImageDescription, Val AlbumID) -Response = "response"; - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result[Response][0]["text"]).Equal(ImageDescription); -OPI_GetTestData.ExpectsThat(Result[Response][0]["album_id"]).Equal(AlbumID); - + Response = "response"; + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result[Response][0]["text"]).Equal(ImageDescription); + OPI_GetTestData.ExpectsThat(Result[Response][0]["album_id"]).Equal(AlbumID); + EndProcedure Procedure Check_VKStory(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["response"]["count"]).HasType("Number").Equal(1); -OPI_GetTestData.ExpectsThat(Result["response"]["items"]).HasType("Array").Filled(); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["response"]["count"]).HasType("Number").Equal(1); + OPI_GetTestData.ExpectsThat(Result["response"]["items"]).HasType("Array").Filled(); + EndProcedure Procedure Check_VKDiscussion(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["response"]).HasType("Number").Filled(); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["response"]).HasType("Number").Filled(); + EndProcedure Procedure Check_GKObject(Val Result, Val Name, Val Description) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match"); -OPI_GetTestData.ExpectsThat(Result["summary"]).Equal(Name); -OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); -OPI_GetTestData.ExpectsThat(Result["id"]).HasType("String").Filled(); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match"); + OPI_GetTestData.ExpectsThat(Result["summary"]).Equal(Name); + OPI_GetTestData.ExpectsThat(Result["description"]).Equal(Description); + OPI_GetTestData.ExpectsThat(Result["id"]).HasType("String").Filled(); + EndProcedure Procedure Check_TwitterText(Val Result, Val Text) - -ReplyText = Result["data"]["text"]; -ReplyText = Left(ReplyText, StrLength(Text)); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(ReplyText).Equal(Text); + + ReplyText = Result["data"]["text"]; + ReplyText = Left(ReplyText, StrLength(Text)); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(ReplyText).Equal(Text); EndProcedure Procedure Check_ViberOk(Val Result) - -OPI_GetTestData.ExpectsThat(Result["status_message"]).Equal("ok"); -OPI_GetTestData.ExpectsThat(Result["status"]).Equal(0); + + OPI_GetTestData.ExpectsThat(Result["status_message"]).Equal("ok"); + OPI_GetTestData.ExpectsThat(Result["status"]).Equal(0); EndProcedure Procedure Check_NotionObject(Val Result, Val View = "page") - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["object"]).Equal(View); - + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["object"]).Equal(View); + EndProcedure Procedure Check_SlackOk(Val Result) - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); -OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + OPI_GetTestData.ExpectsThat(Result["ok"]).Equal(True); EndProcedure Procedure Check_DropboxFile(Val Result, Val Path) - -OPI_GetTestData.ExpectsThat(Result["path_display"]).Equal(Path); - + + OPI_GetTestData.ExpectsThat(Result["path_display"]).Equal(Path); + EndProcedure Procedure Check_DropboxMetadata(Val Result, Val Path) - -OPI_GetTestData.ExpectsThat(Result["metadata"]["path_display"]).Equal(Path); - + + OPI_GetTestData.ExpectsThat(Result["metadata"]["path_display"]).Equal(Path); + EndProcedure Procedure Check_DropboxArray(Val Result, Val Quantity = Undefined) - -OPI_GetTestData.ExpectsThat(Result["entries"]).HasType("Array"); - -If Not Quantity = Undefined Then -OPI_GetTestData.ExpectsThat(Result["entries"].Quantity()).Equal(Quantity); -EndIf; - + + OPI_GetTestData.ExpectsThat(Result["entries"]).HasType("Array"); + + If Not Quantity = Undefined Then + OPI_GetTestData.ExpectsThat(Result["entries"].Quantity()).Equal(Quantity); + EndIf; + EndProcedure Procedure Check_DropboxWork(Val Result) -OPI_GetTestData.ExpectsThat(Result["async_job_id"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["async_job_id"]).Filled(); EndProcedure Procedure Check_DropboxStatus(Val Result) -OPI_GetTestData.ExpectsThat(Result[".tag"]).Equal("complete"); + OPI_GetTestData.ExpectsThat(Result[".tag"]).Equal("complete"); EndProcedure Procedure Check_DropboxTags(Val Result, Val Quantity) - -OPI_GetTestData.ExpectsThat(Result["paths_to_tags"]).HasType("Array"); -OPI_GetTestData.ExpectsThat(Result["paths_to_tags"].Quantity()).Equal(Quantity); - + + OPI_GetTestData.ExpectsThat(Result["paths_to_tags"]).HasType("Array"); + OPI_GetTestData.ExpectsThat(Result["paths_to_tags"].Quantity()).Equal(Quantity); + EndProcedure Procedure Check_DropboxAccount(Val Result) -OPI_GetTestData.ExpectsThat(Result["account_id"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["account_id"]).Filled(); EndProcedure Procedure Check_DropboxSpace(Val Result) -OPI_GetTestData.ExpectsThat(Result["used"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["used"]).Filled(); EndProcedure Procedure Check_DropboxMember(Val Result, Val Email, Val ViewOnly) -OPI_GetTestData.ExpectsThat(Result[0]["result"][".tag"]).Equal("success"); -OPI_GetTestData.ExpectsThat(Result[0]["member"]["email"]).Equal(Email); -OPI_GetTestData.ExpectsThat( -Result[0]["result"]["success"][".tag"]).Equal(?(ViewOnly, "viewer", "editor")); + OPI_GetTestData.ExpectsThat(Result[0]["result"][".tag"]).Equal("success"); + OPI_GetTestData.ExpectsThat(Result[0]["member"]["email"]).Equal(Email); + OPI_GetTestData.ExpectsThat( + Result[0]["result"]["success"][".tag"]).Equal(?(ViewOnly, "viewer", "editor")); EndProcedure Procedure Check_DropboxPublicFolder(Val Result) -OPI_GetTestData.ExpectsThat(Result["shared_folder_id"]).Filled(); + OPI_GetTestData.ExpectsThat(Result["shared_folder_id"]).Filled(); EndProcedure #EndRegion @@ -3623,784 +3623,784 @@ EndProcedure Procedure Telegram_GetBotInformation(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Result = OPI_Telegram.GetBotInformation(Token); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetBotInformation", "Telegram"); - -Check_TelegramBotInformation(Result); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + Result = OPI_Telegram.GetBotInformation(Token); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetBotInformation", "Telegram"); + + Check_TelegramBotInformation(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_GetUpdates(FunctionParameters) + + Token = FunctionParameters["Telegram_Token"]; + Result = OPI_Telegram.GetUpdates(Token); -Token = FunctionParameters["Telegram_Token"]; -Result = OPI_Telegram.GetUpdates(Token); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetUpdates", "Telegram"); - -Check_TelegramArray(Result); - -OPI_Tools.Pause(5); - + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetUpdates", "Telegram"); + + Check_TelegramArray(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SetWebhook(FunctionParameters) - -Token = FunctionParameters["Telegram_Token"]; -URL = FunctionParameters["Telegram_URL"]; - -Result = OPI_Telegram.SetWebhook(Token, URL); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SetWebhook", "Telegram"); - -Check_TelegramWebhookSetup(Result); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Telegram_Token"]; + URL = FunctionParameters["Telegram_URL"]; + + Result = OPI_Telegram.SetWebhook(Token, URL); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SetWebhook", "Telegram"); + + Check_TelegramWebhookSetup(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_DeleteWebhook(FunctionParameters) - -Token = FunctionParameters["Telegram_Token"]; -Result = OPI_Telegram.DeleteWebhook(Token); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteWebhook", "Telegram"); - -Check_TelegramWebhookDeletion(Result); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Telegram_Token"]; + Result = OPI_Telegram.DeleteWebhook(Token); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteWebhook", "Telegram"); + + Check_TelegramWebhookDeletion(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendTextMessage(FunctionParameters) - -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Text = FunctionParameters["String"]; - -Result = OPI_Telegram.SendTextMessage(Token, ChatID, Text); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage", "Telegram"); - -Check_TelegramMessage(Result, Text); // SKIP - -Result = OPI_Telegram.SendTextMessage(Token, ChannelID, Text); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage (toаtoл)"); - -Check_TelegramMessage(Result, Text); - -MessageID = OPI_Tools.NumberToString(Result["result"]["message_id"]); -OPI_GetTestData.WriteParameter("Telegram_ChannelMessageID", MessageID); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Text = FunctionParameters["String"]; + + Result = OPI_Telegram.SendTextMessage(Token, ChatID, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage", "Telegram"); + + Check_TelegramMessage(Result, Text); // SKIP + + Result = OPI_Telegram.SendTextMessage(Token, ChannelID, Text); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage (toаtoл)"); + + Check_TelegramMessage(Result, Text); + + MessageID = OPI_Tools.NumberToString(Result["result"]["message_id"]); + OPI_GetTestData.WriteParameter("Telegram_ChannelMessageID", MessageID); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendPicture(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Text = FunctionParameters["String"]; -Image = FunctionParameters["Picture"]; - -ImagePath = GetTempFileName("png"); -CopyFile(Image, ImagePath); - -ImageDD = New BinaryData(ImagePath); - -Result = OPI_Telegram.SendImage(Token, ChatID, Text, Image); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendImage", "Telegram"); - -Check_TelegramImage(Result, Text); // SKIP - -Result = OPI_Telegram.SendImage(Token, ChannelID, Text, ImagePath); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendImage (Path)"); - -Check_TelegramImage(Result, Text); // SKIP - -Result = OPI_Telegram.SendImage(Token, ChannelID, Text, ImageDD); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendImage (BD)"); - -Check_TelegramImage(Result, Text); - -DeleteFiles(ImagePath); - -FileID = Result["result"]["photo"][0]["file_id"]; -OPI_GetTestData.WriteParameter("Telegram_FileID", FileID); - -FunctionParameters.Insert("Telegram_FileID", FileID); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Text = FunctionParameters["String"]; + Image = FunctionParameters["Picture"]; + + ImagePath = GetTempFileName("png"); + CopyFile(Image, ImagePath); + + ImageDD = New BinaryData(ImagePath); + + Result = OPI_Telegram.SendImage(Token, ChatID, Text, Image); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendImage", "Telegram"); + + Check_TelegramImage(Result, Text); // SKIP + + Result = OPI_Telegram.SendImage(Token, ChannelID, Text, ImagePath); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendImage (Path)"); + + Check_TelegramImage(Result, Text); // SKIP + + Result = OPI_Telegram.SendImage(Token, ChannelID, Text, ImageDD); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendImage (BD)"); + + Check_TelegramImage(Result, Text); + + DeleteFiles(ImagePath); + + FileID = Result["result"]["photo"][0]["file_id"]; + OPI_GetTestData.WriteParameter("Telegram_FileID", FileID); + + FunctionParameters.Insert("Telegram_FileID", FileID); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendVideo(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Text = FunctionParameters["String"]; -Video = FunctionParameters["Video"]; - -VideoPath = GetTempFileName("mp4"); -CopyFile(Video, VideoPath); - -VideoDD = New BinaryData(VideoPath); - -Result = OPI_Telegram.SendVideo(Token, ChatID, Text, Video); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendVideo", "Telegram"); - -Check_TelegramVideo(Result, Text); // SKIP - -Result = OPI_Telegram.SendVideo(Token, ChannelID, Text, VideoPath); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendVideo (Path)"); - -Check_TelegramVideo(Result, Text); // SKIP - -Result = OPI_Telegram.SendVideo(Token, ChannelID, Text, VideoDD); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendVideo (BD)"); - -Check_TelegramVideo(Result, Text); - -DeleteFiles(VideoPath); - -FileID = Result["result"]["video"]["file_id"]; -OPI_GetTestData.WriteParameter("Telegram_FileID", FileID); - -FunctionParameters.Insert("Telegram_FileID", FileID); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Text = FunctionParameters["String"]; + Video = FunctionParameters["Video"]; + + VideoPath = GetTempFileName("mp4"); + CopyFile(Video, VideoPath); + + VideoDD = New BinaryData(VideoPath); + + Result = OPI_Telegram.SendVideo(Token, ChatID, Text, Video); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendVideo", "Telegram"); + + Check_TelegramVideo(Result, Text); // SKIP + + Result = OPI_Telegram.SendVideo(Token, ChannelID, Text, VideoPath); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendVideo (Path)"); + + Check_TelegramVideo(Result, Text); // SKIP + + Result = OPI_Telegram.SendVideo(Token, ChannelID, Text, VideoDD); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendVideo (BD)"); + + Check_TelegramVideo(Result, Text); + + DeleteFiles(VideoPath); + + FileID = Result["result"]["video"]["file_id"]; + OPI_GetTestData.WriteParameter("Telegram_FileID", FileID); + + FunctionParameters.Insert("Telegram_FileID", FileID); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendAudio(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Text = FunctionParameters["String"]; -Audio = FunctionParameters["Audio"]; - -AudioPath = GetTempFileName("mp3"); -CopyFile(Audio, AudioPath); - -AudioDD = New BinaryData(AudioPath); - -Result = OPI_Telegram.SendAudio(Token, ChatID, Text, Audio); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendAudio", "Telegram"); - -Check_TelegramAudio(Result, Text); // SKIP - -Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioPath); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendAudio (Path)"); - -Check_TelegramAudio(Result, Text); // SKIP - -Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioDD); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendAudio (BD)"); - -Check_TelegramAudio(Result, Text); - -DeleteFiles(AudioPath); - -FileID = Result["result"]["audio"]["file_id"]; -OPI_GetTestData.WriteParameter("Telegram_FileID", FileID); - -FunctionParameters.Insert("Telegram_FileID", FileID); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Text = FunctionParameters["String"]; + Audio = FunctionParameters["Audio"]; + + AudioPath = GetTempFileName("mp3"); + CopyFile(Audio, AudioPath); + + AudioDD = New BinaryData(AudioPath); + + Result = OPI_Telegram.SendAudio(Token, ChatID, Text, Audio); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendAudio", "Telegram"); + + Check_TelegramAudio(Result, Text); // SKIP + + Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioPath); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendAudio (Path)"); + + Check_TelegramAudio(Result, Text); // SKIP + + Result = OPI_Telegram.SendAudio(Token, ChannelID, Text, AudioDD); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendAudio (BD)"); + + Check_TelegramAudio(Result, Text); + + DeleteFiles(AudioPath); + + FileID = Result["result"]["audio"]["file_id"]; + OPI_GetTestData.WriteParameter("Telegram_FileID", FileID); + + FunctionParameters.Insert("Telegram_FileID", FileID); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendDocument(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Text = FunctionParameters["String"]; -Document = FunctionParameters["Document"]; - -DocumentPath = GetTempFileName("docx"); -CopyFile(Document, DocumentPath); - -DocumentDD = New BinaryData(DocumentPath); - -Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendDocument", "Telegram"); - -Check_TelegramDocument(Result, Text); // SKIP - -Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentPath); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendDocument (Path)"); - -Check_TelegramDocument(Result, Text); // SKIP - -Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentDD); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendDocument (BD)"); - -Check_TelegramDocument(Result, Text); - -DeleteFiles(DocumentPath); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Text = FunctionParameters["String"]; + Document = FunctionParameters["Document"]; + + DocumentPath = GetTempFileName("docx"); + CopyFile(Document, DocumentPath); + + DocumentDD = New BinaryData(DocumentPath); + + Result = OPI_Telegram.SendDocument(Token, ChatID, Text, Document); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendDocument", "Telegram"); + + Check_TelegramDocument(Result, Text); // SKIP + + Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentPath); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendDocument (Path)"); + + Check_TelegramDocument(Result, Text); // SKIP + + Result = OPI_Telegram.SendDocument(Token, ChannelID, Text, DocumentDD); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendDocument (BD)"); + + Check_TelegramDocument(Result, Text); + + DeleteFiles(DocumentPath); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendGif(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Text = FunctionParameters["String"]; -GIF = FunctionParameters["GIF"]; - -GifPath = GetTempFileName("gif"); -CopyFile(GIF, GifPath); - -GifDD = New BinaryData(GifPath); - -Result = OPI_Telegram.SendGif(Token, ChatID, Text, GIF); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendGif", "Telegram"); - -Check_TelegramGif(Result, Text); // SKIP - -Result = OPI_Telegram.SendGif(Token, ChannelID, Text, GifPath); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendGif (Path)"); - -Check_TelegramGif(Result, Text); // SKIP - -Result = OPI_Telegram.SendGif(Token, ChannelID, Text, GifDD); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendGif (BD)"); - -Check_TelegramGif(Result, Text); - -DeleteFiles(GifPath); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Text = FunctionParameters["String"]; + GIF = FunctionParameters["GIF"]; + + GifPath = GetTempFileName("gif"); + CopyFile(GIF, GifPath); + + GifDD = New BinaryData(GifPath); + + Result = OPI_Telegram.SendGif(Token, ChatID, Text, GIF); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendGif", "Telegram"); + + Check_TelegramGif(Result, Text); // SKIP + + Result = OPI_Telegram.SendGif(Token, ChannelID, Text, GifPath); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendGif (Path)"); + + Check_TelegramGif(Result, Text); // SKIP + + Result = OPI_Telegram.SendGif(Token, ChannelID, Text, GifDD); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendGif (BD)"); + + Check_TelegramGif(Result, Text); + + DeleteFiles(GifPath); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendMediaGroup(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -Text = FunctionParameters["String"]; -Image = FunctionParameters["Picture"]; -Video = FunctionParameters["Video"]; - -ImagePath = GetTempFileName("png"); -CopyFile(Image, ImagePath); - -VideoPath = GetTempFileName("mp4"); -CopyFile(Video, VideoPath); - -VideoDD = New BinaryData(VideoPath); - -MediaGroup = New Match; -MediaGroup.Insert(ImagePath, "photo"); -MediaGroup.Insert(VideoDD , "video"); - -Result = OPI_Telegram.SendMediaGroup(Token, ChatID, Text, MediaGroup); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendMediaGroup", "Telegram"); - -Check_TelegramMediaGroup(Result); - -DeleteFiles(VideoPath); -DeleteFiles(ImagePath); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + Text = FunctionParameters["String"]; + Image = FunctionParameters["Picture"]; + Video = FunctionParameters["Video"]; + + ImagePath = GetTempFileName("png"); + CopyFile(Image, ImagePath); + + VideoPath = GetTempFileName("mp4"); + CopyFile(Video, VideoPath); + + VideoDD = New BinaryData(VideoPath); + + MediaGroup = New Match; + MediaGroup.Insert(ImagePath, "photo"); + MediaGroup.Insert(VideoDD , "video"); + + Result = OPI_Telegram.SendMediaGroup(Token, ChatID, Text, MediaGroup); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendMediaGroup", "Telegram"); + + Check_TelegramMediaGroup(Result); + + DeleteFiles(VideoPath); + DeleteFiles(ImagePath); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendLocation(FunctionParameters) + + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Width = FunctionParameters["Lat"]; + Longitude = FunctionParameters["Long"]; + + Result = OPI_Telegram.SendLocation(Token, ChatID, Width, Longitude); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendLocation", "Telegram"); + + Check_TelegramLocation(Result); // SKIP + + Result = OPI_Telegram.SendLocation(Token, ChannelID, Width, Longitude); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendLocation (toаtoл)"); + + Check_TelegramLocation(Result); -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Width = FunctionParameters["Lat"]; -Longitude = FunctionParameters["Long"]; - -Result = OPI_Telegram.SendLocation(Token, ChatID, Width, Longitude); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendLocation", "Telegram"); - -Check_TelegramLocation(Result); // SKIP - -Result = OPI_Telegram.SendLocation(Token, ChannelID, Width, Longitude); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendLocation (toаtoл)"); - -Check_TelegramLocation(Result); - -OPI_Tools.Pause(5); - + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendContact(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Name = FunctionParameters["Name"]; -Last name = FunctionParameters["Surname"]; -Phone = FunctionParameters["Phone"]; - -Result = OPI_Telegram.SendContact(Token, ChatID , Name, Last name, Phone); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendContact", "Telegram"); - -Check_TelegramContact(Result, Name); // SKIP -OPI_Tools.Pause(20); // SKIP - -Result = OPI_Telegram.SendContact(Token, ChannelID, Name, Last name, Phone); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SendContact (toаtoл)"); - -Check_TelegramContact(Result, Name); - -OPI_Tools.Pause(5); + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Name = FunctionParameters["Name"]; + Last name = FunctionParameters["Surname"]; + Phone = FunctionParameters["Phone"]; + + Result = OPI_Telegram.SendContact(Token, ChatID , Name, Last name, Phone); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendContact", "Telegram"); + + Check_TelegramContact(Result, Name); // SKIP + OPI_Tools.Pause(20); // SKIP + + Result = OPI_Telegram.SendContact(Token, ChannelID, Name, Last name, Phone); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SendContact (toаtoл)"); + + Check_TelegramContact(Result, Name); + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_SendPoll(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Question = "What's your favorite color?"; - -AnswersArray = New Array; -AnswersArray.Add("Red"); -AnswersArray.Add("Yellow"); -AnswersArray.Add("Green"); -AnswersArray.Add("Blue"); - -Result = OPI_Telegram.SendPoll(Token, ChatID , Question, AnswersArray, False); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendPoll", "Telegram"); - -Check_TelegramPoll(Result, Question); // SKIP - -Result = OPI_Telegram.SendPoll(Token, ChannelID, Question, AnswersArray, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendPoll (toаtoл)"); - -Check_TelegramPoll(Result, Question); // SKIP - -// END - -StringArray = "['Red', 'Yellow','Green' ,'Blue']"; - -Result = OPI_Telegram.SendPoll(Token, ChannelID, Question, StringArray, True); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendPoll (withтрочный маwithwithиin)"); - -Check_TelegramPoll(Result, Question); - -OPI_Tools.Pause(5); + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Question = "What's your favorite color?"; + + AnswersArray = New Array; + AnswersArray.Add("Red"); + AnswersArray.Add("Yellow"); + AnswersArray.Add("Green"); + AnswersArray.Add("Blue"); + + Result = OPI_Telegram.SendPoll(Token, ChatID , Question, AnswersArray, False); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendPoll", "Telegram"); + + Check_TelegramPoll(Result, Question); // SKIP + + Result = OPI_Telegram.SendPoll(Token, ChannelID, Question, AnswersArray, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendPoll (toаtoл)"); + + Check_TelegramPoll(Result, Question); // SKIP + + // END + + StringArray = "['Red', 'Yellow','Green' ,'Blue']"; + + Result = OPI_Telegram.SendPoll(Token, ChannelID, Question, StringArray, True); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendPoll (withтрочный маwithwithиin)"); + + Check_TelegramPoll(Result, Question); + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_DownloadFile(FunctionParameters) + + FileID = FunctionParameters["Telegram_FileID"]; + Token = FunctionParameters["Telegram_Token"]; -FileID = FunctionParameters["Telegram_FileID"]; -Token = FunctionParameters["Telegram_Token"]; - -Result = OPI_Telegram.DownloadFile(Token, FileID); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DownloadFile", "Telegram"); - -OPI_GetTestData.ExpectsThat(Result).HasType("BinaryData"); - + Result = OPI_Telegram.DownloadFile(Token, FileID); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DownloadFile", "Telegram"); + + OPI_GetTestData.ExpectsThat(Result).HasType("BinaryData"); + EndProcedure Procedure Telegram_ForwardMessage(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChatID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -MessageID = FunctionParameters["Telegram_ChannelMessageID"]; - -Result = OPI_Telegram.ForwardMessage(Token, MessageID, ChannelID, ChatID); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "ForwardMessage", "Telegram"); - -Check_TelegramForward(Result, MessageID); - -OPI_Tools.Pause(5); + Token = FunctionParameters["Telegram_Token"]; + ChatID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + MessageID = FunctionParameters["Telegram_ChannelMessageID"]; + + Result = OPI_Telegram.ForwardMessage(Token, MessageID, ChannelID, ChatID); + + // END + // !OInt OPI_GetTestData.WriteLog(Result, "ForwardMessage", "Telegram"); + + Check_TelegramForward(Result, MessageID); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_Ban(FunctionParameters) + + Token = FunctionParameters["Telegram_Token"]; + UserID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + + Result = OPI_Telegram.Ban(Token, ChannelID, UserID); -Token = FunctionParameters["Telegram_Token"]; -UserID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; - -Result = OPI_Telegram.Ban(Token, ChannelID, UserID); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "Ban", "Telegram"); - -Check_TelegramBan(Result); -OPI_Tools.Pause(5); - + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "Ban", "Telegram"); + + Check_TelegramBan(Result); + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_Unban(FunctionParameters) + + Token = FunctionParameters["Telegram_Token"]; + UserID = FunctionParameters["Telegram_ChatID"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + + Result = OPI_Telegram.Unban(Token, ChannelID, UserID); -Token = FunctionParameters["Telegram_Token"]; -UserID = FunctionParameters["Telegram_ChatID"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; - -Result = OPI_Telegram.Unban(Token, ChannelID, UserID); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "Unban", "Telegram"); - -Check_TelegramBan(Result); -OPI_Tools.Pause(5); - + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "Unban", "Telegram"); + + Check_TelegramBan(Result); + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_CreateInviteLink(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -Day = 86400; -CurrentDate = OPI_Tools.GetCurrentDate(); + Token = FunctionParameters["Telegram_Token"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + Day = 86400; + CurrentDate = OPI_Tools.GetCurrentDate(); -Title = "Link " + String(CurrentDate); -Expiration = CurrentDate + Day; -UnixExpiration = OPI_Tools.UNIXTime(Expiration); - -Result = OPI_Telegram.CreateInvitationLink(Token, ChannelID, Title, Expiration, 200); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateInvitationLink", "Telegram"); - -Check_TelegramInvitation(Result, Title, UnixExpiration); - -OPI_Tools.Pause(5); + Title = "Link " + String(CurrentDate); + Expiration = CurrentDate + Day; + UnixExpiration = OPI_Tools.UNIXTime(Expiration); + + Result = OPI_Telegram.CreateInvitationLink(Token, ChannelID, Title, Expiration, 200); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateInvitationLink", "Telegram"); + Check_TelegramInvitation(Result, Title, UnixExpiration); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_PinMessage(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -MessageID = FunctionParameters["Telegram_ChannelMessageID"]; - -Result = OPI_Telegram.PinMessage(Token, ChannelID, MessageID); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "PinMessage", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(5); + Token = FunctionParameters["Telegram_Token"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + MessageID = FunctionParameters["Telegram_ChannelMessageID"]; + + Result = OPI_Telegram.PinMessage(Token, ChannelID, MessageID); + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "PinMessage", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_UnpinMessage(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; -MessageID = FunctionParameters["Telegram_ChannelMessageID"]; - -Result = OPI_Telegram.UnpinMessage(Token, ChannelID, MessageID); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "UnpinMessage", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(5); + Token = FunctionParameters["Telegram_Token"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + MessageID = FunctionParameters["Telegram_ChannelMessageID"]; + + Result = OPI_Telegram.UnpinMessage(Token, ChannelID, MessageID); + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "UnpinMessage", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_GetParticipantCount(FunctionParameters) - -Token = FunctionParameters["Telegram_Token"]; -ChannelID = FunctionParameters["Telegram_ChannelID"]; - -Result = OPI_Telegram.GetParticipantCount(Token, ChannelID); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetParticipantCount", "Telegram"); - -Check_TelegramNumber(Result); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Telegram_Token"]; + ChannelID = FunctionParameters["Telegram_ChannelID"]; + + Result = OPI_Telegram.GetParticipantCount(Token, ChannelID); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetParticipantCount", "Telegram"); + + Check_TelegramNumber(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_GetForumAvatarList(FunctionParameters) - -Token = FunctionParameters["Telegram_Token"]; -Result = OPI_Telegram.GetAvatarIconList(Token); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetAvatarIconList", "Telegram"); - -OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Telegram_Token"]; + Result = OPI_Telegram.GetAvatarIconList(Token); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetAvatarIconList", "Telegram"); + + OPI_GetTestData.ExpectsThat(Result).HasType("Match").Filled(); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_CreateForumTopic(FunctionParameters) - -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; -Icon = "5357419403325481346"; -Name = "TestTopic " + String(New UniqueIdentifier); - -Result = OPI_Telegram.CreateForumThread(Token, Chat, Name, Icon); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateForumThread", "Telegram"); - -Topic = Result["result"]["message_thread_id"]; - -FunctionParameters.Insert("Telegram_TopicID", Topic); -OPI_Tools.AddField("Telegram_TopicID", Topic, "String", FunctionParameters); -OPI_GetTestData.WriteParameter("Telegram_TopicID", FunctionParameters["Telegram_TopicID"]); - -Check_TelegramCreateTopic(Result, Name, Icon); - -ChatTopic = Chat + "*" + Topic; -Text = FunctionParameters["String"]; -Result = OPI_Telegram.SendTextMessage(Token, ChatTopic, Text); - -// !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage (форум)"); - -Check_TelegramMessage(Result, Text); - + + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + Icon = "5357419403325481346"; + Name = "TestTopic " + String(New UniqueIdentifier); + + Result = OPI_Telegram.CreateForumThread(Token, Chat, Name, Icon); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateForumThread", "Telegram"); + + Topic = Result["result"]["message_thread_id"]; + + FunctionParameters.Insert("Telegram_TopicID", Topic); + OPI_Tools.AddField("Telegram_TopicID", Topic, "String", FunctionParameters); + OPI_GetTestData.WriteParameter("Telegram_TopicID", FunctionParameters["Telegram_TopicID"]); + + Check_TelegramCreateTopic(Result, Name, Icon); + + ChatTopic = Chat + "*" + Topic; + Text = FunctionParameters["String"]; + Result = OPI_Telegram.SendTextMessage(Token, ChatTopic, Text); + + // !OInt OPI_GetTestData.WriteLog(Result, "SendTextMessage (форум)"); + + Check_TelegramMessage(Result, Text); + EndProcedure Procedure Telegram_EditForumTopic(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; -Topic = FunctionParameters["Telegram_TopicID"]; -NewName = "NewTestTitle"; -NewIcon = "5310132165583840589"; - -Result = OPI_Telegram.EditForumTopic(Token, Chat, Topic, NewName, NewIcon); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "EditForumTopic", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(5); + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + Topic = FunctionParameters["Telegram_TopicID"]; + NewName = "NewTestTitle"; + NewIcon = "5310132165583840589"; + Result = OPI_Telegram.EditForumTopic(Token, Chat, Topic, NewName, NewIcon); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "EditForumTopic", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_CloseForumTopic(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; -Topic = FunctionParameters["Telegram_TopicID"]; - -OPI_Telegram.OpenForumThread(Token, Chat); // SKIP - -Result = OPI_Telegram.CloseForumThread(Token, Chat); // Closes main topic - -// !OInt OPI_GetTestData.WriteLog(Result, "CloseForumThread (глаintoя)"); - -Check_TelegramTrue(Result); // SKIP - -Result = OPI_Telegram.CloseForumThread(Token, Chat, Topic); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CloseForumThread", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(25); + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + Topic = FunctionParameters["Telegram_TopicID"]; + OPI_Telegram.OpenForumThread(Token, Chat); // SKIP + + Result = OPI_Telegram.CloseForumThread(Token, Chat); // Closes main topic + + // !OInt OPI_GetTestData.WriteLog(Result, "CloseForumThread (глаintoя)"); + + Check_TelegramTrue(Result); // SKIP + + Result = OPI_Telegram.CloseForumThread(Token, Chat, Topic); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CloseForumThread", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(25); + EndProcedure Procedure Telegram_OpenForumTopic(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; -Topic = FunctionParameters["Telegram_TopicID"]; - -Result = OPI_Telegram.OpenForumThread(Token, Chat); // Opens main topic - -// !OInt OPI_GetTestData.WriteLog(Result, "OpenForumThread (глаintoя)"); - -Check_TelegramTrue(Result); // SKIP - -Result = OPI_Telegram.OpenForumThread(Token, Chat, Topic); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "OpenForumThread", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(25); + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + Topic = FunctionParameters["Telegram_TopicID"]; + Result = OPI_Telegram.OpenForumThread(Token, Chat); // Opens main topic + + // !OInt OPI_GetTestData.WriteLog(Result, "OpenForumThread (глаintoя)"); + + Check_TelegramTrue(Result); // SKIP + + Result = OPI_Telegram.OpenForumThread(Token, Chat, Topic); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "OpenForumThread", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(25); + EndProcedure Procedure Telegram_DeleteForumTopic(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; -Topic = FunctionParameters["Telegram_TopicID"]; - -Result = OPI_Telegram.DeleteForumTopic(Token, Chat, Topic); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteForumTopic", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(25); - + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + Topic = FunctionParameters["Telegram_TopicID"]; + + Result = OPI_Telegram.DeleteForumTopic(Token, Chat, Topic); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteForumTopic", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(25); + EndProcedure Procedure Telegram_ClearPinnedMessagesList(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; -Topic = FunctionParameters["Telegram_TopicID"]; - -Result = OPI_Telegram.ClearThreadPinnedMessagesList(Token, Chat); - -// !OInt OPI_GetTestData.WriteLog(Result, "ClearThreadPinnedMessagesList (глаintoя)"); - -Check_TelegramTrue(Result); // SKIP - -Result = OPI_Telegram.ClearThreadPinnedMessagesList(Token, Chat, Topic); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "ClearThreadPinnedMessagesList", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + Topic = FunctionParameters["Telegram_TopicID"]; + + Result = OPI_Telegram.ClearThreadPinnedMessagesList(Token, Chat); + + // !OInt OPI_GetTestData.WriteLog(Result, "ClearThreadPinnedMessagesList (глаintoя)"); + + Check_TelegramTrue(Result); // SKIP + + Result = OPI_Telegram.ClearThreadPinnedMessagesList(Token, Chat, Topic); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "ClearThreadPinnedMessagesList", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_HideMainForumTopic(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; - -Result = OPI_Telegram.HideMainForumTopic(Token, Chat); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "HideMainForumTopic", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + + Result = OPI_Telegram.HideMainForumTopic(Token, Chat); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "HideMainForumTopic", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_ShowMainForumTopic(FunctionParameters) -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; - -Result = OPI_Telegram.ShowMainForumTopic(Token, Chat); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "ShowMainForumTopic", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + + Result = OPI_Telegram.ShowMainForumTopic(Token, Chat); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "ShowMainForumTopic", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Telegram_ChangeMainTopicName(FunctionParameters) -Title = "New main thread name " + String(New UniqueIdentifier); -Token = FunctionParameters["Telegram_Token"]; -Chat = FunctionParameters["Telegram_ForumID"]; - -Result = OPI_Telegram.EditMainForumTopicName(Token, Chat, Title); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "EditMainForumTopicName", "Telegram"); - -Check_TelegramTrue(Result); - -OPI_Tools.Pause(5); - + Title = "New main thread name " + String(New UniqueIdentifier); + Token = FunctionParameters["Telegram_Token"]; + Chat = FunctionParameters["Telegram_ForumID"]; + + Result = OPI_Telegram.EditMainForumTopicName(Token, Chat, Title); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "EditMainForumTopicName", "Telegram"); + + Check_TelegramTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure #EndRegion @@ -4409,339 +4409,339 @@ EndProcedure Procedure VK_CreateTokenRetrievalLink(FunctionParameters) -Application = FunctionParameters["VK_AppID"]; -Result = OPI_VK.CreateTokenRetrievalLink(Application); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateTokenRetrievalLink", "VK"); - -OPI_GetTestData.ExpectsThat(Result).HasType("String").Filled(); - -OPI_Tools.Pause(5); - + Application = FunctionParameters["VK_AppID"]; + Result = OPI_VK.CreateTokenRetrievalLink(Application); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateTokenRetrievalLink", "VK"); + + OPI_GetTestData.ExpectsThat(Result).HasType("String").Filled(); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_CreatePost(FunctionParameters) + + Parameters = GetVKParameters(); + Text = "Post from autotest"; + URL = "https://github.com/Bayselonarrend/OpenIntegrations"; + + Image = FunctionParameters["Picture"]; // URL, Path or Binary Data + Image2 = FunctionParameters["Picture2"]; // URL, Path or Binary Data + + AndVF = GetTempFileName("png"); + CopyFile(Image2, AndVF); + + ImageArray = New Array; + ImageArray.Add(Image); + ImageArray.Add(AndVF); + + Result = OPI_VK.CreatePost(Text, ImageArray, True, URL, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePost", "VK"); -Parameters = GetVKParameters(); -Text = "Post from autotest"; -URL = "https://github.com/Bayselonarrend/OpenIntegrations"; + Check_VKPost(Result); // SKIP + PostID = Result["response"]["post_id"]; // SKIP + Result = OPI_VK.DeletePost(PostID, Parameters); // SKIP + + Result = OPI_VK.CreatePost(Text, Image, False , , Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePost (оdto toартинtoа)"); -Image = FunctionParameters["Picture"]; // URL, Path or Binary Data -Image2 = FunctionParameters["Picture2"]; // URL, Path or Binary Data - -AndVF = GetTempFileName("png"); -CopyFile(Image2, AndVF); - -ImageArray = New Array; -ImageArray.Add(Image); -ImageArray.Add(AndVF); - -Result = OPI_VK.CreatePost(Text, ImageArray, True, URL, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePost", "VK"); - -Check_VKPost(Result); // SKIP -PostID = Result["response"]["post_id"]; // SKIP -Result = OPI_VK.DeletePost(PostID, Parameters); // SKIP - -Result = OPI_VK.CreatePost(Text, Image, False , , Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePost (оdto toартинtoа)"); - -Check_VKPost(Result); - -PostID = Result["response"]["post_id"]; -Result = OPI_VK.DeletePost(PostID, Parameters); - -OPI_Tools.Pause(5); - -Result = OPI_VK.CreatePost(Text, AndVF , True, URL, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePost (оdин path)"); - -Check_VKPost(Result); - -PostID = Result["response"]["post_id"]; -OPI_Tools.AddField("VK_PostID", PostID, "String", FunctionParameters); -OPI_GetTestData.WriteParameter("VK_PostID", FunctionParameters["VK_PostID"]); - -DeleteFiles(AndVF); -OPI_Tools.Pause(5); + Check_VKPost(Result); + + PostID = Result["response"]["post_id"]; + Result = OPI_VK.DeletePost(PostID, Parameters); + + OPI_Tools.Pause(5); + + Result = OPI_VK.CreatePost(Text, AndVF , True, URL, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePost (оdин path)"); + Check_VKPost(Result); + + PostID = Result["response"]["post_id"]; + OPI_Tools.AddField("VK_PostID", PostID, "String", FunctionParameters); + OPI_GetTestData.WriteParameter("VK_PostID", FunctionParameters["VK_PostID"]); + + DeleteFiles(AndVF); + OPI_Tools.Pause(5); + EndProcedure Procedure VK_DeletePost(FunctionParameters) + + Parameters = GetVKParameters(); + PostID = FunctionParameters["VK_PostID"]; + + Result = OPI_VK.DeletePost(PostID, Parameters); -Parameters = GetVKParameters(); -PostID = FunctionParameters["VK_PostID"]; - -Result = OPI_VK.DeletePost(PostID, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DeletePost", "VK"); - -Check_VKTrue(Result); + // END + // !OInt OPI_GetTestData.WriteLog(Result, "DeletePost", "VK"); + + Check_VKTrue(Result); + EndProcedure Procedure VK_CreateCompositePost(FunctionParameters) -Parameters = GetVKParameters(); -Text = "Post from autotest"; -URL = "https://github.com/Bayselonarrend/OpenIntegrations"; - -Image = FunctionParameters["Picture"]; // URL, Path or Binary Data -Video = FunctionParameters["Video"]; // URL, Path or Binary Data - -AndVF = GetTempFileName("png"); -CopyFile(Image, AndVF); - -ImageUpload = OPI_VK.UploadPhotoToServer(AndVF, Parameters)["response"][0]; -VideoUpload = OPI_VK.UploadVideoToServer(Video, "NewVideo", , , Parameters); - -ImageOwner = OPI_Tools.NumberToString(ImageUpload["owner_id"]); -VideoOwner = OPI_Tools.NumberToString(VideoUpload["owner_id"]); - -ImageID = OPI_Tools.NumberToString(ImageUpload["id"]); -VideoID = OPI_Tools.NumberToString(VideoUpload["video_id"]); - -AttachmentsArray = New Array; -AttachmentsArray.Add("photo" + ImageOwner + "_" + ImageID); -AttachmentsArray.Add("video" + VideoOwner + "_" + VideoID); - -Result = OPI_VK.CreateCompositePost(Text, AttachmentsArray, False, URL, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateCompositePost", "VK"); - -Check_VKPost(Result); -DeleteFiles(AndVF); - -OPI_Tools.Pause(5); - + Parameters = GetVKParameters(); + Text = "Post from autotest"; + URL = "https://github.com/Bayselonarrend/OpenIntegrations"; + + Image = FunctionParameters["Picture"]; // URL, Path or Binary Data + Video = FunctionParameters["Video"]; // URL, Path or Binary Data + + AndVF = GetTempFileName("png"); + CopyFile(Image, AndVF); + + ImageUpload = OPI_VK.UploadPhotoToServer(AndVF, Parameters)["response"][0]; + VideoUpload = OPI_VK.UploadVideoToServer(Video, "NewVideo", , , Parameters); + + ImageOwner = OPI_Tools.NumberToString(ImageUpload["owner_id"]); + VideoOwner = OPI_Tools.NumberToString(VideoUpload["owner_id"]); + + ImageID = OPI_Tools.NumberToString(ImageUpload["id"]); + VideoID = OPI_Tools.NumberToString(VideoUpload["video_id"]); + + AttachmentsArray = New Array; + AttachmentsArray.Add("photo" + ImageOwner + "_" + ImageID); + AttachmentsArray.Add("video" + VideoOwner + "_" + VideoID); + + Result = OPI_VK.CreateCompositePost(Text, AttachmentsArray, False, URL, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateCompositePost", "VK"); + + Check_VKPost(Result); + DeleteFiles(AndVF); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_CreatePoll() -Parameters = GetVKParameters(); -Question = "What's your favorite color?"; - -OptionArray = New Array; -OptionArray.Add("Red"); -OptionArray.Add("Yellow"); -OptionArray.Add("Green"); - -Result = OPI_VK.CreatePoll(Question, OptionArray, , Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreatePoll", "VK"); - -Check_VKPost(Result); - -PostID = Result["response"]["post_id"]; -OPI_VK.DeletePost(PostID, Parameters); - -OPI_Tools.Pause(10); - + Parameters = GetVKParameters(); + Question = "What's your favorite color?"; + + OptionArray = New Array; + OptionArray.Add("Red"); + OptionArray.Add("Yellow"); + OptionArray.Add("Green"); + + Result = OPI_VK.CreatePoll(Question, OptionArray, , Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreatePoll", "VK"); + + Check_VKPost(Result); + + PostID = Result["response"]["post_id"]; + OPI_VK.DeletePost(PostID, Parameters); + + OPI_Tools.Pause(10); + EndProcedure Procedure VK_CreateAlbum(FunctionParameters) - -Parameters = GetVKParameters(); -Name = "AlbumFromAutoTest"; -Description = "NewAlbumFromAutoTest"; - -Result = OPI_VK.CreateAlbum(Name, Description, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateAlbum", "VK"); - -Check_VKAlbum(Result, Description); - -AlbumID = Result["response"]["id"]; -FunctionParameters.Insert("VK_AlbumID", AlbumID); -OPI_GetTestData.WriteParameter("VK_AlbumID", AlbumID); - + + Parameters = GetVKParameters(); + Name = "AlbumFromAutoTest"; + Description = "NewAlbumFromAutoTest"; + + Result = OPI_VK.CreateAlbum(Name, Description, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateAlbum", "VK"); + + Check_VKAlbum(Result, Description); + + AlbumID = Result["response"]["id"]; + FunctionParameters.Insert("VK_AlbumID", AlbumID); + OPI_GetTestData.WriteParameter("VK_AlbumID", AlbumID); + EndProcedure Procedure VK_SavePictureToAlbum(FunctionParameters) - -Parameters = GetVKParameters(); -ImageDescription = "AutoTestImage"; -AlbumID = FunctionParameters["VK_AlbumID"]; - -Image = FunctionParameters["Picture"]; // URL, Path to file or Binary Data -AndVF = GetTempFileName("png"); -CopyFile(Image, AndVF); - -Image = New BinaryData(AndVF); - -Result = OPI_VK.SaveImageToAlbum(AlbumID, Image, ImageDescription, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "SaveImageToAlbum", "VK"); - -Check_VKAlbumPicture(Result, ImageDescription, AlbumID); // SKIP - -ImageID = Result["response"][0]["id"]; // SKIP -Result = OPI_VK.DeleteImage(ImageID, Parameters); // SKIP - -Result = OPI_VK.SaveImageToAlbum(AlbumID, AndVF, ImageDescription, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "SaveImageToAlbum (path)"); - -Check_VKAlbumPicture(Result, ImageDescription, AlbumID); // SKIP - -ImageID = Result["response"][0]["id"]; -FunctionParameters.Insert("VK_PictureID", ImageID); -OPI_GetTestData.WriteParameter("VK_PictureID", ImageID); - -DeleteFiles(AndVF); -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + ImageDescription = "AutoTestImage"; + AlbumID = FunctionParameters["VK_AlbumID"]; + + Image = FunctionParameters["Picture"]; // URL, Path to file or Binary Data + AndVF = GetTempFileName("png"); + CopyFile(Image, AndVF); + + Image = New BinaryData(AndVF); + + Result = OPI_VK.SaveImageToAlbum(AlbumID, Image, ImageDescription, Parameters); + + // !OInt OPI_GetTestData.WriteLog(Result, "SaveImageToAlbum", "VK"); + + Check_VKAlbumPicture(Result, ImageDescription, AlbumID); // SKIP + + ImageID = Result["response"][0]["id"]; // SKIP + Result = OPI_VK.DeleteImage(ImageID, Parameters); // SKIP + + Result = OPI_VK.SaveImageToAlbum(AlbumID, AndVF, ImageDescription, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "SaveImageToAlbum (path)"); + + Check_VKAlbumPicture(Result, ImageDescription, AlbumID); // SKIP + + ImageID = Result["response"][0]["id"]; + FunctionParameters.Insert("VK_PictureID", ImageID); + OPI_GetTestData.WriteParameter("VK_PictureID", ImageID); + + DeleteFiles(AndVF); + OPI_Tools.Pause(5); + EndProcedure Procedure VK_DeleteImage(FunctionParameters) - -Parameters = GetVKParameters(); -ImageID = FunctionParameters["VK_PictureID"]; - -Result = OPI_VK.DeleteImage(ImageID, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteImage", "VK"); - -Check_VKTrue(Result); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + ImageID = FunctionParameters["VK_PictureID"]; + + Result = OPI_VK.DeleteImage(ImageID, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteImage", "VK"); + + Check_VKTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_DeleteAlbum(FunctionParameters) - -Parameters = GetVKParameters(); -AlbumID = FunctionParameters["VK_AlbumID"]; - -Result = OPI_VK.DeleteAlbum(AlbumID, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteAlbum", "VK"); - -Check_VKTrue(Result); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + AlbumID = FunctionParameters["VK_AlbumID"]; + + Result = OPI_VK.DeleteAlbum(AlbumID, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteAlbum", "VK"); + + Check_VKTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_CreateStory(FunctionParameters) -Parameters = GetVKParameters(); -URL = "https://github.com/Bayselonarrend/OpenIntegrations"; + Parameters = GetVKParameters(); + URL = "https://github.com/Bayselonarrend/OpenIntegrations"; -Image = FunctionParameters["Picture"]; // URL, Path to file or Binary Data -AndVF = GetTempFileName("png"); -CopyFile(Image, AndVF); -Image = New BinaryData(AndVF); - -Result = OPI_VK.CreateStory(Image , URL, Parameters); - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateStory", "VK"); - -Check_VKStory(Result); // SKIP - -Result = OPI_VK.CreateStory(AndVF, , Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateStory (path)"); - -Check_VKStory(Result); - -DeleteFiles(AndVF); - -OPI_Tools.Pause(5); + Image = FunctionParameters["Picture"]; // URL, Path to file or Binary Data + AndVF = GetTempFileName("png"); + CopyFile(Image, AndVF); + Image = New BinaryData(AndVF); + + Result = OPI_VK.CreateStory(Image , URL, Parameters); + // !OInt OPI_GetTestData.WriteLog(Result, "CreateStory", "VK"); + + Check_VKStory(Result); // SKIP + + Result = OPI_VK.CreateStory(AndVF, , Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateStory (path)"); + + Check_VKStory(Result); + + DeleteFiles(AndVF); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_CreateDiscussion(FunctionParameters) -Parameters = GetVKParameters(); -Name = "Discussing: Which color is better?"; -Message = "Red, yellow, blue, or some other?"; - -Result = OPI_VK.CreateDiscussion(Name, Message, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateDiscussion", "VK"); - -Check_VKDiscussion(Result); - -DiscussionID = Result["response"]; -FunctionParameters.Insert("VK_ConvID", DiscussionID); -OPI_GetTestData.WriteParameter("VK_ConvID", DiscussionID); - -OPI_Tools.Pause(5); - + Parameters = GetVKParameters(); + Name = "Discussing: Which color is better?"; + Message = "Red, yellow, blue, or some other?"; + + Result = OPI_VK.CreateDiscussion(Name, Message, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateDiscussion", "VK"); + + Check_VKDiscussion(Result); + + DiscussionID = Result["response"]; + FunctionParameters.Insert("VK_ConvID", DiscussionID); + OPI_GetTestData.WriteParameter("VK_ConvID", DiscussionID); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_CloseDiscussion(FunctionParameters) - -Parameters = GetVKParameters(); -DiscussionID = FunctionParameters["VK_ConvID"]; -Result = OPI_VK.CloseDiscussion(DiscussionID, False, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CloseDiscussion", "VK"); - -Check_VKTrue(Result); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + DiscussionID = FunctionParameters["VK_ConvID"]; + Result = OPI_VK.CloseDiscussion(DiscussionID, False, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CloseDiscussion", "VK"); + + Check_VKTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_OpenDiscussion(FunctionParameters) - -Parameters = GetVKParameters(); -DiscussionID = FunctionParameters["VK_ConvID"]; -Result = OPI_VK.OpenDiscussion(DiscussionID, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "OpenDiscussion", "VK"); - -Check_VKTrue(Result); - -OPI_Tools.Pause(5); - + + Parameters = GetVKParameters(); + DiscussionID = FunctionParameters["VK_ConvID"]; + Result = OPI_VK.OpenDiscussion(DiscussionID, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "OpenDiscussion", "VK"); + + Check_VKTrue(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure VK_PostToDiscussion(FunctionParameters) - -Parameters = GetVKParameters(); -DiscussionID = FunctionParameters["VK_ConvID"]; -Message = "I like yellow more"; - -Result = OPI_VK.WriteInDiscussion(DiscussionID, Message, Parameters); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "WriteInDiscussion", "VK"); - -Check_VKDiscussion(Result); - + + Parameters = GetVKParameters(); + DiscussionID = FunctionParameters["VK_ConvID"]; + Message = "I like yellow more"; + + Result = OPI_VK.WriteInDiscussion(DiscussionID, Message, Parameters); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "WriteInDiscussion", "VK"); + + Check_VKDiscussion(Result); + EndProcedure #EndRegion @@ -4750,554 +4750,554 @@ EndProcedure Procedure Dropbox_GetAuthorizationLink(FunctionParameters) -AppKey = FunctionParameters["Dropbox_Appkey"]; -Result = OPI_Dropbox.GetAuthorizationLink(AppKey); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetAuthorizationLink", "Dropbox"); - -OPI_GetTestData.ExpectsThat(Result).HasType("String"); - + AppKey = FunctionParameters["Dropbox_Appkey"]; + Result = OPI_Dropbox.GetAuthorizationLink(AppKey); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetAuthorizationLink", "Dropbox"); + + OPI_GetTestData.ExpectsThat(Result).HasType("String"); + EndProcedure Procedure Dropbox_GetToken(FunctionParameters) + + AppKey = FunctionParameters["Dropbox_Appkey"]; + AppSecret = FunctionParameters["Dropbox_Appsecret"]; + Code = FunctionParameters["Dropbox_Code"]; -AppKey = FunctionParameters["Dropbox_Appkey"]; -AppSecret = FunctionParameters["Dropbox_Appsecret"]; -Code = FunctionParameters["Dropbox_Code"]; - -Result = OPI_Dropbox.GetToken(AppKey, AppSecret, Code); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetToken"); - -Token = Result["access_token"]; -Refresh = Result["refresh_token"]; - -If ValueIsFilled(Token) Then -OPI_GetTestData.WriteParameter("Dropbox_Token", Token); -EndIf; - -If ValueIsFilled(Refresh) Then -OPI_GetTestData.WriteParameter("Dropbox_Refresh", Refresh); -EndIf; - + Result = OPI_Dropbox.GetToken(AppKey, AppSecret, Code); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetToken"); + + Token = Result["access_token"]; + Refresh = Result["refresh_token"]; + + If ValueIsFilled(Token) Then + OPI_GetTestData.WriteParameter("Dropbox_Token", Token); + EndIf; + + If ValueIsFilled(Refresh) Then + OPI_GetTestData.WriteParameter("Dropbox_Refresh", Refresh); + EndIf; + EndProcedure Procedure Dropbox_UpdateToken(FunctionParameters) -AppKey = FunctionParameters["Dropbox_Appkey"]; -AppSecret = FunctionParameters["Dropbox_Appsecret"]; -RefreshToken = FunctionParameters["Dropbox_Refresh"]; - -Result = OPI_Dropbox.RefreshToken(AppKey, AppSecret, RefreshToken); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "RefreshToken"); - -Token = Result["access_token"]; - -OPI_GetTestData.ExpectsThat(Token).Filled(); - -OPI_GetTestData.WriteParameter("Dropbox_Token", Token); + AppKey = FunctionParameters["Dropbox_Appkey"]; + AppSecret = FunctionParameters["Dropbox_Appsecret"]; + RefreshToken = FunctionParameters["Dropbox_Refresh"]; + + Result = OPI_Dropbox.RefreshToken(AppKey, AppSecret, RefreshToken); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "RefreshToken"); + + Token = Result["access_token"]; + + OPI_GetTestData.ExpectsThat(Token).Filled(); + OPI_GetTestData.WriteParameter("Dropbox_Token", Token); + EndProcedure Procedure Dropbox_GetObjectInformation(FunctionParameters) + + Path = "/New/pic.png"; + Token = FunctionParameters["Dropbox_Token"]; + + Result = OPI_Dropbox.GetObjectInformation(Token, Path, True); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetObjectInformation", "Dropbox"); -Path = "/New/pic.png"; -Token = FunctionParameters["Dropbox_Token"]; - -Result = OPI_Dropbox.GetObjectInformation(Token, Path, True); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetObjectInformation", "Dropbox"); - -Check_DropboxFile(Result, Path); - -OPI_Tools.Pause(5); - + Check_DropboxFile(Result, Path); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_GetPreview(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New/mydoc.docx"; - -Result = OPI_Dropbox.GetPreview(Token, Path); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetPreview", "Dropbox"); - -Check_BinaryData(Result, 190834); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New/mydoc.docx"; + + Result = OPI_Dropbox.GetPreview(Token, Path); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetPreview", "Dropbox"); + + Check_BinaryData(Result, 190834); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_UploadFile(FunctionParameters) -Path = "/New/pic.png"; -Token = FunctionParameters["Dropbox_Token"]; -Image = FunctionParameters["Picture"]; - -ImagePath = GetTempFileName("png"); -CopyFile(Image, ImagePath); - -Result = OPI_Dropbox.UploadFile(Token, ImagePath, Path, True); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "UploadFile", "Dropbox"); - -Check_DropboxFile(Result, Path); -DeleteFiles(ImagePath); - -OPI_Tools.Pause(5); - + Path = "/New/pic.png"; + Token = FunctionParameters["Dropbox_Token"]; + Image = FunctionParameters["Picture"]; + + ImagePath = GetTempFileName("png"); + CopyFile(Image, ImagePath); + + Result = OPI_Dropbox.UploadFile(Token, ImagePath, Path, True); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "UploadFile", "Dropbox"); + + Check_DropboxFile(Result, Path); + DeleteFiles(ImagePath); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_UploadFileByURL(FunctionParameters) - -Path = "/New/url_doc.docx"; -Token = FunctionParameters["Dropbox_Token"]; -URL = FunctionParameters["Document"]; - -Result = OPI_Dropbox.UploadFileByURL(Token, URL, Path); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "UploadFileByURL", "Dropbox"); - -Check_DropboxWork(Result); - -Work = Result["async_job_id"]; - -FunctionParameters.Insert("Dropbox_Job", Work); -OPI_GetTestData.WriteParameter("Dropbox_Job", Work); - -OPI_Tools.Pause(5); - + + Path = "/New/url_doc.docx"; + Token = FunctionParameters["Dropbox_Token"]; + URL = FunctionParameters["Document"]; + + Result = OPI_Dropbox.UploadFileByURL(Token, URL, Path); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "UploadFileByURL", "Dropbox"); + + Check_DropboxWork(Result); + + Work = Result["async_job_id"]; + + FunctionParameters.Insert("Dropbox_Job", Work); + OPI_GetTestData.WriteParameter("Dropbox_Job", Work); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_GetUploadStatusByURL(FunctionParameters) -Token = FunctionParameters["Dropbox_Token"]; -WorkID = FunctionParameters["Dropbox_Job"]; -Status = "in_progress"; - -WHile Status = "in_progress" Do - -Result = OPI_Dropbox.GetUploadStatusByURL(Token, WorkID); -Status = Result[".tag"]; - -OPI_Tools.Pause(5); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetUploadStatusByURL", "Dropbox"); - -EndDo; - -// END - -Check_DropboxStatus(Result); - -Path = "/New/url_doc.docx"; -Result = OPI_Dropbox.DeleteObject(Token, Path); - -Check_DropboxMetadata(Result, Path); -OPI_Tools.Pause(5); - + Token = FunctionParameters["Dropbox_Token"]; + WorkID = FunctionParameters["Dropbox_Job"]; + Status = "in_progress"; + + WHile Status = "in_progress" Do + + Result = OPI_Dropbox.GetUploadStatusByURL(Token, WorkID); + Status = Result[".tag"]; + + OPI_Tools.Pause(5); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetUploadStatusByURL", "Dropbox"); + + EndDo; + + // END + + Check_DropboxStatus(Result); + + Path = "/New/url_doc.docx"; + Result = OPI_Dropbox.DeleteObject(Token, Path); + + Check_DropboxMetadata(Result, Path); + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_DeleteObject(FunctionParameters) + + Path = "/New/pic.png"; + Token = FunctionParameters["Dropbox_Token"]; + + Result = OPI_Dropbox.DeleteObject(Token, Path); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject", "Dropbox"); -Path = "/New/pic.png"; -Token = FunctionParameters["Dropbox_Token"]; - -Result = OPI_Dropbox.DeleteObject(Token, Path); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteObject", "Dropbox"); - -Check_DropboxMetadata(Result, Path); - -OPI_Tools.Pause(5); - + Check_DropboxMetadata(Result, Path); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_CopyObject(FunctionParameters) - -Original = "/New/pic.png"; -Copy = "/New/pic_copy.png"; -Token = FunctionParameters["Dropbox_Token"]; - -Result = OPI_Dropbox.CopyObject(Token, Original, Copy); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CopyObject", "Dropbox"); - -Check_DropboxMetadata(Result, Copy); - -Result = OPI_Dropbox.DeleteObject(Token, Copy); -Check_DropboxMetadata(Result, Copy); - -OPI_Tools.Pause(5); - + + Original = "/New/pic.png"; + Copy = "/New/pic_copy.png"; + Token = FunctionParameters["Dropbox_Token"]; + + Result = OPI_Dropbox.CopyObject(Token, Original, Copy); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CopyObject", "Dropbox"); + + Check_DropboxMetadata(Result, Copy); + + Result = OPI_Dropbox.DeleteObject(Token, Copy); + Check_DropboxMetadata(Result, Copy); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_MoveObject(FunctionParameters) - -OriginalPath = "/New/pic.png"; -TargetPath = "/pic.png"; -Token = FunctionParameters["Dropbox_Token"]; - -Result = OPI_Dropbox.MoveObject(Token, OriginalPath, TargetPath); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "Dropbox_MoveObject", "Dropbox"); - -Check_DropboxMetadata(Result, TargetPath); - -Result = OPI_Dropbox.MoveObject(Token, TargetPath, OriginalPath); -Check_DropboxMetadata(Result, OriginalPath); - -OPI_Tools.Pause(5); - + + OriginalPath = "/New/pic.png"; + TargetPath = "/pic.png"; + Token = FunctionParameters["Dropbox_Token"]; + + Result = OPI_Dropbox.MoveObject(Token, OriginalPath, TargetPath); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "Dropbox_MoveObject", "Dropbox"); + + Check_DropboxMetadata(Result, TargetPath); + + Result = OPI_Dropbox.MoveObject(Token, TargetPath, OriginalPath); + Check_DropboxMetadata(Result, OriginalPath); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_CreateFolder(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New toаталог"; - -Result = OPI_Dropbox.CreateFolder(Token, Path); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CreateFolder", "Dropbox"); - -Check_DropboxMetadata(Result, Path); - -Result = OPI_Dropbox.DeleteObject(Token, Path); -Check_DropboxMetadata(Result, Path); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New toаталог"; + + Result = OPI_Dropbox.CreateFolder(Token, Path); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CreateFolder", "Dropbox"); + + Check_DropboxMetadata(Result, Path); + + Result = OPI_Dropbox.DeleteObject(Token, Path); + Check_DropboxMetadata(Result, Path); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_DownloadFile(FunctionParameters) -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New/pic.png"; - -Result = OPI_Dropbox.DownloadFile(Token, Path); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DownloadFile", "Dropbox"); - -Check_BinaryData(Result, 2114023); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New/pic.png"; + + Result = OPI_Dropbox.DownloadFile(Token, Path); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DownloadFile", "Dropbox"); + + Check_BinaryData(Result, 2114023); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_DownloadFolder(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New"; - -Result = OPI_Dropbox.DownloadFolder(Token, Path); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DownloadFolder", "Dropbox"); - -Check_BinaryData(Result); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New"; + + Result = OPI_Dropbox.DownloadFolder(Token, Path); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DownloadFolder", "Dropbox"); + + Check_BinaryData(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_GetFolderFileList(FunctionParameters) + + Path = "/New"; + Token = FunctionParameters["Dropbox_Token"]; + + Result = OPI_Dropbox.GetListOfFolderFiles(Token, Path, True); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetListOfFolderFiles", "Dropbox"); -Path = "/New"; -Token = FunctionParameters["Dropbox_Token"]; - -Result = OPI_Dropbox.GetListOfFolderFiles(Token, Path, True); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetListOfFolderFiles", "Dropbox"); - -Check_DropboxArray(Result); - -OPI_Tools.Pause(5); - -EndProcedure + Check_DropboxArray(Result); + + OPI_Tools.Pause(5); + +EndProcedure Procedure Dropbox_GetObjectVersionList(FunctionParameters) -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New/pic.png"; - -Result = OPI_Dropbox.GetObjectVersionList(Token, Path, 1); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetObjectVersionList", "Dropbox"); - -Check_DropboxArray(Result, 1); - -Revision = Result["entries"][0]["rev"]; - -FunctionParameters.Insert("Dropbox_FileRevision", Revision); -OPI_GetTestData.WriteParameter("Dropbox_FileRevision", Revision); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New/pic.png"; + + Result = OPI_Dropbox.GetObjectVersionList(Token, Path, 1); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetObjectVersionList", "Dropbox"); + + Check_DropboxArray(Result, 1); + + Revision = Result["entries"][0]["rev"]; + + FunctionParameters.Insert("Dropbox_FileRevision", Revision); + OPI_GetTestData.WriteParameter("Dropbox_FileRevision", Revision); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_RestoreObjectToVersion(FunctionParameters) - -Version = FunctionParameters["Dropbox_FileRevision"]; -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New/pic.png"; - -Result = OPI_Dropbox.RestoreObjectToVersion(Token, Path, Version); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "RestoreObjectToVersion", "Dropbox"); - -Check_DropboxFile(Result, Path); - -OPI_Tools.Pause(5); - + + Version = FunctionParameters["Dropbox_FileRevision"]; + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New/pic.png"; + + Result = OPI_Dropbox.RestoreObjectToVersion(Token, Path, Version); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "RestoreObjectToVersion", "Dropbox"); + + Check_DropboxFile(Result, Path); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_GetTagList(FunctionParameters) -Token = FunctionParameters["Dropbox_Token"]; - -PathsArray = New Array; -PathsArray.Add("/New/Dogs.mp3"); -PathsArray.Add("/New/mydoc.docx"); - -Result = OPI_Dropbox.GetTagList(Token, PathsArray); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetTagList", "Dropbox"); - -Check_DropboxTags(Result, PathsArray.Quantity()); - -Result = OPI_Dropbox.GetTagList(Token, "/New/mydoc.docx"); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetTagList (оdиночный)"); - -Check_DropboxTags(Result, 1); - -HasTag = False; - -For Each Tag In Result["paths_to_tags"][0]["tags"] Do -If Tag["tag_text"] = "important" Then -HasTag = True; -EndIf; -EndDo; - -OPI_GetTestData.ExpectsThat(HasTag).Equal(True); - -OPI_Tools.Pause(5); - + Token = FunctionParameters["Dropbox_Token"]; + + PathsArray = New Array; + PathsArray.Add("/New/Dogs.mp3"); + PathsArray.Add("/New/mydoc.docx"); + + Result = OPI_Dropbox.GetTagList(Token, PathsArray); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetTagList", "Dropbox"); + + Check_DropboxTags(Result, PathsArray.Quantity()); + + Result = OPI_Dropbox.GetTagList(Token, "/New/mydoc.docx"); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetTagList (оdиночный)"); + + Check_DropboxTags(Result, 1); + + HasTag = False; + + For Each Tag In Result["paths_to_tags"][0]["tags"] Do + If Tag["tag_text"] = "important" Then + HasTag = True; + EndIf; + EndDo; + + OPI_GetTestData.ExpectsThat(HasTag).Equal(True); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_AddTag(FunctionParameters) - -Tag = "Important"; -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New/mydoc.docx"; - -Result = OPI_Dropbox.AddTag(Token, Path, Tag); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "AddTag", "Dropbox"); - -Check_Empty(Result); - -OPI_Tools.Pause(5); - + + Tag = "Important"; + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New/mydoc.docx"; + + Result = OPI_Dropbox.AddTag(Token, Path, Tag); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "AddTag", "Dropbox"); + + Check_Empty(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_DeleteTag(FunctionParameters) - -Tag = "Important"; -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New/mydoc.docx"; - -Result = OPI_Dropbox.DeleteTag(Token, Path, Tag); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "DeleteTag", "Dropbox"); - -Check_Empty(Result); - -OPI_Tools.Pause(5); - + + Tag = "Important"; + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New/mydoc.docx"; + + Result = OPI_Dropbox.DeleteTag(Token, Path, Tag); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "DeleteTag", "Dropbox"); + + Check_Empty(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_GetAccountInformation(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; - -Result = OPI_Dropbox.GetAccountInformation(Token); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetAccountInformation", "Dropbox"); - -Check_DropboxAccount(Result); - -Result = OPI_Dropbox.GetAccountInformation(Token, Result["account_id"]); - -// !OInt OPI_GetTestData.WriteLog(Result, "GetAccountInformation (withторонний)"); - -Check_DropboxAccount(Result); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Dropbox_Token"]; + + Result = OPI_Dropbox.GetAccountInformation(Token); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetAccountInformation", "Dropbox"); + + Check_DropboxAccount(Result); + + Result = OPI_Dropbox.GetAccountInformation(Token, Result["account_id"]); + + // !OInt OPI_GetTestData.WriteLog(Result, "GetAccountInformation (withторонний)"); + + Check_DropboxAccount(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_GetSpaceUsageData(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; - -Result = OPI_Dropbox.GetSpaceUsageData(Token); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "GetSpaceUsageData", "Dropbox"); - -Check_DropboxSpace(Result); - + + Token = FunctionParameters["Dropbox_Token"]; + + Result = OPI_Dropbox.GetSpaceUsageData(Token); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "GetSpaceUsageData", "Dropbox"); + + Check_DropboxSpace(Result); + EndProcedure Procedure Dropbox_AddUsersToFile(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -Email = FunctionParameters["Dropbox_OtherUser"]; -File = FunctionParameters["Dropbox_FileID"]; - -Result = OPI_Dropbox.AddUsersToFile(Token, File, Email, False); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "AddUserToFile", "Dropbox"); - -Check_DropboxMember(Result, Email, False); - -Mails = New Array; -Mails.Add(Email); - -Result = OPI_Dropbox.AddUsersToFile(Token, File, Mails, True); - -Check_DropboxMember(Result, Email, True); - + + Token = FunctionParameters["Dropbox_Token"]; + Email = FunctionParameters["Dropbox_OtherUser"]; + File = FunctionParameters["Dropbox_FileID"]; + + Result = OPI_Dropbox.AddUsersToFile(Token, File, Email, False); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "AddUserToFile", "Dropbox"); + + Check_DropboxMember(Result, Email, False); + + Mails = New Array; + Mails.Add(Email); + + Result = OPI_Dropbox.AddUsersToFile(Token, File, Mails, True); + + Check_DropboxMember(Result, Email, True); + EndProcedure Procedure Dropbox_PublishFolder(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -Path = "/New"; - -Result = OPI_Dropbox.PublishFolder(Token, Path); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "PublishFolder", "Dropbox"); - -Check_DropboxPublicFolder(Result); - -FolderID = Result["shared_folder_id"]; - -FunctionParameters.Insert("Dropbox_SharedFolder", FolderID); -OPI_GetTestData.WriteParameter("Dropbox_SharedFolder", FolderID); - -OPI_Tools.Pause(5); + + Token = FunctionParameters["Dropbox_Token"]; + Path = "/New"; + + Result = OPI_Dropbox.PublishFolder(Token, Path); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "PublishFolder", "Dropbox"); + + Check_DropboxPublicFolder(Result); + + FolderID = Result["shared_folder_id"]; + + FunctionParameters.Insert("Dropbox_SharedFolder", FolderID); + OPI_GetTestData.WriteParameter("Dropbox_SharedFolder", FolderID); + + OPI_Tools.Pause(5); EndProcedure Procedure Dropbox_CancelFolderPublication(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -Folder = FunctionParameters["Dropbox_SharedFolder"]; - -Result = OPI_Dropbox.CancelFolderPublication(Token, Folder); -CurrentStatus = "in_progress"; -JobID = Result["async_job_id"]; - -WHile CurrentStatus = "in_progress" Do -Result = OPI_Dropbox.GetAsynchronousChangeStatus(Token, JobID); -CurrentStatus = Result[".tag"]; -OPI_Tools.Pause(3); -EndDo; - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CancelFolderPublication", "Dropbox"); - -Check_DropboxStatus(Result); - -OPI_Tools.Pause(5); - + + Token = FunctionParameters["Dropbox_Token"]; + Folder = FunctionParameters["Dropbox_SharedFolder"]; + + Result = OPI_Dropbox.CancelFolderPublication(Token, Folder); + CurrentStatus = "in_progress"; + JobID = Result["async_job_id"]; + + WHile CurrentStatus = "in_progress" Do + Result = OPI_Dropbox.GetAsynchronousChangeStatus(Token, JobID); + CurrentStatus = Result[".tag"]; + OPI_Tools.Pause(3); + EndDo; + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CancelFolderPublication", "Dropbox"); + + Check_DropboxStatus(Result); + + OPI_Tools.Pause(5); + EndProcedure Procedure Dropbox_AddUsersToFolder(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -Email = FunctionParameters["Dropbox_OtherUser"]; -Folder = FunctionParameters["Dropbox_SharedFolder"]; // shared_folder_id - -Result = OPI_Dropbox.AddUsersToFolder(Token, Folder, Email, False); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "AddUserToFile", "Dropbox"); - -Check_Empty(Result); - -Mails = New Array; -Mails.Add(Email); - -Result = OPI_Dropbox.AddUsersToFolder(Token, Folder, Mails, True); - -Check_Empty(Result); - + + Token = FunctionParameters["Dropbox_Token"]; + Email = FunctionParameters["Dropbox_OtherUser"]; + Folder = FunctionParameters["Dropbox_SharedFolder"]; // shared_folder_id + + Result = OPI_Dropbox.AddUsersToFolder(Token, Folder, Email, False); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "AddUserToFile", "Dropbox"); + + Check_Empty(Result); + + Mails = New Array; + Mails.Add(Email); + + Result = OPI_Dropbox.AddUsersToFolder(Token, Folder, Mails, True); + + Check_Empty(Result); + EndProcedure Procedure Dropbox_CancelFilePublication(FunctionParameters) - -Token = FunctionParameters["Dropbox_Token"]; -File = FunctionParameters["Dropbox_FileID"]; - -Result = OPI_Dropbox.CancelFilePublication(Token, File); - -// END - -// !OInt OPI_GetTestData.WriteLog(Result, "CancelFilePublication", "Dropbox"); - -Check_Empty(Result); - + + Token = FunctionParameters["Dropbox_Token"]; + File = FunctionParameters["Dropbox_FileID"]; + + Result = OPI_Dropbox.CancelFilePublication(Token, File); + + // END + + // !OInt OPI_GetTestData.WriteLog(Result, "CancelFilePublication", "Dropbox"); + + Check_Empty(Result); + EndProcedure #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Tests/OPI_Tests.mdo b/src/en/OPI/src/CommonModules/OPI_Tests/OPI_Tests.mdo index d05c3b53e2..84a3a1c9f9 100644 --- a/src/en/OPI/src/CommonModules/OPI_Tests/OPI_Tests.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Tests/OPI_Tests.mdo @@ -1,15 +1,15 @@  -OPI_Tests - - -OPI tests - - -ru -Tests for YaxUnit (OPI) - -true -true -true + OPI_Tests + + + OPI tests + + + ru + Tests for YaxUnit (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Tools/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Tools/Module.bsl index 6dffa2f14d..9840f2ab31 100644 --- a/src/en/OPI/src/CommonModules/OPI_Tools/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Tools/Module.bsl @@ -41,11 +41,11 @@ #Region RequestsWithoutBody Function Get(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val ResponseFile = Undefined) Export -Return ExecuteRequestWithoutBody(URL, "GET", Parameters, AdditionalHeaders, ResponseFile); + Return ExecuteRequestWithoutBody(URL, "GET", Parameters, AdditionalHeaders, ResponseFile); EndFunction Function Delete(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val ResponseFile = Undefined) Export -Return ExecuteRequestWithoutBody(URL, "DELETE", Parameters, AdditionalHeaders, ResponseFile); + Return ExecuteRequestWithoutBody(URL, "DELETE", Parameters, AdditionalHeaders, ResponseFile); EndFunction #EndRegion @@ -53,169 +53,169 @@ EndFunction #Region RequestsWithBody Function Post(Val URL -, Val Parameters = "" -, Val AdditionalHeaders = "" -, Val JSON = True -, Val FullResponse = False -, Val ResponseFile = Undefined) Export - -Return ExecuteRequestWithBody(URL, "POST", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile); - + , Val Parameters = "" + , Val AdditionalHeaders = "" + , Val JSON = True + , Val FullResponse = False + , Val ResponseFile = Undefined) Export + + Return ExecuteRequestWithBody(URL, "POST", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile); + EndFunction Function Patch(Val URL -, Val Parameters = "" -, Val AdditionalHeaders = "" -, Val JSON = True -, Val FullResponse = False -, Val ResponseFile = Undefined) Export - -Return ExecuteRequestWithBody(URL, "PATCH", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile); - + , Val Parameters = "" + , Val AdditionalHeaders = "" + , Val JSON = True + , Val FullResponse = False + , Val ResponseFile = Undefined) Export + + Return ExecuteRequestWithBody(URL, "PATCH", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile); + EndFunction Function Put(Val URL -, Val Parameters = "" -, Val AdditionalHeaders = "" -, Val JSON = True -, Val FullResponse = False -, Val ResponseFile = Undefined) Export - -Return ExecuteRequestWithBody(URL, "PUT", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile); - + , Val Parameters = "" + , Val AdditionalHeaders = "" + , Val JSON = True + , Val FullResponse = False + , Val ResponseFile = Undefined) Export + + Return ExecuteRequestWithBody(URL, "PUT", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile); + EndFunction Function PostBinary(Val URL -, Val Body -, Val AdditionalHeaders -, Val FullResponse = False -, Val DataType = "application/octet-stream") Export - -Return ExecuteRequestWithBinaryData(URL, "POST", Body, AdditionalHeaders, FullResponse, DataType); - + , Val Body + , Val AdditionalHeaders + , Val FullResponse = False + , Val DataType = "application/octet-stream") Export + + Return ExecuteRequestWithBinaryData(URL, "POST", Body, AdditionalHeaders, FullResponse, DataType); + EndFunction -#EndRegion +#EndRegion #Region MultipartRequests Function PostMultipart(Val URL -, Val Parameters = "" -, Val Files = "" -, Val ContentType = "image/jpeg" -, Val AdditionalHeaders = "" -, Val ResponseFile = Undefined) Export + , Val Parameters = "" + , Val Files = "" + , Val ContentType = "image/jpeg" + , Val AdditionalHeaders = "" + , Val ResponseFile = Undefined) Export -Return ExecuteMultipartRequest(URL, "POST", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile); + Return ExecuteMultipartRequest(URL, "POST", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile); EndFunction Function PutMultipart(Val URL -, Val Parameters = "" -, Val Files = "" -, Val ContentType = "image/jpeg" -, Val AdditionalHeaders = "" -, Val ResponseFile = Undefined) Export + , Val Parameters = "" + , Val Files = "" + , Val ContentType = "image/jpeg" + , Val AdditionalHeaders = "" + , Val ResponseFile = Undefined) Export -Return ExecuteMultipartRequest(URL, "PUT", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile); + Return ExecuteMultipartRequest(URL, "PUT", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile); EndFunction Function PostMultipartRelated(Val URL -, Val JSON = "" -, Val Files = "" -, Val AdditionalHeaders = "" -, Val ResponseFile = Undefined) Export - -Return ExecuteMultipartRelatedRequest(URL, "POST", JSON, Files, AdditionalHeaders, ResponseFile); - + , Val JSON = "" + , Val Files = "" + , Val AdditionalHeaders = "" + , Val ResponseFile = Undefined) Export + + Return ExecuteMultipartRelatedRequest(URL, "POST", JSON, Files, AdditionalHeaders, ResponseFile); + EndFunction Function PatchMultipartRelated(Val URL -, Val JSON = "" -, Val Files = "" -, Val AdditionalHeaders = "" -, Val ResponseFile = Undefined) Export - -Return ExecuteMultipartRelatedRequest(URL, "PATCH", JSON, Files, AdditionalHeaders, ResponseFile); - + , Val JSON = "" + , Val Files = "" + , Val AdditionalHeaders = "" + , Val ResponseFile = Undefined) Export + + Return ExecuteMultipartRelatedRequest(URL, "PATCH", JSON, Files, AdditionalHeaders, ResponseFile); + EndFunction #EndRegion #Region Miscellaneous -Procedure ProcessResponse(Response, Val FullResponse = False) Export - -If FullResponse Or TypeValue(Response) <> Type("HTTPResponse") Then -Return; -EndIf; - -BodyFile = Response.GetBodyFileName(); - -If Not BodyFile = Undefined Then -Response = BodyFile; -Return; -EndIf; - -GZip = "gzip"; -NeedsUnpacking = -Response.Headers.Get("Content-Encoding") = GZip -Or Response.Headers.Get("content-encoding") = GZip; - -If NeedsUnpacking Then -Response = UnpackResponse(Response); -EndIf; - -Response = ?(TypeValue(Response) = Type("HTTPResponse"), Response.GetBodyAsBinaryData(), Response); - -If TypeValue(Response) = Type("BinaryData") Then - -Try -Response = JsonToStructure(Response); -Except -Return; -EndTry; - -EndIf; - +Procedure ProcessResponse(Response, Val FullResponse = False) Export + + If FullResponse Or TypeValue(Response) <> Type("HTTPResponse") Then + Return; + EndIf; + + BodyFile = Response.GetBodyFileName(); + + If Not BodyFile = Undefined Then + Response = BodyFile; + Return; + EndIf; + + GZip = "gzip"; + NeedsUnpacking = + Response.Headers.Get("Content-Encoding") = GZip + Or Response.Headers.Get("content-encoding") = GZip; + + If NeedsUnpacking Then + Response = UnpackResponse(Response); + EndIf; + + Response = ?(TypeValue(Response) = Type("HTTPResponse"), Response.GetBodyAsBinaryData(), Response); + + If TypeValue(Response) = Type("BinaryData") Then + + Try + Response = JsonToStructure(Response); + Except + Return; + EndTry; + + EndIf; + EndProcedure Function CreateRequest(Val Address, Val AdditionalHeaders = "", Val DataType = "") Export - -Headers = New Match; -Headers.Insert("Accept-Encoding", "gzip"); -Headers.Insert("Accept" , "*/*"); -Headers.Insert("Connection" , "keep-alive"); -Headers.Insert("Accept-Charset" , "utf-8"); - -If ValueIsFilled(DataType) Then -Headers.Insert("Content-Type", DataType); -EndIf; - -If TypeValue(AdditionalHeaders) = Type("Match") Then - -For Each Title In AdditionalHeaders Do -Headers.Insert(Title.Key, Title.Value); -EndDo; - -EndIf; - -NewRequest = New HTTPRequest(Address, Headers); - -Return NewRequest; - + + Headers = New Match; + Headers.Insert("Accept-Encoding", "gzip"); + Headers.Insert("Accept" , "*/*"); + Headers.Insert("Connection" , "keep-alive"); + Headers.Insert("Accept-Charset" , "utf-8"); + + If ValueIsFilled(DataType) Then + Headers.Insert("Content-Type", DataType); + EndIf; + + If TypeValue(AdditionalHeaders) = Type("Match") Then + + For Each Title In AdditionalHeaders Do + Headers.Insert(Title.Key, Title.Value); + EndDo; + + EndIf; + + NewRequest = New HTTPRequest(Address, Headers); + + Return NewRequest; + EndFunction Function CreateConnection(Val Server, Val User = "", Val Password = "") Export - -Try -SSL = New SecureConnectionOpenSSL; -Return New HTTPConnection(Server, 443, User, Password, , 3000, SSL); -Except -Return New HTTPConnection(Server, 443, User, Password, , 3000); -EndTry; - + + Try + SSL = New SecureConnectionOpenSSL; + Return New HTTPConnection(Server, 443, User, Password, , 3000, SSL); + Except + Return New HTTPConnection(Server, 443, User, Password, , 3000); + EndTry; + EndFunction #EndRegion @@ -226,306 +226,306 @@ EndFunction Function RequestParametersToString(Val Parameters) Export -If Parameters.Quantity() = 0 Then -Return ""; -EndIf; + If Parameters.Quantity() = 0 Then + Return ""; + EndIf; -ParameterString = "?"; + ParameterString = "?"; -For Each Parameter In Parameters Do + For Each Parameter In Parameters Do + + ParameterValue = ConvertParameterToString(Parameter.Value); + + ParameterString = ParameterString + + Parameter.Key + + "=" + + ParameterValue + + "&"; + EndDo; -ParameterValue = ConvertParameterToString(Parameter.Value); + ParameterString = Left(ParameterString, StrLength(ParameterString) - 1); -ParameterString = ParameterString -+ Parameter.Key -+ "=" -+ ParameterValue -+ "&"; -EndDo; - -ParameterString = Left(ParameterString, StrLength(ParameterString) - 1); - -Return ParameterString; + Return ParameterString; EndFunction Function SplitURL(Val URL) Export -URL = StringReplace(URL, "https://", ""); -URL = StringReplace(URL, "http://", ""); -URL = StringReplace(URL, ":443", ""); + URL = StringReplace(URL, "https://", ""); + URL = StringReplace(URL, "http://", ""); + URL = StringReplace(URL, ":443", ""); -Address = Right(URL, StrLength(URL) - StrFind(URL, "/", SearchDirection.FromStart) + 1); -Server = Left(URL, StrFind(URL, "/", SearchDirection.FromStart) - 1); + Address = Right(URL, StrLength(URL) - StrFind(URL, "/", SearchDirection.FromStart) + 1); + Server = Left(URL, StrFind(URL, "/", SearchDirection.FromStart) - 1); + + Try + SSL = New SecureConnectionOpenSSL; + Except + Server = "https://" + Server; + EndTry; + + ReturnStructure = New Structure; + ReturnStructure.Insert("Server", Server); + ReturnStructure.Insert("Address" , Address); -Try -SSL = New SecureConnectionOpenSSL; -Except -Server = "https://" + Server; -EndTry; - -ReturnStructure = New Structure; -ReturnStructure.Insert("Server", Server); -ReturnStructure.Insert("Address" , Address); - -Return ReturnStructure; + Return ReturnStructure; EndFunction Function JsonToStructure(Val Text) Export -If Not ValueIsFilled(Text) Then -Return ""; -EndIf; + If Not ValueIsFilled(Text) Then + Return ""; + EndIf; + + Text = ?(TypeValue(Text) = Type("BinaryData"), GetStringFromBinaryData(Text), Text); -Text = ?(TypeValue(Text) = Type("BinaryData"), GetStringFromBinaryData(Text), Text); + ReadingJSON = New ReadingJSON; + ReadingJSON.SetString(Text); -ReadingJSON = New ReadingJSON; -ReadingJSON.SetString(Text); + Data = ReadJSON(ReadingJSON, True, Undefined, JSONDateFormat.ISO); + ReadingJSON.Close(); -Data = ReadJSON(ReadingJSON, True, Undefined, JSONDateFormat.ISO); -ReadingJSON.Close(); - -Return Data; + Return Data; EndFunction Function JSONString(Val Data, Val Escaping = "No") Export -JSONParameters = New JSONWriteParameters(JSONLineBreak.Windows -, " " -, True -, EscapeJSONCharacters[Escaping] -, False -, False -, False -, False); + JSONParameters = New JSONWriteParameters(JSONLineBreak.Windows + , " " + , True + , EscapeJSONCharacters[Escaping] + , False + , False + , False + , False); -Try - -WritingJSON = New WritingJSON; -WritingJSON.SetString(JSONParameters); - -WriteJSON(WritingJSON, Data); -Return WritingJSON.Close(); - -Except -Return "NOT JSON: " + String(Data); -EndTry; + Try + + WritingJSON = New WritingJSON; + WritingJSON.SetString(JSONParameters); + + WriteJSON(WritingJSON, Data); + Return WritingJSON.Close(); + + Except + Return "NOT JSON: " + String(Data); + EndTry; EndFunction Function NumberToString(Val Number) Export -Return StringReplace(String(Number), Symbols.NPP, ""); + Return StringReplace(String(Number), Symbols.NPP, ""); EndFunction Function ReadJSONFile(Val Path) Export - -ReadingJSON = New ReadingJSON; -ReadingJSON.OpenFile(Path); -Values = ReadJSON(ReadingJSON); - -ReadingJSON.Close(); - -Return Values; - + + ReadingJSON = New ReadingJSON; + ReadingJSON.OpenFile(Path); + Values = ReadJSON(ReadingJSON); + + ReadingJSON.Close(); + + Return Values; + EndFunction Function RequestParametersToMatch(Val ParameterString) Export -ReturnMapping = New Match; -NumberOfParts = 2; -ParameterArray = StrSplit(ParameterString, "&", False); + ReturnMapping = New Match; + NumberOfParts = 2; + ParameterArray = StrSplit(ParameterString, "&", False); -For Each Parameter In ParameterArray Do + For Each Parameter In ParameterArray Do -KeyValueArray = StrSplit(Parameter, "="); + KeyValueArray = StrSplit(Parameter, "="); -If KeyValueArray.Quantity() = NumberOfParts Then -ReturnMapping.Insert(KeyValueArray[0], KeyValueArray[1]); -EndIf; + If KeyValueArray.Quantity() = NumberOfParts Then + ReturnMapping.Insert(KeyValueArray[0], KeyValueArray[1]); + EndIf; -EndDo; + EndDo; -Return ReturnMapping; + Return ReturnMapping; EndFunction Function GetCurrentDate() Export -Return LocalTime(CurrentUniversalDate()); + Return LocalTime(CurrentUniversalDate()); EndFunction Function UNIXTime(Val Date) Export - -OTD = New TypeDescription("Date"); -Date = OTD.ConvertValue(Date); - -UNIX = Format(Date - Date(1970, 1, 1, 1, 0, 0), "HC=10; HDC=0; HG=0"); -UNIX = StringReplace(UNIX, ",", ""); -UNIX = Left(UNIX, 10); - -Return UNIX; - + + OTD = New TypeDescription("Date"); + Date = OTD.ConvertValue(Date); + + UNIX = Format(Date - Date(1970, 1, 1, 1, 0, 0), "HC=10; HDC=0; HG=0"); + UNIX = StringReplace(UNIX, ",", ""); + UNIX = Left(UNIX, 10); + + Return UNIX; + EndFunction Function ProgressInformation(Val Current, Val Total, Val Unit, Val Divider = 1) Export - -Whole = 100; -Current = Round(Current / Divider, 2); -Total = Round(Total / Divider, 2); -Percent = Goal(Current / Total * Whole); - -StrCurrent = NumberToString(Current); -StrTotal = NumberToString(Total); -StrPercentage = NumberToString(Percent); - -Information = StrCurrent + "/" + StrTotal + " " + Unit + " ( " + StrPercentage + "% )"; - -Return Information; - + + Whole = 100; + Current = Round(Current / Divider, 2); + Total = Round(Total / Divider, 2); + Percent = Goal(Current / Total * Whole); + + StrCurrent = NumberToString(Current); + StrTotal = NumberToString(Total); + StrPercentage = NumberToString(Percent); + + Information = StrCurrent + "/" + StrTotal + " " + Unit + " ( " + StrPercentage + "% )"; + + Return Information; + EndFunction Function ConvertDataWithSizeRetrieval(Data, Val MinimumStreamSize = 0) Export - -Size = 0; - -If TypeValue(Data) = Type("String") Then - -FileOnDisk = New File(Data); - -If FileOnDisk.Exists() Then -Size = FileOnDisk.Size(); -Else -OPI_TypeConversion.GetBinaryData(Data); -Size = Data.Size(); -EndIf; - -Else -OPI_TypeConversion.GetBinaryData(Data); -Size = Data.Size(); -EndIf; - -If ValueIsFilled(MinimumStreamSize) Then -If Size < MinimumStreamSize Then -OPI_TypeConversion.GetBinaryData(Data); -Else -OPI_TypeConversion.GetBinaryOrStream(Data); -EndIf; -Else -OPI_TypeConversion.GetBinaryOrStream(Data); -EndIf; - -Return Size; - + + Size = 0; + + If TypeValue(Data) = Type("String") Then + + FileOnDisk = New File(Data); + + If FileOnDisk.Exists() Then + Size = FileOnDisk.Size(); + Else + OPI_TypeConversion.GetBinaryData(Data); + Size = Data.Size(); + EndIf; + + Else + OPI_TypeConversion.GetBinaryData(Data); + Size = Data.Size(); + EndIf; + + If ValueIsFilled(MinimumStreamSize) Then + If Size < MinimumStreamSize Then + OPI_TypeConversion.GetBinaryData(Data); + Else + OPI_TypeConversion.GetBinaryOrStream(Data); + EndIf; + Else + OPI_TypeConversion.GetBinaryOrStream(Data); + EndIf; + + Return Size; + EndFunction Procedure ValueToArray(Value) Export - -Value_ = New Array; -Value_.Add(Value); -Value = Value_; + + Value_ = New Array; + Value_.Add(Value); + Value = Value_; EndProcedure Procedure ReplaceSpecialCharacters(Text, Markup = "Markdown") Export + + CharacterMapping = New Match; + + If Markup = "HTML" Then + + CharacterMapping.Insert("&", "&"); + + ElsIf Markup = "MarkdownV2" Then + + CharacterMapping.Insert("-", "\-"); + CharacterMapping.Insert("+", "\+"); + CharacterMapping.Insert("#", "\#"); + CharacterMapping.Insert("=", "\="); + CharacterMapping.Insert("{", "\{"); + CharacterMapping.Insert("}", "\}"); + CharacterMapping.Insert(".", "\."); + + Else + Return; + EndIf; -CharacterMapping = New Match; - -If Markup = "HTML" Then - -CharacterMapping.Insert("&", "&"); - -ElsIf Markup = "MarkdownV2" Then - -CharacterMapping.Insert("-", "\-"); -CharacterMapping.Insert("+", "\+"); -CharacterMapping.Insert("#", "\#"); -CharacterMapping.Insert("=", "\="); -CharacterMapping.Insert("{", "\{"); -CharacterMapping.Insert("}", "\}"); -CharacterMapping.Insert(".", "\."); - -Else -Return; -EndIf; - -For Each ArraySymbol In CharacterMapping Do -Text = StringReplace(Text, ArraySymbol.Key, ArraySymbol.Value); -EndDo; + For Each ArraySymbol In CharacterMapping Do + Text = StringReplace(Text, ArraySymbol.Key, ArraySymbol.Value); + EndDo; EndProcedure Procedure RemoveEmptyCollectionFields(Collection) Export - -CollectionType = TypeValue(Collection); -OutputCollection = New(CollectionType); - -If CollectionType = Type("Match") Or CollectionType = Type("Structure") Then - -RemoveEmptyKeyValues(Collection, OutputCollection); - -ElsIf CollectionType = Type("Array") Then - -RemoveEmptyArrayElements(Collection, OutputCollection); - -Else - -OutputCollection = Collection; - -EndIf; - -Collection = OutputCollection; - + + CollectionType = TypeValue(Collection); + OutputCollection = New(CollectionType); + + If CollectionType = Type("Match") Or CollectionType = Type("Structure") Then + + RemoveEmptyKeyValues(Collection, OutputCollection); + + ElsIf CollectionType = Type("Array") Then + + RemoveEmptyArrayElements(Collection, OutputCollection); + + Else + + OutputCollection = Collection; + + EndIf; + + Collection = OutputCollection; + EndProcedure Procedure Pause(Val Seconds) Export - -Connection = New HTTPConnection("1C.ru", 11111, , , , Seconds); -Try -Connection.Get(New HTTPRequest("")); -Except -Return; -EndTry; - + + Connection = New HTTPConnection("1C.ru", 11111, , , , Seconds); + Try + Connection.Get(New HTTPRequest("")); + Except + Return; + EndTry; + EndProcedure Procedure AddField(Val Name, Val Value, Val Type, Collection) Export - -Filled = ValueIsFilled(Value); - -If Not Filled Then -Return; -EndIf; - -If Type = "Date" Then -OPI_TypeConversion.GetDate(Value); -Value = UNIXTime(Value); - -ElsIf Type = "Collection" Then -OPI_TypeConversion.GetCollection(Value); - -ElsIf Type = "Boolean" Then -OPI_TypeConversion.GetBoolean(Value); - -ElsIf Type = "FileString" Then -OPI_TypeConversion.GetLine(Value, True); - -ElsIf Type = "Array" Then -OPI_TypeConversion.GetArray(Value); - -ElsIf Type = "BinaryData" Then -OPI_TypeConversion.GetBinaryData(Value); - -ElsIf Type = "Number" Then -OPI_TypeConversion.GetNumber(Value); - -Else -OPI_TypeConversion.GetLine(Value); - -EndIf; - -Collection.Insert(Name, Value); - + + Filled = ValueIsFilled(Value); + + If Not Filled Then + Return; + EndIf; + + If Type = "Date" Then + OPI_TypeConversion.GetDate(Value); + Value = UNIXTime(Value); + + ElsIf Type = "Collection" Then + OPI_TypeConversion.GetCollection(Value); + + ElsIf Type = "Boolean" Then + OPI_TypeConversion.GetBoolean(Value); + + ElsIf Type = "FileString" Then + OPI_TypeConversion.GetLine(Value, True); + + ElsIf Type = "Array" Then + OPI_TypeConversion.GetArray(Value); + + ElsIf Type = "BinaryData" Then + OPI_TypeConversion.GetBinaryData(Value); + + ElsIf Type = "Number" Then + OPI_TypeConversion.GetNumber(Value); + + Else + OPI_TypeConversion.GetLine(Value); + + EndIf; + + Collection.Insert(Name, Value); + EndProcedure #EndRegion @@ -535,497 +535,497 @@ EndProcedure #Region ServiceProceduresAndFunctions Function ExecuteRequestWithBody(Val URL -, Val View -, Val Parameters = "" -, Val AdditionalHeaders = "" -, Val JSON = True -, Val FullResponse = False -, Val ResponseFile = Undefined) + , Val View + , Val Parameters = "" + , Val AdditionalHeaders = "" + , Val JSON = True + , Val FullResponse = False + , Val ResponseFile = Undefined) + + If Not ValueIsFilled(Parameters) Then + Parameters = New Structure; + EndIf; + + DataType = ?(JSON, "application/json; charset=utf-8", "application/x-www-form-urlencoded; charset=utf-8"); + URLStructure = SplitURL(URL); + Server = URLStructure["Server"]; + Address = URLStructure["Address"]; + + Request = CreateRequest(Address, AdditionalHeaders, DataType); + Connection = CreateConnection(Server); + + SetRequestBody(Request, Parameters, JSON); -If Not ValueIsFilled(Parameters) Then -Parameters = New Structure; -EndIf; + If ValueIsFilled(ResponseFile) Then + Response = Connection.CallHTTPMethod(View, Request, ResponseFile); + Else + Response = Connection.CallHTTPMethod(View, Request); + EndIf; + + If ThisIsRedirection(Response) Then + Response = ExecuteRequestWithBody(Response.Headers["Location"] + , View + , Parameters + , AdditionalHeaders + , JSON + , FullResponse + , ResponseFile); + Else + ProcessResponse(Response, FullResponse); + EndIf; -DataType = ?(JSON, "application/json; charset=utf-8", "application/x-www-form-urlencoded; charset=utf-8"); -URLStructure = SplitURL(URL); -Server = URLStructure["Server"]; -Address = URLStructure["Address"]; - -Request = CreateRequest(Address, AdditionalHeaders, DataType); -Connection = CreateConnection(Server); - -SetRequestBody(Request, Parameters, JSON); - -If ValueIsFilled(ResponseFile) Then -Response = Connection.CallHTTPMethod(View, Request, ResponseFile); -Else -Response = Connection.CallHTTPMethod(View, Request); -EndIf; - -If ThisIsRedirection(Response) Then -Response = ExecuteRequestWithBody(Response.Headers["Location"] -, View -, Parameters -, AdditionalHeaders -, JSON -, FullResponse -, ResponseFile); -Else -ProcessResponse(Response, FullResponse); -EndIf; - -Return Response; + Return Response; EndFunction Function ExecuteRequestWithBinaryData(Val URL -, Val View -, Val Data -, Val AdditionalHeaders -, Val FullResponse -, Val DataType) + , Val View + , Val Data + , Val AdditionalHeaders + , Val FullResponse + , Val DataType) + + URLStructure = SplitURL(URL); + Server = URLStructure["Server"]; + Address = URLStructure["Address"]; + + Request = CreateRequest(Address, AdditionalHeaders, DataType); + Connection = CreateConnection(Server); + + Request.SetBodyFromBinaryData(Data); + + Response = Connection.CallHTTPMethod(View, Request); -URLStructure = SplitURL(URL); -Server = URLStructure["Server"]; -Address = URLStructure["Address"]; + If ThisIsRedirection(Response) Then + Response = ExecuteRequestWithBinaryData(Response.Headers["Location"] + , View + , Data + , AdditionalHeaders + , FullResponse + , DataType); + Else + ProcessResponse(Response, FullResponse); + EndIf; -Request = CreateRequest(Address, AdditionalHeaders, DataType); -Connection = CreateConnection(Server); - -Request.SetBodyFromBinaryData(Data); - -Response = Connection.CallHTTPMethod(View, Request); - -If ThisIsRedirection(Response) Then -Response = ExecuteRequestWithBinaryData(Response.Headers["Location"] -, View -, Data -, AdditionalHeaders -, FullResponse -, DataType); -Else -ProcessResponse(Response, FullResponse); -EndIf; - -Return Response; + Return Response; EndFunction Function ExecuteRequestWithoutBody(Val URL -, Val View -, Val Parameters = "" -, Val AdditionalHeaders = "" -, Val ResponseFile = Undefined) + , Val View + , Val Parameters = "" + , Val AdditionalHeaders = "" + , Val ResponseFile = Undefined) + + If Not ValueIsFilled(Parameters) Then + Parameters = New Structure; + EndIf; -If Not ValueIsFilled(Parameters) Then -Parameters = New Structure; -EndIf; - -URLStructure = SplitURL(URL); -Server = URLStructure["Server"]; -Address = URLStructure["Address"] + RequestParametersToString(Parameters); - -Request = CreateRequest(Address, AdditionalHeaders); -Connection = CreateConnection(Server); - -If ValueIsFilled(ResponseFile) Then -Response = Connection.CallHTTPMethod(View, Request, ResponseFile); -Else -Response = Connection.CallHTTPMethod(View, Request); -EndIf; - -If ThisIsRedirection(Response) Then -Response = ExecuteRequestWithoutBody(Response.Headers["Location"], View, Parameters, AdditionalHeaders, ResponseFile); -Else -ProcessResponse(Response); -EndIf; - -Return Response; + URLStructure = SplitURL(URL); + Server = URLStructure["Server"]; + Address = URLStructure["Address"] + RequestParametersToString(Parameters); + + Request = CreateRequest(Address, AdditionalHeaders); + Connection = CreateConnection(Server); + + If ValueIsFilled(ResponseFile) Then + Response = Connection.CallHTTPMethod(View, Request, ResponseFile); + Else + Response = Connection.CallHTTPMethod(View, Request); + EndIf; + + If ThisIsRedirection(Response) Then + Response = ExecuteRequestWithoutBody(Response.Headers["Location"], View, Parameters, AdditionalHeaders, ResponseFile); + Else + ProcessResponse(Response); + EndIf; + Return Response; + EndFunction Function ExecuteMultipartRequest(Val URL -, Val View -, Val Parameters = "" -, Val Files = "" -, Val ContentType = "image/jpeg" -, Val AdditionalHeaders = "" -, Val ResponseFile = Undefined) + , Val View + , Val Parameters = "" + , Val Files = "" + , Val ContentType = "image/jpeg" + , Val AdditionalHeaders = "" + , Val ResponseFile = Undefined) + + If Not ValueIsFilled(Parameters) Then + Parameters = New Structure; + EndIf; -If Not ValueIsFilled(Parameters) Then -Parameters = New Structure; -EndIf; + If Not ValueIsFilled(Files) Then + Files = New Match; + EndIf; -If Not ValueIsFilled(Files) Then -Files = New Match; -EndIf; + Redirection = 300; + Error = 400; + Boundary = StringReplace(String(New UniqueIdentifier), "-", ""); + LineSeparator = Symbols.VK + Symbols.PS; + DataType = "multipart/form-data; boundary=" + Boundary; + URLStructure = SplitURL(URL); + Server = URLStructure["Server"]; + Address = URLStructure["Address"]; + + Request = CreateRequest(Address, AdditionalHeaders, DataType); + Connection = CreateConnection(Server); + + RequestBody = GetTempFileName(); + TextRecord = New DataRecording(RequestBody + , TextEncoding.UTF8 + , ByteOrder.LittleEndian + , "" + , False + , "" + , False); -Redirection = 300; -Error = 400; -Boundary = StringReplace(String(New UniqueIdentifier), "-", ""); -LineSeparator = Symbols.VK + Symbols.PS; -DataType = "multipart/form-data; boundary=" + Boundary; -URLStructure = SplitURL(URL); -Server = URLStructure["Server"]; -Address = URLStructure["Address"]; - -Request = CreateRequest(Address, AdditionalHeaders, DataType); -Connection = CreateConnection(Server); - -RequestBody = GetTempFileName(); -TextRecord = New DataRecording(RequestBody -, TextEncoding.UTF8 -, ByteOrder.LittleEndian -, "" -, False -, "" -, False); - -WriteMultipartParameters(TextRecord, Boundary, Parameters); -WriteMultipartFiles(TextRecord, Boundary, ContentType, Files); - -TextRecord.WriteString("--" + boundary + "--" + LineSeparator); -TextRecord.Close(); - -Request.SetBodyFileName(RequestBody); - -If ValueIsFilled(ResponseFile) Then -Response = Connection.CallHTTPMethod(View, Request, ResponseFile); -Else -Response = Connection.CallHTTPMethod(View, Request); -EndIf; - -ThisIsRedirection = Response.StatusCode >= Redirection And Response.StatusCode < Error; - -If ThisIsRedirection Then -Response = ExecuteMultipartRequest(Response.Headers["Location"] -, View -, Parameters -, Files -, ContentType -, AdditionalHeaders -, ResponseFile); -Else -ProcessResponse(Response); -EndIf; - -Request = Undefined; -TextRecord = Undefined; - -DeleteFiles(RequestBody); -Return Response; + WriteMultipartParameters(TextRecord, Boundary, Parameters); + WriteMultipartFiles(TextRecord, Boundary, ContentType, Files); + + TextRecord.WriteString("--" + boundary + "--" + LineSeparator); + TextRecord.Close(); + Request.SetBodyFileName(RequestBody); + + If ValueIsFilled(ResponseFile) Then + Response = Connection.CallHTTPMethod(View, Request, ResponseFile); + Else + Response = Connection.CallHTTPMethod(View, Request); + EndIf; + + ThisIsRedirection = Response.StatusCode >= Redirection And Response.StatusCode < Error; + + If ThisIsRedirection Then + Response = ExecuteMultipartRequest(Response.Headers["Location"] + , View + , Parameters + , Files + , ContentType + , AdditionalHeaders + , ResponseFile); + Else + ProcessResponse(Response); + EndIf; + + Request = Undefined; + TextRecord = Undefined; + + DeleteFiles(RequestBody); + Return Response; + EndFunction Function ExecuteMultipartRelatedRequest(Val URL -, Val View -, Val JSON = "" -, Val Files = "" -, Val AdditionalHeaders = "" -, Val ResponseFile = Undefined) + , Val View + , Val JSON = "" + , Val Files = "" + , Val AdditionalHeaders = "" + , Val ResponseFile = Undefined) + + Redirection = 300; + Error = 400; + Boundary = StringReplace(String(New UniqueIdentifier), "-", ""); + LineSeparator = Symbols.VK + Symbols.PS; + DataType = "multipart/related; boundary=" + Boundary; + URLStructure = SplitURL(URL); + Server = URLStructure["Server"]; + Address = URLStructure["Address"]; + + Request = CreateRequest(Address, AdditionalHeaders, DataType); + Connection = CreateConnection(Server); + + RequestBody = GetTempFileName(); + TextRecord = New DataRecording(RequestBody + , TextEncoding.UTF8 + , ByteOrder.LittleEndian + , "" + , False + , "" + , False); + + WriteJSONMultipart(TextRecord, Boundary, JSON); + WriteRelatedFiles(TextRecord, Boundary, Files); + + TextRecord.WriteString("--" + boundary + "--" + LineSeparator); + TextRecord.Close(); + + AddContentLength(Request); + + Request.SetBodyFileName(RequestBody); + + If ValueIsFilled(ResponseFile) Then + Response = Connection.CallHTTPMethod(View, Request, ResponseFile); + Else + Response = Connection.CallHTTPMethod(View, Request); + EndIf; + + ThisIsRedirection = Response.StatusCode >= Redirection And Response.StatusCode < Error; + + If ThisIsRedirection Then + Response = ExecuteMultipartRelatedRequest(Response.Headers["Location"] + , View + , JSON + , Files + , AdditionalHeaders + , ResponseFile); + Else + ProcessResponse(Response); + EndIf; + + Request = Undefined; + TextRecord = Undefined; -Redirection = 300; -Error = 400; -Boundary = StringReplace(String(New UniqueIdentifier), "-", ""); -LineSeparator = Symbols.VK + Symbols.PS; -DataType = "multipart/related; boundary=" + Boundary; -URLStructure = SplitURL(URL); -Server = URLStructure["Server"]; -Address = URLStructure["Address"]; - -Request = CreateRequest(Address, AdditionalHeaders, DataType); -Connection = CreateConnection(Server); - -RequestBody = GetTempFileName(); -TextRecord = New DataRecording(RequestBody -, TextEncoding.UTF8 -, ByteOrder.LittleEndian -, "" -, False -, "" -, False); - -WriteJSONMultipart(TextRecord, Boundary, JSON); -WriteRelatedFiles(TextRecord, Boundary, Files); - -TextRecord.WriteString("--" + boundary + "--" + LineSeparator); -TextRecord.Close(); - -AddContentLength(Request); - -Request.SetBodyFileName(RequestBody); - -If ValueIsFilled(ResponseFile) Then -Response = Connection.CallHTTPMethod(View, Request, ResponseFile); -Else -Response = Connection.CallHTTPMethod(View, Request); -EndIf; - -ThisIsRedirection = Response.StatusCode >= Redirection And Response.StatusCode < Error; - -If ThisIsRedirection Then -Response = ExecuteMultipartRelatedRequest(Response.Headers["Location"] -, View -, JSON -, Files -, AdditionalHeaders -, ResponseFile); -Else -ProcessResponse(Response); -EndIf; - -Request = Undefined; -TextRecord = Undefined; - -DeleteFiles(RequestBody); -Return Response; + DeleteFiles(RequestBody); + Return Response; EndFunction Function ThisIsRedirection(Val Response) + + Redirection = 300; + Error = 400; -Redirection = 300; -Error = 400; - -ThisIsRedirection = Response.StatusCode >= Redirection -And Response.StatusCode < Error -And ValueIsFilled(Response.Headers["Location"]); - -Return ThisIsRedirection; - + ThisIsRedirection = Response.StatusCode >= Redirection + And Response.StatusCode < Error + And ValueIsFilled(Response.Headers["Location"]); + + Return ThisIsRedirection; + EndFunction Function ConvertParameterToString(Val Value) -If TypeValue(Value) = Type("Array") Then -Value = StrJoin(Value, ","); -Value = EncodeString(Value, StringEncodingMethod.URLencoding); -Value = "[" + Value + "]"; -Else -Value = NumberToString(Value); -Value = EncodeString(Value, StringEncodingMethod.URLencoding); -EndIf; - -Return Value; - + If TypeValue(Value) = Type("Array") Then + Value = StrJoin(Value, ","); + Value = EncodeString(Value, StringEncodingMethod.URLencoding); + Value = "[" + Value + "]"; + Else + Value = NumberToString(Value); + Value = EncodeString(Value, StringEncodingMethod.URLencoding); + EndIf; + + Return Value; + EndFunction Procedure SetRequestBody(Request, Val Parameters, Val JSON) - -Collection = TypeValue(Parameters) = Type("Structure") -Or TypeValue(Parameters) = Type("Match") -Or TypeValue(Parameters) = Type("Array"); - -If JSON Then -Data = JSONString(Parameters); -ElsIf Not Collection Then -Data = Parameters; -Else -ParameterString = RequestParametersToString(Parameters); -Data = Right(ParameterString, StrLength(ParameterString) - 1); -EndIf; - -If TypeValue(Data) = Type("String") Then -Request.SetBodyFromString(Data); -Else -//@skip-check wrong-type-expression -Request.SetBodyFromBinaryData(Data); -EndIf; - + + Collection = TypeValue(Parameters) = Type("Structure") + Or TypeValue(Parameters) = Type("Match") + Or TypeValue(Parameters) = Type("Array"); + + If JSON Then + Data = JSONString(Parameters); + ElsIf Not Collection Then + Data = Parameters; + Else + ParameterString = RequestParametersToString(Parameters); + Data = Right(ParameterString, StrLength(ParameterString) - 1); + EndIf; + + If TypeValue(Data) = Type("String") Then + Request.SetBodyFromString(Data); + Else + //@skip-check wrong-type-expression + Request.SetBodyFromBinaryData(Data); + EndIf; + EndProcedure Procedure WriteMultipartParameters(TextRecord, Val Boundary, Val Parameters) - -LineSeparator = Symbols.VK + Symbols.PS; - -For Each Parameter In Parameters Do - -If Parameter.Value = Undefined -Or Parameter.Value = NULL Then -Continue; -EndIf; - -TextRecord.WriteString("--" + boundary + LineSeparator); -TextRecord.WriteString("Content-Disposition: form-data; name=""" + Parameter.Key + """"); -TextRecord.WriteString(LineSeparator); -TextRecord.WriteString(LineSeparator); - -If TypeValue(Parameter.Value) = Type("String") -Or TypeValue(Parameter.Value) = Type("Number") Then - -ValueAsString = NumberToString(Parameter.Value); -TextRecord.WriteString(ValueAsString); - -ElsIf TypeValue(Parameter.Value) = Type("Boolean") Then - -TextRecord.WriteString(?(Parameter.Value, "true", "false")); - -Else - -TextRecord.Write(Parameter.Value); - -EndIf; - -TextRecord.WriteString(LineSeparator); - -EndDo; - + + LineSeparator = Symbols.VK + Symbols.PS; + + For Each Parameter In Parameters Do + + If Parameter.Value = Undefined + Or Parameter.Value = NULL Then + Continue; + EndIf; + + TextRecord.WriteString("--" + boundary + LineSeparator); + TextRecord.WriteString("Content-Disposition: form-data; name=""" + Parameter.Key + """"); + TextRecord.WriteString(LineSeparator); + TextRecord.WriteString(LineSeparator); + + If TypeValue(Parameter.Value) = Type("String") + Or TypeValue(Parameter.Value) = Type("Number") Then + + ValueAsString = NumberToString(Parameter.Value); + TextRecord.WriteString(ValueAsString); + + ElsIf TypeValue(Parameter.Value) = Type("Boolean") Then + + TextRecord.WriteString(?(Parameter.Value, "true", "false")); + + Else + + TextRecord.Write(Parameter.Value); + + EndIf; + + TextRecord.WriteString(LineSeparator); + + EndDo; + EndProcedure Procedure WriteMultipartFiles(TextRecord, Val Boundary, Val ContentType, Val Files) - -ContentType = ShortLP(ContentType); -LineSeparator = Symbols.VK + Symbols.PS; -DotReplacement = "___"; - -For Each File In Files Do - -FilePath = StringReplace(File.Key, DotReplacement, "."); - -If ContentType = "image/jpeg" Then -SendingFileName = "photo"; -Else -SendingFileName = StringReplace(File.Key, DotReplacement, "."); -SendingFileName = Left(SendingFileName, StrFind(SendingFileName, ".") - 1); -SendingFileName = ?(ValueIsFilled(SendingFileName), SendingFileName, StringReplace(File.Key, -DotReplacement, ".")); -EndIf; - -TextRecord.WriteString("--" + boundary + LineSeparator); -TextRecord.WriteString("Content-Disposition: form-data; name=""" -+ SendingFileName -+ """; filename=""" -+ FilePath -+ """"); -TextRecord.WriteString(LineSeparator); - -If ValueIsFilled(ContentType) Then -TextRecord.WriteString("Content-Type: " + ContentType); -EndIf; - -TextRecord.WriteString(LineSeparator); -TextRecord.WriteString(LineSeparator); -WriteBinaryData(TextRecord, File.Value); -TextRecord.WriteString(LineSeparator); - -EndDo; + + ContentType = ShortLP(ContentType); + LineSeparator = Symbols.VK + Symbols.PS; + DotReplacement = "___"; + + For Each File In Files Do + + FilePath = StringReplace(File.Key, DotReplacement, "."); + + If ContentType = "image/jpeg" Then + SendingFileName = "photo"; + Else + SendingFileName = StringReplace(File.Key, DotReplacement, "."); + SendingFileName = Left(SendingFileName, StrFind(SendingFileName, ".") - 1); + SendingFileName = ?(ValueIsFilled(SendingFileName), SendingFileName, StringReplace(File.Key, + DotReplacement, ".")); + EndIf; + + TextRecord.WriteString("--" + boundary + LineSeparator); + TextRecord.WriteString("Content-Disposition: form-data; name=""" + + SendingFileName + + """; filename=""" + + FilePath + + """"); + TextRecord.WriteString(LineSeparator); + + If ValueIsFilled(ContentType) Then + TextRecord.WriteString("Content-Type: " + ContentType); + EndIf; + + TextRecord.WriteString(LineSeparator); + TextRecord.WriteString(LineSeparator); + WriteBinaryData(TextRecord, File.Value); + TextRecord.WriteString(LineSeparator); + + EndDo; EndProcedure Procedure WriteRelatedFiles(TextRecord, Val Boundary, Val Files) - -If Not ValueIsFilled(Files) Then -Return; -EndIf; - -LineSeparator = Symbols.VK + Symbols.PS; - -If TypeValue(Files) = Type("Match") Then -For Each File In Files Do - -TextRecord.WriteString("--" + boundary + LineSeparator); -TextRecord.WriteString("Content-Type: " + File.Value); -TextRecord.WriteString(LineSeparator); -TextRecord.WriteString(LineSeparator); -WriteBinaryData(TextRecord, File.Key); -TextRecord.WriteString(LineSeparator); -TextRecord.WriteString(LineSeparator); - -EndDo; - -EndIf; + + If Not ValueIsFilled(Files) Then + Return; + EndIf; + + LineSeparator = Symbols.VK + Symbols.PS; + + If TypeValue(Files) = Type("Match") Then + For Each File In Files Do + + TextRecord.WriteString("--" + boundary + LineSeparator); + TextRecord.WriteString("Content-Type: " + File.Value); + TextRecord.WriteString(LineSeparator); + TextRecord.WriteString(LineSeparator); + WriteBinaryData(TextRecord, File.Key); + TextRecord.WriteString(LineSeparator); + TextRecord.WriteString(LineSeparator); + + EndDo; + + EndIf; EndProcedure Procedure WriteBinaryData(DataRecording, Val BinaryData) + + ChunkSize = 268435456; + BytesRead = 0; + CurrentPosition = 0; + TotalSize = BinaryData.Size(); -ChunkSize = 268435456; -BytesRead = 0; -CurrentPosition = 0; -TotalSize = BinaryData.Size(); + WHile BytesRead < TotalSize Do + + ReadingData = New ReadingData(BinaryData); + BytesRead = ReadingData.Skip(CurrentPosition); + Result = ReadingData.Read(ChunkSize); + Current data = Result.GetBinaryData(); + CurrentSize = Current data.Size(); + + If Not ValueIsFilled(Current data) Then + Break; + EndIf; -WHile BytesRead < TotalSize Do + DataRecording.Write(Current data); + + // !OInt ReleaseObject(Current data); + // !OInt PerformGarbageCollection(); -ReadingData = New ReadingData(BinaryData); -BytesRead = ReadingData.Skip(CurrentPosition); -Result = ReadingData.Read(ChunkSize); -Current data = Result.GetBinaryData(); -CurrentSize = Current data.Size(); - -If Not ValueIsFilled(Current data) Then -Break; -EndIf; - -DataRecording.Write(Current data); - -// !OInt ReleaseObject(Current data); -// !OInt PerformGarbageCollection(); - -CurrentPosition = CurrentPosition + CurrentSize; - -EndDo; + CurrentPosition = CurrentPosition + CurrentSize; + + EndDo; EndProcedure Procedure WriteJSONMultipart(TextRecord, Val Boundary, Val JSON) - -If Not ValueIsFilled(JSON) Then -Return; -EndIf; - -LineSeparator = Symbols.VK + Symbols.PS; - -TextRecord.WriteString("--" + boundary + LineSeparator); -TextRecord.WriteString("Content-Type: application/json; charset=UTF-8"); -TextRecord.WriteString(LineSeparator); -TextRecord.WriteString(LineSeparator); -TextRecord.WriteString(JSON); -TextRecord.WriteString(LineSeparator); -TextRecord.WriteString(LineSeparator); + + If Not ValueIsFilled(JSON) Then + Return; + EndIf; + + LineSeparator = Symbols.VK + Symbols.PS; + + TextRecord.WriteString("--" + boundary + LineSeparator); + TextRecord.WriteString("Content-Type: application/json; charset=UTF-8"); + TextRecord.WriteString(LineSeparator); + TextRecord.WriteString(LineSeparator); + TextRecord.WriteString(JSON); + TextRecord.WriteString(LineSeparator); + TextRecord.WriteString(LineSeparator); EndProcedure Procedure AddContentLength(Request) - -RequestBody = Request.GetBodyAsBinaryData(); - -If ValueIsFilled(RequestBody) Then - -Size = RequestBody.Size(); -Request.Headers.Insert("Content-Length", NumberToString(Size)); - -EndIf; + + RequestBody = Request.GetBodyAsBinaryData(); + + If ValueIsFilled(RequestBody) Then + + Size = RequestBody.Size(); + Request.Headers.Insert("Content-Length", NumberToString(Size)); + + EndIf; EndProcedure Procedure RemoveEmptyKeyValues(Val Collection, OutputCollection) - -For Each CollectionItem In Collection Do - -If Not CollectionItem.Value = Undefined And Not CollectionItem.Value = NULL Then -OutputCollection.Insert(CollectionItem.Key, CollectionItem.Value); -EndIf; - -EndDo; - + + For Each CollectionItem In Collection Do + + If Not CollectionItem.Value = Undefined And Not CollectionItem.Value = NULL Then + OutputCollection.Insert(CollectionItem.Key, CollectionItem.Value); + EndIf; + + EndDo; + EndProcedure Procedure RemoveEmptyArrayElements(Val Collection, OutputCollection) - -For Each CollectionItem In Collection Do - -If Not CollectionItem = Undefined And Not CollectionItem = NULL Then -OutputCollection.Add(CollectionItem); -EndIf; - -EndDo; - + + For Each CollectionItem In Collection Do + + If Not CollectionItem = Undefined And Not CollectionItem = NULL Then + OutputCollection.Add(CollectionItem); + EndIf; + + EndDo; + EndProcedure #Region GZip // Description withтруtoтур withм. зdеwithь https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT -// Source: https://github.com/vbondarevsky/Connector +// Source: https://github.com/vbondarevsky/Connector // Connector: convenient HTTP client for 1C:Enterprise 8 // @@ -1052,175 +1052,175 @@ EndProcedure Function UnpackResponse(Response) -Try -Return ReadGZip(Response.GetBodyAsBinaryData()); -Except -Return Response; -EndTry; + Try + Return ReadGZip(Response.GetBodyAsBinaryData()); + Except + Return Response; + EndTry; EndFunction Function ReadGZip(CompressedData) Export -GZipPrefixSize = 10; -GZipPostfixSize = 8; + GZipPrefixSize = 10; + GZipPostfixSize = 8; + + SizeDD = ZipSizeDD(); + SizeCDH = ZipSizeCDH(); + SizeESD = ZipSizeEOCD(); + SizeLFH = ZipSizeLFH(); -SizeDD = ZipSizeDD(); -SizeCDH = ZipSizeCDH(); -SizeESD = ZipSizeEOCD(); -SizeLFH = ZipSizeLFH(); + ReadingData = New ReadingData(CompressedData); + ReadingData.Skip(GZipPrefixSize); + CompressedDataSize = ReadingData.SourceStream().Size() - GZipPrefixSize - GZipPostfixSize; -ReadingData = New ReadingData(CompressedData); -ReadingData.Skip(GZipPrefixSize); -CompressedDataSize = ReadingData.SourceStream().Size() - GZipPrefixSize - GZipPostfixSize; + ZipStream = New MemoryStream(SizeLFH + + CompressedDataSize + + SizeDD + + SizeCDH + + SizeESD); + + DataRecording = New DataRecording(ZipStream); + DataRecording.WriteBinaryDataBuffer(ZipLFH()); + ReadingData.CopyTo(DataRecording, CompressedDataSize); -ZipStream = New MemoryStream(SizeLFH -+ CompressedDataSize -+ SizeDD -+ SizeCDH -+ SizeESD); + DataRecording.Close(); + DataRecording = New DataRecording(ZipStream); -DataRecording = New DataRecording(ZipStream); -DataRecording.WriteBinaryDataBuffer(ZipLFH()); -ReadingData.CopyTo(DataRecording, CompressedDataSize); + CRC32 = ReadingData.ReadInt32(); + UncompressedDataSize = ReadingData.ReadInt32(); + ReadingData.Close(); -DataRecording.Close(); -DataRecording = New DataRecording(ZipStream); + DataRecording.WriteBinaryDataBuffer(ZipDD(CRC32, CompressedDataSize, UncompressedDataSize)); + DataRecording.WriteBinaryDataBuffer(ZipCDH(CRC32, CompressedDataSize, UncompressedDataSize)); + DataRecording.WriteBinaryDataBuffer(ZipEOCD(CompressedDataSize)); + DataRecording.Close(); -CRC32 = ReadingData.ReadInt32(); -UncompressedDataSize = ReadingData.ReadInt32(); -ReadingData.Close(); - -DataRecording.WriteBinaryDataBuffer(ZipDD(CRC32, CompressedDataSize, UncompressedDataSize)); -DataRecording.WriteBinaryDataBuffer(ZipCDH(CRC32, CompressedDataSize, UncompressedDataSize)); -DataRecording.WriteBinaryDataBuffer(ZipEOCD(CompressedDataSize)); -DataRecording.Close(); - -Return ReadZip(ZipStream); + Return ReadZip(ZipStream); EndFunction Function ReadZip(CompressedData, ErrorText = Undefined) -Directory = GetTempFileName(); -ReadingZip = New ReadingZipFile(CompressedData); -FileName = ReadingZip.Elements[0].Name; -Try -ReadingZip.Extract(ReadingZip.Elements[0], Directory, ZIPFilePathRecoveryMode.DoNotRestore); -Except -// Ignore archive integrity check, just read the result -ErrorText = DetailedErrorRepresentation(ErrorInformation()); -EndTry; -ReadingZip.Close(); + Directory = GetTempFileName(); + ReadingZip = New ReadingZipFile(CompressedData); + FileName = ReadingZip.Elements[0].Name; + Try + ReadingZip.Extract(ReadingZip.Elements[0], Directory, ZIPFilePathRecoveryMode.DoNotRestore); + Except + // Ignore archive integrity check, just read the result + ErrorText = DetailedErrorRepresentation(ErrorInformation()); + EndTry; + ReadingZip.Close(); -Result = New BinaryData(Directory + GetPathSeparator() + FileName); -DeleteFiles(Directory); + Result = New BinaryData(Directory + GetPathSeparator() + FileName); + DeleteFiles(Directory); -Return Result; + Return Result; EndFunction Function ZipSizeLFH() -Return 34; + Return 34; EndFunction Function ZipSizeDD() -Return 16; + Return 16; EndFunction Function ZipSizeCDH() -Return 50; + Return 50; EndFunction Function ZipSizeEOCD() -Return 22; + Return 22; EndFunction Function ZipLFH() + + // Local file header + Buffer = New BinaryDataBuffer(ZipSizeLFH()); + Buffer.WriteInt32(0, 67324752); // signature 0x04034b50 + Buffer.WriteInt16(4, 20); // version + Buffer.WriteInt16(6, 10); // bit flags + Buffer.WriteInt16(8, 8); // compression method + Buffer.WriteInt16(10, 0); // time + Buffer.WriteInt16(12, 0); // date + Buffer.WriteInt32(14, 0); // crc-32 + Buffer.WriteInt32(18, 0); // compressed size + Buffer.WriteInt32(22, 0); // uncompressed size + Buffer.WriteInt16(26, 4); // filename legth - "data" + Buffer.WriteInt16(28, 0); // extra field length + Buffer.Write(30, GetBinaryDataBufferFromString("data", "ascii", False)); -// Local file header -Buffer = New BinaryDataBuffer(ZipSizeLFH()); -Buffer.WriteInt32(0, 67324752); // signature 0x04034b50 -Buffer.WriteInt16(4, 20); // version -Buffer.WriteInt16(6, 10); // bit flags -Buffer.WriteInt16(8, 8); // compression method -Buffer.WriteInt16(10, 0); // time -Buffer.WriteInt16(12, 0); // date -Buffer.WriteInt32(14, 0); // crc-32 -Buffer.WriteInt32(18, 0); // compressed size -Buffer.WriteInt32(22, 0); // uncompressed size -Buffer.WriteInt16(26, 4); // filename legth - "data" -Buffer.WriteInt16(28, 0); // extra field length -Buffer.Write(30, GetBinaryDataBufferFromString("data", "ascii", False)); - -Return Buffer; + Return Buffer; EndFunction Function ZipDD(CRC32, CompressedDataSize, UncompressedDataSize) + + // Data descriptor + Buffer = New BinaryDataBuffer(ZipSizeDD()); + Buffer.WriteInt32(0, 134695760); + Buffer.WriteInt32(4, CRC32); + Buffer.WriteInt32(8, CompressedDataSize); + Buffer.WriteInt32(12, UncompressedDataSize); -// Data descriptor -Buffer = New BinaryDataBuffer(ZipSizeDD()); -Buffer.WriteInt32(0, 134695760); -Buffer.WriteInt32(4, CRC32); -Buffer.WriteInt32(8, CompressedDataSize); -Buffer.WriteInt32(12, UncompressedDataSize); - -Return Buffer; + Return Buffer; EndFunction Function ZipCDH(CRC32, CompressedDataSize, UncompressedDataSize) + + // Central directory header + Buffer = New BinaryDataBuffer(ZipSizeCDH()); + Buffer.WriteInt32(0, 33639248); // signature 0x02014b50 + Buffer.WriteInt16(4, 798); // version made by + Buffer.WriteInt16(6, 20); // version needed to extract + Buffer.WriteInt16(8, 10); // bit flags + Buffer.WriteInt16(10, 8); // compression method + Buffer.WriteInt16(12, 0); // time + Buffer.WriteInt16(14, 0); // date + Buffer.WriteInt32(16, CRC32); // crc-32 + Buffer.WriteInt32(20, CompressedDataSize); // compressed size + Buffer.WriteInt32(24, UncompressedDataSize); // uncompressed size + Buffer.WriteInt16(28, 4); // file name length + Buffer.WriteInt16(30, 0); // extra field length + Buffer.WriteInt16(32, 0); // file comment length + Buffer.WriteInt16(34, 0); // disk number start + Buffer.WriteInt16(36, 0); // internal file attributes + Buffer.WriteInt32(38, 2176057344); // external file attributes + Buffer.WriteInt32(42, 0); // relative offset of local header + Buffer.Write(46, GetBinaryDataBufferFromString("data", "ascii", False)); -// Central directory header -Buffer = New BinaryDataBuffer(ZipSizeCDH()); -Buffer.WriteInt32(0, 33639248); // signature 0x02014b50 -Buffer.WriteInt16(4, 798); // version made by -Buffer.WriteInt16(6, 20); // version needed to extract -Buffer.WriteInt16(8, 10); // bit flags -Buffer.WriteInt16(10, 8); // compression method -Buffer.WriteInt16(12, 0); // time -Buffer.WriteInt16(14, 0); // date -Buffer.WriteInt32(16, CRC32); // crc-32 -Buffer.WriteInt32(20, CompressedDataSize); // compressed size -Buffer.WriteInt32(24, UncompressedDataSize); // uncompressed size -Buffer.WriteInt16(28, 4); // file name length -Buffer.WriteInt16(30, 0); // extra field length -Buffer.WriteInt16(32, 0); // file comment length -Buffer.WriteInt16(34, 0); // disk number start -Buffer.WriteInt16(36, 0); // internal file attributes -Buffer.WriteInt32(38, 2176057344); // external file attributes -Buffer.WriteInt32(42, 0); // relative offset of local header -Buffer.Write(46, GetBinaryDataBufferFromString("data", "ascii", False)); - -Return Buffer; + Return Buffer; EndFunction Function ZipEOCD(CompressedDataSize) + + // End of central directory + SizeCDH = 50; + Buffer = New BinaryDataBuffer(ZipSizeEOCD()); + Buffer.WriteInt32(0, 101010256); // signature 0x06054b50 + Buffer.WriteInt16(4, 0); // number of this disk + Buffer.WriteInt16(6, 0); // number of the disk with the start of the central directory + Buffer.WriteInt16(8, 1); // total number of entries in the central directory on this disk + Buffer.WriteInt16(10, 1); // total number of entries in the central directory + Buffer.WriteInt32(12, SizeCDH); // size of the central directory + // offset of start of central directory with respect to the starting disk number + Buffer.WriteInt32(16, ZipSizeLFH() + CompressedDataSize + ZipSizeDD()); + Buffer.WriteInt16(20, 0); // the starting disk number -// End of central directory -SizeCDH = 50; -Buffer = New BinaryDataBuffer(ZipSizeEOCD()); -Buffer.WriteInt32(0, 101010256); // signature 0x06054b50 -Buffer.WriteInt16(4, 0); // number of this disk -Buffer.WriteInt16(6, 0); // number of the disk with the start of the central directory -Buffer.WriteInt16(8, 1); // total number of entries in the central directory on this disk -Buffer.WriteInt16(10, 1); // total number of entries in the central directory -Buffer.WriteInt32(12, SizeCDH); // size of the central directory -// offset of start of central directory with respect to the starting disk number -Buffer.WriteInt32(16, ZipSizeLFH() + CompressedDataSize + ZipSizeDD()); -Buffer.WriteInt16(20, 0); // the starting disk number - -Return Buffer; + Return Buffer; EndFunction diff --git a/src/en/OPI/src/CommonModules/OPI_Tools/OPI_Tools.mdo b/src/en/OPI/src/CommonModules/OPI_Tools/OPI_Tools.mdo index 475c3d2a77..d6c0917565 100644 --- a/src/en/OPI/src/CommonModules/OPI_Tools/OPI_Tools.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Tools/OPI_Tools.mdo @@ -1,11 +1,11 @@  -OPI_Tools - -ru -OPI tools - -true -true -true + OPI_Tools + + ru + OPI tools + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Twitter/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Twitter/Module.bsl index b2cd4873e1..7315187983 100644 --- a/src/en/OPI/src/CommonModules/OPI_Twitter/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Twitter/Module.bsl @@ -45,84 +45,84 @@ // Get authorization link // Forms a link for authorization via the browser -// +// // Parameters: // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // String - URL for browser transition Function GetAuthorizationLink(Parameters = "") Export - -Parameters_ = GetStandardParameters(Parameters); - -URLParameters = New Structure; - -URLParameters.Insert("response_type" , "code"); -URLParameters.Insert("client_id" , Parameters_["client_id"]); -URLParameters.Insert("redirect_uri" , Parameters_["redirect_uri"]); -URLParameters.Insert("scope" , Parameters_["scope"]); -URLParameters.Insert("state" , "state"); -URLParameters.Insert("code_challenge" , "challenge"); -URLParameters.Insert("code_challenge_method", "plain"); - -URLParameters = OPI_Tools.RequestParametersToString(URLParameters); -Link = "https://twitter.com/i/oauth2/authorize" + URLParameters; - -Return Link; - + + Parameters_ = GetStandardParameters(Parameters); + + URLParameters = New Structure; + + URLParameters.Insert("response_type" , "code"); + URLParameters.Insert("client_id" , Parameters_["client_id"]); + URLParameters.Insert("redirect_uri" , Parameters_["redirect_uri"]); + URLParameters.Insert("scope" , Parameters_["scope"]); + URLParameters.Insert("state" , "state"); + URLParameters.Insert("code_challenge" , "challenge"); + URLParameters.Insert("code_challenge_method", "plain"); + + URLParameters = OPI_Tools.RequestParametersToString(URLParameters); + Link = "https://twitter.com/i/oauth2/authorize" + URLParameters; + + Return Link; + EndFunction // Get token // Gets the token by the code obtained during authorization via the link from GetAuthorizationLink -// +// // Parameters: // Code - String - Code obtained from authorization See GetAuthorizationLink - code // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function GetToken(Val Code, Val Parameters = "") Export -OPI_TypeConversion.GetLine(Code); - -Parameters_ = GetStandardParameters(Parameters); - -RequestParameters = New Structure; -RequestParameters.Insert("code" , Code); -RequestParameters.Insert("grant_type" , "authorization_code"); -RequestParameters.Insert("client_id" , Parameters_["client_id"]); -RequestParameters.Insert("redirect_uri" , Parameters_["redirect_uri"]); -RequestParameters.Insert("code_verifier", "challenge"); - -Response = OPI_Tools.Post("https://api.twitter.com/2/oauth2/token" -, RequestParameters, , False); - -Return Response; + OPI_TypeConversion.GetLine(Code); + + Parameters_ = GetStandardParameters(Parameters); + RequestParameters = New Structure; + RequestParameters.Insert("code" , Code); + RequestParameters.Insert("grant_type" , "authorization_code"); + RequestParameters.Insert("client_id" , Parameters_["client_id"]); + RequestParameters.Insert("redirect_uri" , Parameters_["redirect_uri"]); + RequestParameters.Insert("code_verifier", "challenge"); + + Response = OPI_Tools.Post("https://api.twitter.com/2/oauth2/token" + , RequestParameters, , False); + + Return Response; + EndFunction -// Refresh token +// Refresh token // Updates the v2 token using the refresh_token -// +// // Parameters: // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function RefreshToken(Val Parameters = "") Export - -Parameters_ = GetStandardParameters(Parameters); -Refresh = "refresh_token"; - -RequestParameters = New Structure; -RequestParameters.Insert(Refresh , Parameters_[Refresh]); -RequestParameters.Insert("grant_type" , Refresh); -RequestParameters.Insert("client_id" , Parameters_["client_id"]); - -Response = OPI_Tools.Post("https://api.twitter.com/2/oauth2/token" -, RequestParameters, , False); - -Return Response; + + Parameters_ = GetStandardParameters(Parameters); + Refresh = "refresh_token"; + + RequestParameters = New Structure; + RequestParameters.Insert(Refresh , Parameters_[Refresh]); + RequestParameters.Insert("grant_type" , Refresh); + RequestParameters.Insert("client_id" , Parameters_["client_id"]); + + Response = OPI_Tools.Post("https://api.twitter.com/2/oauth2/token" + , RequestParameters, , False); + + Return Response; EndFunction @@ -130,24 +130,24 @@ EndFunction // Method for insertion into an http service, the address of which is specified in redirect_uri // Calls the token acquisition method, as for obtaining a token from the code received // on redirect_uri after authorization via the browser is only 30 seconds -// +// // Parameters: // Request - HTTPServiceRequest - Request coming to the http service -// +// // Return value: // HTTPResponse, Arbitrary, BinaryData - Result of reading the JSON response from the server Function HandleIncomingRequestAfterAuthorization(Request) Export - -Code = Request.RequestParameters["code"]; -TokenResponse = GetToken(Code); - -// BSLLS:CommentedCode-off -// Preferred token storage -// Constants.TwitterRefresh.Уwithтаноinить(TokenResponse["refresh_token"]); -// Constants.TwitterToken.Уwithтаноinить(TokenResponse["access_token"]); -// BSLLS:CommentedCode-on - -Return TokenResponse; + + Code = Request.RequestParameters["code"]; + TokenResponse = GetToken(Code); + + // BSLLS:CommentedCode-off + // Preferred token storage + // Constants.TwitterRefresh.Уwithтаноinить(TokenResponse["refresh_token"]); + // Constants.TwitterToken.Уwithтаноinить(TokenResponse["access_token"]); + // BSLLS:CommentedCode-on + + Return TokenResponse; EndFunction @@ -157,187 +157,187 @@ EndFunction // !NOCLI // Create custom tweet -// +// // Parameters: // Text - String - Tweet text // MediaArray - Array from String, BinaryData - Array of binary data or file paths // PollOptionsArray - Array of Strings - Array of poll options, if necessary // PollDuration - String, Number - Poll duration, еwithли необхоdимо (опроwith without dлительноwithти не withозdаетwithя) // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function CreateCustomTweet(Val Text = "" -, Val MediaArray = "" -, Val PollOptionsArray = "" -, Val PollDuration = "" -, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Text); -OPI_TypeConversion.GetLine(PollDuration); - -If ValueIsFilled(MediaArray) Then -OPI_TypeConversion.GetCollection(MediaArray); -EndIf; - -If ValueIsFilled(PollOptionsArray) Then -OPI_TypeConversion.GetCollection(PollOptionsArray); -EndIf; - -Parameters_ = GetStandardParameters(Parameters); -URL = "https://api.twitter.com/2/tweets"; -Array = "Array"; -Fields = New Match; - -If ValueIsFilled(Text) Then -Fields.Insert("text", Text); -EndIf; - -If TypeValue(PollOptionsArray) = Type(Array) And ValueIsFilled(PollDuration) Then - -PollDuration = Number(PollDuration); - -If PollOptionsArray.Quantity() > 0 Then - -OptionStructure = New Structure("options,duration_minutes", PollOptionsArray, PollDuration); -Fields.Insert("poll", OptionStructure); - -EndIf; - -EndIf; - -If TypeValue(MediaArray) = Type(Array) Then -If MediaArray.Quantity() > 0 Then -Fields.Insert("media", New Structure("media_ids", MediaArray)); -EndIf; -EndIf; - -Authorization = CreateAuthorizationHeaderV2(Parameters_); -Response = OPI_Tools.Post(URL, Fields, Authorization); - -Return Response; + , Val MediaArray = "" + , Val PollOptionsArray = "" + , Val PollDuration = "" + , Val Parameters = "") Export + + OPI_TypeConversion.GetLine(Text); + OPI_TypeConversion.GetLine(PollDuration); + + If ValueIsFilled(MediaArray) Then + OPI_TypeConversion.GetCollection(MediaArray); + EndIf; + + If ValueIsFilled(PollOptionsArray) Then + OPI_TypeConversion.GetCollection(PollOptionsArray); + EndIf; + + Parameters_ = GetStandardParameters(Parameters); + URL = "https://api.twitter.com/2/tweets"; + Array = "Array"; + Fields = New Match; + + If ValueIsFilled(Text) Then + Fields.Insert("text", Text); + EndIf; + + If TypeValue(PollOptionsArray) = Type(Array) And ValueIsFilled(PollDuration) Then + + PollDuration = Number(PollDuration); + + If PollOptionsArray.Quantity() > 0 Then + + OptionStructure = New Structure("options,duration_minutes", PollOptionsArray, PollDuration); + Fields.Insert("poll", OptionStructure); + + EndIf; + + EndIf; + + If TypeValue(MediaArray) = Type(Array) Then + If MediaArray.Quantity() > 0 Then + Fields.Insert("media", New Structure("media_ids", MediaArray)); + EndIf; + EndIf; + + Authorization = CreateAuthorizationHeaderV2(Parameters_); + Response = OPI_Tools.Post(URL, Fields, Authorization); + Return Response; + EndFunction // Create text tweet // Creates a tweet without attachments -// +// // Parameters: // Text - String - Tweet text - text // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function CreateTextTweet(Val Text, Val Parameters = "") Export -Return CreateCustomTweet(Text, , , , Parameters); + Return CreateCustomTweet(Text, , , , Parameters); EndFunction // Create image tweet // Creates a tweet with an image attachment -// +// // Parameters: // Text - String - Tweet text - text // ImageArray - Array from String, BinaryData - Image files array - pictures // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function Create image tweet(Val Text, Val ImageArray, Val Parameters = "") Export - -MediaArray = Upload attachments array(ImageArray, "tweet_image", Parameters); -Return CreateCustomTweet(Text, MediaArray, , , Parameters); - + + MediaArray = Upload attachments array(ImageArray, "tweet_image", Parameters); + Return CreateCustomTweet(Text, MediaArray, , , Parameters); + EndFunction // Create gif tweet // Creates a tweet with a gif attachment -// +// // Parameters: // Text - String - Tweet text - text // Gif array - Array from String, BinaryData - Gif files array - gifs // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function CreateGifTweet(Val Text, Val Gif array, Val Parameters = "") Export - -MediaArray = Upload attachments array(Gif array, "tweet_gif", Parameters); -Return CreateCustomTweet(Text, MediaArray, , , Parameters); - + + MediaArray = Upload attachments array(Gif array, "tweet_gif", Parameters); + Return CreateCustomTweet(Text, MediaArray, , , Parameters); + EndFunction // Create video tweet // Creates a tweet with a video attachment -// +// // Parameters: // Text - String - Tweet text - text // Video array - Array from String, BinaryData - Video files array - videos // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function CreateVideoTweet(Val Text, Val Video array, Val Parameters = "") Export - -MediaArray = Upload attachments array(Video array, "tweet_video", Parameters); -Return CreateCustomTweet(Text, MediaArray, , , Parameters); - + + MediaArray = Upload attachments array(Video array, "tweet_video", Parameters); + Return CreateCustomTweet(Text, MediaArray, , , Parameters); + EndFunction // Create poll tweet // Creates a tweet with a poll -// +// // Parameters: // Text - String - Tweet text - text // OptionArray - Array of Strings - Poll options array - options // Duration - String, Number - Poll duration - duration // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - serialized JSON response from Twitter Function CreatePollTweet(Val Text, Val OptionArray, Val Duration, Val Parameters = "") Export -Return CreateCustomTweet(Text, , OptionArray, Duration, Parameters); + Return CreateCustomTweet(Text, , OptionArray, Duration, Parameters); EndFunction // Upload attachments array !NOCLI // Uploads files to the server and returns their IDs -// +// // Parameters: // ArrayOfFiles - Array from String, BinaryData - Files array // AttachmentsType - String - Attachments type // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Array Of String - Media ID array Function Upload attachments array(Val ArrayOfFiles, Val AttachmentsType, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(AttachmentsType); -OPI_TypeConversion.GetCollection(ArrayOfFiles); - -MediaArray = New Array; -Parameters_ = GetStandardParameters(Parameters); -MIS = "media_id_string"; - -If ValueIsFilled(ArrayOfFiles) Then - -For Each SendingFile In ArrayOfFiles Do - -OPI_TypeConversion.GetBinaryData(SendingFile); - -Response = UploadMediaFile(SendingFile, AttachmentsType, Parameters_); -MediaID = Response[MIS]; - -If Not ValueIsFilled(MediaID) Then -Return Response; -EndIf; - -MediaArray.Add(MediaID); - -EndDo; - -EndIf; - -Return MediaArray; - + + OPI_TypeConversion.GetLine(AttachmentsType); + OPI_TypeConversion.GetCollection(ArrayOfFiles); + + MediaArray = New Array; + Parameters_ = GetStandardParameters(Parameters); + MIS = "media_id_string"; + + If ValueIsFilled(ArrayOfFiles) Then + + For Each SendingFile In ArrayOfFiles Do + + OPI_TypeConversion.GetBinaryData(SendingFile); + + Response = UploadMediaFile(SendingFile, AttachmentsType, Parameters_); + MediaID = Response[MIS]; + + If Not ValueIsFilled(MediaID) Then + Return Response; + EndIf; + + MediaArray.Add(MediaID); + + EndDo; + + EndIf; + + Return MediaArray; + EndFunction #EndRegion @@ -346,337 +346,337 @@ EndFunction #Region ServiceProceduresAndFunctions -Function UploadMediaFile(Val File, Val Type, Val Parameters) - -OPI_TypeConversion.GetBinaryData(File); - -RequestType = "POST"; -Parameters_ = GetStandardParameters(Parameters); -URL = "https://upload.twitter.com/1.1/media/upload.json"; - -If Type = "tweet_image" Then - -Fields = New Structure; -Fields.Insert("media_data" , Base64String(File)); -Fields.Insert("media_category", Type); - -Authorization = CreateAuthorizationHeaderV1(Parameters_, Fields, RequestType, URL); -Response = OPI_Tools.Post(URL, Fields, Authorization, False); - -Else - -Response = UploadMediaInParts(File, Type, RequestType, URL, Parameters_); - -EndIf; - -Return Response; - +Function UploadMediaFile(Val File, Val Type, Val Parameters) + + OPI_TypeConversion.GetBinaryData(File); + + RequestType = "POST"; + Parameters_ = GetStandardParameters(Parameters); + URL = "https://upload.twitter.com/1.1/media/upload.json"; + + If Type = "tweet_image" Then + + Fields = New Structure; + Fields.Insert("media_data" , Base64String(File)); + Fields.Insert("media_category", Type); + + Authorization = CreateAuthorizationHeaderV1(Parameters_, Fields, RequestType, URL); + Response = OPI_Tools.Post(URL, Fields, Authorization, False); + + Else + + Response = UploadMediaInParts(File, Type, RequestType, URL, Parameters_); + + EndIf; + + Return Response; + EndFunction Function UploadMediaInParts(Val File, Val Type, Val RequestType, Val URL, Parameters) + + Unit = 1024; + Quantity = 4; + MediaKey = "media_key"; + MIS = "media_id_string"; + Command = "command"; + Size = File.Size(); + + MIMETypeMapping = New Match; + MIMETypeMapping.Insert("tweet_image", "image/jpeg"); + MIMETypeMapping.Insert("tweet_video", "video/mp4"); + MIMETypeMapping.Insert("tweet_gif" , "image/gif"); + + ChunkSize = Quantity * Unit * Unit; + ArrayReading = SplitBinaryData(File, ChunkSize); + + Fields = New Structure; + Fields.Insert(Command , "INIT"); + Fields.Insert("total_bytes" , OPI_Tools.NumberToString(Size)); + Fields.Insert("media_type" , MIMETypeMapping.Get(Type)); + Fields.Insert("media_category" , Type); + + Authorization = CreateAuthorizationHeaderV1(Parameters, Fields, RequestType, URL); -Unit = 1024; -Quantity = 4; -MediaKey = "media_key"; -MIS = "media_id_string"; -Command = "command"; -Size = File.Size(); - -MIMETypeMapping = New Match; -MIMETypeMapping.Insert("tweet_image", "image/jpeg"); -MIMETypeMapping.Insert("tweet_video", "video/mp4"); -MIMETypeMapping.Insert("tweet_gif" , "image/gif"); - -ChunkSize = Quantity * Unit * Unit; -ArrayReading = SplitBinaryData(File, ChunkSize); - -Fields = New Structure; -Fields.Insert(Command , "INIT"); -Fields.Insert("total_bytes" , OPI_Tools.NumberToString(Size)); -Fields.Insert("media_type" , MIMETypeMapping.Get(Type)); -Fields.Insert("media_category" , Type); - -Authorization = CreateAuthorizationHeaderV1(Parameters, Fields, RequestType, URL); - -InitializationResponse = OPI_Tools.Post(URL, Fields, Authorization, False); -InitializationKey = InitializationResponse[MediaKey]; -InitializationID = InitializationResponse[MIS]; - -If Not ValueIsFilled(InitializationKey) Or Not ValueIsFilled(InitializationID) Then -Return InitializationResponse; -EndIf; - -Counter = 0; - -For Each Part In ArrayReading Do - -Fields = New Structure; -Fields.Insert(Command , "APPEND"); -Fields.Insert("media_key" , InitializationKey); -Fields.Insert("segment_index" , OPI_Tools.NumberToString(Counter)); -Fields.Insert("media" , Part); - -Authorization = CreateAuthorizationHeaderV1(Parameters, New Structure, RequestType, URL); - -OPI_Tools.PostMultipart(URL, Fields, , , Authorization); - -Counter = Counter + 1; - -EndDo; - -Fields = New Structure; -Fields.Insert(Command , "FINALIZE"); -Fields.Insert("media_id", InitializationID); - -ProcessingStatus = GetProcessingStatus(Parameters, Fields, URL); - -If Not TypeValue(ProcessingStatus) = Type("String") Then -Return ProcessingStatus; -EndIf; - -Response = WaitForProcessingCompletion(ProcessingStatus, InitializationID, URL, Parameters); - -Return Response; + InitializationResponse = OPI_Tools.Post(URL, Fields, Authorization, False); + InitializationKey = InitializationResponse[MediaKey]; + InitializationID = InitializationResponse[MIS]; + + If Not ValueIsFilled(InitializationKey) Or Not ValueIsFilled(InitializationID) Then + Return InitializationResponse; + EndIf; + + Counter = 0; + + For Each Part In ArrayReading Do + + Fields = New Structure; + Fields.Insert(Command , "APPEND"); + Fields.Insert("media_key" , InitializationKey); + Fields.Insert("segment_index" , OPI_Tools.NumberToString(Counter)); + Fields.Insert("media" , Part); + Authorization = CreateAuthorizationHeaderV1(Parameters, New Structure, RequestType, URL); + + OPI_Tools.PostMultipart(URL, Fields, , , Authorization); + + Counter = Counter + 1; + + EndDo; + + Fields = New Structure; + Fields.Insert(Command , "FINALIZE"); + Fields.Insert("media_id", InitializationID); + + ProcessingStatus = GetProcessingStatus(Parameters, Fields, URL); + + If Not TypeValue(ProcessingStatus) = Type("String") Then + Return ProcessingStatus; + EndIf; + + Response = WaitForProcessingCompletion(ProcessingStatus, InitializationID, URL, Parameters); + + Return Response; + EndFunction Function WaitForProcessingCompletion(Val ProcessingStatus, Val InitializationID, Val URL, Val Parameters) + + ProcessingInfo = "processing_info"; + Command = "command"; + Fields = New Structure; + + Fields.Insert(Command , "STATUS"); + Fields.Insert("media_id", InitializationID); -ProcessingInfo = "processing_info"; -Command = "command"; -Fields = New Structure; - -Fields.Insert(Command , "STATUS"); -Fields.Insert("media_id", InitializationID); - -WHile String(ProcessingStatus) = "pending" Or String(ProcessingStatus) = "in_progress" Do - -Authorization = CreateAuthorizationHeaderV1(Parameters, Fields, "GET", URL); -Response = OPI_Tools.Get(URL, Fields, Authorization); -Information = Response[ProcessingInfo]; - -If Not ValueIsFilled(Information) Then -Return Response; -EndIf; - -ProcessingStatus = Information["state"]; - -If Not ValueIsFilled(ProcessingStatus) Then -Return Response; -EndIf; - -EndDo; - -If ProcessingStatus = "failed" Then -Raise "Twitter could not process the video you uploaded"; -EndIf; - -Return Response; + WHile String(ProcessingStatus) = "pending" Or String(ProcessingStatus) = "in_progress" Do + + Authorization = CreateAuthorizationHeaderV1(Parameters, Fields, "GET", URL); + Response = OPI_Tools.Get(URL, Fields, Authorization); + Information = Response[ProcessingInfo]; + If Not ValueIsFilled(Information) Then + Return Response; + EndIf; + + ProcessingStatus = Information["state"]; + + If Not ValueIsFilled(ProcessingStatus) Then + Return Response; + EndIf; + + EndDo; + + If ProcessingStatus = "failed" Then + Raise "Twitter could not process the video you uploaded"; + EndIf; + + Return Response; + EndFunction Function GetStandardParameters(Val Parameters = "") + + // Зdеwithь withобрано опреdеление data, необхоdимых for work. + // For Twitter this dоinольно зtoчительный toбор, which is due to the presence of two at once API, + // toоторые, при thisм, withозdаны не for разныз заdач, но проwithто яinляютwithя inерwithиями dруг dруга. + // Аtoтуальной inерwithией API яinляетwithя v2 и оto требует получения inременных тоtoеноin. Notwithмотря to то, + // that Twitter insists on using this latest version, they somehow managed not to transfer + // file upload mechanism and some others from the old version - v1.1. Therefore, something needs to be done + // to inерwithии 1.1, and something on 2: up to the point that they removed the ability to post tweets from v1.1, + // but only through it you can add a picture to the tweet. At the same time, their authentication methods and tokens are different + + // Мироinая гигоtoорпорация Andлоto Маwithtoа, towithтати, toпомиtoю ;) + + // P.S Далее чаwithто упомиtoетwithя "withтраница towithтроеto Twitter Developer" - this + // https://developer.twitter.com/en/portal/dashboard и inыбор toонtoретного проеtoта from withпиwithtoа (зtoчеto c toлючем) + + Parameters_ = New Match; + Permissions = "tweet.read tweet.write tweet.moderate.write users.read " + + "follows.read follows.write offline.access space.read mute.read " + + "mute.write like.read like.write list.read list.write block.read " + + "block.write bookmark.read bookmark.write"; + + // Data for API v2 + + // redirect_uri - URL of your http service (or other request handler) for authorization + // scope - a set of permissions for the received key. Can be any, but offline.access is mandatory + // client_id - From OAuth 2.0 Client ID and Client Secret settings page of Twitter Developer + // client_secret - From OAuth 2.0 Client ID and Client Secret settings page of Twitter Developer + // access_token - GetAuthorizationLink() -> Браузер -> code приdет to redirect_uri -> GetToken(code) + // refresh_token - Comes together with access_token and is used to refresh it (access_token lifetime - 2 ч) + // Обноinление проиwithхоdит methodом RefreshToken with ноinыми access_token и refresh_token. + // For the next update, you need to use a new refresh_token, so hardcode + // не получитwithя (access_token тоже не получитwithя) + + // |--> RefreshToken() ->|access_token --> Andwithпользуетwithя in т-нии 2-х чаwithоin for запроwithоin + // | |refresh_token --| + // |--------[after 2 hrs.]-------------------| + + // Data for API v1.1 + + // oauth_token - From Authentication Tokens -> Access Token and Secret settings page of Twitter Developer + // oauth_token_secret - From Authentication Tokens -> Access Token and Secret settings page of Twitter Developer + // oauth_consumer_key - From Consumer Keys -> Access Token and Secret settings page of Twitter Developer + // oauth_consumer_secret - From Consumer Keys -> Access Token and Secret settings page of Twitter Developer + + // These tokens do not need to be updated + + Parameters_.Insert("redirect_uri" , ""); + Parameters_.Insert("scope" , Permissions); + Parameters_.Insert("client_id" , ""); + Parameters_.Insert("client_secret" , ""); + Parameters_.Insert("access_token" , ""); // Should be something like Constants.TwitterToken.Get() + Parameters_.Insert("refresh_token" , ""); // Should be something like Constants.TwitterRefresh.Get() + Parameters_.Insert("oauth_token" , ""); + Parameters_.Insert("oauth_token_secret" , ""); + Parameters_.Insert("oauth_consumer_key" , ""); + Parameters_.Insert("oauth_consumer_secret", ""); + + OPI_TypeConversion.GetCollection(Parameters); + + If TypeValue(Parameters) = Type("Structure") Or TypeValue(Parameters) = Type("Match") Then + For Each PassedParameter In Parameters Do + Parameters_.Insert(PassedParameter.Key, OPI_Tools.NumberToString(PassedParameter.Value)); + EndDo; + EndIf; -// Зdеwithь withобрано опреdеление data, необхоdимых for work. -// For Twitter this dоinольно зtoчительный toбор, which is due to the presence of two at once API, -// toоторые, при thisм, withозdаны не for разныз заdач, но проwithто яinляютwithя inерwithиями dруг dруга. -// Аtoтуальной inерwithией API яinляетwithя v2 и оto требует получения inременных тоtoеноin. Notwithмотря to то, -// that Twitter insists on using this latest version, they somehow managed not to transfer -// file upload mechanism and some others from the old version - v1.1. Therefore, something needs to be done -// to inерwithии 1.1, and something on 2: up to the point that they removed the ability to post tweets from v1.1, -// but only through it you can add a picture to the tweet. At the same time, their authentication methods and tokens are different - -// Мироinая гигоtoорпорация Andлоto Маwithtoа, towithтати, toпомиtoю ;) - -// P.S Далее чаwithто упомиtoетwithя "withтраница towithтроеto Twitter Developer" - this -// https://developer.twitter.com/en/portal/dashboard и inыбор toонtoретного проеtoта from withпиwithtoа (зtoчеto c toлючем) - -Parameters_ = New Match; -Permissions = "tweet.read tweet.write tweet.moderate.write users.read " -+ "follows.read follows.write offline.access space.read mute.read " -+ "mute.write like.read like.write list.read list.write block.read " -+ "block.write bookmark.read bookmark.write"; - -// Data for API v2 - -// redirect_uri - URL of your http service (or other request handler) for authorization -// scope - a set of permissions for the received key. Can be any, but offline.access is mandatory -// client_id - From OAuth 2.0 Client ID and Client Secret settings page of Twitter Developer -// client_secret - From OAuth 2.0 Client ID and Client Secret settings page of Twitter Developer -// access_token - GetAuthorizationLink() -> Браузер -> code приdет to redirect_uri -> GetToken(code) -// refresh_token - Comes together with access_token and is used to refresh it (access_token lifetime - 2 ч) -// Обноinление проиwithхоdит methodом RefreshToken with ноinыми access_token и refresh_token. -// For the next update, you need to use a new refresh_token, so hardcode -// не получитwithя (access_token тоже не получитwithя) - -// |--> RefreshToken() ->|access_token --> Andwithпользуетwithя in т-нии 2-х чаwithоin for запроwithоin -// | |refresh_token --| -// |--------[after 2 hrs.]-------------------| - -// Data for API v1.1 - -// oauth_token - From Authentication Tokens -> Access Token and Secret settings page of Twitter Developer -// oauth_token_secret - From Authentication Tokens -> Access Token and Secret settings page of Twitter Developer -// oauth_consumer_key - From Consumer Keys -> Access Token and Secret settings page of Twitter Developer -// oauth_consumer_secret - From Consumer Keys -> Access Token and Secret settings page of Twitter Developer - -// These tokens do not need to be updated - -Parameters_.Insert("redirect_uri" , ""); -Parameters_.Insert("scope" , Permissions); -Parameters_.Insert("client_id" , ""); -Parameters_.Insert("client_secret" , ""); -Parameters_.Insert("access_token" , ""); // Should be something like Constants.TwitterToken.Get() -Parameters_.Insert("refresh_token" , ""); // Should be something like Constants.TwitterRefresh.Get() -Parameters_.Insert("oauth_token" , ""); -Parameters_.Insert("oauth_token_secret" , ""); -Parameters_.Insert("oauth_consumer_key" , ""); -Parameters_.Insert("oauth_consumer_secret", ""); - -OPI_TypeConversion.GetCollection(Parameters); - -If TypeValue(Parameters) = Type("Structure") Or TypeValue(Parameters) = Type("Match") Then -For Each PassedParameter In Parameters Do -Parameters_.Insert(PassedParameter.Key, OPI_Tools.NumberToString(PassedParameter.Value)); -EndDo; -EndIf; - -Return Parameters_; + Return Parameters_; EndFunction Function CreateAuthorizationHeaderV1(Val Parameters, Val Fields, Val RequestType, Val URL) + + CurrentDate = OPI_Tools.GetCurrentDate(); + AuthorizationHeader = ""; + HashingMethod = "HMAC-SHA1"; + APIVersion = "1.0"; + SignatureString = ""; + Signature = ""; + OCK = "oauth_consumer_key"; + OTK = "oauth_token"; + CurrentUNIXDate = OPI_Tools.UNIXTime(CurrentDate); + CurrentUNIXDate = OPI_Tools.NumberToString(CurrentUNIXDate); + ParametersTable = New ValueTable; + ParametersTable.Columns.Add("Key"); + ParametersTable.Columns.Add("Value"); + + For Each Field In Fields Do + + NewLine = ParametersTable.Add(); + NewLine.Key = Field.Key; + NewLine.Value = Field.Value; + + EndDo; + + NewLine = ParametersTable.Add(); + NewLine.Key = OCK; + NewLine.Value = Parameters[OCK]; + + NewLine = ParametersTable.Add(); + NewLine.Key = OTK; + NewLine.Value = Parameters[OTK]; + + NewLine = ParametersTable.Add(); + NewLine.Key = "oauth_version"; + NewLine.Value = APIVersion; + + NewLine = ParametersTable.Add(); + NewLine.Key = "oauth_signature_method"; + NewLine.Value = HashingMethod; -CurrentDate = OPI_Tools.GetCurrentDate(); -AuthorizationHeader = ""; -HashingMethod = "HMAC-SHA1"; -APIVersion = "1.0"; -SignatureString = ""; -Signature = ""; -OCK = "oauth_consumer_key"; -OTK = "oauth_token"; -CurrentUNIXDate = OPI_Tools.UNIXTime(CurrentDate); -CurrentUNIXDate = OPI_Tools.NumberToString(CurrentUNIXDate); -ParametersTable = New ValueTable; -ParametersTable.Columns.Add("Key"); -ParametersTable.Columns.Add("Value"); + NewLine = ParametersTable.Add(); + NewLine.Key = "oauth_timestamp"; + NewLine.Value = CurrentUNIXDate; -For Each Field In Fields Do - -NewLine = ParametersTable.Add(); -NewLine.Key = Field.Key; -NewLine.Value = Field.Value; - -EndDo; - -NewLine = ParametersTable.Add(); -NewLine.Key = OCK; -NewLine.Value = Parameters[OCK]; - -NewLine = ParametersTable.Add(); -NewLine.Key = OTK; -NewLine.Value = Parameters[OTK]; - -NewLine = ParametersTable.Add(); -NewLine.Key = "oauth_version"; -NewLine.Value = APIVersion; - -NewLine = ParametersTable.Add(); -NewLine.Key = "oauth_signature_method"; -NewLine.Value = HashingMethod; - -NewLine = ParametersTable.Add(); -NewLine.Key = "oauth_timestamp"; -NewLine.Value = CurrentUNIXDate; - -NewLine = ParametersTable.Add(); -NewLine.Key = "oauth_nonce"; -NewLine.Value = CurrentUNIXDate; - -For Each TableRow In ParametersTable Do - -TableRow.Key = EncodeString(TableRow.Key, StringEncodingMethod.URLencoding); -TableRow.Value = EncodeString(TableRow.Value, StringEncodingMethod.URLencoding); - -EndDo; - -ParametersTable.Sort("Key"); - -For Each TableRow In ParametersTable Do - -SignatureString = SignatureString -+ TableRow.Key -+ "=" -+ TableRow.Value -+ "&"; - -EndDo; - -SignatureString = Left(SignatureString, StrLength(SignatureString) - 1); -SignatureString = inReg(RequestType) -+ "&" -+ EncodeString(URL, StringEncodingMethod.URLencoding) -+ "&" -+ EncodeString(SignatureString, StringEncodingMethod.URLencoding); - -Signature = EncodeString(Parameters["oauth_consumer_secret"], StringEncodingMethod.URLencoding) -+ "&" -+ EncodeString(Parameters["oauth_token_secret"], StringEncodingMethod.URLencoding); - -Signature = OPI_Cryptography.HMAC(GetBinaryDataFromString(Signature) -, GetBinaryDataFromString(SignatureString) -, HashFunction.SHA1 -, 64); - -Signature = EncodeString(Base64String(Signature), StringEncodingMethod.URLencoding); - -Delimiter = ""","; -AuthorizationHeader = AuthorizationHeader -+ "OAuth " -+ "oauth_consumer_key=""" + Parameters[OCK] + Delimiter -+ "oauth_token=""" + Parameters[OTK] + Delimiter -+ "oauth_signature_method=""" + HashingMethod + Delimiter -+ "oauth_timestamp=""" + CurrentUNIXDate + Delimiter -+ "oauth_nonce=""" + CurrentUNIXDate + Delimiter -+ "oauth_version=""" + APIVersion + Delimiter -+ "oauth_signature=""" + Signature; - -HeaderMapping = New Match; -HeaderMapping.Insert("authorization", AuthorizationHeader); - -Return HeaderMapping; + NewLine = ParametersTable.Add(); + NewLine.Key = "oauth_nonce"; + NewLine.Value = CurrentUNIXDate; + For Each TableRow In ParametersTable Do + + TableRow.Key = EncodeString(TableRow.Key, StringEncodingMethod.URLencoding); + TableRow.Value = EncodeString(TableRow.Value, StringEncodingMethod.URLencoding); + + EndDo; + + ParametersTable.Sort("Key"); + + For Each TableRow In ParametersTable Do + + SignatureString = SignatureString + + TableRow.Key + + "=" + + TableRow.Value + + "&"; + + EndDo; + + SignatureString = Left(SignatureString, StrLength(SignatureString) - 1); + SignatureString = inReg(RequestType) + + "&" + + EncodeString(URL, StringEncodingMethod.URLencoding) + + "&" + + EncodeString(SignatureString, StringEncodingMethod.URLencoding); + + Signature = EncodeString(Parameters["oauth_consumer_secret"], StringEncodingMethod.URLencoding) + + "&" + + EncodeString(Parameters["oauth_token_secret"], StringEncodingMethod.URLencoding); + + Signature = OPI_Cryptography.HMAC(GetBinaryDataFromString(Signature) + , GetBinaryDataFromString(SignatureString) + , HashFunction.SHA1 + , 64); + + Signature = EncodeString(Base64String(Signature), StringEncodingMethod.URLencoding); + + Delimiter = ""","; + AuthorizationHeader = AuthorizationHeader + + "OAuth " + + "oauth_consumer_key=""" + Parameters[OCK] + Delimiter + + "oauth_token=""" + Parameters[OTK] + Delimiter + + "oauth_signature_method=""" + HashingMethod + Delimiter + + "oauth_timestamp=""" + CurrentUNIXDate + Delimiter + + "oauth_nonce=""" + CurrentUNIXDate + Delimiter + + "oauth_version=""" + APIVersion + Delimiter + + "oauth_signature=""" + Signature; + + HeaderMapping = New Match; + HeaderMapping.Insert("authorization", AuthorizationHeader); + + Return HeaderMapping; + EndFunction Function CreateAuthorizationHeaderV2(Val Parameters) - -ReturnMapping = New Match; -ReturnMapping.Insert("Authorization", "Bearer " + Parameters["access_token"]); - -Return ReturnMapping; - + + ReturnMapping = New Match; + ReturnMapping.Insert("Authorization", "Bearer " + Parameters["access_token"]); + + Return ReturnMapping; + EndFunction Function GetProcessingStatus(Val Parameters, Val Fields, Val URL) -ProcessingInfo = "processing_info"; -Authorization = CreateAuthorizationHeaderV1(Parameters, Fields, "POST", URL); - -Response = OPI_Tools.Post(URL, Fields, Authorization, False); -Information = Response[ProcessingInfo]; - -If Not ValueIsFilled(Information) Then -Return Response; -EndIf; - -ProcessingStatus = Information["state"]; - -If Not ValueIsFilled(ProcessingStatus) Then -Return Response; -Else -Return ProcessingStatus; -EndIf; - + ProcessingInfo = "processing_info"; + Authorization = CreateAuthorizationHeaderV1(Parameters, Fields, "POST", URL); + + Response = OPI_Tools.Post(URL, Fields, Authorization, False); + Information = Response[ProcessingInfo]; + + If Not ValueIsFilled(Information) Then + Return Response; + EndIf; + + ProcessingStatus = Information["state"]; + + If Not ValueIsFilled(ProcessingStatus) Then + Return Response; + Else + Return ProcessingStatus; + EndIf; + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Twitter/OPI_Twitter.mdo b/src/en/OPI/src/CommonModules/OPI_Twitter/OPI_Twitter.mdo index 53a41b1e7b..c6382a73c3 100644 --- a/src/en/OPI/src/CommonModules/OPI_Twitter/OPI_Twitter.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Twitter/OPI_Twitter.mdo @@ -1,11 +1,11 @@  -OPI_Twitter - -ru -Methodы work with Twitter (OPI) - -true -true -true + OPI_Twitter + + ru + Methodы work with Twitter (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_TypeConversion/Module.bsl b/src/en/OPI/src/CommonModules/OPI_TypeConversion/Module.bsl index 141bc7a116..955be4d2d0 100644 --- a/src/en/OPI/src/CommonModules/OPI_TypeConversion/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_TypeConversion/Module.bsl @@ -33,268 +33,268 @@ #Region ServiceProgramInterface Procedure GetBinaryData(Value) Export - -If Value = Undefined Then -Return; -EndIf; - -Try - -If TypeValue(Value) = Type("BinaryData") Then -Return; -Else - -File = New File(Value); - -If File.Exists() Then -Value = New BinaryData(Value); - -ElsIf StrFind(Value, "//") Then - -Value = OPI_Tools.Get(Value); - -Else - -Value = Base64Value(Value); - -EndIf; - -EndIf; - -Except -Raise "Error getting binary data from parameter: " + ErrorDescription(); -EndTry; - + + If Value = Undefined Then + Return; + EndIf; + + Try + + If TypeValue(Value) = Type("BinaryData") Then + Return; + Else + + File = New File(Value); + + If File.Exists() Then + Value = New BinaryData(Value); + + ElsIf StrFind(Value, "//") Then + + Value = OPI_Tools.Get(Value); + + Else + + Value = Base64Value(Value); + + EndIf; + + EndIf; + + Except + Raise "Error getting binary data from parameter: " + ErrorDescription(); + EndTry; + EndProcedure Procedure GetBinaryOrStream(Value) Export - -If Value = Undefined Then -Return; -EndIf; - -If TypeValue(Value) <> Type("String") Then -GetBinaryData(Value); -Return; -EndIf; - -File = New File(Value); - -If File.Exists() Then -Value = New FileStream(Value, FileOpenMode.Open); -Else -GetBinaryData(Value); -EndIf; - + + If Value = Undefined Then + Return; + EndIf; + + If TypeValue(Value) <> Type("String") Then + GetBinaryData(Value); + Return; + EndIf; + + File = New File(Value); + + If File.Exists() Then + Value = New FileStream(Value, FileOpenMode.Open); + Else + GetBinaryData(Value); + EndIf; + EndProcedure Procedure GetCollection(Value) Export - -If Value = Undefined Then -Return; -EndIf; - -Try - -InitialValue = Value; - -If ThisIsCollection(Value) Then -Return; -Else - -If TypeValue(Value) = Type("BinaryData") Then -Value = GetStringFromBinaryData(Value); -Else -Value = OPI_Tools.NumberToString(Value); -EndIf; - -File = New File(Value); -ReadingJSON = New ReadingJSON; - -If File.Exists() Then - -ReadingJSON.OpenFile(Value); - -ElsIf StringStartsWith(nReg(Value), "http") Then - -AndVF = GetTempFileName(); -CopyFile(Value, AndVF); -ReadingJSON.OpenFile(AndVF); -ReadingJSON.Read(); - -DeleteFiles(AndVF); - -Else - -ReadingJSON.SetString(ShortLP(Value)); - -EndIf; - -Value = ReadJSON(ReadingJSON, True, Undefined, JSONDateFormat.ISO); -ReadingJSON.Close(); - -If (Not ThisIsCollection(Value)) Or Not ValueIsFilled(Value) Then - -Value = InitialValue; -GetArray(Value); - -EndIf; - -EndIf; - -Except - -Value = InitialValue; -GetArray(Value); - -EndTry; - + + If Value = Undefined Then + Return; + EndIf; + + Try + + InitialValue = Value; + + If ThisIsCollection(Value) Then + Return; + Else + + If TypeValue(Value) = Type("BinaryData") Then + Value = GetStringFromBinaryData(Value); + Else + Value = OPI_Tools.NumberToString(Value); + EndIf; + + File = New File(Value); + ReadingJSON = New ReadingJSON; + + If File.Exists() Then + + ReadingJSON.OpenFile(Value); + + ElsIf StringStartsWith(nReg(Value), "http") Then + + AndVF = GetTempFileName(); + CopyFile(Value, AndVF); + ReadingJSON.OpenFile(AndVF); + ReadingJSON.Read(); + + DeleteFiles(AndVF); + + Else + + ReadingJSON.SetString(ShortLP(Value)); + + EndIf; + + Value = ReadJSON(ReadingJSON, True, Undefined, JSONDateFormat.ISO); + ReadingJSON.Close(); + + If (Not ThisIsCollection(Value)) Or Not ValueIsFilled(Value) Then + + Value = InitialValue; + GetArray(Value); + + EndIf; + + EndIf; + + Except + + Value = InitialValue; + GetArray(Value); + + EndTry; + EndProcedure Procedure GetArray(Value) Export - -If TypeValue(Value) = Type("Array") Then -Return; -EndIf; - -If TypeValue(Value) = Type("String") -And StringStartsWith(Value, "[") -And StrEndsWith(Value, "]") Then - -CommaInQuotes = "','"; - -Value = StringReplace(Value, "['" , ""); -Value = StringReplace(Value, "']" , ""); -Value = StringReplace(Value, "', '" , CommaInQuotes); -Value = StringReplace(Value, "' , '", CommaInQuotes); -Value = StringReplace(Value, "' ,'" , CommaInQuotes); - -Value = StrSplit(Value, CommaInQuotes, False); - -For N = 0 For Value.WithinBoundary() Do -Value[N] = ShortLP(Value[N]); -EndDo; - -Else - -If TypeValue(Value) = Type("Number") Then -Value = OPI_Tools.NumberToString(Value); -EndIf; - -OPI_Tools.ValueToArray(Value); - -EndIf; - + + If TypeValue(Value) = Type("Array") Then + Return; + EndIf; + + If TypeValue(Value) = Type("String") + And StringStartsWith(Value, "[") + And StrEndsWith(Value, "]") Then + + CommaInQuotes = "','"; + + Value = StringReplace(Value, "['" , ""); + Value = StringReplace(Value, "']" , ""); + Value = StringReplace(Value, "', '" , CommaInQuotes); + Value = StringReplace(Value, "' , '", CommaInQuotes); + Value = StringReplace(Value, "' ,'" , CommaInQuotes); + + Value = StrSplit(Value, CommaInQuotes, False); + + For N = 0 For Value.WithinBoundary() Do + Value[N] = ShortLP(Value[N]); + EndDo; + + Else + + If TypeValue(Value) = Type("Number") Then + Value = OPI_Tools.NumberToString(Value); + EndIf; + + OPI_Tools.ValueToArray(Value); + + EndIf; + EndProcedure Procedure GetBoolean(Value) Export - -If Value = Undefined Then -Return; -EndIf; - -Try - -If TypeValue(Value) = Type("Boolean") Then -Return; -Else -Value = Boolean(Value); -EndIf; - -Except -Raise "Error getting boolean data from parameter"; -EndTry; - + + If Value = Undefined Then + Return; + EndIf; + + Try + + If TypeValue(Value) = Type("Boolean") Then + Return; + Else + Value = Boolean(Value); + EndIf; + + Except + Raise "Error getting boolean data from parameter"; + EndTry; + EndProcedure Procedure GetLine(Value, Val FromSource = False) Export - -If Value = Undefined Then -Return; -EndIf; - -Try - -If ThisIsSymbolic(Value) Then - -If Not FromSource Then -Value = OPI_Tools.NumberToString(Value); -Return; -EndIf; - -Value = OPI_Tools.NumberToString(Value); -File = New File(Value); - -If File.Exists() Then - -ReadingText = New ReadingText(Value); -Value = ReadingText.Read(); -ReadingText.Close(); - -ElsIf StringStartsWith(nReg(Value), "http") Then - -AndVF = GetTempFileName(); -CopyFile(Value, AndVF); - -ReadingText = New ReadingText(AndVF); -Value = ReadingText.Read(); -ReadingText.Close(); - -DeleteFiles(AndVF); - -Else - -Return; - -EndIf; - -ElsIf TypeValue(Value) = Type("BinaryData") Then - -Value = GetStringFromBinaryData(Value); - -ElsIf ThisIsCollection(Value) Then - -Value = OPI_Tools.JSONString(Value); - -Else -Return; -EndIf; - -Except -Value = String(Value); -Return; -EndTry; - + + If Value = Undefined Then + Return; + EndIf; + + Try + + If ThisIsSymbolic(Value) Then + + If Not FromSource Then + Value = OPI_Tools.NumberToString(Value); + Return; + EndIf; + + Value = OPI_Tools.NumberToString(Value); + File = New File(Value); + + If File.Exists() Then + + ReadingText = New ReadingText(Value); + Value = ReadingText.Read(); + ReadingText.Close(); + + ElsIf StringStartsWith(nReg(Value), "http") Then + + AndVF = GetTempFileName(); + CopyFile(Value, AndVF); + + ReadingText = New ReadingText(AndVF); + Value = ReadingText.Read(); + ReadingText.Close(); + + DeleteFiles(AndVF); + + Else + + Return; + + EndIf; + + ElsIf TypeValue(Value) = Type("BinaryData") Then + + Value = GetStringFromBinaryData(Value); + + ElsIf ThisIsCollection(Value) Then + + Value = OPI_Tools.JSONString(Value); + + Else + Return; + EndIf; + + Except + Value = String(Value); + Return; + EndTry; + EndProcedure Procedure GetDate(Value) Export - -If Value = Undefined Then -Return; -EndIf; - -Date = "Date"; - -Try - -If TypeValue(Value) = Type(Date) Then -Return; -Else -Value = XMLValue(Type(Date), Value); -EndIf; - -Except -OOD = New TypeDescription(Date); -Value = OOD.ConvertValue(Value); -EndTry; - + + If Value = Undefined Then + Return; + EndIf; + + Date = "Date"; + + Try + + If TypeValue(Value) = Type(Date) Then + Return; + Else + Value = XMLValue(Type(Date), Value); + EndIf; + + Except + OOD = New TypeDescription(Date); + Value = OOD.ConvertValue(Value); + EndTry; + EndProcedure Procedure GetNumber(Value) Export - -TypeDescription = New TypeDescription("Number"); -Value = TypeDescription.ConvertValue(Value); - + + TypeDescription = New TypeDescription("Number"); + Value = TypeDescription.ConvertValue(Value); + EndProcedure #EndRegion @@ -302,19 +302,19 @@ EndProcedure #Region ServiceProceduresAndFunctions Function ThisIsCollection(Val Value) - -Return TypeValue(Value) = Type("Array") -Or TypeValue(Value) = Type("Structure") -Or TypeValue(Value) = Type("Match"); - -EndFunction + + Return TypeValue(Value) = Type("Array") + Or TypeValue(Value) = Type("Structure") + Or TypeValue(Value) = Type("Match"); + +EndFunction Function ThisIsSymbolic(Val Value) - -Return TypeValue(Value) = Type("String") -Or TypeValue(Value) = Type("Number") -Or TypeValue(Value) = Type("Date"); - -EndFunction + + Return TypeValue(Value) = Type("String") + Or TypeValue(Value) = Type("Number") + Or TypeValue(Value) = Type("Date"); + +EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_TypeConversion/OPI_TypeConversion.mdo b/src/en/OPI/src/CommonModules/OPI_TypeConversion/OPI_TypeConversion.mdo index a72db09a50..e0e787b206 100644 --- a/src/en/OPI/src/CommonModules/OPI_TypeConversion/OPI_TypeConversion.mdo +++ b/src/en/OPI/src/CommonModules/OPI_TypeConversion/OPI_TypeConversion.mdo @@ -1,11 +1,11 @@  -OPI_TypeConversion - -ru -Преобразоinание typeоin (OPI) - -true -true -true + OPI_TypeConversion + + ru + Преобразоinание typeоin (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_VK/Module.bsl b/src/en/OPI/src/CommonModules/OPI_VK/Module.bsl index 8bc01032ac..0b8f8e5daf 100644 --- a/src/en/OPI/src/CommonModules/OPI_VK/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_VK/Module.bsl @@ -22,7 +22,7 @@ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. +// SOFTWARE. // https://github.com/Bayselonarrend/OpenIntegrations // If in не зtoете with чего toчать, то withтоит toйти method GetStandardParameters() @@ -48,112 +48,112 @@ // Create token retrieval link // Getting a link for interactive token retrieval (access_token), which is necessary // for further actions -// +// // Parameters: // app_id - String, Number - app_id from application settings - app -// +// // Return value: -// String - URL to go to in the browser +// String - URL to go to in the browser Function CreateTokenRetrievalLink(Val App_id) Export - -OPI_TypeConversion.GetLine(App_id); - -// access_token will need to be taken from the parameter in the browser address bar -Return "https://oauth.vk.com/authorize?client_id=" + App_id -+ "&scope=offline,wall,groups,photos,stats,stories,ads,market,video" -+ "&v=5.131&response_type=token&redirect_uri=https://api.vk.com/blank.html"; - + + OPI_TypeConversion.GetLine(App_id); + + // access_token will need to be taken from the parameter in the browser address bar + Return "https://oauth.vk.com/authorize?client_id=" + App_id + + "&scope=offline,wall,groups,photos,stats,stories,ads,market,video" + + "&v=5.131&response_type=token&redirect_uri=https://api.vk.com/blank.html"; + EndFunction - + #EndRegion #Region GroupWork // Create post // Creates a post with images -// +// // Parameters: // Text - String - Post text - text -// ImageArray - Array from String, BinaryData - Array of images - pictures +// ImageArray - Array from String, BinaryData - Array of images - pictures // Advertisement - Boolean - Indication ""Это реtoлама"" - ad // LinkUnderPost - String - Link (URL) under the post - url // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreatePost(Val Text -, Val ImageArray -, Val Advertisement = False -, Val LinkUnderPost = "" -, Val Parameters = "") Export + , Val ImageArray + , Val Advertisement = False + , Val LinkUnderPost = "" + , Val Parameters = "") Export + + OPI_TypeConversion.GetCollection(ImageArray); + + Parameters_ = GetStandardParameters(Parameters); + AttachmentsArray = New Array; + + For Each PostImage In ImageArray Do + + Parameters_ = GetStandardParameters(Parameters); + ResponseCorrespondence = GetImageCorrespondence(PostImage, Parameters_, "Post"); + + OwnerId = ResponseCorrespondence.Get("owner_id"); + ObjectId = ResponseCorrespondence.Get("id"); + + If Not ValueIsFilled(OwnerId) Or Not ValueIsFilled(ObjectId) Then + Return ResponseCorrespondence; + EndIf; + + OwnerId = OPI_Tools.NumberToString(OwnerId); + ObjectId = OPI_Tools.NumberToString(ObjectId); + + PhotoID = "photo" + OwnerId + "_" + ObjectId; -OPI_TypeConversion.GetCollection(ImageArray); - -Parameters_ = GetStandardParameters(Parameters); -AttachmentsArray = New Array; - -For Each PostImage In ImageArray Do - -Parameters_ = GetStandardParameters(Parameters); -ResponseCorrespondence = GetImageCorrespondence(PostImage, Parameters_, "Post"); - -OwnerId = ResponseCorrespondence.Get("owner_id"); -ObjectId = ResponseCorrespondence.Get("id"); - -If Not ValueIsFilled(OwnerId) Or Not ValueIsFilled(ObjectId) Then -Return ResponseCorrespondence; -EndIf; - -OwnerId = OPI_Tools.NumberToString(OwnerId); -ObjectId = OPI_Tools.NumberToString(ObjectId); - -PhotoID = "photo" + OwnerId + "_" + ObjectId; - -AttachmentsArray.Add(PhotoID); - -EndDo; - -Response = CreateCompositePost(Text, AttachmentsArray, Advertisement, LinkUnderPost, Parameters); - -Return Response; + AttachmentsArray.Add(PhotoID); + + EndDo; + Response = CreateCompositePost(Text, AttachmentsArray, Advertisement, LinkUnderPost, Parameters); + + Return Response; + EndFunction // Create composite post // Созdает поwithт to mainоinе маwithwithиinа иdетифиtoатороin объеtoтоin (toартиноto, inиdео и dр.) -// +// // Parameters: // Text - String - Post text - text -// Objects - Array of Strings - Array of identifiers like photo123_123 - objects +// Objects - Array of Strings - Array of identifiers like photo123_123 - objects // Advertisement - Boolean - Indication ""Это реtoлама"" - ad // LinkUnderPost - String - Link (URL) under the post - url // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreateCompositePost(Val Text -, Val Objects -, Val Advertisement = False -, Val LinkUnderPost = "" -, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Text); -OPI_TypeConversion.GetLine(LinkUnderPost); -OPI_TypeConversion.GetBoolean(Advertisement); - -Parameters = GetStandardParameters(Parameters); -AttachmentsString = StrJoin(Objects, ","); -AttachmentsString = AttachmentsString + LinkUnderPost; - -Parameters.Insert("message" , Text); -Parameters.Insert("attachments" , AttachmentsString); -Parameters.Insert("mark_as_ads" , ?(Advertisement, 1, 0)); -Parameters.Insert("close_comments" , ?(Advertisement, 1, 0)); - -Response = OPI_Tools.Get("api.vk.com/method/wall.post", Parameters); - -Return Response; + , Val Objects + , Val Advertisement = False + , Val LinkUnderPost = "" + , Val Parameters = "") Export + + OPI_TypeConversion.GetLine(Text); + OPI_TypeConversion.GetLine(LinkUnderPost); + OPI_TypeConversion.GetBoolean(Advertisement); + + Parameters = GetStandardParameters(Parameters); + AttachmentsString = StrJoin(Objects, ","); + AttachmentsString = AttachmentsString + LinkUnderPost; + + Parameters.Insert("message" , Text); + Parameters.Insert("attachments" , AttachmentsString); + Parameters.Insert("mark_as_ads" , ?(Advertisement, 1, 0)); + Parameters.Insert("close_comments" , ?(Advertisement, 1, 0)); + Response = OPI_Tools.Get("api.vk.com/method/wall.post", Parameters); + + Return Response; + EndFunction // Delete post @@ -162,20 +162,20 @@ EndFunction // Parameters: // PostID - String, Number - Post ID - post // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function DeletePost(Val PostID, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(PostID); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("post_id", PostID); - -Response = OPI_Tools.Get("api.vk.com/method/wall.delete", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(PostID); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("post_id", PostID); + + Response = OPI_Tools.Get("api.vk.com/method/wall.delete", Parameters_); + + Return Response; + EndFunction // Create poll @@ -186,72 +186,72 @@ EndFunction // AnswersArray - Array of Strings - Array of answer options - options // Image - String, BinaryData - Poll image - picture // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreatePoll(Val Question, Val AnswersArray, Val Image = "", Val Parameters = "") Export + + OPI_TypeConversion.GetLine(Question); + OPI_TypeConversion.GetCollection(AnswersArray); + + Parameters_ = GetStandardParameters(Parameters); + Response = "response"; -OPI_TypeConversion.GetLine(Question); -OPI_TypeConversion.GetCollection(AnswersArray); - -Parameters_ = GetStandardParameters(Parameters); -Response = "response"; - -If ValueIsFilled(Image) Then - -Response = UploadPhotoToServer(Image, Parameters_, "Poll"); - -Photo = Response.Get(Response); - -If ValueIsFilled(Photo) Then - -PhotoID = Photo["id"]; - -If Not ValueIsFilled(PhotoID) Then -Return Response; -EndIf; - -Else -Return Response; -EndIf; - -EndIf; - -Parameters_.Insert("is_anonymous", 1); -Parameters_.Insert("is_multiple" , 0); - -Answers = StrJoin(AnswersArray, ""","""); -Answers = "[""" + Answers + """]"; - -Parameters_.Insert("add_answers", Answers); -Parameters_.Insert("photo_id" , OPI_Tools.NumberToString(PhotoID)); -Parameters_.Insert("question" , Question); - -Poll = OPI_Tools.Get("api.vk.com/method/polls.create", Parameters_); -PollCorrespondence = Poll.Get(Response); - -If Not ValueIsFilled(PollCorrespondence) Then -Return Poll; -EndIf; - -OwnerId = PollCorrespondence.Get("owner_id"); -ObjectId = PollCorrespondence.Get("id"); - -If Not ValueIsFilled(OwnerId) Or Not ValueIsFilled(ObjectId) Then -Return Poll; -EndIf; - -PollID = "poll" -+ OPI_Tools.NumberToString(OwnerId) -+ "_" -+ OPI_Tools.NumberToString(ObjectId); - -Parameters_.Insert("attachments", PollID); - -Response = OPI_Tools.Get("api.vk.com/method/wall.post", Parameters_); - -Return Response; - + If ValueIsFilled(Image) Then + + Response = UploadPhotoToServer(Image, Parameters_, "Poll"); + + Photo = Response.Get(Response); + + If ValueIsFilled(Photo) Then + + PhotoID = Photo["id"]; + + If Not ValueIsFilled(PhotoID) Then + Return Response; + EndIf; + + Else + Return Response; + EndIf; + + EndIf; + + Parameters_.Insert("is_anonymous", 1); + Parameters_.Insert("is_multiple" , 0); + + Answers = StrJoin(AnswersArray, ""","""); + Answers = "[""" + Answers + """]"; + + Parameters_.Insert("add_answers", Answers); + Parameters_.Insert("photo_id" , OPI_Tools.NumberToString(PhotoID)); + Parameters_.Insert("question" , Question); + + Poll = OPI_Tools.Get("api.vk.com/method/polls.create", Parameters_); + PollCorrespondence = Poll.Get(Response); + + If Not ValueIsFilled(PollCorrespondence) Then + Return Poll; + EndIf; + + OwnerId = PollCorrespondence.Get("owner_id"); + ObjectId = PollCorrespondence.Get("id"); + + If Not ValueIsFilled(OwnerId) Or Not ValueIsFilled(ObjectId) Then + Return Poll; + EndIf; + + PollID = "poll" + + OPI_Tools.NumberToString(OwnerId) + + "_" + + OPI_Tools.NumberToString(ObjectId); + + Parameters_.Insert("attachments", PollID); + + Response = OPI_Tools.Get("api.vk.com/method/wall.post", Parameters_); + + Return Response; + EndFunction // Create album @@ -261,24 +261,24 @@ EndFunction // Name - String - Album name - title // Description - String - Album description - description // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreateAlbum(Val Name, Val Description = "", Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetLine(Description); - -Parameters_ = GetStandardParameters(Parameters); - -Parameters_.Insert("title" , Name); -Parameters_.Insert("description" , Description); -Parameters_.Insert("upload_by_admins_only", 1); - -Response = OPI_Tools.Get("api.vk.com/method/photos.createAlbum", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetLine(Description); + + Parameters_ = GetStandardParameters(Parameters); + + Parameters_.Insert("title" , Name); + Parameters_.Insert("description" , Description); + Parameters_.Insert("upload_by_admins_only", 1); + + Response = OPI_Tools.Get("api.vk.com/method/photos.createAlbum", Parameters_); + + Return Response; + EndFunction // Delete album @@ -287,20 +287,20 @@ EndFunction // Parameters: // AlbumID - String, Number - Album ID - album // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function DeleteAlbum(Val AlbumID, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(AlbumID); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("album_id", OPI_Tools.NumberToString(AlbumID)); - -Response = OPI_Tools.Get("api.vk.com/method/photos.deleteAlbum", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(AlbumID); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("album_id", OPI_Tools.NumberToString(AlbumID)); + + Response = OPI_Tools.Get("api.vk.com/method/photos.deleteAlbum", Parameters_); + + Return Response; + EndFunction // Create story @@ -310,187 +310,187 @@ EndFunction // Image - String, BinaryData - Story background - picture // URL - String - URL for button under the story - url // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreateStory(Val Image, Val URL = "", Val Parameters = "") Export - -OPI_TypeConversion.GetLine(URL); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("link_text" , "more"); -Parameters_.Insert("link_url" , URL); -Parameters_.Insert("add_to_news", "1"); - -Response = UploadPhotoToServer(Image, Parameters_, "Story"); -Return Response; - + + OPI_TypeConversion.GetLine(URL); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("link_text" , "more"); + Parameters_.Insert("link_url" , URL); + Parameters_.Insert("add_to_news", "1"); + + Response = UploadPhotoToServer(Image, Parameters_, "Story"); + Return Response; + EndFunction // Save image to album // Saves an image to the community album // // Parameters: -// AlbumID - String, Number - Album ID - album +// AlbumID - String, Number - Album ID - album // Image - BinaryData,String - Image file - picture // Description - String - Image description - description // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function SaveImageToAlbum(Val AlbumID, Val Image, Val Description = "", Val Parameters = "") Export - -OPI_TypeConversion.GetLine(AlbumID); -OPI_TypeConversion.GetLine(Description); - -Parameters_ = GetStandardParameters(Parameters); - -Parameters_.Insert("album_id", AlbumID); -Parameters_.Insert("caption" , Description); - -Return UploadPhotoToServer(Image, Parameters_, "Album"); - + + OPI_TypeConversion.GetLine(AlbumID); + OPI_TypeConversion.GetLine(Description); + + Parameters_ = GetStandardParameters(Parameters); + + Parameters_.Insert("album_id", AlbumID); + Parameters_.Insert("caption" , Description); + + Return UploadPhotoToServer(Image, Parameters_, "Album"); + EndFunction // Delete image // Deletes an image from the album // // Parameters: -// ImageID - String, Number - Image ID - pictureid +// ImageID - String, Number - Image ID - pictureid // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function DeleteImage(Val ImageID, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(ImageID); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("photo_id", ImageID); - -Response = OPI_Tools.Get("api.vk.com/method/photos.delete", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(ImageID); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("photo_id", ImageID); + + Response = OPI_Tools.Get("api.vk.com/method/photos.delete", Parameters_); + + Return Response; + EndFunction // Upload video to server // Uploads video to the group for further use -// +// // Parameters: // Video - String, BinaryData - Video file - file // Name - String - Video name - title // Description - String - Video description - description // Album - String - Album ID, if necessary - album // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function UploadVideoToServer(Val Video -, Val Name -, Val Description = "" -, Val Album = "" -, Val Parameters = "") Export - -String_ = "String"; -Parameters = GetStandardParameters(Parameters); - -OPI_Tools.AddField("name" , Name, String_, Parameters); -OPI_Tools.AddField("description", Description , String_, Parameters); -OPI_Tools.AddField("album_id" , Album , String_, Parameters); - -Response = OPI_Tools.Get("api.vk.com/method/video.save", Parameters); - -Result = Response["response"]; - -If Not ValueIsFilled(Result) Then -Return Response; -EndIf; - -URL = Result["upload_url"]; - -If Not ValueIsFilled(URL) Then -Return Response; -EndIf; - -FileMapping = New Match; -OPI_Tools.AddField("video_file.mp4", Video, "BinaryData", FileMapping); - -DataSize = FileMapping["video_file.mp4"].Size(); -DataSize = OPI_Tools.NumberToString(DataSize); - -Response = OPI_Tools.PostMultipart(URL, , FileMapping, "video/mp4"); - -Return Response; - + , Val Name + , Val Description = "" + , Val Album = "" + , Val Parameters = "") Export + + String_ = "String"; + Parameters = GetStandardParameters(Parameters); + + OPI_Tools.AddField("name" , Name, String_, Parameters); + OPI_Tools.AddField("description", Description , String_, Parameters); + OPI_Tools.AddField("album_id" , Album , String_, Parameters); + + Response = OPI_Tools.Get("api.vk.com/method/video.save", Parameters); + + Result = Response["response"]; + + If Not ValueIsFilled(Result) Then + Return Response; + EndIf; + + URL = Result["upload_url"]; + + If Not ValueIsFilled(URL) Then + Return Response; + EndIf; + + FileMapping = New Match; + OPI_Tools.AddField("video_file.mp4", Video, "BinaryData", FileMapping); + + DataSize = FileMapping["video_file.mp4"].Size(); + DataSize = OPI_Tools.NumberToString(DataSize); + + Response = OPI_Tools.PostMultipart(URL, , FileMapping, "video/mp4"); + + Return Response; + EndFunction // Upload photo to server // Uploads photo to server for further use -// +// // Parameters: // Image - String, BinaryData - Image file - file // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json // View - String - View upload (Post, Product, Story, Poll, Miscellaneous) - type -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function UploadPhotoToServer(Val Image, Val Parameters = "", Val View = "Post") Export + + Parameters = GetStandardParameters(Parameters); + Method = DetermineImageUploadMethod(View); + Files = New Match; + + Response = "response"; + URL = "api.vk.com/method/"; + Upload = URL + Method["Upload"]; + Save = URL + Method["Save"]; + + If TypeValue(Image) = Type("String") Then + ImageKey = StringReplace(Image, ".", "___"); + OPI_TypeConversion.GetBinaryData(Image); + Else + ImageKey = "image___jpeg"; + EndIf; + + Files.Insert(ImageKey, Image); + + For N = 1 For 5 Do + + Response = OPI_Tools.Get(Upload, Parameters); + Result = Response[Response]; + + If ValueIsFilled(Result) Then + + URL = Result["upload_url"]; + + If Not ValueIsFilled(URL) Then + Return Response; + EndIf; + + Else + Return Response; + EndIf; + + Parameters.Insert("upload_url", URL); + Response = OPI_Tools.PostMultipart(URL, Parameters, Files); + + If TypeValue(Response) = Type("Match") Then + Break; + EndIf; + + EndDo; + + If TypeValue(Response) <> Type("Match") Then + Return GetStringFromBinaryData(Response); + EndIf; -Parameters = GetStandardParameters(Parameters); -Method = DetermineImageUploadMethod(View); -Files = New Match; - -Response = "response"; -URL = "api.vk.com/method/"; -Upload = URL + Method["Upload"]; -Save = URL + Method["Save"]; - -If TypeValue(Image) = Type("String") Then -ImageKey = StringReplace(Image, ".", "___"); -OPI_TypeConversion.GetBinaryData(Image); -Else -ImageKey = "image___jpeg"; -EndIf; - -Files.Insert(ImageKey, Image); - -For N = 1 For 5 Do - -Response = OPI_Tools.Get(Upload, Parameters); -Result = Response[Response]; - -If ValueIsFilled(Result) Then - -URL = Result["upload_url"]; - -If Not ValueIsFilled(URL) Then -Return Response; -EndIf; - -Else -Return Response; -EndIf; - -Parameters.Insert("upload_url", URL); -Response = OPI_Tools.PostMultipart(URL, Parameters, Files); - -If TypeValue(Response) = Type("Match") Then -Break; -EndIf; - -EndDo; - -If TypeValue(Response) <> Type("Match") Then -Return GetStringFromBinaryData(Response); -EndIf; - -FillPhotoUploadParameters(Method, Response, Parameters); - -Response = OPI_Tools.Get(Save, Parameters); - -Return Response; - + FillPhotoUploadParameters(Method, Response, Parameters); + + Response = OPI_Tools.Get(Save, Parameters); + + Return Response; + EndFunction #EndRegion @@ -504,22 +504,22 @@ EndFunction // Name - String - Discussion name - title // Text of the first message - String - Text of the first message - text // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreateDiscussion(Val Name, Val Text of the first message, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetLine(Text of the first message); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("title", Name); -Parameters_.Insert("text" , Text of the first message); - -Response = OPI_Tools.Get("api.vk.com/method/board.addTopic", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetLine(Text of the first message); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("title", Name); + Parameters_.Insert("text" , Text of the first message); + + Response = OPI_Tools.Get("api.vk.com/method/board.addTopic", Parameters_); + + Return Response; + EndFunction // Close discussion @@ -529,21 +529,21 @@ EndFunction // DiscussionID - String, Number - Discussion ID - topic // Delete completely - Boolean - Delete completely (True) or close - remove // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CloseDiscussion(Val DiscussionID, Val Delete completely = False, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(DiscussionID); -OPI_TypeConversion.GetBoolean(Delete completely); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("topic_id", DiscussionID); - -Method = ?(Delete completely, "deleteTopic", "closeTopic"); -Response = OPI_Tools.Get("api.vk.com/method/board." + Method, Parameters_); - -Return Response; + + OPI_TypeConversion.GetLine(DiscussionID); + OPI_TypeConversion.GetBoolean(Delete completely); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("topic_id", DiscussionID); + + Method = ?(Delete completely, "deleteTopic", "closeTopic"); + Response = OPI_Tools.Get("api.vk.com/method/board." + Method, Parameters_); + + Return Response; EndFunction @@ -553,19 +553,19 @@ EndFunction // Parameters: // DiscussionID - String, Number - Discussion ID - topic // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function OpenDiscussion(Val DiscussionID, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(DiscussionID); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("topic_id", DiscussionID); - -Response = OPI_Tools.Get("api.vk.com/method/board.openTopic", Parameters_); - -Return Response; + + OPI_TypeConversion.GetLine(DiscussionID); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("topic_id", DiscussionID); + + Response = OPI_Tools.Get("api.vk.com/method/board.openTopic", Parameters_); + + Return Response; EndFunction @@ -576,21 +576,21 @@ EndFunction // DiscussionID - String, Number - Discussion ID - topic // Text - String - Message text - text // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function WriteInDiscussion(Val DiscussionID, Val Text, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(DiscussionID); -OPI_TypeConversion.GetLine(Text); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("topic_id", DiscussionID); -Parameters_.Insert("message" , Text); - -Response = OPI_Tools.Get("api.vk.com/method/board.createComment", Parameters_); - -Return Response; + + OPI_TypeConversion.GetLine(DiscussionID); + OPI_TypeConversion.GetLine(Text); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("topic_id", DiscussionID); + Parameters_.Insert("message" , Text); + + Response = OPI_Tools.Get("api.vk.com/method/board.createComment", Parameters_); + + Return Response; EndFunction @@ -605,27 +605,27 @@ EndFunction // PostID - String, Number - Post ID - post // WallID - String, Number - ID of the wall where the post is located - wall // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function LikePost(Val PostID, Val WallID = "", Val Parameters = "") Export - -OPI_TypeConversion.GetLine(PostID); -OPI_TypeConversion.GetLine(WallID); - -Parameters_ = GetStandardParameters(Parameters); -WallID = ?(ValueIsFilled(WallID), WallID, Parameters_["owner_id"]); -VKObject = "wall" + WallID + "_" + OPI_Tools.NumberToString(PostID); - -Parameters_.Insert("type" , "post"); -Parameters_.Insert("object" , VKObject); -Parameters_.Insert("item_id" , OPI_Tools.NumberToString(PostID)); -Parameters_.Insert("owner_id" , OPI_Tools.NumberToString(WallID)); -Parameters_.Insert("from_group" , 0); - -Response = OPI_Tools.Get("api.vk.com/method/likes.add", Parameters_); - -Return Response; + + OPI_TypeConversion.GetLine(PostID); + OPI_TypeConversion.GetLine(WallID); + + Parameters_ = GetStandardParameters(Parameters); + WallID = ?(ValueIsFilled(WallID), WallID, Parameters_["owner_id"]); + VKObject = "wall" + WallID + "_" + OPI_Tools.NumberToString(PostID); + + Parameters_.Insert("type" , "post"); + Parameters_.Insert("object" , VKObject); + Parameters_.Insert("item_id" , OPI_Tools.NumberToString(PostID)); + Parameters_.Insert("owner_id" , OPI_Tools.NumberToString(WallID)); + Parameters_.Insert("from_group" , 0); + + Response = OPI_Tools.Get("api.vk.com/method/likes.add", Parameters_); + + Return Response; EndFunction @@ -638,34 +638,34 @@ EndFunction // Target wall - String, Number - ID of the target wall or group - to // Advertising - Boolean - Sign of an advertising post - ad // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function MakeRepost(Val PostID -, Val WallID = "" -, Val Target wall = "" -, Val Advertising = False -, Val Parameters = "") Export + , Val WallID = "" + , Val Target wall = "" + , Val Advertising = False + , Val Parameters = "") Export + + Parameters_ = GetStandardParameters(Parameters); + GroupId = Parameters_["group_id"]; + + OPI_TypeConversion.GetLine(GroupId); + OPI_TypeConversion.GetLine(PostID); + OPI_TypeConversion.GetLine(WallID); + OPI_TypeConversion.GetLine(Target wall); + OPI_TypeConversion.GetBoolean(Advertising); + + Source = ?(ValueIsFilled(WallID), WallID, GroupId); + Receiver = ?(ValueIsFilled(Target wall), Target wall, GroupId); -Parameters_ = GetStandardParameters(Parameters); -GroupId = Parameters_["group_id"]; - -OPI_TypeConversion.GetLine(GroupId); -OPI_TypeConversion.GetLine(PostID); -OPI_TypeConversion.GetLine(WallID); -OPI_TypeConversion.GetLine(Target wall); -OPI_TypeConversion.GetBoolean(Advertising); - -Source = ?(ValueIsFilled(WallID), WallID, GroupId); -Receiver = ?(ValueIsFilled(Target wall), Target wall, GroupId); - -Parameters_.Insert("object" , "wall" + Source + "_" + OPI_Tools.NumberToString(PostID)); -Parameters_.Insert("group_id" , StringReplace(Receiver, "-", "")); -Parameters_.Insert("mark_as_ads" , ?(Advertising, 1, 0)); - -Response = OPI_Tools.Get("api.vk.com/method/wall.repost", Parameters_); - -Return Response; + Parameters_.Insert("object" , "wall" + Source + "_" + OPI_Tools.NumberToString(PostID)); + Parameters_.Insert("group_id" , StringReplace(Receiver, "-", "")); + Parameters_.Insert("mark_as_ads" , ?(Advertising, 1, 0)); + + Response = OPI_Tools.Get("api.vk.com/method/wall.repost", Parameters_); + + Return Response; EndFunction @@ -678,36 +678,36 @@ EndFunction // Communitytoken - String - Community chat bot token, which can be obtained in the settings - ct // Keyboard - String - JSON keyboard. See FormKeyboard - keyboard // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function WriteMessage(Val Text -, Val UserID -, Val Communitytoken -, Val Keyboard = "" -, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Text); -OPI_TypeConversion.GetLine(UserID); -OPI_TypeConversion.GetLine(Communitytoken); -OPI_TypeConversion.GetLine(Keyboard); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("access_token", Communitytoken); - -Parameters_.Insert("user_id" , UserID); -Parameters_.Insert("peer_id" , UserID); -Parameters_.Insert("parse_mode" , "Markdown"); -Parameters_.Insert("random_id" , 0); -Parameters_.Insert("message" , Text); - -If ValueIsFilled(Keyboard) Then -Parameters_.Insert("keyboard", Keyboard); -EndIf; - -Response = OPI_Tools.Get("api.vk.com/method/messages.send", Parameters_); - -Return Response; + , Val UserID + , Val Communitytoken + , Val Keyboard = "" + , Val Parameters = "") Export + + OPI_TypeConversion.GetLine(Text); + OPI_TypeConversion.GetLine(UserID); + OPI_TypeConversion.GetLine(Communitytoken); + OPI_TypeConversion.GetLine(Keyboard); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("access_token", Communitytoken); + + Parameters_.Insert("user_id" , UserID); + Parameters_.Insert("peer_id" , UserID); + Parameters_.Insert("parse_mode" , "Markdown"); + Parameters_.Insert("random_id" , 0); + Parameters_.Insert("message" , Text); + + If ValueIsFilled(Keyboard) Then + Parameters_.Insert("keyboard", Keyboard); + EndIf; + + Response = OPI_Tools.Get("api.vk.com/method/messages.send", Parameters_); + + Return Response; EndFunction @@ -719,29 +719,29 @@ EndFunction // WallID - String, Number - ID of the wall where the post is located - wall // Text - String - Comment text - text // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function WriteComment(Val PostID, Val WallID, Val Text, Val Parameters = "") Export -Parameters_ = GetStandardParameters(Parameters); -GroupId = Parameters_["group_id"]; - -OPI_TypeConversion.GetLine(GroupId); -OPI_TypeConversion.GetLine(PostID); -OPI_TypeConversion.GetLine(WallID); -OPI_TypeConversion.GetLine(Text); - -Parameters_.Insert("owner_id" , WallID); -Parameters_.Insert("from_group" , GroupId); -Parameters_.Insert("post_id" , PostID); -Parameters_.Insert("message" , Text); - -Parameters_.Delete("group_id"); - -Response = OPI_Tools.Get("api.vk.com/method/wall.createComment", Parameters_); - -Return Response; + Parameters_ = GetStandardParameters(Parameters); + GroupId = Parameters_["group_id"]; + + OPI_TypeConversion.GetLine(GroupId); + OPI_TypeConversion.GetLine(PostID); + OPI_TypeConversion.GetLine(WallID); + OPI_TypeConversion.GetLine(Text); + + Parameters_.Insert("owner_id" , WallID); + Parameters_.Insert("from_group" , GroupId); + Parameters_.Insert("post_id" , PostID); + Parameters_.Insert("message" , Text); + + Parameters_.Delete("group_id"); + + Response = OPI_Tools.Get("api.vk.com/method/wall.createComment", Parameters_); + + Return Response; EndFunction @@ -751,35 +751,35 @@ EndFunction // Parameters: // URL - String - URL for shortening - url // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// String - Shortened URL +// String - Shortened URL Function ShortenLink(Val URL, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(URL); - -Response = "response"; -Parameters_ = New Structure; -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("url", URL); - -Response = OPI_Tools.Get("https://api.vk.com/method/utils.getShortLink", Parameters_); -Result = Response[Response]; - -If ValueIsFilled(Result) Then - -URL = Result["short_url"]; - -If ValueIsFilled(URL) Then -Return URL; -Else -Return Response; -EndIf; - -Else -Return Response; -EndIf; - + + OPI_TypeConversion.GetLine(URL); + + Response = "response"; + Parameters_ = New Structure; + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("url", URL); + + Response = OPI_Tools.Get("https://api.vk.com/method/utils.getShortLink", Parameters_); + Result = Response[Response]; + + If ValueIsFilled(Result) Then + + URL = Result["short_url"]; + + If ValueIsFilled(URL) Then + Return URL; + Else + Return Response; + EndIf; + + Else + Return Response; + EndIf; + EndFunction #EndRegion @@ -793,27 +793,27 @@ EndFunction // StartDate - Date - Start date of the period - datefrom // EndDate - Date - End date of the period - dateto // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function GetStatistics(Val StartDate, Val EndDate, Val Parameters = "") Export - -OPI_TypeConversion.GetDate(StartDate); -OPI_TypeConversion.GetDate(EndDate); - -Parameters_ = GetStandardParameters(Parameters); - -StartDate = OPI_Tools.UNIXTime(StartDate); -EndDate = OPI_Tools.UNIXTime(EndDate); - -Parameters_.Insert("timestamp_from", StartDate); -Parameters_.Insert("timestamp_to" , EndDate); -Parameters_.Insert("stats_groups" , "visitors, reach, activity"); - -Response = OPI_Tools.Get("api.vk.com/method/stats.get", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetDate(StartDate); + OPI_TypeConversion.GetDate(EndDate); + + Parameters_ = GetStandardParameters(Parameters); + + StartDate = OPI_Tools.UNIXTime(StartDate); + EndDate = OPI_Tools.UNIXTime(EndDate); + + Parameters_.Insert("timestamp_from", StartDate); + Parameters_.Insert("timestamp_to" , EndDate); + Parameters_.Insert("stats_groups" , "visitors, reach, activity"); + + Response = OPI_Tools.Get("api.vk.com/method/stats.get", Parameters_); + + Return Response; + EndFunction // Get post statistics @@ -822,57 +822,57 @@ EndFunction // Parameters: // Array of post IDs - Array of String,Number - Array of post IDs - posts // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Array of Arbitrary - Array of post statistics data Function GetPostStatistics(Val Array of post IDs, Val Parameters = "") Export + + OPI_TypeConversion.GetCollection(Array of post IDs); + + Parameters_ = GetStandardParameters(Parameters); + AnswersArray = New Array; + Array of Sets = New Array; + MaximumPosts = 30; + Response = "response"; + + For Each Post In Array of post IDs Do + + Array of Sets.Add(OPI_Tools.NumberToString(Post)); + + If Array of Sets.Quantity() = MaximumPosts Then + + NumbersString = StrJoin(Array of Sets, ","); + Parameters_.Insert("post_ids", NumbersString); + + Statistics = OPI_Tools.Get("api.vk.com/method/stats.getPostReach", Parameters_); + Array of Statistics = Statistics[Response]; + + For Each StatisticsItem In Array of Statistics Do + AnswersArray.Add(StatisticsItem); + EndDo; + + Array of Sets = New Array; + + EndIf; + + EndDo; + + NumbersString = StrJoin(Array of Sets, ","); + Parameters_.Insert("post_ids", NumbersString); + + Statistics = OPI_Tools.Get("api.vk.com/method/stats.getPostReach", Parameters_); + Array of Statistics = Statistics[Response]; + + If TypeValue(Array of Statistics) = Type("Array") Then + For Each StatisticsItem In Array of Statistics Do + AnswersArray.Add(StatisticsItem); + EndDo; + EndIf; -OPI_TypeConversion.GetCollection(Array of post IDs); - -Parameters_ = GetStandardParameters(Parameters); -AnswersArray = New Array; -Array of Sets = New Array; -MaximumPosts = 30; -Response = "response"; - -For Each Post In Array of post IDs Do - -Array of Sets.Add(OPI_Tools.NumberToString(Post)); - -If Array of Sets.Quantity() = MaximumPosts Then - -NumbersString = StrJoin(Array of Sets, ","); -Parameters_.Insert("post_ids", NumbersString); - -Statistics = OPI_Tools.Get("api.vk.com/method/stats.getPostReach", Parameters_); -Array of Statistics = Statistics[Response]; - -For Each StatisticsItem In Array of Statistics Do -AnswersArray.Add(StatisticsItem); -EndDo; - -Array of Sets = New Array; - -EndIf; - -EndDo; - -NumbersString = StrJoin(Array of Sets, ","); -Parameters_.Insert("post_ids", NumbersString); - -Statistics = OPI_Tools.Get("api.vk.com/method/stats.getPostReach", Parameters_); -Array of Statistics = Statistics[Response]; - -If TypeValue(Array of Statistics) = Type("Array") Then -For Each StatisticsItem In Array of Statistics Do -AnswersArray.Add(StatisticsItem); -EndDo; -EndIf; - -Return AnswersArray; - + Return AnswersArray; + EndFunction - + #EndRegion #Region AdAccountManagement @@ -884,43 +884,43 @@ EndFunction // AccountID - String, Number - Advertising account ID - cabinet // Name - String - Campaign name - title // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreateAdvertisingCampaign(Val AccountID, Val Name, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(AccountID); -OPI_TypeConversion.GetLine(Name); - -CurrentDate = OPI_Tools.GetCurrentDate(); -EndDate = AddMonth(CurrentDate, 24); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("account_id", AccountID); - -Array of Structures = New Array; -StartDate = OPI_Tools.UNIXTime(CurrentDate); -EndDate = OPI_Tools.UNIXTime(EndDate); - -CampaignStructure = New Structure; -CampaignStructure.Insert("type" , "promoted_posts"); -CampaignStructure.Insert("name" , Name); -CampaignStructure.Insert("day_limit" , 0); -CampaignStructure.Insert("all_limit" , 0); -CampaignStructure.Insert("start_time" , StartDate); -CampaignStructure.Insert("stop_time" , EndDate); -CampaignStructure.Insert("status" , 1); - -Array of Structures.Add(CampaignStructure); - -JSONDate = OPI_Tools.JSONString(Array of Structures); - -Parameters_.Insert("data", JSONDate); - -Response = OPI_Tools.Get("api.vk.com/method/ads.createCampaigns", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(AccountID); + OPI_TypeConversion.GetLine(Name); + + CurrentDate = OPI_Tools.GetCurrentDate(); + EndDate = AddMonth(CurrentDate, 24); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("account_id", AccountID); + + Array of Structures = New Array; + StartDate = OPI_Tools.UNIXTime(CurrentDate); + EndDate = OPI_Tools.UNIXTime(EndDate); + + CampaignStructure = New Structure; + CampaignStructure.Insert("type" , "promoted_posts"); + CampaignStructure.Insert("name" , Name); + CampaignStructure.Insert("day_limit" , 0); + CampaignStructure.Insert("all_limit" , 0); + CampaignStructure.Insert("start_time" , StartDate); + CampaignStructure.Insert("stop_time" , EndDate); + CampaignStructure.Insert("status" , 1); + + Array of Structures.Add(CampaignStructure); + + JSONDate = OPI_Tools.JSONString(Array of Structures); + + Parameters_.Insert("data", JSONDate); + + Response = OPI_Tools.Get("api.vk.com/method/ads.createCampaigns", Parameters_); + + Return Response; + EndFunction // Create advertising post @@ -933,58 +933,58 @@ EndFunction // PostID - String, Number - ID of the post used for advertising - post // AccountID - String, Number - Advertising account ID - cabinet // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreateAd(Val CampaignNumber -, Val DailyLimit -, Val CategoryNumber -, Val PostID -, Val AccountID -, Val Parameters = "") Export - -Parameters_ = GetStandardParameters(Parameters); -GroupId = Parameters_["group_id"]; - -OPI_TypeConversion.GetLine(GroupId); -OPI_TypeConversion.GetLine(CampaignNumber); -OPI_TypeConversion.GetLine(DailyLimit); -OPI_TypeConversion.GetLine(CategoryNumber); -OPI_TypeConversion.GetLine(PostID); -OPI_TypeConversion.GetLine(AccountID); - -Link = "https://vk.com/wall-" + GroupId + "_" + PostID; - -Array of Structures = New Array; -CampaignStructure = New Structure; -CampaignStructure.Insert("campaign_id" , CampaignNumber); -CampaignStructure.Insert("ad_format" , 9); -CampaignStructure.Insert("conversion_event_id" , 1); -CampaignStructure.Insert("autobidding" , 1); -CampaignStructure.Insert("cost_type" , 3); -CampaignStructure.Insert("goal_type" , 2); -CampaignStructure.Insert("ad_platform" , "all"); -CampaignStructure.Insert("publisher_platforms" , "vk"); -CampaignStructure.Insert("publisher_platforms_auto" , "1"); -CampaignStructure.Insert("day_limit" , DailyLimit); -CampaignStructure.Insert("all_limit" , "0"); -CampaignStructure.Insert("category1_id" , CategoryNumber); -CampaignStructure.Insert("age_restriction" , 0); -CampaignStructure.Insert("status" , 1); -CampaignStructure.Insert("name" , "Ad"); -CampaignStructure.Insert("link_url" , Link); - -Array of Structures.Add(CampaignStructure); - -OPI_TypeConversion.GetLine(Array of Structures, True); - -Parameters_.Insert("data" , Array of Structures); -Parameters_.Insert("account_id" , AccountID); - -Response = OPI_Tools.Get("api.vk.com/method/ads.createAds", Parameters_); - -Return Response; - + , Val DailyLimit + , Val CategoryNumber + , Val PostID + , Val AccountID + , Val Parameters = "") Export + + Parameters_ = GetStandardParameters(Parameters); + GroupId = Parameters_["group_id"]; + + OPI_TypeConversion.GetLine(GroupId); + OPI_TypeConversion.GetLine(CampaignNumber); + OPI_TypeConversion.GetLine(DailyLimit); + OPI_TypeConversion.GetLine(CategoryNumber); + OPI_TypeConversion.GetLine(PostID); + OPI_TypeConversion.GetLine(AccountID); + + Link = "https://vk.com/wall-" + GroupId + "_" + PostID; + + Array of Structures = New Array; + CampaignStructure = New Structure; + CampaignStructure.Insert("campaign_id" , CampaignNumber); + CampaignStructure.Insert("ad_format" , 9); + CampaignStructure.Insert("conversion_event_id" , 1); + CampaignStructure.Insert("autobidding" , 1); + CampaignStructure.Insert("cost_type" , 3); + CampaignStructure.Insert("goal_type" , 2); + CampaignStructure.Insert("ad_platform" , "all"); + CampaignStructure.Insert("publisher_platforms" , "vk"); + CampaignStructure.Insert("publisher_platforms_auto" , "1"); + CampaignStructure.Insert("day_limit" , DailyLimit); + CampaignStructure.Insert("all_limit" , "0"); + CampaignStructure.Insert("category1_id" , CategoryNumber); + CampaignStructure.Insert("age_restriction" , 0); + CampaignStructure.Insert("status" , 1); + CampaignStructure.Insert("name" , "Ad"); + CampaignStructure.Insert("link_url" , Link); + + Array of Structures.Add(CampaignStructure); + + OPI_TypeConversion.GetLine(Array of Structures, True); + + Parameters_.Insert("data" , Array of Structures); + Parameters_.Insert("account_id" , AccountID); + + Response = OPI_Tools.Get("api.vk.com/method/ads.createAds", Parameters_); + + Return Response; + EndFunction // Pause advertising post @@ -992,36 +992,36 @@ EndFunction // // Parameters: // AccountID - String, Number - Advertising account ID - cabinet -// AdID - String, Number - Ad ID - adv +// AdID - String, Number - Ad ID - adv // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function PauseAdvertisingAd(Val AccountID, Val AdID, Val Parameters = "") Export + + OPI_TypeConversion.GetLine(AccountID); + OPI_TypeConversion.GetLine(AdID); + + Parameters_ = GetStandardParameters(Parameters); -OPI_TypeConversion.GetLine(AccountID); -OPI_TypeConversion.GetLine(AdID); - -Parameters_ = GetStandardParameters(Parameters); - -Parameters_.Insert("account_id", AccountID); - -Array of Structures = New Array; -CampaignStructure = New Structure; - -CampaignStructure.Insert("ad_id" , AdID); -CampaignStructure.Insert("status" , 0); - -Array of Structures.Add(CampaignStructure); - -OPI_TypeConversion.GetLine(Array of Structures, True); - -Parameters_.Insert("data", Array of Structures); - -Response = OPI_Tools.Get("api.vk.com/method/ads.updateAds", Parameters_); - -Return Response; - + Parameters_.Insert("account_id", AccountID); + + Array of Structures = New Array; + CampaignStructure = New Structure; + + CampaignStructure.Insert("ad_id" , AdID); + CampaignStructure.Insert("status" , 0); + + Array of Structures.Add(CampaignStructure); + + OPI_TypeConversion.GetLine(Array of Structures, True); + + Parameters_.Insert("data", Array of Structures); + + Response = OPI_Tools.Get("api.vk.com/method/ads.updateAds", Parameters_); + + Return Response; + EndFunction // Get a list of advertising categories @@ -1029,15 +1029,15 @@ EndFunction // // Parameters: // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function GetAdvertisingCategoryList(Val Parameters = "") Export - -Parameters_ = GetStandardParameters(Parameters); -Response = OPI_Tools.Get("api.vk.com/method/ads.getCategories", Parameters_); - -Return Response; + + Parameters_ = GetStandardParameters(Parameters); + Response = OPI_Tools.Get("api.vk.com/method/ads.getCategories", Parameters_); + + Return Response; EndFunction @@ -1050,52 +1050,52 @@ EndFunction // // Parameters: // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Compliance From String - Key - ID, Value - Name Function GetProductCategoryList(Val Parameters = "") Export - -Response = "response"; -Parameters_ = GetStandardParameters(Parameters); -Response = OPI_Tools.Get("api.vk.com/method/market.getCategories", Parameters_); -Result = Response[Response]; - -If ValueIsFilled(Result) Then - -Quantity = Result["count"]; - -If Not ValueIsFilled(Quantity) Then -Return Response; -EndIf; - -Else -Return Response; -EndIf; - -Parameters_.Insert("count", Quantity); -Response = OPI_Tools.Get("api.vk.com/method/market.getCategories", Parameters_); -Result = Response[Response]; - -If ValueIsFilled(Result) Then - -Categories = Result["items"]; - -If Not ValueIsFilled(Categories) Then -Return Response; -EndIf; - -Else -Return Response; -EndIf; - -CategoryCorrespondence = New Match; - -For Each Category In Categories Do -CategoryCorrespondence.Insert(Category["id"], Category["name"]); -EndDo; - -Return CategoryCorrespondence; - + + Response = "response"; + Parameters_ = GetStandardParameters(Parameters); + Response = OPI_Tools.Get("api.vk.com/method/market.getCategories", Parameters_); + Result = Response[Response]; + + If ValueIsFilled(Result) Then + + Quantity = Result["count"]; + + If Not ValueIsFilled(Quantity) Then + Return Response; + EndIf; + + Else + Return Response; + EndIf; + + Parameters_.Insert("count", Quantity); + Response = OPI_Tools.Get("api.vk.com/method/market.getCategories", Parameters_); + Result = Response[Response]; + + If ValueIsFilled(Result) Then + + Categories = Result["items"]; + + If Not ValueIsFilled(Categories) Then + Return Response; + EndIf; + + Else + Return Response; + EndIf; + + CategoryCorrespondence = New Match; + + For Each Category In Categories Do + CategoryCorrespondence.Insert(Category["id"], Category["name"]); + EndDo; + + Return CategoryCorrespondence; + EndFunction // Get product list @@ -1104,60 +1104,60 @@ EndFunction // Parameters: // Selection - String, Number - Selection ID, if filtering is needed - sel // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Array of product matches Function GetProductList(Val Selection = "", Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Selection); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("count" , 200); -Parameters_.Insert("extended" , 1); -Parameters_.Insert("with_disabled", 1); - -If ValueIsFilled(Selection) Then -Parameters_.Insert("album_id", Selection); -EndIf; - -Array of products = New Array; -GetProductListRecursively(Array of products, Parameters_); - -Return Array of products; - + + OPI_TypeConversion.GetLine(Selection); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("count" , 200); + Parameters_.Insert("extended" , 1); + Parameters_.Insert("with_disabled", 1); + + If ValueIsFilled(Selection) Then + Parameters_.Insert("album_id", Selection); + EndIf; + + Array of products = New Array; + GetProductListRecursively(Array of products, Parameters_); + + Return Array of products; + EndFunction // Get products by ID // Gets information about products by array of IDs // // Parameters: -// Products - String, Array of Strings - Array of product IDs - items +// Products - String, Array of Strings - Array of product IDs - items // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function GetProductsByID(Val Products, Val Parameters = "") Export - -OPI_TypeConversion.GetCollection(Products); - -Parameters_ = GetStandardParameters(Parameters); -ProductsString = ""; -Owner = "owner_id"; - -For Each Product In Products Do -CurrentProduct = Parameters_[Owner] + "_" + Product; -CurrentProduct = OPI_Tools.NumberToString(CurrentProduct); -ProductsString = ProductsString + CurrentProduct + ","; -EndDo; - -ProductsString = Left(ProductsString, StrLength(ProductsString) - 1); -Parameters_.Insert("item_ids", ProductsString); -Parameters_.Insert("extended", 1); - -Response = OPI_Tools.Get("api.vk.com/method/market.getById", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetCollection(Products); + + Parameters_ = GetStandardParameters(Parameters); + ProductsString = ""; + Owner = "owner_id"; + + For Each Product In Products Do + CurrentProduct = Parameters_[Owner] + "_" + Product; + CurrentProduct = OPI_Tools.NumberToString(CurrentProduct); + ProductsString = ProductsString + CurrentProduct + ","; + EndDo; + + ProductsString = Left(ProductsString, StrLength(ProductsString) - 1); + Parameters_.Insert("item_ids", ProductsString); + Parameters_.Insert("extended", 1); + + Response = OPI_Tools.Get("api.vk.com/method/market.getById", Parameters_); + + Return Response; + EndFunction // Add product @@ -1167,11 +1167,11 @@ EndFunction // ProductDescription - Key-Value Pair - See GetProductDescription - product - JSON description of the product or path // Selection - String - Selection ID for placing the product, if needed - sel // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK -Function AddProduct(Val ProductDescription, Val Selection = "", Val Parameters = "") Export -Return ProductManagement(ProductDescription, , Selection, Parameters); +Function AddProduct(Val ProductDescription, Val Selection = "", Val Parameters = "") Export + Return ProductManagement(ProductDescription, , Selection, Parameters); EndFunction // Edit product @@ -1180,13 +1180,13 @@ EndFunction // Parameters: // Product - Number, String - Identifier of the product being edited - item // ProductDescription - Key-Value Pair - See GetProductDescription - product - JSON description of the product or path -// Selection - String - Identifier of the new selection, if needed - sel +// Selection - String - Identifier of the new selection, if needed - sel // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function EditProduct(Val Product, Val ProductDescription, Val Selection = "", Val Parameters = "") Export -Return ProductManagement(ProductDescription, Product, Selection, Parameters); + Return ProductManagement(ProductDescription, Product, Selection, Parameters); EndFunction // Delete product @@ -1195,20 +1195,20 @@ EndFunction // Parameters: // Product - String, Number - Product ID - item // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function DeleteProduct(Val Product, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Product); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("item_id", Product); - -Response = OPI_Tools.Get("api.vk.com/method/market.delete", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Product); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("item_id", Product); + + Response = OPI_Tools.Get("api.vk.com/method/market.delete", Parameters_); + + Return Response; + EndFunction // Group products @@ -1218,37 +1218,37 @@ EndFunction // Array of products - Array Of String - Array of product IDs - items // ExistingGroup - String - ID of the existing group, if needed - sellgroup // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function GroupProducts(Val Array of products, Val ExistingGroup = "", Val Parameters = "") Export - -OPI_TypeConversion.GetLine(ExistingGroup); -OPI_TypeConversion.GetCollection(Array of products); - -Parameters_ = GetStandardParameters(Parameters); -Array_of_Products = New Array; - -For Each Product In Array of products Do -Array_of_Products.Add(OPI_Tools.NumberToString(Product)); -EndDo; - -Products = StrJoin(Array_of_Products, ","); - -Parameters_.Insert("item_ids", Products); - -If ValueIsFilled(ExistingGroup) Then -Parameters_.Insert("item_group_id", ExistingGroup); -EndIf; - -Response = OPI_Tools.Get("api.vk.com/method/market.groupItems", Parameters_); - -Return Response; + + OPI_TypeConversion.GetLine(ExistingGroup); + OPI_TypeConversion.GetCollection(Array of products); + + Parameters_ = GetStandardParameters(Parameters); + Array_of_Products = New Array; + + For Each Product In Array of products Do + Array_of_Products.Add(OPI_Tools.NumberToString(Product)); + EndDo; + + Products = StrJoin(Array_of_Products, ","); + + Parameters_.Insert("item_ids", Products); + + If ValueIsFilled(ExistingGroup) Then + Parameters_.Insert("item_group_id", ExistingGroup); + EndIf; + + Response = OPI_Tools.Get("api.vk.com/method/market.groupItems", Parameters_); + + Return Response; EndFunction // Get product description. !NOCLI -// +// // Return value: // Key-Value Pair - Empty product description: // *Name - String - Product name @@ -1268,27 +1268,27 @@ EndFunction // *SKU - String - SKU // *AvailableBalance - Number - Balance. -1 - unlimited Function GetProductDescription() Export - -Product = New Match(); -Product.Insert("Name" , "New product"); // Product name -Product.Insert("Description" , "Product description"); // Product description -Product.Insert("Category" , "20173"); // See GetProductCategoryList() -Product.Insert("Price" , 1); // Price. -Product.Insert("OldPrice" , Undefined); // For reflection change price -Product.Insert("MainPhoto" , Undefined); // BD or path to main. photo -Product.Insert("URL" , Undefined); // Link to page store -Product.Insert("AdditionalPhotos" , New Array); // Array paths or BD for add. photo -Product.Insert("PropertyValues" , New Array); // Values properties (variants). Maximum 2 -Product.Insert("MainInGroup" , False); // Make main in of its group -Product.Insert("Width" , Undefined); // In millimeters -Product.Insert("Height" , Undefined); // In millimeters -Product.Insert("Depth" , Undefined); // In millimeters -Product.Insert("Weight" , Undefined); // In grams -Product.Insert("SKU" , Undefined); // SKU -Product.Insert("AvailableBalance" , 1); - -Return Product; - + + Product = New Match(); + Product.Insert("Name" , "New product"); // Product name + Product.Insert("Description" , "Product description"); // Product description + Product.Insert("Category" , "20173"); // See GetProductCategoryList() + Product.Insert("Price" , 1); // Price. + Product.Insert("OldPrice" , Undefined); // For reflection change price + Product.Insert("MainPhoto" , Undefined); // BD or path to main. photo + Product.Insert("URL" , Undefined); // Link to page store + Product.Insert("AdditionalPhotos" , New Array); // Array paths or BD for add. photo + Product.Insert("PropertyValues" , New Array); // Values properties (variants). Maximum 2 + Product.Insert("MainInGroup" , False); // Make main in of its group + Product.Insert("Width" , Undefined); // In millimeters + Product.Insert("Height" , Undefined); // In millimeters + Product.Insert("Depth" , Undefined); // In millimeters + Product.Insert("Weight" , Undefined); // In grams + Product.Insert("SKU" , Undefined); // SKU + Product.Insert("AvailableBalance" , 1); + + Return Product; + EndFunction #EndRegion @@ -1300,19 +1300,19 @@ EndFunction // // Parameters: // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Array of selection matches Function GetSelectionList(Val Parameters = "") Export - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("count", 100); - -ArrayOfAlbums = New Array; -GetAlbumListRecursively(ArrayOfAlbums, Parameters_); - -Return ArrayOfAlbums; - + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("count", 100); + + ArrayOfAlbums = New Array; + GetAlbumListRecursively(ArrayOfAlbums, Parameters_); + + Return ArrayOfAlbums; + EndFunction // Get selections by ID @@ -1321,29 +1321,29 @@ EndFunction // Parameters: // Selections - String, Array of Strings - Selection IDs - sels // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function GetSelectionsByID(Val Selections, Val Parameters = "") Export - -OPI_TypeConversion.GetCollection(Selections); - -Parameters_ = GetStandardParameters(Parameters); -Selections_ = New Array; -SelectionsString = ""; - -For Each Selection In Selections Do -Selections_.Add(OPI_Tools.NumberToString(Selection)); -EndDo; - -SelectionsString = StrJoin(Selections_, ","); - -Parameters_.Insert("album_ids", SelectionsString); - -Response = OPI_Tools.Get("api.vk.com/method/market.getAlbumById", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetCollection(Selections); + + Parameters_ = GetStandardParameters(Parameters); + Selections_ = New Array; + SelectionsString = ""; + + For Each Selection In Selections Do + Selections_.Add(OPI_Tools.NumberToString(Selection)); + EndDo; + + SelectionsString = StrJoin(Selections_, ","); + + Parameters_.Insert("album_ids", SelectionsString); + + Response = OPI_Tools.Get("api.vk.com/method/market.getAlbumById", Parameters_); + + Return Response; + EndFunction // Create product selection @@ -1355,17 +1355,17 @@ EndFunction // Main - Boolean - Main - main // Hidden - Boolean - Hidden - hidden // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function CreateProductCollection(Val Name -, Val Image -, Val Main = False -, Val Hidden = False -, Val Parameters = "") Export - -Return SelectionManagement(Name, Image, , Main, Hidden, Parameters); - + , Val Image + , Val Main = False + , Val Hidden = False + , Val Parameters = "") Export + + Return SelectionManagement(Name, Image, , Main, Hidden, Parameters); + EndFunction // Edit product selection @@ -1378,18 +1378,18 @@ EndFunction // Main - Boolean - Main - main // Hidden - Boolean - Hidden - hidden // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function EditProductCollection(Val Name -, Val Selection -, Val Image = "" -, Val Main = False -, Val Hidden = False -, Val Parameters = "") Export - -Return SelectionManagement(Name, Image, Selection, Main, Hidden, Parameters); - + , Val Selection + , Val Image = "" + , Val Main = False + , Val Hidden = False + , Val Parameters = "") Export + + Return SelectionManagement(Name, Image, Selection, Main, Hidden, Parameters); + EndFunction // Add product to selection @@ -1399,56 +1399,56 @@ EndFunction // Array of products - Array of string, number - Array of products or product - items // Selection - String - Selection ID - sel // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function AddProductToSelection(Val Array of products, Val Selection, Val Parameters = "") Export - -OPI_TypeConversion.GetCollection(Array of products); -OPI_TypeConversion.GetLine(Selection); - -Parameters_ = GetStandardParameters(Parameters); -Array_of_Products = New Array; - -For Each Product In Array of products Do -Array_of_Products.Add(OPI_Tools.NumberToString(Product)); -EndDo; - -ProductList = StrJoin(Array_of_Products, ","); - -Parameters_.Insert("item_ids" , ProductList); -Parameters_.Insert("album_ids", Selection); - -Response = OPI_Tools.Get("api.vk.com/method/market.addToAlbum", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetCollection(Array of products); + OPI_TypeConversion.GetLine(Selection); + + Parameters_ = GetStandardParameters(Parameters); + Array_of_Products = New Array; + + For Each Product In Array of products Do + Array_of_Products.Add(OPI_Tools.NumberToString(Product)); + EndDo; + + ProductList = StrJoin(Array_of_Products, ","); + + Parameters_.Insert("item_ids" , ProductList); + Parameters_.Insert("album_ids", Selection); + + Response = OPI_Tools.Get("api.vk.com/method/market.addToAlbum", Parameters_); + + Return Response; + EndFunction // Remove product from selection // Removes a previously added product from the selection -// +// // Parameters: // Product - String - Product ID - item // Selection - String - Selection ID - sel // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function RemoveProductFromSelection(Val Product, Val Selection, Val Parameters = "") Export + + OPI_TypeConversion.GetLine(Product); + OPI_TypeConversion.GetLine(Selection); -OPI_TypeConversion.GetLine(Product); -OPI_TypeConversion.GetLine(Selection); - -Parameters_ = GetStandardParameters(Parameters); - -Parameters_.Insert("item_id" , Product); -Parameters_.Insert("album_ids", Selection); - -Response = OPI_Tools.Get("api.vk.com/method/market.removeFromAlbum", Parameters_); - -Return Response; - + Parameters_ = GetStandardParameters(Parameters); + + Parameters_.Insert("item_id" , Product); + Parameters_.Insert("album_ids", Selection); + + Response = OPI_Tools.Get("api.vk.com/method/market.removeFromAlbum", Parameters_); + + Return Response; + EndFunction // DeleteSelection @@ -1457,20 +1457,20 @@ EndFunction // Parameters: // Selection - String - Selection ID - sel // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: // Key-Value Pair - Serialized JSON response from VK Function DeleteSelection(Val Selection, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Selection); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("album_id", Selection); - -Response = OPI_Tools.Get("api.vk.com/method/market.deleteAlbum", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Selection); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("album_id", Selection); + + Response = OPI_Tools.Get("api.vk.com/method/market.deleteAlbum", Parameters_); + + Return Response; + EndFunction #EndRegion @@ -1479,167 +1479,167 @@ EndFunction // Get property list // Gets the list of properties of group products -// +// // Parameters: // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function GetPropertyList(Val Parameters = "") Export - -Response = "response"; -Parameters_ = GetStandardParameters(Parameters); - -Response = OPI_Tools.Get("api.vk.com/method/market.getProperties", Parameters_); -Properties = Response[Response]["items"]; - -Return Properties; - + + Response = "response"; + Parameters_ = GetStandardParameters(Parameters); + + Response = OPI_Tools.Get("api.vk.com/method/market.getProperties", Parameters_); + Properties = Response[Response]["items"]; + + Return Properties; + EndFunction // Create product property // Creates a new property for use in products -// +// // Parameters: // Name - String - Property name - title // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function CreateProductProperty(Val Name, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Name); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("title", Name); - -Response = OPI_Tools.Get("api.vk.com/method/market.addProperty", Parameters_); - -Return Response; + + OPI_TypeConversion.GetLine(Name); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("title", Name); + + Response = OPI_Tools.Get("api.vk.com/method/market.addProperty", Parameters_); + + Return Response; EndFunction // Edit product property // Edits the existing product property -// +// // Parameters: // Name - String - New name - title // Property - String, Number - Property ID - prop // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function EditProductProperty(Val Name, Val Property, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetLine(Property); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("title" , Name); -Parameters_.Insert("property_id", Property); -Parameters_.Insert("type" , "text"); - -Response = OPI_Tools.Get("api.vk.com/method/market.editProperty", Parameters_); - -Return Response; + + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetLine(Property); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("title" , Name); + Parameters_.Insert("property_id", Property); + Parameters_.Insert("type" , "text"); + + Response = OPI_Tools.Get("api.vk.com/method/market.editProperty", Parameters_); + + Return Response; EndFunction // Delete product property // Deletes the existing product property -// +// // Parameters: // Property - String, Number - Property ID - prop // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function DeleteProductProperty(Val Property, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Property); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("property_id", Property); - -Response = OPI_Tools.Get("api.vk.com/method/market.deleteProperty", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Property); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("property_id", Property); + + Response = OPI_Tools.Get("api.vk.com/method/market.deleteProperty", Parameters_); + + Return Response; + EndFunction // Add product property variant // Adds a variant for an existing property -// +// // Parameters: // Value - String - Property value - value // Property - String, Number - Property ID where the variant is added - prop // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function AddProductPropertyVariant(Val Value, Val Property, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Property); -OPI_TypeConversion.GetLine(Value); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("property_id", Property); -Parameters_.Insert("title" , Value); - -Response = OPI_Tools.Get("api.vk.com/method/market.addPropertyVariant", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Property); + OPI_TypeConversion.GetLine(Value); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("property_id", Property); + Parameters_.Insert("title" , Value); + + Response = OPI_Tools.Get("api.vk.com/method/market.addPropertyVariant", Parameters_); + + Return Response; + EndFunction // Edit product property variant // Edits the value of an existing product property variant -// +// // Parameters: // Value - String - New property value - value // Property - String, Number - Property ID - prop // Option - String, Number - Variant ID - option // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function EditProductPropertyVariant(Val Value, Val Property, Val Option, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Value); -OPI_TypeConversion.GetLine(Property); -OPI_TypeConversion.GetLine(Option); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("property_id", Property); -Parameters_.Insert("variant_id" , Option); -Parameters_.Insert("title" , Value); - -Response = OPI_Tools.Get("api.vk.com/method/market.editPropertyVariant", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Value); + OPI_TypeConversion.GetLine(Property); + OPI_TypeConversion.GetLine(Option); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("property_id", Property); + Parameters_.Insert("variant_id" , Option); + Parameters_.Insert("title" , Value); + + Response = OPI_Tools.Get("api.vk.com/method/market.editPropertyVariant", Parameters_); + + Return Response; + EndFunction // Delete product property variant // Deletes the previously created product property variant -// +// // Parameters: // Option - String, Number - Variant ID - option // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function DeleteProductPropertyVariant(Val Option, Val Parameters = "") Export - -OPI_TypeConversion.GetLine(Option); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("variant_id", Option); - -Response = OPI_Tools.Get("api.vk.com/method/market.deletePropertyVariant", Parameters_); - -Return Response; - + + OPI_TypeConversion.GetLine(Option); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("variant_id", Option); + + Response = OPI_Tools.Get("api.vk.com/method/market.deletePropertyVariant", Parameters_); + + Return Response; + EndFunction #EndRegion @@ -1648,22 +1648,22 @@ EndFunction // Get order list // Returns the community's order list -// +// // Parameters: // Parameters - Structure Of String - See GetStandardParameters - auth - Authorization JSON or path to .json -// +// // Return value: -// Key-Value Pair - Serialized JSON response from VK +// Key-Value Pair - Serialized JSON response from VK Function GetOrderList(Val Parameters = "") Export - -Parameters = GetStandardParameters(Parameters); -Parameters.Insert("count", 50); - -ArrayOfOrders = New Array; -GetOrderListRecursively(ArrayOfOrders, Parameters); - -Return ArrayOfOrders; - + + Parameters = GetStandardParameters(Parameters); + Parameters.Insert("count", 50); + + ArrayOfOrders = New Array; + GetOrderListRecursively(ArrayOfOrders, Parameters); + + Return ArrayOfOrders; + EndFunction #EndRegion @@ -1672,40 +1672,40 @@ EndFunction // Create keyboard // Forms a keyboard from an array of buttons -// +// // Parameters: // ButtonArray - Array of Strings - Array of button titles - buttons -// +// // Return value: // String - Keyboard JSON Function FormKeyboard(Val ButtonArray) Export - -OPI_TypeConversion.GetCollection(ButtonArray); - -Keyboard = New Structure; -KeyboardArray = New Array; -ArrayBlock = New Array; - -For Each Action In ButtonArray Do - -Button = New Structure; -Expression = New Structure; - -Expression.Insert("type" , "text"); -Expression.Insert("label", Action); - -Button.Insert("action", Expression); -ArrayBlock.Add(Button); - -EndDo; - -KeyboardArray.Add(ArrayBlock); - -Keyboard.Insert("buttons" , KeyboardArray); -Keyboard.Insert("one_time", False); - -Return OPI_Tools.JSONString(Keyboard); - + + OPI_TypeConversion.GetCollection(ButtonArray); + + Keyboard = New Structure; + KeyboardArray = New Array; + ArrayBlock = New Array; + + For Each Action In ButtonArray Do + + Button = New Structure; + Expression = New Structure; + + Expression.Insert("type" , "text"); + Expression.Insert("label", Action); + + Button.Insert("action", Expression); + ArrayBlock.Add(Button); + + EndDo; + + KeyboardArray.Add(ArrayBlock); + + Keyboard.Insert("buttons" , KeyboardArray); + Keyboard.Insert("one_time", False); + + Return OPI_Tools.JSONString(Keyboard); + EndFunction #EndRegion @@ -1715,476 +1715,476 @@ EndFunction #Region ServiceProceduresAndFunctions Function GetStandardParameters(Val Parameters = "") + + // Here is a collection of data definitions for working with the VK API + // You can override them by passing them as a parameter + // Matching fields will be overwritten with the parameter of the function + + Parameters_ = New Structure; + + // access_token - можно получить in браузере по URL from фунtoции CreateTokenRetrievalLink() + // from_group - actions will be performed on behalf of the group + // owner_id - group ID with "-" at the beginning. Can be found in the settings of the VK group or in its URL if not set + // set your + // app_id - application ID that needs to be created in the profile on the developer page + // group_id - owner_id, но without "-" + + Parameters_.Insert("access_token" , ""); + Parameters_.Insert("from_group" , "1"); + Parameters_.Insert("owner_id" , ""); + Parameters_.Insert("v" , "5.131"); + Parameters_.Insert("app_id" , ""); + Parameters_.Insert("group_id" , ""); + + OPI_TypeConversion.GetCollection(Parameters); + + If TypeValue(Parameters) = Type("Structure") Or TypeValue(Parameters) = Type("Match") Then + For Each PassedParameter In Parameters Do + Parameters_.Insert(PassedParameter.Key, OPI_Tools.NumberToString(PassedParameter.Value)); + EndDo; + EndIf; -// Here is a collection of data definitions for working with the VK API -// You can override them by passing them as a parameter -// Matching fields will be overwritten with the parameter of the function - -Parameters_ = New Structure; - -// access_token - можно получить in браузере по URL from фунtoции CreateTokenRetrievalLink() -// from_group - actions will be performed on behalf of the group -// owner_id - group ID with "-" at the beginning. Can be found in the settings of the VK group or in its URL if not set -// set your -// app_id - application ID that needs to be created in the profile on the developer page -// group_id - owner_id, но without "-" - -Parameters_.Insert("access_token" , ""); -Parameters_.Insert("from_group" , "1"); -Parameters_.Insert("owner_id" , ""); -Parameters_.Insert("v" , "5.131"); -Parameters_.Insert("app_id" , ""); -Parameters_.Insert("group_id" , ""); - -OPI_TypeConversion.GetCollection(Parameters); - -If TypeValue(Parameters) = Type("Structure") Or TypeValue(Parameters) = Type("Match") Then -For Each PassedParameter In Parameters Do -Parameters_.Insert(PassedParameter.Key, OPI_Tools.NumberToString(PassedParameter.Value)); -EndDo; -EndIf; - -Return Parameters_; + Return Parameters_; EndFunction Function GetImageID(Val Image, Val Parameters, Val View) + + Response = "response"; + Response = UploadPhotoToServer(Image, Parameters, View); + Result = Response[Response]; -Response = "response"; -Response = UploadPhotoToServer(Image, Parameters, View); -Result = Response[Response]; - -If ValueIsFilled(Result) Then -PhotoID = Result["photo_id"]; - -If Not ValueIsFilled(PhotoID) Then -Return Response; -EndIf; - -Else -Return Response; -EndIf; - -PhotoID = OPI_Tools.NumberToString(PhotoID); -Return PhotoID; - + If ValueIsFilled(Result) Then + PhotoID = Result["photo_id"]; + + If Not ValueIsFilled(PhotoID) Then + Return Response; + EndIf; + + Else + Return Response; + EndIf; + + PhotoID = OPI_Tools.NumberToString(PhotoID); + Return PhotoID; + EndFunction Function GetImageCorrespondence(Val Image, Val Parameters, Val View) - -Response = UploadPhotoToServer(Image, Parameters, View); -ResponseArray = Response.Get("response"); - -If Not ValueIsFilled(ResponseArray) Or Not TypeValue(ResponseArray) = Type("Array") Then -Return Response; -Else -If ResponseArray.Quantity() = 0 Then -Return Response; -Else -ResponseCorrespondence = ResponseArray[0]; -EndIf; -EndIf; - -Return ResponseCorrespondence; - + + Response = UploadPhotoToServer(Image, Parameters, View); + ResponseArray = Response.Get("response"); + + If Not ValueIsFilled(ResponseArray) Or Not TypeValue(ResponseArray) = Type("Array") Then + Return Response; + Else + If ResponseArray.Quantity() = 0 Then + Return Response; + Else + ResponseCorrespondence = ResponseArray[0]; + EndIf; + EndIf; + + Return ResponseCorrespondence; + EndFunction Function GetSelectionArray(Val Selections, Val Parameters = "") - -Response = "response"; -Selections = GetSelectionsByID(Selections, Parameters); -Result = Selections[Response]; - -If ValueIsFilled(Result) Then - -SelectionArray = Result["items"]; - -If Not ValueIsFilled(SelectionArray) Then -Return Selections; -EndIf; - -Else -Return Selections; -EndIf; - -Return SelectionArray; - + + Response = "response"; + Selections = GetSelectionsByID(Selections, Parameters); + Result = Selections[Response]; + + If ValueIsFilled(Result) Then + + SelectionArray = Result["items"]; + + If Not ValueIsFilled(SelectionArray) Then + Return Selections; + EndIf; + + Else + Return Selections; + EndIf; + + Return SelectionArray; + EndFunction Function DetermineImageUploadMethod(Val View) - -MethodCorrespondence = New Match; -Upload = "Upload"; -Save = "Save"; -Method = "Method"; -Photo = "Photo"; - -If View = "Post" Then - -MethodCorrespondence.Insert(Upload , "photos.getWallUploadServer"); -MethodCorrespondence.Insert(Save, "photos.saveWallPhoto"); -MethodCorrespondence.Insert(Photo , "photo"); -MethodCorrespondence.Insert(Method , 1); - -ElsIf View = "Product" Then - -MethodCorrespondence.Insert(Upload , "market.getProductPhotoUploadServer"); -MethodCorrespondence.Insert(Save, "market.saveProductPhoto"); -MethodCorrespondence.Insert(Method , 2); - -ElsIf View = "Story" Then - -MethodCorrespondence.Insert(Upload , "stories.getPhotoUploadServer"); -MethodCorrespondence.Insert(Save, "stories.save"); -MethodCorrespondence.Insert(Method , 3); - -ElsIf View = "Poll" Then - -MethodCorrespondence.Insert(Upload , "polls.getPhotoUploadServer"); -MethodCorrespondence.Insert(Save, "polls.savePhoto"); -MethodCorrespondence.Insert(Photo , "photo"); -MethodCorrespondence.Insert(Method , 1); - -Else - -MethodCorrespondence.Insert(Upload , "photos.getUploadServer"); -MethodCorrespondence.Insert(Save, "photos.save"); -MethodCorrespondence.Insert(Photo , "photos_list"); -MethodCorrespondence.Insert(Method , 1); - -EndIf; - -Return MethodCorrespondence; - + + MethodCorrespondence = New Match; + Upload = "Upload"; + Save = "Save"; + Method = "Method"; + Photo = "Photo"; + + If View = "Post" Then + + MethodCorrespondence.Insert(Upload , "photos.getWallUploadServer"); + MethodCorrespondence.Insert(Save, "photos.saveWallPhoto"); + MethodCorrespondence.Insert(Photo , "photo"); + MethodCorrespondence.Insert(Method , 1); + + ElsIf View = "Product" Then + + MethodCorrespondence.Insert(Upload , "market.getProductPhotoUploadServer"); + MethodCorrespondence.Insert(Save, "market.saveProductPhoto"); + MethodCorrespondence.Insert(Method , 2); + + ElsIf View = "Story" Then + + MethodCorrespondence.Insert(Upload , "stories.getPhotoUploadServer"); + MethodCorrespondence.Insert(Save, "stories.save"); + MethodCorrespondence.Insert(Method , 3); + + ElsIf View = "Poll" Then + + MethodCorrespondence.Insert(Upload , "polls.getPhotoUploadServer"); + MethodCorrespondence.Insert(Save, "polls.savePhoto"); + MethodCorrespondence.Insert(Photo , "photo"); + MethodCorrespondence.Insert(Method , 1); + + Else + + MethodCorrespondence.Insert(Upload , "photos.getUploadServer"); + MethodCorrespondence.Insert(Save, "photos.save"); + MethodCorrespondence.Insert(Photo , "photos_list"); + MethodCorrespondence.Insert(Method , 1); + + EndIf; + + Return MethodCorrespondence; + EndFunction Function GetProductParameterMapping() - -Fields = New Match(); -Fields.Insert("Name" , "name"); -Fields.Insert("Description" , "description"); -Fields.Insert("Category" , "category_id"); -Fields.Insert("Price" , "price"); -Fields.Insert("OldPrice" , "old_price"); -Fields.Insert("URL" , "url"); -Fields.Insert("MainInGroup" , "is_main_variant"); -Fields.Insert("Width" , "dimension_width"); -Fields.Insert("Height" , "dimension_height"); -Fields.Insert("Depth" , "dimension_length"); -Fields.Insert("Weight" , "weight"); -Fields.Insert("SKU" , "sku"); -Fields.Insert("AvailableBalance" , "stock_amount"); - -Return Fields; + + Fields = New Match(); + Fields.Insert("Name" , "name"); + Fields.Insert("Description" , "description"); + Fields.Insert("Category" , "category_id"); + Fields.Insert("Price" , "price"); + Fields.Insert("OldPrice" , "old_price"); + Fields.Insert("URL" , "url"); + Fields.Insert("MainInGroup" , "is_main_variant"); + Fields.Insert("Width" , "dimension_width"); + Fields.Insert("Height" , "dimension_height"); + Fields.Insert("Depth" , "dimension_length"); + Fields.Insert("Weight" , "weight"); + Fields.Insert("SKU" , "sku"); + Fields.Insert("AvailableBalance" , "stock_amount"); + + Return Fields; EndFunction Function ProductManagement(Val ProductDescription, Val ProductID = "", Val Selection = "", Val Parameters = "") - -OPI_TypeConversion.GetLine(ProductID); -OPI_TypeConversion.GetLine(Selection); -OPI_TypeConversion.GetCollection(ProductDescription); - -Parameters_ = GetStandardParameters(Parameters); -Parameters_.Insert("v", "5.199"); - -Response = "response"; - -FillProductRequestFields(ProductDescription, Parameters_); - -If ValueIsFilled(ProductID) Then -Parameters_.Insert("item_id", ProductID); -Method = "edit"; -Else -Method = "add"; -EndIf; - -Response = OPI_Tools.Get("api.vk.com/method/market." + Method, Parameters_); -Result = Response[Response]; - -If Not ValueIsFilled(ProductID) And ValueIsFilled(Result) Then - -ProductID = Result["market_item_id"]; - -If Not ValueIsFilled(ProductID) Then -Return Response; -EndIf; - -Else -Return Response; -EndIf; - -If ValueIsFilled(Selection) And ValueIsFilled(ProductID) Then -AddProductToSelection(ProductID, Selection, Parameters_); -EndIf; - -Return Response; + + OPI_TypeConversion.GetLine(ProductID); + OPI_TypeConversion.GetLine(Selection); + OPI_TypeConversion.GetCollection(ProductDescription); + + Parameters_ = GetStandardParameters(Parameters); + Parameters_.Insert("v", "5.199"); + + Response = "response"; + + FillProductRequestFields(ProductDescription, Parameters_); + + If ValueIsFilled(ProductID) Then + Parameters_.Insert("item_id", ProductID); + Method = "edit"; + Else + Method = "add"; + EndIf; + + Response = OPI_Tools.Get("api.vk.com/method/market." + Method, Parameters_); + Result = Response[Response]; + + If Not ValueIsFilled(ProductID) And ValueIsFilled(Result) Then + + ProductID = Result["market_item_id"]; + + If Not ValueIsFilled(ProductID) Then + Return Response; + EndIf; + + Else + Return Response; + EndIf; + + If ValueIsFilled(Selection) And ValueIsFilled(ProductID) Then + AddProductToSelection(ProductID, Selection, Parameters_); + EndIf; + + Return Response; EndFunction Function SelectionManagement(Val Name -, Val Image = "" -, Val SelectionID = "" -, Val Main = False -, Val Hidden = False -, Val Parameters = "") - -OPI_TypeConversion.GetLine(Name); -OPI_TypeConversion.GetLine(SelectionID); -OPI_TypeConversion.GetBoolean(Main); -OPI_TypeConversion.GetBoolean(Hidden); - -Parameters_ = GetStandardParameters(Parameters); -Response = AddImageParameter(Image, SelectionID, Parameters_); - -If ValueIsFilled(Response) Then -Return Response; -EndIf; - -Parameters_.Insert("title" , Name); -Parameters_.Insert("main_album" , ?(Main, 1, 0)); -Parameters_.Insert("is_hidden" , ?(Hidden, 1, 0)); - -If ValueIsFilled(SelectionID) Then -Parameters_.Insert("album_id", SelectionID); -Method = "editAlbum"; -Else -Method = "addAlbum"; -EndIf; - -Response = OPI_Tools.Get("api.vk.com/method/market." + Method, Parameters_); - -Return Response; + , Val Image = "" + , Val SelectionID = "" + , Val Main = False + , Val Hidden = False + , Val Parameters = "") + + OPI_TypeConversion.GetLine(Name); + OPI_TypeConversion.GetLine(SelectionID); + OPI_TypeConversion.GetBoolean(Main); + OPI_TypeConversion.GetBoolean(Hidden); + + Parameters_ = GetStandardParameters(Parameters); + Response = AddImageParameter(Image, SelectionID, Parameters_); + + If ValueIsFilled(Response) Then + Return Response; + EndIf; + + Parameters_.Insert("title" , Name); + Parameters_.Insert("main_album" , ?(Main, 1, 0)); + Parameters_.Insert("is_hidden" , ?(Hidden, 1, 0)); + + If ValueIsFilled(SelectionID) Then + Parameters_.Insert("album_id", SelectionID); + Method = "editAlbum"; + Else + Method = "addAlbum"; + EndIf; + + Response = OPI_Tools.Get("api.vk.com/method/market." + Method, Parameters_); + + Return Response; EndFunction Function AddImageParameter(Val Image, Val SelectionID, Parameters) - -PhotoID = "photo_id"; - -If ValueIsFilled(Image) Then - -PhotoID = GetImageID(Image, Parameters, "Product"); - -If Not TypeValue(PhotoID) = Type("String") Then -Return PhotoID; -EndIf; - -Parameters.Insert(PhotoID, PhotoID); - -Else - -If ValueIsFilled(SelectionID) Then - -Selections = GetSelectionArray(SelectionID, Parameters); - -If Not TypeValue(Selections) = Type("Array") Then -Return Selections; -EndIf; - -If Not Selections.Quantity() = 0 Then -PhotoID = Selections[0]["photo"]["id"]; -OPI_TypeConversion.GetLine(PhotoID); -Parameters.Insert(PhotoID, PhotoID); -EndIf; - -EndIf; - -EndIf; - -Return ""; - + + PhotoID = "photo_id"; + + If ValueIsFilled(Image) Then + + PhotoID = GetImageID(Image, Parameters, "Product"); + + If Not TypeValue(PhotoID) = Type("String") Then + Return PhotoID; + EndIf; + + Parameters.Insert(PhotoID, PhotoID); + + Else + + If ValueIsFilled(SelectionID) Then + + Selections = GetSelectionArray(SelectionID, Parameters); + + If Not TypeValue(Selections) = Type("Array") Then + Return Selections; + EndIf; + + If Not Selections.Quantity() = 0 Then + PhotoID = Selections[0]["photo"]["id"]; + OPI_TypeConversion.GetLine(PhotoID); + Parameters.Insert(PhotoID, PhotoID); + EndIf; + + EndIf; + + EndIf; + + Return ""; + EndFunction Procedure FillPhotoUploadParameters(Val Method, Val Response, Parameters) + + Response = "response"; + Method = Method["Method"]; + StandardMethod = 1; + NewMethod = 2; -Response = "response"; -Method = Method["Method"]; -StandardMethod = 1; -NewMethod = 2; - -If Method = StandardMethod Then - -Hash = "hash"; -Serv = "server"; -Aid = "aid"; -Photo = Method["Photo"]; - -Parameters.Insert(Hash, Response[Hash]); -Parameters.Insert(Photo, Response[Photo]); - -PhotoServer = Response.Get(Serv); - -If ValueIsFilled(PhotoServer) Then -PhotoServer = OPI_Tools.NumberToString(PhotoServer); -Parameters.Insert(Serv, PhotoServer); -EndIf; - -Identifier = Response.Get(Aid); - -If ValueIsFilled(Identifier) Then -Identifier = OPI_Tools.NumberToString(Identifier); -Parameters.Insert(Aid , Identifier); -EndIf; - -ElsIf Method = NewMethod Then - -ResponseString = OPI_Tools.JSONString(Response); -Parameters.Insert("upload_response", ResponseString); - -Else - -Parameters.Insert("upload_results", Response[Response]["upload_result"]); - -EndIf; + If Method = StandardMethod Then + + Hash = "hash"; + Serv = "server"; + Aid = "aid"; + Photo = Method["Photo"]; + + Parameters.Insert(Hash, Response[Hash]); + Parameters.Insert(Photo, Response[Photo]); + + PhotoServer = Response.Get(Serv); + + If ValueIsFilled(PhotoServer) Then + PhotoServer = OPI_Tools.NumberToString(PhotoServer); + Parameters.Insert(Serv, PhotoServer); + EndIf; + + Identifier = Response.Get(Aid); + + If ValueIsFilled(Identifier) Then + Identifier = OPI_Tools.NumberToString(Identifier); + Parameters.Insert(Aid , Identifier); + EndIf; + + ElsIf Method = NewMethod Then + + ResponseString = OPI_Tools.JSONString(Response); + Parameters.Insert("upload_response", ResponseString); + + Else + + Parameters.Insert("upload_results", Response[Response]["upload_result"]); + + EndIf; EndProcedure Procedure FillProductRequestFields(Val ProductDescription, Parameters) - -Response = "response"; -MainPhoto = ProductDescription["MainPhoto"]; -AdditionalPhoto = ProductDescription["AdditionalPhotos"]; -Properties = ProductDescription["PropertyValues"]; - -If ValueIsFilled(MainPhoto) Then - -Response = UploadPhotoToServer(MainPhoto, Parameters, "Product"); -Result = Response[Response]; - -If ValueIsFilled(Result) Then -PhotoID = Result["photo_id"]; - -If Not ValueIsFilled(PhotoID) Then -Return; -EndIf; - -Else -Return; -EndIf; - -PhotoID = OPI_Tools.NumberToString(PhotoID); -Parameters.Insert("main_photo_id", PhotoID); - -EndIf; - -If TypeValue(Properties) = Type("Array") Then - -Properties_ = New Array; - -For Each Property In Properties Do -Properties_.Add(OPI_Tools.NumberToString(Property)); -EndDo; - -Properties = StrJoin(Properties_, ","); - -EndIf; - -If ValueIsFilled(Properties) Then -Parameters.Insert("variant_ids", OPI_Tools.NumberToString(Properties)); -EndIf; - -AddAdditionalProductPhotos(AdditionalPhoto, Parameters); - -For Each Field In GetProductParameterMapping() Do - -Value = ProductDescription[Field.Key]; - -If Value <> Undefined Then -Parameters.Insert(Field.Value, ProductDescription[Field.Key]); -EndIf; - -EndDo; + + Response = "response"; + MainPhoto = ProductDescription["MainPhoto"]; + AdditionalPhoto = ProductDescription["AdditionalPhotos"]; + Properties = ProductDescription["PropertyValues"]; + + If ValueIsFilled(MainPhoto) Then + + Response = UploadPhotoToServer(MainPhoto, Parameters, "Product"); + Result = Response[Response]; + + If ValueIsFilled(Result) Then + PhotoID = Result["photo_id"]; + + If Not ValueIsFilled(PhotoID) Then + Return; + EndIf; + + Else + Return; + EndIf; + + PhotoID = OPI_Tools.NumberToString(PhotoID); + Parameters.Insert("main_photo_id", PhotoID); + + EndIf; + + If TypeValue(Properties) = Type("Array") Then + + Properties_ = New Array; + + For Each Property In Properties Do + Properties_.Add(OPI_Tools.NumberToString(Property)); + EndDo; + + Properties = StrJoin(Properties_, ","); + + EndIf; + + If ValueIsFilled(Properties) Then + Parameters.Insert("variant_ids", OPI_Tools.NumberToString(Properties)); + EndIf; + + AddAdditionalProductPhotos(AdditionalPhoto, Parameters); + + For Each Field In GetProductParameterMapping() Do + + Value = ProductDescription[Field.Key]; + + If Value <> Undefined Then + Parameters.Insert(Field.Value, ProductDescription[Field.Key]); + EndIf; + + EndDo; EndProcedure Procedure AddAdditionalProductPhotos(Val PhotoArray, Parameters) + + If TypeValue(PhotoArray) = Type("Array") Then + If PhotoArray.Quantity() > 0 Then + + PhotoString = ""; + + For Each Photo In PhotoArray Do + + PhotoID = GetImageID(Photo, Parameters, "Product"); + + If Not TypeValue(PhotoID) = Type("String") Then + Return; + EndIf; -If TypeValue(PhotoArray) = Type("Array") Then -If PhotoArray.Quantity() > 0 Then - -PhotoString = ""; - -For Each Photo In PhotoArray Do - -PhotoID = GetImageID(Photo, Parameters, "Product"); - -If Not TypeValue(PhotoID) = Type("String") Then -Return; -EndIf; - -PhotoString = PhotoString + PhotoID + ","; - -EndDo; - -PhotoString = Left(PhotoString, StrLength(PhotoString) - 1); -Parameters.Insert("photo_ids", PhotoString); -EndIf; -EndIf; - + PhotoString = PhotoString + PhotoID + ","; + + EndDo; + + PhotoString = Left(PhotoString, StrLength(PhotoString) - 1); + Parameters.Insert("photo_ids", PhotoString); + EndIf; + EndIf; + EndProcedure Procedure GetProductListRecursively(Array of products, Parameters, Shift = 0) - -Response = "response"; -MaxInRequest = 200; -Response = OPI_Tools.Get("api.vk.com/method/market.get", Parameters); -Products = Response[Response]["items"]; - -If Products.Quantity() = 0 Then -Return; -EndIf; - -For Each Product In Products Do -Array of products.Add(Product); -EndDo; - -Shift = Shift + MaxInRequest; -Parameters.Insert("offset", Shift); -GetProductListRecursively(Array of products, Parameters, Shift); - + + Response = "response"; + MaxInRequest = 200; + Response = OPI_Tools.Get("api.vk.com/method/market.get", Parameters); + Products = Response[Response]["items"]; + + If Products.Quantity() = 0 Then + Return; + EndIf; + + For Each Product In Products Do + Array of products.Add(Product); + EndDo; + + Shift = Shift + MaxInRequest; + Parameters.Insert("offset", Shift); + GetProductListRecursively(Array of products, Parameters, Shift); + EndProcedure Procedure GetAlbumListRecursively(ArrayOfAlbums, Parameters, Shift = 0) - -Response = "response"; -MaxInRequest = 100; -Response = OPI_Tools.Get("api.vk.com/method/market.getAlbums", Parameters); -Albums = Response[Response]["items"]; - -If Albums.Quantity() = 0 Then -Return; -EndIf; - -For Each Album In Albums Do -ArrayOfAlbums.Add(Album); -EndDo; - -Shift = Shift + MaxInRequest; -Parameters.Insert("offset", Shift); -GetAlbumListRecursively(ArrayOfAlbums, Parameters, Shift); - + + Response = "response"; + MaxInRequest = 100; + Response = OPI_Tools.Get("api.vk.com/method/market.getAlbums", Parameters); + Albums = Response[Response]["items"]; + + If Albums.Quantity() = 0 Then + Return; + EndIf; + + For Each Album In Albums Do + ArrayOfAlbums.Add(Album); + EndDo; + + Shift = Shift + MaxInRequest; + Parameters.Insert("offset", Shift); + GetAlbumListRecursively(ArrayOfAlbums, Parameters, Shift); + EndProcedure Procedure GetOrderListRecursively(ArrayOfOrders, Parameters, Shift = 0) - -Response = "response"; -MaxInRequest = 50; -Response = OPI_Tools.Get("api.vk.com/method/market.getGroupOrders", Parameters); -Orders = Response[Response]["items"]; - -If Orders.Quantity() = 0 Then -Return; -EndIf; - -For Each Order In Orders Do -ArrayOfOrders.Add(Order); -EndDo; - -Shift = Shift + MaxInRequest; -Parameters.Insert("offset", Shift); -GetOrderListRecursively(ArrayOfOrders, Parameters, Shift); - + + Response = "response"; + MaxInRequest = 50; + Response = OPI_Tools.Get("api.vk.com/method/market.getGroupOrders", Parameters); + Orders = Response[Response]["items"]; + + If Orders.Quantity() = 0 Then + Return; + EndIf; + + For Each Order In Orders Do + ArrayOfOrders.Add(Order); + EndDo; + + Shift = Shift + MaxInRequest; + Parameters.Insert("offset", Shift); + GetOrderListRecursively(ArrayOfOrders, Parameters, Shift); + EndProcedure #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_VK/OPI_VK.mdo b/src/en/OPI/src/CommonModules/OPI_VK/OPI_VK.mdo index 376f601cf4..c7eca11ad8 100644 --- a/src/en/OPI/src/CommonModules/OPI_VK/OPI_VK.mdo +++ b/src/en/OPI/src/CommonModules/OPI_VK/OPI_VK.mdo @@ -1,11 +1,11 @@  -OPI_VK - -ru -Methodы интеграции with VK (OPI) - -true -true -true + OPI_VK + + ru + Methodы интеграции with VK (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_Viber/Module.bsl b/src/en/OPI/src/CommonModules/OPI_Viber/Module.bsl index 5b672ff216..f967a237a0 100644 --- a/src/en/OPI/src/CommonModules/OPI_Viber/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_Viber/Module.bsl @@ -23,7 +23,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. - + // https://github.com/Bayselonarrend/OpenIntegrations // BSLLS:LatinAndCyrillicSymbolInWord-off @@ -41,80 +41,80 @@ // which will return 200 and a genuine SSL certificate. If there is a certificate and the database is published // on the server - you can use an HTTP service. Information about new messages will also be sent there // Viber periodically knocks on the Webhook address, so if it is inactive, everything will stop working -// +// // Parameters: // Token - String - Viber Token - token // URL - String - URL for setting up Webhook - url -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function SetWebhook(Val Token, Val URL) Export - -Parameters = New Structure; -OPI_Tools.AddField("url" , URL , "String", Parameters); -OPI_Tools.AddField("auth_token" , Token, "String", Parameters); - -Return OPI_Tools.Post("https://chatapi.viber.com/pa/set_webhook", Parameters); - + + Parameters = New Structure; + OPI_Tools.AddField("url" , URL , "String", Parameters); + OPI_Tools.AddField("auth_token" , Token, "String", Parameters); + + Return OPI_Tools.Post("https://chatapi.viber.com/pa/set_webhook", Parameters); + EndFunction // Get channel information // Here you can get the channel's user IDs. Bot IDs need to be obtained from the Webhook arrivals // The user ID from channel information is not suitable for sending messages through the bot - they are different -// +// // Parameters: // Token - String - Token - token -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function GetChannelInformation(Val Token) Export - -URL = "https://chatapi.viber.com/pa/get_account_info"; -Return OPI_Tools.Get(URL, , TokenInHeaders(Token)); - + + URL = "https://chatapi.viber.com/pa/get_account_info"; + Return OPI_Tools.Get(URL, , TokenInHeaders(Token)); + EndFunction // Get user data // Gets user information by ID -// +// // Parameters: // Token - String - Token - token // UserID - String, Number - Viber User ID - user -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function GetUserData(Val Token, Val UserID) Export + + URL = "https://chatapi.viber.com/pa/get_user_details"; + + Parameters = New Structure; + OPI_Tools.AddField("id", UserID, "String", Parameters); + + Response = OPI_Tools.Post(URL, Parameters, TokenInHeaders(Token)); -URL = "https://chatapi.viber.com/pa/get_user_details"; - -Parameters = New Structure; -OPI_Tools.AddField("id", UserID, "String", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, TokenInHeaders(Token)); - -Return Response; + Return Response; EndFunction // Get online users // Gets the status of a user or several users by ID -// +// // Parameters: // Token - String - Viber Token - token // UserIDs - String,Number,Array of String,Number - Viber User(s) ID - users -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function GetOnlineUsers(Val Token, Val UserIDs) Export - -URL = "https://chatapi.viber.com/pa/get_online"; - -Parameters = New Structure; -OPI_Tools.AddField("ids", UserIDs, "Collection", Parameters); - -Response = OPI_Tools.Post(URL, Parameters, TokenInHeaders(Token)); - -Return Response; + + URL = "https://chatapi.viber.com/pa/get_online"; + + Parameters = New Structure; + OPI_Tools.AddField("ids", UserIDs, "Collection", Parameters); + + Response = OPI_Tools.Post(URL, Parameters, TokenInHeaders(Token)); + + Return Response; EndFunction @@ -124,185 +124,185 @@ EndFunction // Send text message // Sends a text message to a chat or channel -// +// // Parameters: // Token - String - Token - token // Text - String - Message text - text // UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user // SendingToChannel - Boolean - Sending to channel or bot chat - ischannel // Keyboard - Structure Of String - See CreateKeyboardFromArrayButton - keyboard -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function SendTextMessage(Val Token -, Val Text -, Val UserID -, Val SendingToChannel -, Val Keyboard = "") Export - -Return SendMessage(Token, "text", UserID, SendingToChannel, , Text, Keyboard); - + , Val Text + , Val UserID + , Val SendingToChannel + , Val Keyboard = "") Export + + Return SendMessage(Token, "text", UserID, SendingToChannel, , Text, Keyboard); + EndFunction // Send image // Sends an image to a chat or channel -// +// // Parameters: // Token - String - Token - token // URL - String - Image URL - picture // UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user // SendingToChannel - boolean - Sending to channel or bot chat - ischannel // Description - String - Image annotation - description -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function SendImage(Val Token, Val URL, Val UserID, Val SendingToChannel, Val Description = "") Export - -Return SendMessage(Token, "picture", UserID, SendingToChannel, URL, Description); - + + Return SendMessage(Token, "picture", UserID, SendingToChannel, URL, Description); + EndFunction // SendFile // Sends a file (document) to a chat or channel -// +// // Parameters: // Token - String - Token - token -// URL - String - File URL - file -// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user +// URL - String - File URL - file +// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user // SendingToChannel - Boolean - Sending to channel or bot chat - ischannel // Extension - String - File extension - ext // Size - Number - File size. If not filled in > determined automatically by downloading the file - size -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function SendFile(Val Token -, Val URL -, Val UserID -, Val SendingToChannel -, Val Extension -, Val Size = "") Export - -If Not ValueIsFilled(Size) Then - -Response = OPI_Tools.Get(URL); -Size = Response.Size(); - -EndIf; - -String_ = "String"; -Extension = StringReplace(Extension, ".", ""); - -Parameters = New Structure; -OPI_Tools.AddField("URL" , URL , String_, Parameters); -OPI_Tools.AddField("Size" , Size , String_, Parameters); -OPI_Tools.AddField("Extension", Extension, String_, Parameters); - -Return SendMessage(Token, "file", UserID, SendingToChannel, Parameters); - + , Val URL + , Val UserID + , Val SendingToChannel + , Val Extension + , Val Size = "") Export + + If Not ValueIsFilled(Size) Then + + Response = OPI_Tools.Get(URL); + Size = Response.Size(); + + EndIf; + + String_ = "String"; + Extension = StringReplace(Extension, ".", ""); + + Parameters = New Structure; + OPI_Tools.AddField("URL" , URL , String_, Parameters); + OPI_Tools.AddField("Size" , Size , String_, Parameters); + OPI_Tools.AddField("Extension", Extension, String_, Parameters); + + Return SendMessage(Token, "file", UserID, SendingToChannel, Parameters); + EndFunction // Send contact // Sends a contact with a phone number to a chat or channel -// +// // Parameters: // Token - String - Token - token // ContactName - String - Contact name - name // PhoneNumber - String - Phone number - phone -// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user +// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user // SendingToChannel - Boolean - Sending to channel or bot chat - ischannel -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function SendContact(Val Token -, Val ContactName -, Val PhoneNumber -, Val UserID -, Val SendingToChannel) Export - -Parameters = New Structure; -OPI_Tools.AddField("name" , ContactName , "String", Parameters); -OPI_Tools.AddField("phone_number", PhoneNumber, "String", Parameters); - -Return SendMessage(Token, "contact", UserID, SendingToChannel, Parameters); - + , Val ContactName + , Val PhoneNumber + , Val UserID + , Val SendingToChannel) Export + + Parameters = New Structure; + OPI_Tools.AddField("name" , ContactName , "String", Parameters); + OPI_Tools.AddField("phone_number", PhoneNumber, "String", Parameters); + + Return SendMessage(Token, "contact", UserID, SendingToChannel, Parameters); + EndFunction // SendLocation // Sends geographic coordinates to a chat or channel -// +// // Parameters: // Token - String - Token - token // Latitude - String, Number - Geographic latitude - lat // Longitude - String, Number - Geographic longitude - long -// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user +// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user // SendingToChannel - Boolean - Sending to channel or bot chat - ischannel -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function SendLocation(Val Token, Val Latitude, Val Longitude, Val UserID, Val SendingToChannel) Export - -Parameters = New Structure; -OPI_Tools.AddField("lat", Latitude , "String", Parameters); -OPI_Tools.AddField("lon", Longitude, "String", Parameters); - -Return SendMessage(Token, "location", UserID, SendingToChannel, Parameters); - + + Parameters = New Structure; + OPI_Tools.AddField("lat", Latitude , "String", Parameters); + OPI_Tools.AddField("lon", Longitude, "String", Parameters); + + Return SendMessage(Token, "location", UserID, SendingToChannel, Parameters); + EndFunction // SendLink // Sends a URL with a preview to a chat or channel -// +// // Parameters: // Token - String - Token - token // URL - String - SentLink - url -// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user +// UserID - String, Number - User ID. For channel > administrator, for bot > recipient - user // SendingToChannel - Boolean - Sending to channel or bot chat - ischannel -// +// // Return value: // Key-Value Pair - serialized JSON response from Viber Function SendLink(Val Token, Val URL, Val UserID, Val SendingToChannel) Export - -Return SendMessage(Token, "url", UserID, SendingToChannel, URL); - + + Return SendMessage(Token, "url", UserID, SendingToChannel, URL); + EndFunction // Create a keyboard from an array of buttons // Returns a keyboard structure for messages -// +// // Parameters: // ButtonArray - Array of Strings - Array of buttons - buttons // ButtonColor - String - HEX color of buttons with # at the beginning - color -// +// // Return value: // Structure - Create a keyboard from an array of buttons: -// * Buttons - Array of Structure - Array of formed buttons -// * Type - String - KeyboardType +// * Buttons - Array of Structure - Array of formed buttons +// * Type - String - KeyboardType Function CreateKeyboardFromArrayButton(Val ButtonArray, Val ButtonColor = "#2db9b9") Export - -OPI_TypeConversion.GetLine(ButtonColor); -OPI_TypeConversion.GetCollection(ButtonArray); - -ArrayOfButtonStructures = New Array; -KeyboardStructure = New Structure; - -For Each ButtonText In ButtonArray Do - -ButtonStructure = New Structure; -ButtonStructure.Insert("ActionType", "reply"); -ButtonStructure.Insert("ActionBody", ButtonText); -ButtonStructure.Insert("Text" , ButtonText); -ButtonStructure.Insert("BgColor" , ButtonColor); -ButtonStructure.Insert("Coloumns" , 3); - -ArrayOfButtonStructures.Add(ButtonStructure); - -EndDo; - -KeyboardStructure.Insert("Buttons", ArrayOfButtonStructures); -KeyboardStructure.Insert("Type" , "keyboard"); - -Return KeyboardStructure; - + + OPI_TypeConversion.GetLine(ButtonColor); + OPI_TypeConversion.GetCollection(ButtonArray); + + ArrayOfButtonStructures = New Array; + KeyboardStructure = New Structure; + + For Each ButtonText In ButtonArray Do + + ButtonStructure = New Structure; + ButtonStructure.Insert("ActionType", "reply"); + ButtonStructure.Insert("ActionBody", ButtonText); + ButtonStructure.Insert("Text" , ButtonText); + ButtonStructure.Insert("BgColor" , ButtonColor); + ButtonStructure.Insert("Coloumns" , 3); + + ArrayOfButtonStructures.Add(ButtonStructure); + + EndDo; + + KeyboardStructure.Insert("Buttons", ArrayOfButtonStructures); + KeyboardStructure.Insert("Type" , "keyboard"); + + Return KeyboardStructure; + EndFunction #EndRegion @@ -312,7 +312,7 @@ EndFunction #Region ServiceProceduresAndFunctions // Send message. -// +// // Parameters: // Token - String - Token // Type - String - TypeOfSentMessage @@ -323,92 +323,92 @@ EndFunction // * Size - Number, String - File size in case of sending // * Extension - String - File extension in case of sending // Text - String - Message text -// Keyboard - Structure Of String - Keyboard, if needed, see CreateKeyboardFromArrayButton -// +// Keyboard - Structure Of String - Keyboard, if needed, see CreateKeyboardFromArrayButton +// // Return value: // Arbitrary, HTTP Response - Send message Function SendMessage(Val Token -, Val Type -, Val UserID -, Val IsChannel -, Val Value = "" -, Val Text = "" -, Val Keyboard = "") - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Type); -OPI_TypeConversion.GetLine(UserID); -OPI_TypeConversion.GetLine(Text); -OPI_TypeConversion.GetBoolean(IsChannel); -OPI_TypeConversion.GetCollection(Keyboard); - -ParametersStructure = ReturnStandardParameters(); -ParametersStructure.Insert("type", Type); - -If (Type = "text" Or Type = "picture") And ValueIsFilled(Text) Then -ParametersStructure.Insert("text", Text); -EndIf; - -If TypeValue(Keyboard) = Type("Structure") Then -ParametersStructure.Insert("keyboard", Keyboard); -EndIf; - -If ValueIsFilled(Value) Then - -If Type = "file" Then -ParametersStructure.Insert("media" , Value["URL"]); -ParametersStructure.Insert("size" , Value["Size"]); -ParametersStructure.Insert("file_name", "File." + Value["Extension"]); -ElsIf Type = "contact" Then -ParametersStructure.Insert("contact" , Value); -ElsIf Type = "location" Then -ParametersStructure.Insert("location" , Value); -Else -ParametersStructure.Insert("media" , Value); -EndIf; - -EndIf; - -If IsChannel Then -ParametersStructure.Insert("from", UserID); -URL = "https://chatapi.viber.com/pa/post"; -Else -ParametersStructure.Insert("receiver", UserID); -URL = "https://chatapi.viber.com/pa/send_message"; -EndIf; - -Response = OPI_Tools.Post(URL, ParametersStructure, TokenInHeaders(Token)); - -Try -Return OPI_Tools.JsonToStructure(Response.GetBodyAsBinaryData()); -Except -Return Response; -EndTry; - + , Val Type + , Val UserID + , Val IsChannel + , Val Value = "" + , Val Text = "" + , Val Keyboard = "") + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Type); + OPI_TypeConversion.GetLine(UserID); + OPI_TypeConversion.GetLine(Text); + OPI_TypeConversion.GetBoolean(IsChannel); + OPI_TypeConversion.GetCollection(Keyboard); + + ParametersStructure = ReturnStandardParameters(); + ParametersStructure.Insert("type", Type); + + If (Type = "text" Or Type = "picture") And ValueIsFilled(Text) Then + ParametersStructure.Insert("text", Text); + EndIf; + + If TypeValue(Keyboard) = Type("Structure") Then + ParametersStructure.Insert("keyboard", Keyboard); + EndIf; + + If ValueIsFilled(Value) Then + + If Type = "file" Then + ParametersStructure.Insert("media" , Value["URL"]); + ParametersStructure.Insert("size" , Value["Size"]); + ParametersStructure.Insert("file_name", "File." + Value["Extension"]); + ElsIf Type = "contact" Then + ParametersStructure.Insert("contact" , Value); + ElsIf Type = "location" Then + ParametersStructure.Insert("location" , Value); + Else + ParametersStructure.Insert("media" , Value); + EndIf; + + EndIf; + + If IsChannel Then + ParametersStructure.Insert("from", UserID); + URL = "https://chatapi.viber.com/pa/post"; + Else + ParametersStructure.Insert("receiver", UserID); + URL = "https://chatapi.viber.com/pa/send_message"; + EndIf; + + Response = OPI_Tools.Post(URL, ParametersStructure, TokenInHeaders(Token)); + + Try + Return OPI_Tools.JsonToStructure(Response.GetBodyAsBinaryData()); + Except + Return Response; + EndTry; + EndFunction -Function ReturnStandardParameters() - -SenderStructure = New Structure; -SenderStructure.Insert("name" , "Bot"); -SenderStructure.Insert("avatar", ""); - -ParametersStructure = New Structure; -ParametersStructure.Insert("sender", SenderStructure); -ParametersStructure.Insert("min_api_version", 1); - -Return ParametersStructure; - +Function ReturnStandardParameters() + + SenderStructure = New Structure; + SenderStructure.Insert("name" , "Bot"); + SenderStructure.Insert("avatar", ""); + + ParametersStructure = New Structure; + ParametersStructure.Insert("sender", SenderStructure); + ParametersStructure.Insert("min_api_version", 1); + + Return ParametersStructure; + EndFunction Function TokenInHeaders(Val Token) - -OPI_TypeConversion.GetLine(Token); - -HeadersStructure = New Match; -HeadersStructure.Insert("X-Viber-Auth-Token", Token); -Return HeadersStructure; - + + OPI_TypeConversion.GetLine(Token); + + HeadersStructure = New Match; + HeadersStructure.Insert("X-Viber-Auth-Token", Token); + Return HeadersStructure; + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_Viber/OPI_Viber.mdo b/src/en/OPI/src/CommonModules/OPI_Viber/OPI_Viber.mdo index 7f26465e4c..ec0d881730 100644 --- a/src/en/OPI/src/CommonModules/OPI_Viber/OPI_Viber.mdo +++ b/src/en/OPI/src/CommonModules/OPI_Viber/OPI_Viber.mdo @@ -1,11 +1,11 @@  -OPI_Viber - -ru -Methodы интеграции with Viber (OPI) - -true -true -true + OPI_Viber + + ru + Methodы интеграции with Viber (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_YandexDisk/Module.bsl b/src/en/OPI/src/CommonModules/OPI_YandexDisk/Module.bsl index b3e38b49fa..cdca8192e8 100644 --- a/src/en/OPI/src/CommonModules/OPI_YandexDisk/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_YandexDisk/Module.bsl @@ -34,7 +34,7 @@ //@skip-check method-too-many-params // Uncomment if OneScript is executed -// #Use "../../tools" +// #Use "../../tools" #Region ProgrammingInterface @@ -42,367 +42,367 @@ // Get disk information // Gets information about the current disk -// +// // Parameters: // Token - String - Token - token -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetDiskInformation(Val Token) Export - -OPI_TypeConversion.GetLine(Token); - -Headers = AuthorizationHeader(Token); -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk", , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + + Headers = AuthorizationHeader(Token); + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk", , Headers); + + Return Response; + EndFunction // Create folder // Creates a directory on the disk -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the created folder - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function CreateFolder(Val Token, Val Path) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Path); - -Headers = AuthorizationHeader(Token); -URL = "https://cloud-api.yandex.net/v1/disk/resources"; -Href = "href"; - -Parameters = New Structure; -Parameters.Insert("path", Path); - -Parameters = OPI_Tools.RequestParametersToString(Parameters); -Response = OPI_Tools.Put(URL + Parameters, , Headers, False); - -ResponseURL = Response[Href]; - -If Not ValueIsFilled(ResponseURL) Then -Return Response; -EndIf; - -Response = OPI_Tools.Get(ResponseURL, , Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Path); + + Headers = AuthorizationHeader(Token); + URL = "https://cloud-api.yandex.net/v1/disk/resources"; + Href = "href"; + + Parameters = New Structure; + Parameters.Insert("path", Path); + + Parameters = OPI_Tools.RequestParametersToString(Parameters); + Response = OPI_Tools.Put(URL + Parameters, , Headers, False); + + ResponseURL = Response[Href]; + + If Not ValueIsFilled(ResponseURL) Then + Return Response; + EndIf; + + Response = OPI_Tools.Get(ResponseURL, , Headers); + + Return Response; EndFunction // Get object // Gets information about a disk object at the specified path -// +// // Parameters: // Token - String - Token - token // Path - String - Path to folder or file - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetObject(Val Token, Val Path) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Path); - -Headers = AuthorizationHeader(Token); -Parameters = New Structure; -Parameters.Insert("path", Path); - -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources", Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Path); + + Headers = AuthorizationHeader(Token); + Parameters = New Structure; + Parameters.Insert("path", Path); + + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources", Parameters, Headers); + + Return Response; EndFunction // Delete object // Deletes an object at the specified path -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the folder or file to be deleted - path // ToCart - Boolean - To cart - can -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function DeleteObject(Val Token, Val Path, Val ToCart = True) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Path); -OPI_TypeConversion.GetBoolean(ToCart); - -Headers = AuthorizationHeader(Token); - -Parameters = New Structure; -Parameters.Insert("path" , Path); -Parameters.Insert("permanently", Not ToCart); - -Response = OPI_Tools.Delete("https://cloud-api.yandex.net/v1/disk/resources", Parameters, Headers); - -Return Response; + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Path); + OPI_TypeConversion.GetBoolean(ToCart); + + Headers = AuthorizationHeader(Token); + + Parameters = New Structure; + Parameters.Insert("path" , Path); + Parameters.Insert("permanently", Not ToCart); + + Response = OPI_Tools.Delete("https://cloud-api.yandex.net/v1/disk/resources", Parameters, Headers); + + Return Response; EndFunction // Create object copy // Creates a copy of the object at the specified path and path to the original -// +// // Parameters: // Token - String - Token - token // Original - String - Path to the original file or directory - from // Path - String - Destination path for the copy - to // Overwrite - Boolean - Overwrite if a file with the same name already exists - rewrite -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function CreateObjectCopy(Val Token, Val Original, Val Path, Val Overwrite = False) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Original); -OPI_TypeConversion.GetLine(Path); -OPI_TypeConversion.GetBoolean(Overwrite); - -Headers = AuthorizationHeader(Token); -URL = "https://cloud-api.yandex.net/v1/disk/resources/copy"; -Href = "href"; - -Parameters = New Structure; -Parameters.Insert("from" , Original); -Parameters.Insert("path" , Path); -Parameters.Insert("overwrite" , Overwrite); - -Parameters = OPI_Tools.RequestParametersToString(Parameters); -Response = OPI_Tools.Post(URL + Parameters, , Headers, False); - -ResponseURL = Response[Href]; - -If Not ValueIsFilled(ResponseURL) Then -Return Response; -EndIf; - -Response = OPI_Tools.Get(ResponseURL, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Original); + OPI_TypeConversion.GetLine(Path); + OPI_TypeConversion.GetBoolean(Overwrite); + + Headers = AuthorizationHeader(Token); + URL = "https://cloud-api.yandex.net/v1/disk/resources/copy"; + Href = "href"; + + Parameters = New Structure; + Parameters.Insert("from" , Original); + Parameters.Insert("path" , Path); + Parameters.Insert("overwrite" , Overwrite); + + Parameters = OPI_Tools.RequestParametersToString(Parameters); + Response = OPI_Tools.Post(URL + Parameters, , Headers, False); + + ResponseURL = Response[Href]; + + If Not ValueIsFilled(ResponseURL) Then + Return Response; + EndIf; + + Response = OPI_Tools.Get(ResponseURL, , Headers); + + Return Response; + EndFunction // Get download link // Gets a download link for the file -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the file for downloading - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetDownloadLink(Val Token, Val Path) Export -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Path); - -Headers = AuthorizationHeader(Token); - -Parameters = New Structure; -Parameters.Insert("path", Path); - -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/download", Parameters, Headers); - -Return Response; - + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Path); + + Headers = AuthorizationHeader(Token); + + Parameters = New Structure; + Parameters.Insert("path", Path); + + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/download", Parameters, Headers); + + Return Response; + EndFunction // Download file // Downloads a file at the specified path -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the file for downloading - path -// SavePath - String - File save path - out -// +// SavePath - String - File save path - out +// // Return value: // BinaryData,String - Binary data or file path when SavePath parameter is specified Function DownloadFile(Val Token, Val Path, Val SavePath = "") Export - -OPI_TypeConversion.GetLine(SavePath); -Response = GetDownloadLink(Token, Path); -URL = Response["href"]; - -If Not ValueIsFilled(URL) Then -Return Response; -EndIf; - -Response = OPI_Tools.Get(URL, , , SavePath); - -Return Response; - + + OPI_TypeConversion.GetLine(SavePath); + Response = GetDownloadLink(Token, Path); + URL = Response["href"]; + + If Not ValueIsFilled(URL) Then + Return Response; + EndIf; + + Response = OPI_Tools.Get(URL, , , SavePath); + + Return Response; + EndFunction // Get list of files // Gets a list of files with or without filtering by type -// List available typeоin: audio, backup, book, compressed, data, development, -// diskimage, document, encoded, executable, flash, font, +// List available typeоin: audio, backup, book, compressed, data, development, +// diskimage, document, encoded, executable, flash, font, // mage, settings, spreadsheet, text, unknown, video, web -// +// // Parameters: // Token - String - Token - token // Quantity - Number, String - Number of returned objects - amount // OffsetFromStart - Number - Offset for getting objects not from the beginning of the list - offset // FilterByType - String - Filter by file type - type // SortByDate - Boolean - True > sort by date, False > alphabetically - datesort -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetFilesList(Val Token -, Val Quantity = 0 -, Val OffsetFromStart = 0 -, Val FilterByType = "" -, Val SortByDate = False) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Quantity); -OPI_TypeConversion.GetLine(OffsetFromStart); -OPI_TypeConversion.GetLine(FilterByType); -OPI_TypeConversion.GetBoolean(SortByDate); - -Headers = AuthorizationHeader(Token); - -Parameters = New Structure; - -If ValueIsFilled(Quantity) Then -Parameters.Insert("limit", OPI_Tools.NumberToString(Quantity)); -EndIf; - -If ValueIsFilled(OffsetFromStart) Then -Parameters.Insert("offset", OPI_Tools.NumberToString(OffsetFromStart)); -EndIf; - -If ValueIsFilled(FilterByType) Then -Parameters.Insert("media_type", FilterByType); -EndIf; - -If SortByDate Then -Destination = "last-uploaded"; -Else -Destination = "files"; -EndIf; - -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/" + Destination, Parameters, Headers); - -Return Response; - + , Val Quantity = 0 + , Val OffsetFromStart = 0 + , Val FilterByType = "" + , Val SortByDate = False) Export + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Quantity); + OPI_TypeConversion.GetLine(OffsetFromStart); + OPI_TypeConversion.GetLine(FilterByType); + OPI_TypeConversion.GetBoolean(SortByDate); + + Headers = AuthorizationHeader(Token); + + Parameters = New Structure; + + If ValueIsFilled(Quantity) Then + Parameters.Insert("limit", OPI_Tools.NumberToString(Quantity)); + EndIf; + + If ValueIsFilled(OffsetFromStart) Then + Parameters.Insert("offset", OPI_Tools.NumberToString(OffsetFromStart)); + EndIf; + + If ValueIsFilled(FilterByType) Then + Parameters.Insert("media_type", FilterByType); + EndIf; + + If SortByDate Then + Destination = "last-uploaded"; + Else + Destination = "files"; + EndIf; + + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/" + Destination, Parameters, Headers); + + Return Response; + EndFunction // Move object // Moves the object to the specified path and path to the original -// +// // Parameters: // Token - String - Token - token // Original - String - Path to the original file or folder - from // Path - String - Destination path for moving - to // Overwrite - Boolean - Overwrite if a file with the same name already exists - rewrite -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function MoveObject(Val Token, Val Original, Val Path, Val Overwrite = False) Export -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Original); -OPI_TypeConversion.GetLine(Path); -OPI_TypeConversion.GetBoolean(Overwrite); - -Headers = AuthorizationHeader(Token); -URL = "https://cloud-api.yandex.net/v1/disk/resources/move"; -Href = "href"; - -Parameters = New Structure; -Parameters.Insert("from" , Original); -Parameters.Insert("path" , Path); -Parameters.Insert("overwrite" , Overwrite); - -Parameters = OPI_Tools.RequestParametersToString(Parameters); -Response = OPI_Tools.Post(URL + Parameters, , Headers, False); -ResponseURL = Response[Href]; - -If Not ValueIsFilled(ResponseURL) Then -Return Response; -EndIf; - -Response = OPI_Tools.Get(ResponseURL, , Headers); - -Return Response; - + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Original); + OPI_TypeConversion.GetLine(Path); + OPI_TypeConversion.GetBoolean(Overwrite); + + Headers = AuthorizationHeader(Token); + URL = "https://cloud-api.yandex.net/v1/disk/resources/move"; + Href = "href"; + + Parameters = New Structure; + Parameters.Insert("from" , Original); + Parameters.Insert("path" , Path); + Parameters.Insert("overwrite" , Overwrite); + + Parameters = OPI_Tools.RequestParametersToString(Parameters); + Response = OPI_Tools.Post(URL + Parameters, , Headers, False); + ResponseURL = Response[Href]; + + If Not ValueIsFilled(ResponseURL) Then + Return Response; + EndIf; + + Response = OPI_Tools.Get(ResponseURL, , Headers); + + Return Response; + EndFunction // Upload file // Uploads a file to disk at the specified path -// +// // Parameters: // Token - String - Token - token // Path - String - Path for saving the file to disk - path // File - String, BinaryData - File for upload - file // Overwrite - Boolean - Overwrite if a file with the same name already exists - rewrite -// +// // Return value: -// Key-Value Pair - serialized JSON response from Yandex +// Key-Value Pair - serialized JSON response from Yandex Function UploadFile(Val Token, Val Path, Val File, Val Overwrite = False) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Path); -OPI_TypeConversion.GetBoolean(Overwrite); -OPI_TypeConversion.GetBinaryData(File); - -Headers = AuthorizationHeader(Token); -Href = "href"; -File = New Structure("file", File); - -Parameters = New Structure; -Parameters.Insert("path" , Path); -Parameters.Insert("overwrite" , Overwrite); - -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/upload", Parameters, Headers); -URL = Response[Href]; - -If Not ValueIsFilled(URL) Then -Return Response; -EndIf; - -Response = OPI_Tools.PutMultipart(URL, New Structure(), File, "multipart", Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Path); + OPI_TypeConversion.GetBoolean(Overwrite); + OPI_TypeConversion.GetBinaryData(File); + + Headers = AuthorizationHeader(Token); + Href = "href"; + File = New Structure("file", File); + + Parameters = New Structure; + Parameters.Insert("path" , Path); + Parameters.Insert("overwrite" , Overwrite); + + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/upload", Parameters, Headers); + URL = Response[Href]; + + If Not ValueIsFilled(URL) Then + Return Response; + EndIf; + + Response = OPI_Tools.PutMultipart(URL, New Structure(), File, "multipart", Headers); + + Return Response; + EndFunction // Upload file by URL // Downloads a file to disk from the specified URL -// +// // Parameters: // Token - String - Token - token // Path - String - Path to place the downloaded file - path // Address - String - File URL - url -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function UploadFileByURL(Val Token, Val Path, Val Address) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Path); -OPI_TypeConversion.GetLine(Address); - -Headers = AuthorizationHeader(Token); -URL = "https://cloud-api.yandex.net/v1/disk/resources/upload"; - -Parameters = New Structure; -Parameters.Insert("url" , EncodeString(Address, StringEncodingMethod.URLInURLEncoding)); -Parameters.Insert("path", Path); - -Parameters = OPI_Tools.RequestParametersToString(Parameters); -Response = OPI_Tools.Post(URL + Parameters, , Headers, False); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Path); + OPI_TypeConversion.GetLine(Address); + + Headers = AuthorizationHeader(Token); + URL = "https://cloud-api.yandex.net/v1/disk/resources/upload"; + + Parameters = New Structure; + Parameters.Insert("url" , EncodeString(Address, StringEncodingMethod.URLInURLEncoding)); + Parameters.Insert("path", Path); + + Parameters = OPI_Tools.RequestParametersToString(Parameters); + Response = OPI_Tools.Post(URL + Parameters, , Headers, False); + + Return Response; + EndFunction #EndRegion @@ -411,182 +411,182 @@ EndFunction // Publish object // Publishes the disk object for public access -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the object to be published - path -// +// // Return value: -// Key-Value Pair - serialized JSON response from Yandex +// Key-Value Pair - serialized JSON response from Yandex Function PublishObject(Val Token, Val Path) Export -Return TogglePublicAccess(Token, Path, True); + Return TogglePublicAccess(Token, Path, True); EndFunction // Unpublish object // Unpublishes a previously published object -// +// // Parameters: // Token - String - Token - token // Path - String - Path to the previously published object - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function CancelObjectPublication(Val Token, Val Path) Export -Return TogglePublicAccess(Token, Path, False); + Return TogglePublicAccess(Token, Path, False); EndFunction // Get published list объеtoтоin. // Gets a list of published objects -// +// // Parameters: -// Token - String - Token - token +// Token - String - Token - token // Quantity - Number - Number of returned objects - amount // OffsetFromStart - Number - Offset for getting objects not from the beginning of the list - offset -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetPublishedObjectsList(Val Token, Val Quantity = 0, Val OffsetFromStart = 0) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Quantity); -OPI_TypeConversion.GetLine(OffsetFromStart); - -Headers = AuthorizationHeader(Token); - -Parameters = New Structure; - -If ValueIsFilled(Quantity) Then -Parameters.Insert("limit", Quantity); -EndIf; - -If ValueIsFilled(OffsetFromStart) Then -Parameters.Insert("offset", OffsetFromStart); -EndIf; - -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/public", Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Quantity); + OPI_TypeConversion.GetLine(OffsetFromStart); + + Headers = AuthorizationHeader(Token); + + Parameters = New Structure; + + If ValueIsFilled(Quantity) Then + Parameters.Insert("limit", Quantity); + EndIf; + + If ValueIsFilled(OffsetFromStart) Then + Parameters.Insert("offset", OffsetFromStart); + EndIf; + + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/resources/public", Parameters, Headers); + + Return Response; + EndFunction // Get public object // Gets information about the published object by its URL -// +// // Parameters: // Token - String - Token - token -// URL - String - Object address - url +// URL - String - Object address - url // Quantity - Number - Quantity inозinращаемых inложенных объеtoтоin (for directory) - amount // OffsetFromStart - Number - Offset for getting nested objects not from the beginning of the list - offset -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetPublicObject(Val Token, Val URL, Val Quantity = 0, Val OffsetFromStart = 0) Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(URL); -OPI_TypeConversion.GetLine(Quantity); -OPI_TypeConversion.GetLine(OffsetFromStart); - -Headers = AuthorizationHeader(Token); - -Parameters = New Structure; - -If ValueIsFilled(Quantity) Then -Parameters.Insert("limit", OPI_Tools.NumberToString(Quantity)); -EndIf; - -If ValueIsFilled(OffsetFromStart) Then -Parameters.Insert("offset", OPI_Tools.NumberToString(OffsetFromStart)); -EndIf; - -Parameters.Insert("public_key", URL); - -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/public/resources", Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(URL); + OPI_TypeConversion.GetLine(Quantity); + OPI_TypeConversion.GetLine(OffsetFromStart); + + Headers = AuthorizationHeader(Token); + + Parameters = New Structure; + + If ValueIsFilled(Quantity) Then + Parameters.Insert("limit", OPI_Tools.NumberToString(Quantity)); + EndIf; + + If ValueIsFilled(OffsetFromStart) Then + Parameters.Insert("offset", OPI_Tools.NumberToString(OffsetFromStart)); + EndIf; + + Parameters.Insert("public_key", URL); + + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/public/resources", Parameters, Headers); + + Return Response; + EndFunction // Get download link for public object // Gets a direct link to download the public object -// +// // Parameters: // Token - String - Token - token // URL - String - Object address - url // Path - String - Path inside the object - path -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetDownloadLinkForPublicObject(Val Token, Val URL, Val Path = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(URL); -OPI_TypeConversion.GetLine(Path); - -Headers = AuthorizationHeader(Token); - -Parameters = New Structure; - -If ValueIsFilled(Path) Then -Parameters.Insert("path", Path); -EndIf; - -Parameters.Insert("public_key", URL); - -Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/public/resources/download", Parameters, Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(URL); + OPI_TypeConversion.GetLine(Path); + + Headers = AuthorizationHeader(Token); + + Parameters = New Structure; + + If ValueIsFilled(Path) Then + Parameters.Insert("path", Path); + EndIf; + + Parameters.Insert("public_key", URL); + + Response = OPI_Tools.Get("https://cloud-api.yandex.net/v1/disk/public/resources/download", Parameters, Headers); + + Return Response; + EndFunction - + // Save public object to disk // Saves the public object to your disk -// +// // Parameters: // Token - String - Token - token // URL - String - Object address - url // From - String - Path inнутри публичного directory (тольtoо for папоto) - from // To - String - File save path - to -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function SavePublicObjectToDisk(Val Token, Val URL, From = "", To = "") Export - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(URL); -OPI_TypeConversion.GetLine(From); -OPI_TypeConversion.GetLine(To); - -Headers = AuthorizationHeader(Token); -Address = "https://cloud-api.yandex.net/v1/disk/public/resources/save-to-disk"; -Href = "href"; - -Parameters = New Structure; -Parameters.Insert("public_key", URL); - -If ValueIsFilled(From) Then -Parameters.Insert("path", From); -EndIf; - -If ValueIsFilled(To) Then -Parameters.Insert("save_path", To); -EndIf; - -Parameters = OPI_Tools.RequestParametersToString(Parameters); -Response = OPI_Tools.Post(Address + Parameters, , Headers, False); - -ResponseURL = Response[Href]; - -If Not ValueIsFilled(ResponseURL) Then -Return Response; -EndIf; - -Response = OPI_Tools.Get(ResponseURL, , Headers); - -Return Response; - + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(URL); + OPI_TypeConversion.GetLine(From); + OPI_TypeConversion.GetLine(To); + + Headers = AuthorizationHeader(Token); + Address = "https://cloud-api.yandex.net/v1/disk/public/resources/save-to-disk"; + Href = "href"; + + Parameters = New Structure; + Parameters.Insert("public_key", URL); + + If ValueIsFilled(From) Then + Parameters.Insert("path", From); + EndIf; + + If ValueIsFilled(To) Then + Parameters.Insert("save_path", To); + EndIf; + + Parameters = OPI_Tools.RequestParametersToString(Parameters); + Response = OPI_Tools.Post(Address + Parameters, , Headers, False); + + ResponseURL = Response[Href]; + + If Not ValueIsFilled(ResponseURL) Then + Return Response; + EndIf; + + Response = OPI_Tools.Get(ResponseURL, , Headers); + + Return Response; + EndFunction - + #EndRegion #EndRegion @@ -594,42 +594,42 @@ EndFunction #Region ServiceProceduresAndFunctions Function AuthorizationHeader(Val Token) - -Headers = New Match; -Headers.Insert("Authorization", "OAuth " + Token); - -Return Headers; - + + Headers = New Match; + Headers.Insert("Authorization", "OAuth " + Token); + + Return Headers; + EndFunction -Function TogglePublicAccess(Val Token, Val Path, Val PublicAccess) - -OPI_TypeConversion.GetLine(Token); -OPI_TypeConversion.GetLine(Path); -OPI_TypeConversion.GetBoolean(PublicAccess); - -Headers = AuthorizationHeader(Token); -Destination = ?(PublicAccess, "publish", "unpublish"); -Href = "href"; - -URL = "https://cloud-api.yandex.net/v1/disk/resources/" + Destination; - -Parameters = New Structure; -Parameters.Insert("path", Path); - -Parameters = OPI_Tools.RequestParametersToString(Parameters); -Response = OPI_Tools.Put(URL + Parameters, , Headers, False); - -ResponseURL = Response[Href]; - -If Not ValueIsFilled(ResponseURL) Then -Return Response; -EndIf; - -Response = OPI_Tools.Get(ResponseURL, , Headers); - -Return Response; - +Function TogglePublicAccess(Val Token, Val Path, Val PublicAccess) + + OPI_TypeConversion.GetLine(Token); + OPI_TypeConversion.GetLine(Path); + OPI_TypeConversion.GetBoolean(PublicAccess); + + Headers = AuthorizationHeader(Token); + Destination = ?(PublicAccess, "publish", "unpublish"); + Href = "href"; + + URL = "https://cloud-api.yandex.net/v1/disk/resources/" + Destination; + + Parameters = New Structure; + Parameters.Insert("path", Path); + + Parameters = OPI_Tools.RequestParametersToString(Parameters); + Response = OPI_Tools.Put(URL + Parameters, , Headers, False); + + ResponseURL = Response[Href]; + + If Not ValueIsFilled(ResponseURL) Then + Return Response; + EndIf; + + Response = OPI_Tools.Get(ResponseURL, , Headers); + + Return Response; + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_YandexDisk/OPI_YandexDisk.mdo b/src/en/OPI/src/CommonModules/OPI_YandexDisk/OPI_YandexDisk.mdo index 9b087975fb..08aea07cf7 100644 --- a/src/en/OPI/src/CommonModules/OPI_YandexDisk/OPI_YandexDisk.mdo +++ b/src/en/OPI/src/CommonModules/OPI_YandexDisk/OPI_YandexDisk.mdo @@ -1,11 +1,11 @@  -OPI_YandexDisk - -ru -Methodы work with Yandex Disk (OPI) - -true -true -true + OPI_YandexDisk + + ru + Methodы work with Yandex Disk (OPI) + + true + true + true diff --git a/src/en/OPI/src/CommonModules/OPI_YandexID/Module.bsl b/src/en/OPI/src/CommonModules/OPI_YandexID/Module.bsl index 0ba3454fc0..484332943f 100644 --- a/src/en/OPI/src/CommonModules/OPI_YandexID/Module.bsl +++ b/src/en/OPI/src/CommonModules/OPI_YandexID/Module.bsl @@ -36,77 +36,77 @@ // Get confirmation code // Gets the confirmation code and the address of the page where it needs to be entered -// +// // Parameters: // ClientId - String - Client id - id -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function GetConfirmationCode(Val ClientId) Export -OPI_TypeConversion.GetLine(ClientId); - -Parameters = New Structure("client_id", ClientId); -Response = OPI_Tools.Post("https://oauth.yandex.ru/device/code", Parameters, , False); - -Return Response; - + OPI_TypeConversion.GetLine(ClientId); + + Parameters = New Structure("client_id", ClientId); + Response = OPI_Tools.Post("https://oauth.yandex.ru/device/code", Parameters, , False); + + Return Response; + EndFunction // Convert code to token // Converts the code to a token after entering the code when executing GetConfirmationCode -// +// // Parameters: // ClientId - String - Client id - id // ClientSecret - String - Client secret - secret // DeviceCode - String - device_code from GetConfirmationCode() - device -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function ConvertCodeToToken(Val ClientId, Val ClientSecret, Val DeviceCode) Export - -OPI_TypeConversion.GetLine(ClientId); -OPI_TypeConversion.GetLine(ClientSecret); -OPI_TypeConversion.GetLine(DeviceCode); - -Parameters = New Structure; -Parameters.Insert("grant_type" , "device_code"); -Parameters.Insert("code" , DeviceCode); -Parameters.Insert("client_id" , ClientId); -Parameters.Insert("client_secret" , ClientSecret); - -Response = OPI_Tools.Post("https://oauth.yandex.ru/token", Parameters, , False); - -Return Response; - + + OPI_TypeConversion.GetLine(ClientId); + OPI_TypeConversion.GetLine(ClientSecret); + OPI_TypeConversion.GetLine(DeviceCode); + + Parameters = New Structure; + Parameters.Insert("grant_type" , "device_code"); + Parameters.Insert("code" , DeviceCode); + Parameters.Insert("client_id" , ClientId); + Parameters.Insert("client_secret" , ClientSecret); + + Response = OPI_Tools.Post("https://oauth.yandex.ru/token", Parameters, , False); + + Return Response; + EndFunction // Refresh token // Updates token by Refresh token -// +// // Parameters: // ClientId - String - Client id - id // ClientSecret - String - Client secret - secret // RefreshToken - String - Refresh token - refresh -// +// // Return value: // Key-Value Pair - serialized JSON response from Yandex Function RefreshToken(Val ClientId, Val ClientSecret, Val RefreshToken) Export - -OPI_TypeConversion.GetLine(ClientId); -OPI_TypeConversion.GetLine(ClientSecret); -OPI_TypeConversion.GetLine(RefreshToken); - -Parameters = New Structure; -Parameters.Insert("grant_type" , "refresh_token"); -Parameters.Insert("refresh_token" , RefreshToken); -Parameters.Insert("client_id" , ClientId); -Parameters.Insert("client_secret" , ClientSecret); - -Response = OPI_Tools.Post("https://oauth.yandex.ru/token", Parameters, , False); - -Return Response; - + + OPI_TypeConversion.GetLine(ClientId); + OPI_TypeConversion.GetLine(ClientSecret); + OPI_TypeConversion.GetLine(RefreshToken); + + Parameters = New Structure; + Parameters.Insert("grant_type" , "refresh_token"); + Parameters.Insert("refresh_token" , RefreshToken); + Parameters.Insert("client_id" , ClientId); + Parameters.Insert("client_secret" , ClientSecret); + + Response = OPI_Tools.Post("https://oauth.yandex.ru/token", Parameters, , False); + + Return Response; + EndFunction #EndRegion diff --git a/src/en/OPI/src/CommonModules/OPI_YandexID/OPI_YandexID.mdo b/src/en/OPI/src/CommonModules/OPI_YandexID/OPI_YandexID.mdo index c3df5601df..6329dbbaf4 100644 --- a/src/en/OPI/src/CommonModules/OPI_YandexID/OPI_YandexID.mdo +++ b/src/en/OPI/src/CommonModules/OPI_YandexID/OPI_YandexID.mdo @@ -1,11 +1,11 @@  -OPI_YandexID - -ru -Methodы work with Yandex ID (OPI) - -true -true -true + OPI_YandexID + + ru + Methodы work with Yandex ID (OPI) + + true + true + true diff --git a/src/en/OPI/src/Configuration/Configuration.mdo b/src/en/OPI/src/Configuration/Configuration.mdo index 3b72a6160b..ff9dd10b11 100644 --- a/src/en/OPI/src/Configuration/Configuration.mdo +++ b/src/en/OPI/src/Configuration/Configuration.mdo @@ -1,70 +1,70 @@  -OpenIntegrations - -ru -Open integrations package - -Adopted - -Checked -Checked -Checked - - - - - - - - -true -OPI_ -8.3.9 -Customization -ManagedApplication -PersonalComputer -Russian -Bayselonarrend -1.9.0 - -ru -Open integrations package - toбор библиотеto for интеграции with неtoоторыми популярными API for 1C:Enterprise. He consists of general modules, each responsible for its own API, as well as several tool modules common for all. - - -ru -https://github.com/Bayselonarrend - - -ru -https://github.com/Bayselonarrend/OpenIntegrations - - -Russian -Adopted - -Checked - -ru - -Subsystem.OPI_Integrations -CommonModule.OPI_Tools -CommonModule.OPI_Cryptography -CommonModule.OPI_TypeConversion -CommonModule.OPI_Telegram -CommonModule.OPI_VK -CommonModule.OPI_Viber -CommonModule.OPI_Twitter -CommonModule.OPI_Notion -CommonModule.OPI_YandexID -CommonModule.OPI_YandexDisk -CommonModule.OPI_GoogleWorkspace -CommonModule.OPI_GoogleCalendar -CommonModule.OPI_GoogleDrive -CommonModule.OPI_GoogleSheets -CommonModule.OPI_Slack -CommonModule.OPI_Airtable -CommonModule.OPI_Dropbox -CommonModule.OPI_Tests -CommonModule.OPI_TestDataRetrieval + OpenIntegrations + + ru + Open integrations package + + Adopted + + Checked + Checked + Checked + + + + + + + + + true + OPI_ + 8.3.9 + Customization + ManagedApplication + PersonalComputer + Russian + Bayselonarrend + 1.9.0 + + ru + Open integrations package - toбор библиотеto for интеграции with неtoоторыми популярными API for 1C:Enterprise. He consists of general modules, each responsible for its own API, as well as several tool modules common for all. + + + ru + https://github.com/Bayselonarrend + + + ru + https://github.com/Bayselonarrend/OpenIntegrations + + + Russian + Adopted + + Checked + + ru + + Subsystem.OPI_Integrations + CommonModule.OPI_Tools + CommonModule.OPI_Cryptography + CommonModule.OPI_TypeConversion + CommonModule.OPI_Telegram + CommonModule.OPI_VK + CommonModule.OPI_Viber + CommonModule.OPI_Twitter + CommonModule.OPI_Notion + CommonModule.OPI_YandexID + CommonModule.OPI_YandexDisk + CommonModule.OPI_GoogleWorkspace + CommonModule.OPI_GoogleCalendar + CommonModule.OPI_GoogleDrive + CommonModule.OPI_GoogleSheets + CommonModule.OPI_Slack + CommonModule.OPI_Airtable + CommonModule.OPI_Dropbox + CommonModule.OPI_Tests + CommonModule.OPI_TestDataRetrieval diff --git a/src/en/OPI/src/Subsystems/OPI_Integrations/OPI_Integrations.mdo b/src/en/OPI/src/Subsystems/OPI_Integrations/OPI_Integrations.mdo index 8d6a631a97..75a848be36 100644 --- a/src/en/OPI/src/Subsystems/OPI_Integrations/OPI_Integrations.mdo +++ b/src/en/OPI/src/Subsystems/OPI_Integrations/OPI_Integrations.mdo @@ -1,28 +1,28 @@  -OPI_Integrations - -ru -Integrations - -true -true -CommonModule.OPI_Tools -CommonModule.OPI_Cryptography -CommonModule.OPI_TypeConversion -CommonModule.OPI_VK -CommonModule.OPI_Telegram -CommonModule.OPI_Viber -CommonModule.OPI_Twitter -CommonModule.OPI_Notion -CommonModule.OPI_YandexID -CommonModule.OPI_YandexDisk -CommonModule.OPI_GoogleWorkspace -CommonModule.OPI_GoogleCalendar -CommonModule.OPI_GoogleDrive -CommonModule.OPI_GoogleSheets -CommonModule.OPI_Slack -CommonModule.OPI_Airtable -CommonModule.OPI_Tests -CommonModule.OPI_TestDataRetrieval + OPI_Integrations + + ru + Integrations + + true + true + CommonModule.OPI_Tools + CommonModule.OPI_Cryptography + CommonModule.OPI_TypeConversion + CommonModule.OPI_VK + CommonModule.OPI_Telegram + CommonModule.OPI_Viber + CommonModule.OPI_Twitter + CommonModule.OPI_Notion + CommonModule.OPI_YandexID + CommonModule.OPI_YandexDisk + CommonModule.OPI_GoogleWorkspace + CommonModule.OPI_GoogleCalendar + CommonModule.OPI_GoogleDrive + CommonModule.OPI_GoogleSheets + CommonModule.OPI_Slack + CommonModule.OPI_Airtable + CommonModule.OPI_Tests + CommonModule.OPI_TestDataRetrieval