From d6460243d723376f999e9abad3aa55bbcccace7e Mon Sep 17 00:00:00 2001 From: Pasindu599 Date: Thu, 2 Jan 2025 17:09:10 +0530 Subject: [PATCH 1/2] [Automated] Update the toml files --- ballerina/Dependencies.toml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index ad5efed..76190bf 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -61,7 +61,7 @@ dependencies = [ [[package]] org = "ballerina" name = "http" -version = "2.12.0" +version = "2.12.4" dependencies = [ {org = "ballerina", name = "auth"}, {org = "ballerina", name = "cache"}, @@ -93,7 +93,7 @@ modules = [ [[package]] org = "ballerina" name = "io" -version = "1.6.1" +version = "1.6.3" dependencies = [ {org = "ballerina", name = "jballerina.java"}, {org = "ballerina", name = "lang.value"} @@ -219,7 +219,7 @@ dependencies = [ [[package]] org = "ballerina" name = "mime" -version = "2.10.0" +version = "2.10.1" dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "jballerina.java"}, @@ -286,10 +286,13 @@ modules = [ [[package]] org = "ballerina" name = "time" -version = "2.4.0" +version = "2.5.0" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] +modules = [ + {org = "ballerina", packageName = "time", moduleName = "time"} +] [[package]] org = "ballerina" @@ -323,6 +326,7 @@ dependencies = [ {org = "ballerina", name = "io"}, {org = "ballerina", name = "oauth2"}, {org = "ballerina", name = "test"}, + {org = "ballerina", name = "time"}, {org = "ballerina", name = "url"}, {org = "ballerinai", name = "observe"} ] From 4909cf29dd1255d1d6adc123eb050cdcf3970d83 Mon Sep 17 00:00:00 2001 From: Pasindu599 Date: Fri, 3 Jan 2025 10:17:17 +0530 Subject: [PATCH 2/2] regenerate client --- ballerina/client.bal | 35 +-- ballerina/tests/tests.bal | 445 +++++++++++++++++--------------------- ballerina/types.bal | 26 +-- 3 files changed, 231 insertions(+), 275 deletions(-) diff --git a/ballerina/client.bal b/ballerina/client.bal index 44a83ad..17f7610 100644 --- a/ballerina/client.bal +++ b/ballerina/client.bal @@ -11,7 +11,7 @@ public isolated client class Client { # + config - The configurations to be used when initializing the `connector` # + serviceUrl - URL of the target service # + return - An error if connector initialization failed - public isolated function init(ConnectionConfig config, string serviceUrl = "https://api.hubapi.com") returns error? { + public isolated function init(ConnectionConfig config, string serviceUrl = "https://api.hubapi.com/marketing/v3/forms") returns error? { http:ClientConfiguration httpClientConfig = {httpVersion: config.httpVersion, timeout: config.timeout, forwarded: config.forwarded, poolConfig: config.poolConfig, compression: config.compression, circuitBreaker: config.circuitBreaker, retryConfig: config.retryConfig, validation: config.validation}; do { if config.http1Settings is ClientHttp1Settings { @@ -50,8 +50,8 @@ public isolated client class Client { # + formId - The ID of the form to archive. # + headers - Headers to be sent with the request # + return - No content - resource isolated function delete marketing/v3/forms/[string formId](map headers = {}) returns json|error { - string resourcePath = string `/marketing/v3/forms/${getEncodedUri(formId)}`; + resource isolated function delete [string formId](map headers = {}) returns json|error { + string resourcePath = string `/${getEncodedUri(formId)}`; map headerValues = {...headers}; if self.apiKeyConfig is ApiKeysConfig { headerValues["private-app-legacy"] = self.apiKeyConfig?.private\-app\-legacy; @@ -60,8 +60,13 @@ public isolated client class Client { return self.clientEp->delete(resourcePath, headers = httpHeaders); } - resource isolated function get marketing/v3/forms(map headers = {}, *GetMarketingV3Forms_getpageQueries queries) returns CollectionResponseFormDefinitionBaseForwardPaging|error { - string resourcePath = string `/marketing/v3/forms/`; + # Get a list of forms + # + # + headers - Headers to be sent with the request + # + queries - Queries to be sent with the request + # + return - successful operation + resource isolated function get .(map headers = {}, *GetMarketingV3Forms_getpageQueries queries) returns CollectionResponseFormDefinitionBaseForwardPaging|error { + string resourcePath = string `/`; map headerValues = {...headers}; if self.apiKeyConfig is ApiKeysConfig { headerValues["private-app-legacy"] = self.apiKeyConfig?.private\-app\-legacy; @@ -78,8 +83,8 @@ public isolated client class Client { # + headers - Headers to be sent with the request # + queries - Queries to be sent with the request # + return - successful operation - resource isolated function get marketing/v3/forms/[string formId](map headers = {}, *GetMarketingV3FormsFormid_getbyidQueries queries) returns FormDefinitionBase|error { - string resourcePath = string `/marketing/v3/forms/${getEncodedUri(formId)}`; + resource isolated function get [string formId](map headers = {}, *GetMarketingV3FormsFormid_getbyidQueries queries) returns FormDefinitionBase|error { + string resourcePath = string `/${getEncodedUri(formId)}`; map headerValues = {...headers}; if self.apiKeyConfig is ApiKeysConfig { headerValues["private-app-legacy"] = self.apiKeyConfig?.private\-app\-legacy; @@ -94,8 +99,8 @@ public isolated client class Client { # + formId - The ID of the form to update. # + headers - Headers to be sent with the request # + return - successful operation - resource isolated function patch marketing/v3/forms/[string formId](HubSpotFormDefinitionPatchRequest payload, map headers = {}) returns FormDefinitionBase|error { - string resourcePath = string `/marketing/v3/forms/${getEncodedUri(formId)}`; + resource isolated function patch [string formId](HubSpotFormDefinitionPatchRequest payload, map headers = {}) returns FormDefinitionBase|error { + string resourcePath = string `/${getEncodedUri(formId)}`; map headerValues = {...headers}; if self.apiKeyConfig is ApiKeysConfig { headerValues["private-app-legacy"] = self.apiKeyConfig?.private\-app\-legacy; @@ -107,8 +112,12 @@ public isolated client class Client { return self.clientEp->patch(resourcePath, request, httpHeaders); } - resource isolated function post marketing/v3/forms(FormDefinitionCreateRequestBase payload, map headers = {}) returns FormDefinitionBase|error { - string resourcePath = string `/marketing/v3/forms/`; + # Create a form + # + # + headers - Headers to be sent with the request + # + return - successful operation + resource isolated function post .(FormDefinitionCreateRequestBase payload, map headers = {}) returns FormDefinitionBase|error { + string resourcePath = string `/`; map headerValues = {...headers}; if self.apiKeyConfig is ApiKeysConfig { headerValues["private-app-legacy"] = self.apiKeyConfig?.private\-app\-legacy; @@ -124,8 +133,8 @@ public isolated client class Client { # # + headers - Headers to be sent with the request # + return - successful operation - resource isolated function put marketing/v3/forms/[string formId](HubSpotFormDefinition payload, map headers = {}) returns FormDefinitionBase|error { - string resourcePath = string `/marketing/v3/forms/${getEncodedUri(formId)}`; + resource isolated function put [string formId](HubSpotFormDefinition payload, map headers = {}) returns FormDefinitionBase|error { + string resourcePath = string `/${getEncodedUri(formId)}`; map headerValues = {...headers}; if self.apiKeyConfig is ApiKeysConfig { headerValues["private-app-legacy"] = self.apiKeyConfig?.private\-app\-legacy; diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 9df8e52..9db8adc 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -23,277 +23,224 @@ configurable string refreshToken = ?; ConnectionConfig config = {auth : auth}; -final Client baseClient = check new Client(config, serviceUrl = "https://api.hubapi.com"); +final Client baseClient = check new Client(config, serviceUrl = "https://api.hubapi.com/marketing/v3/forms"); final time:Utc currentUtc = time:utcNow(); -final string formId = "637b69f2-e2cc-4908-9094-8a3fff4f20f9"; - -final string deleteFormId = "cc1f5a3e-8dd3-4a8a-a4ae-da37ee90ccdb"; +final string formId = "4b85ae4d-eb2f-4f1a-b712-25702d0f68f1"; +final string deleteFormId = "d167c0f7-d042-49ef-a162-1cf548cc170b"; +// 4b85ae4d-eb2f-4f1a-b712-25702d0f68f1 +// d167c0f7-d042-49ef-a162-1cf548cc170b @test:Config { groups: ["live_tests", "mock_tests"] } isolated function testGetForm() returns error? { - CollectionResponseFormDefinitionBaseForwardPaging response = check baseClient->/marketing/v3/forms.get(); + CollectionResponseFormDefinitionBaseForwardPaging response = check baseClient->/.get(); test:assertTrue(response?.results.length() > 0); - io:println(response); - } -// @test:Config {} -// isolated function testCreateForm() returns error? { -// FormDefinitionBase response = check baseClient->/marketing/v3/forms.post( -// { -// formType: "hubspot", -// name: "form" + currentUtc.toString(), -// createdAt: "2024-12-23T07:13:28.102Z", -// updatedAt: "2024-12-23T07:13:28.102Z", -// archived: false, -// fieldGroups: [ -// { -// groupType: "default_group", -// richTextType: "text", -// fields: [ -// { -// objectTypeId: "0-1", -// name: "email", -// label: "Email", -// required: true, -// hidden: false, -// fieldType: "email", -// validation: { -// blockedEmailDomains: [], -// useDefaultBlockList: false -// }, -// dependentFields: [] +@test:Config {} +isolated function testCreateForm() returns error? { + FormDefinitionBase response = check baseClient->/.post( + { + formType: "hubspot", + name: "form" + currentUtc.toString(), + createdAt: "2024-12-23T07:13:28.102Z", + updatedAt: "2024-12-23T07:13:28.102Z", + archived: false, + fieldGroups: [ + { + groupType: "default_group", + richTextType: "text", + fields: [ + { + objectTypeId: "0-1", + name: "email", + label: "Email", + required: true, + hidden: false, + fieldType: "email", + validation: { + blockedEmailDomains: [], + useDefaultBlockList: false + } -// } -// ] -// } -// ], -// configuration: { -// language: "en", -// createNewContactForNewEmail: true, -// editable: true, -// allowLinkToResetKnownValues: true, -// lifecycleStages: [], -// postSubmitAction: { -// 'type: "thank_you", -// value: "Thank you for subscribing!" -// }, -// prePopulateKnownValues: true, -// cloneable: true, -// notifyContactOwner: true, -// recaptchaEnabled: false, -// archivable: true, -// notifyRecipients: ["example@example.com"] -// }, -// displayOptions: { -// renderRawHtml: false, -// cssClass: "hs-form stacked", -// theme: "default_style", -// submitButtonText: "Submit", -// style: { -// labelTextSize: "13px", -// legalConsentTextColor: "#33475b", -// fontFamily: "arial, helvetica, sans-serif", -// legalConsentTextSize: "14px", -// backgroundWidth: "100%", -// helpTextSize: "11px", -// submitFontColor: "#ffffff", -// labelTextColor: "#33475b", -// submitAlignment: "left", -// submitSize: "12px", -// helpTextColor: "#7C98B6", -// submitColor: "#ff7a59" -// } -// }, -// legalConsentOptions: { -// 'type: "none" -// } -// } -// ); - -// test:assertTrue(response?.id !is ""); -// io:println(response); -// io:println(response?.id); + } + ] + } + ], + configuration: { + language: "en", + createNewContactForNewEmail: true, + editable: true, + allowLinkToResetKnownValues: true, + lifecycleStages: [], + postSubmitAction: { + 'type: "thank_you", + value: "Thank you for subscribing!" + }, + prePopulateKnownValues: true, + cloneable: true, + notifyContactOwner: true, + recaptchaEnabled: false, + archivable: true, + notifyRecipients: ["example@example.com"] + }, + displayOptions: { + renderRawHtml: false, + cssClass: "hs-form stacked", + theme: "default_style", + submitButtonText: "Submit", + style: { + labelTextSize: "13px", + legalConsentTextColor: "#33475b", + fontFamily: "arial, helvetica, sans-serif", + legalConsentTextSize: "14px", + backgroundWidth: "100%", + helpTextSize: "11px", + submitFontColor: "#ffffff", + labelTextColor: "#33475b", + submitAlignment: "left", + submitSize: "12px", + helpTextColor: "#7C98B6", + submitColor: "#ff7a59" + } + }, + legalConsentOptions: { + 'type: "none" + } + } + ); + + test:assertTrue(response?.id !is ""); + io:println(response?.id); -// } - - -// @test:Config {} -// isolated function testGetFormById() returns error? { - -// allowLinkToResetKnownValues: true, -// lifecycleStages: [], -// postSubmitAction: { -// 'type: "thank_you", -// value: "Thank you for subscribing!" -// }, -// prePopulateKnownValues: true, -// cloneable: true, -// notifyContactOwner: true, -// recaptchaEnabled: false, -// archivable: true, -// notifyRecipients: ["example@example.com"] -// }, -// displayOptions: { -// renderRawHtml: false, -// cssClass: "hs-form stacked", -// theme: "default_style", -// submitButtonText: "Submit", -// style: { -// labelTextSize: "13px", -// legalConsentTextColor: "#33475b", -// fontFamily: "arial, helvetica, sans-serif", -// legalConsentTextSize: "14px", -// backgroundWidth: "100%", -// helpTextSize: "11px", -// submitFontColor: "#ffffff", -// labelTextColor: "#33475b", -// submitAlignment: "left", -// submitSize: "12px", -// helpTextColor: "#7C98B6", -// submitColor: "#ff7a59" -// } -// }, -// legalConsentOptions: { -// 'type: "none" -// } -// } -// ); - -// test:assertTrue(response?.id !is ""); -// io:println(response); -// io:println(response?.id); - - -// } - -// @test:Config {} -// isolated function testGetFormById() returns error? { - -// FormDefinitionBase response = check baseClient->/marketing/v3/forms/[formId](); - -// test:assertTrue(response?.id == formId); - - -// } - -// @test:Config {} -// isolated function testUpdateEntireForm() returns error? { - -// FormDefinitionBase response = check baseClient->/marketing/v3/forms/[formId].put( -// { -// formType: "hubspot", -// id: formId, -// name: "form" + currentUtc.toString() + "updated", -// createdAt: "2024-12-23T07:13:28.102Z", -// updatedAt: "2024-12-23T07:13:28.102Z", -// archived: true, -// archivedAt: "2024-12-23T07:13:28.102Z", -// fieldGroups: [ -// { -// groupType: "default_group", -// richTextType: "text", -// fields: [ -// { -// objectTypeId: "0-1", -// name: "email", -// label: "Email", -// required: true, -// hidden: false, -// fieldType: "email", -// validation: { -// blockedEmailDomains: [], -// useDefaultBlockList: false -// }, -// dependentFields: [] +} + + +@test:Config {} +isolated function testGetFormById() returns error? { + + FormDefinitionBase response = check baseClient->/[formId](); + + test:assertTrue(response?.id == formId); + + +} + +@test:Config {} +isolated function testUpdateEntireForm() returns error? { + + FormDefinitionBase response = check baseClient->/[formId].put( + { + formType: "hubspot", + id: formId, + name: "form" + currentUtc.toString() + "updated", + createdAt: "2024-12-23T07:13:28.102Z", + updatedAt: "2024-12-23T07:13:28.102Z", + archived: true, + archivedAt: "2024-12-23T07:13:28.102Z", + fieldGroups: [ + { + groupType: "default_group", + richTextType: "text", + fields: [ + { + objectTypeId: "0-1", + name: "email", + label: "Email", + required: true, + hidden: false, + fieldType: "email", + validation: { + blockedEmailDomains: [], + useDefaultBlockList: false + } -// } -// ] -// } -// ], -// configuration: { -// language: "en", -// createNewContactForNewEmail: true, -// editable: true, -// allowLinkToResetKnownValues: true, -// lifecycleStages: [], -// postSubmitAction: { -// 'type: "thank_you", -// value: "Thank you for subscribing!" -// }, -// prePopulateKnownValues: true, -// cloneable: true, -// notifyContactOwner: true, -// recaptchaEnabled: false, -// archivable: true, -// notifyRecipients: ["example@example.com"] -// }, -// displayOptions: { -// renderRawHtml: false, -// cssClass: "hs-form stacked", -// theme: "default_style", -// submitButtonText: "Submit", -// style: { -// labelTextSize: "13px", -// legalConsentTextColor: "#33475b", -// fontFamily: "arial, helvetica, sans-serif", -// legalConsentTextSize: "14px", -// backgroundWidth: "100%", -// helpTextSize: "11px", -// submitFontColor: "#ffffff", -// labelTextColor: "#33475b", -// submitAlignment: "left", -// submitSize: "12px", -// helpTextColor: "#7C98B6", -// submitColor: "#ff7a59" -// } -// }, -// legalConsentOptions: { -// 'type: "none" -// } -// } -// ); - -// test:assertTrue(response?.id == formId); -// test:assertEquals(response?.archived, true); - -// } - -// @test:Config {} -// isolated function testUpdateForm() returns error? { - -// FormDefinitionBase response = check baseClient->/marketing/v3/forms/[formId].patch( -// { -// name: "form2" -// } -// ); - -// test:assertTrue(response?.id == formId); -// test:assertEquals(response?.name, "form2"); - -// } - -// @test:Config {} -// isolated function testDeleteForm() returns error? { - -// json response = check baseClient->/marketing/v3/forms/[deleteFormId].delete(); - -// io:println(response); -// test:assertTrue(response == ()); - -// } + } + ] + } + ], + configuration: { + language: "en", + createNewContactForNewEmail: true, + editable: true, + allowLinkToResetKnownValues: true, + lifecycleStages: [], + postSubmitAction: { + 'type: "thank_you", + value: "Thank you for subscribing!" + }, + prePopulateKnownValues: true, + cloneable: true, + notifyContactOwner: true, + recaptchaEnabled: false, + archivable: true, + notifyRecipients: ["example@example.com"] + }, + displayOptions: { + renderRawHtml: false, + cssClass: "hs-form stacked", + theme: "default_style", + submitButtonText: "Submit", + style: { + labelTextSize: "13px", + legalConsentTextColor: "#33475b", + fontFamily: "arial, helvetica, sans-serif", + legalConsentTextSize: "14px", + backgroundWidth: "100%", + helpTextSize: "11px", + submitFontColor: "#ffffff", + labelTextColor: "#33475b", + submitAlignment: "left", + submitSize: "12px", + helpTextColor: "#7C98B6", + submitColor: "#ff7a59" + } + }, + legalConsentOptions: { + 'type: "none" + } + } + ); + + test:assertTrue(response?.id == formId); + test:assertEquals(response?.archived, true); + +} + +@test:Config {} +isolated function testUpdateForm() returns error? { + + FormDefinitionBase response = check baseClient->/[formId].patch( + { + name: "form2" + } + ); + + test:assertTrue(response?.id == formId); + test:assertEquals(response?.name, "form2"); + +} + +@test:Config {} +isolated function testDeleteForm() returns error? { + + json response = check baseClient->/[deleteFormId].delete(); + + io:println(response); + test:assertTrue(response == ()); + +} diff --git a/ballerina/types.bal b/ballerina/types.bal index d122535..8ee6061 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -64,7 +64,7 @@ public type MultiLineTextField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -88,7 +88,7 @@ public type MobilePhoneField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -146,7 +146,7 @@ public type DatepickerField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -214,7 +214,7 @@ public type DropdownField record { # The values selected by default. Those values will be submitted unless the customer modifies them. string[] defaultValues; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -240,7 +240,7 @@ public type RadioField record { # The values selected by default. Those values will be submitted unless the customer modifies them. string[] defaultValues; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -281,7 +281,7 @@ public type EmailField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -389,7 +389,7 @@ public type FileField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -435,7 +435,7 @@ public type NumberField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -454,7 +454,7 @@ public type PaymentLinkRadioField record { EnumeratedFieldOption[] options; string description?; string[] defaultValues; - DependentField[] dependentFields; + DependentField[] dependentFields?; string label; "payment_link_radio" fieldType; boolean required; @@ -475,7 +475,7 @@ public type MultipleCheckboxesField record { # The values selected by default. Those values will be submitted unless the customer modifies them. string[] defaultValues; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # Determines how the field will be displayed and validated. @@ -536,7 +536,7 @@ public type SingleCheckboxField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # Determines how the field will be displayed and validated. @@ -609,7 +609,7 @@ public type PhoneField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in. @@ -634,7 +634,7 @@ public type SingleLineTextField record { # Additional text helping the customer to complete the field. string description?; # A list of other fields to make visible based on the value filled in for this field. - DependentField[] dependentFields; + DependentField[] dependentFields?; # The main label for the form field. string label; # The prompt text showing when the field isn't filled in.