From 9503f9a49d10b5dd9639ce1a9f860be3b4ab1e1b Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 11:40:46 +0530 Subject: [PATCH 01/12] Change Test Structure to default to mock tests --- ballerina/tests/mock_tests.bal | 187 --------------------------------- ballerina/tests/tests.bal | 122 +++++++++++++-------- 2 files changed, 80 insertions(+), 229 deletions(-) delete mode 100644 ballerina/tests/mock_tests.bal diff --git a/ballerina/tests/mock_tests.bal b/ballerina/tests/mock_tests.bal deleted file mode 100644 index 170bbf9..0000000 --- a/ballerina/tests/mock_tests.bal +++ /dev/null @@ -1,187 +0,0 @@ -import ballerina/http; -import ballerina/log; -import ballerina/test; - -configurable int localPort = 9090; - -// Using Separate Client for Mock Tests -Client mockClient = test:mock(Client); - -// Create Mock Auth Config -OAuth2RefreshTokenGrantConfig mockAuth = { - clientId: "mock", - clientSecret: "mock", - refreshToken: "mock", - refreshUrl: string `http://localhost:${localPort}/oauth2/token` -}; -ConnectionConfig mockConfig = {auth: mockAuth}; - -string mockTestObjId = ""; - -@test:BeforeGroups { - value: ["mock_tests"] -} -function setupMock() returns error? { - log:printInfo(string `Initiating mock server in port ${localPort}`); - check httpListener.attach(mockService, "/"); - check httpListener.'start(); - - log:printInfo("Starting Mock Tests"); - // Create Mock Client - mockClient = check new (mockConfig, string `http://localhost:${localPort}`); -}; - -@test:Config { - groups: ["mock_tests"] -} -function CreateMarketingEventMockTest() returns error? { - - // Create a New event - CrmPropertyWrapper customProperty = { - name: "test_name", - value: "Custom Value" - }; - - MarketingEventCreateRequestParams sampleCreatePayload = { - externalAccountId: "11111", - externalEventId: "10000", - eventName: "Winter webinar", - eventOrganizer: "Snowman Fellowship", - eventCancelled: false, - eventUrl: "https://example.com/holiday-jam", - eventType: "WEBINAR", - eventDescription: "Let's get together to plan for the holidays", - eventCompleted: false, - startDateTime: "2024-08-07T12:36:59.286Z", - endDateTime: "2024-08-07T12:36:59.286Z", - customProperties: [ - customProperty - ] - }; - - MarketingEventDefaultResponse createResp = check mockClient->postEvents_create(sampleCreatePayload); - - test:assertTrue(createResp?.objectId !is "" && createResp?.objectId is string); - test:assertTrue(createResp.eventName == sampleCreatePayload.eventName); - mockTestObjId = createResp?.objectId is null ? "" : createResp?.objectId.toString(); -}; - -@test:Config { - groups: ["mock_tests"] -} -function CreateOrUpdateMarketingEventMockTest() returns error? { - - // Create a New event - - string externalEventId = "11000"; - - CrmPropertyWrapper customProperty = { - name: "test_name", - value: "Custom Value" - }; - - MarketingEventCreateRequestParams sampleCreatePayload = { - externalAccountId: "11111", - externalEventId: externalEventId, - eventName: "Test 2", - eventOrganizer: "Organizer 2", - eventCancelled: false, - eventUrl: "https://example.com/test-2", - eventDescription: "Test 2", - eventCompleted: false, - eventType: "CONFERENCE", - startDateTime: "2024-08-07T12:36:59.286Z", - endDateTime: "2024-08-07T12:36:59.286Z", - customProperties: [ - customProperty - ] - }; - - MarketingEventPublicDefaultResponse createResp = check mockClient->putEventsExternaleventid_upsert( - externalEventId, sampleCreatePayload); - - test:assertTrue(createResp?.objectId !is "" && createResp?.objectId is string); - test:assertTrue(createResp.eventName == sampleCreatePayload.eventName); - - // Update an existing event - - string updatedEventName = "Test 2 Updated"; - string updatedEventOrganizer = "Organizer 2 Updated"; - - MarketingEventCreateRequestParams sampleUpdatePayload = { - externalAccountId: "11111", - externalEventId: externalEventId, - eventName: updatedEventName, - eventOrganizer: updatedEventOrganizer - }; - - MarketingEventPublicDefaultResponse updateResp = check mockClient->putEventsExternaleventid_upsert( - externalEventId, sampleUpdatePayload); - - test:assertEquals(updateResp.eventName, updatedEventName); - test:assertEquals(updateResp.eventOrganizer, updatedEventOrganizer); -}; - -@test:Config { - groups: ["mock_tests"], - dependsOn: [CreateMarketingEventMockTest, CreateOrUpdateMarketingEventMockTest] -} -function GetAllMarketingEventsMockTest() returns error? { - - CollectionResponseMarketingEventPublicReadResponseV2ForwardPaging getResp = check mockClient->get(); - - test:assertTrue(getResp?.results !is ()); -}; - -@test:Config { - groups: ["mock_tests"], - dependsOn: [CreateMarketingEventMockTest, CreateOrUpdateMarketingEventMockTest] -} -function AssociateListFromInternalIdsMockTest() returns error? { - - string listId = "9"; // ILS List ID of the list - - http:Response createResp = check - mockClient->putAssociationsMarketingeventidListsListid_associatebymarketingeventid(testObjId, listId); - - test:assertTrue(createResp.statusCode >= 200 && createResp.statusCode < 300); -} - -// Delete All the Event Objects (After Group) - -@test:AfterGroups { - value: ["mock_tests"], - alwaysRun: true -} -function DeleteMarketingEventByObjectIdMockTest() returns error? { - - // Valid ObjID - - http:Response deleteResp = check mockClient->deleteObjectid(testObjId); - - test:assertTrue(deleteResp.statusCode == 204); - - // Invalid ObjID - - string invalidObjId = "8436"; - - http:Response deleteResp2 = check mockClient->deleteObjectid(invalidObjId); - - test:assertTrue(deleteResp2.statusCode == 404); - mockTestObjId = ""; -}; - -@test:AfterGroups { - value: ["mock_tests"], - alwaysRun: true -} -function DeleteMarketingEventByExternalIdsMockTest() returns error? { - - string externalAccountId = "11111"; - string externalEventId = "11000"; - - http:Response deleteResp = check - mockClient->deleteEventsExternaleventid_archive(externalEventId, externalAccountId = externalAccountId); - - test:assertTrue(deleteResp.statusCode == 204); -}; diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 428032e..1e7e412 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -19,52 +19,68 @@ import ballerina/log; import ballerina/oauth2; import ballerina/test; -configurable string refreshToken = ""; -configurable string clientId = ""; -configurable string clientSecret = ""; +configurable boolean isLiveServer = false; +configurable string refreshToken = "mock"; +configurable string clientId = "mock"; +configurable string clientSecret = "mock"; configurable string devApiKey = "-1"; +configurable int localPort = 9090; Client hubspotClient = test:mock(Client); // Using a separate client for app setting tests since it need developer API key Client hubspotAppSettingClient = test:mock(Client); -// Create Auth Config for Live OAuth2 -OAuth2RefreshTokenGrantConfig auth = { - clientId, - clientSecret, - refreshToken, - credentialBearer: oauth2:POST_BODY_BEARER // this line should be added in to when you are going to create auth object. -}; -ConnectionConfig config = {auth}; - string testObjId = ""; string[] batchTestObjIds = []; string appId = ""; -@test:BeforeGroups { - value: ["live_tests"] -} -function setupLive() returns error? { - log:printInfo("Starting Live Tests"); - - hubspotClient = check new (config); - - // Only create the app setting client if the Dev API key is set - if devApiKey != "-1" { - log:printInfo("Developer API Key Found. Running App Setting Tests"); - ApiKeysConfig apiKeysConfig = { - hapikey: devApiKey, - private\-app\-legacy: "" +@test:BeforeSuite +function setupTests() returns error? { + if isLiveServer { + log:printInfo("Initiating live server"); + OAuth2RefreshTokenGrantConfig auth = { + clientId, + clientSecret, + refreshToken, + credentialBearer: oauth2:POST_BODY_BEARER // this line should be added in to when you are going to create auth object. }; - hubspotAppSettingClient = check new ({auth: apiKeysConfig}); + ConnectionConfig config = {auth}; + hubspotClient = check new (config); + + // Only create the app setting client if the Dev API key is set + if devApiKey != "-1" { + log:printInfo("Developer API Key Found. Running App Setting Tests"); + ApiKeysConfig apiKeysConfig = { + hapikey: devApiKey, + private\-app\-legacy: "" + }; + hubspotAppSettingClient = check new ({auth: apiKeysConfig}); + } else { + log:printInfo("Developer API Key Not Found. Skipping App Setting Tests"); + } + } else { - log:printInfo("Developer API Key Not Found. Skipping App Setting Tests"); + log:printInfo("Initiating mock server"); + check httpListener.attach(mockService, "/"); + check httpListener.'start(); + + // Create Mock Auth Config + OAuth2RefreshTokenGrantConfig mockAuth = { + clientId, + clientSecret, + refreshToken, + refreshUrl: string `http://localhost:${localPort}/oauth2/token` + }; + ConnectionConfig mockConfig = {auth: mockAuth}; + + hubspotClient = check new (mockConfig, string `http://localhost:${localPort}`); } + }; @test:Config { - groups: ["BASIC", "live_tests"] + groups: ["BASIC", "live_tests", "mock_tests"] } function CreateMarketingEventTest() returns error? { @@ -99,7 +115,7 @@ function CreateMarketingEventTest() returns error? { }; @test:Config { - groups: ["BASIC", "live_tests"] + groups: ["BASIC", "live_tests", "mock_tests"] } function CreateOrUpdateMarketingEventTest() returns error? { @@ -156,6 +172,7 @@ function CreateOrUpdateMarketingEventTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [CreateOrUpdateMarketingEventTest] } function UpdateMarketingEventByExternalIdsTest() returns error? { @@ -185,6 +202,7 @@ function UpdateMarketingEventByExternalIdsTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function updateMarketingEventByObjectIdTest() returns error? { @@ -218,7 +236,7 @@ function updateMarketingEventByObjectIdTest() returns error? { }; @test:Config { - groups: ["BASIC", "live_tests"], + groups: ["BASIC", "live_tests", "mock_tests"], dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function GetAllMarketingEventsTest() returns error? { @@ -230,6 +248,7 @@ function GetAllMarketingEventsTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [UpdateMarketingEventByExternalIdsTest, updateMarketingEventByObjectIdTest] } function GetMarketingEventbyExternalIdsTest() returns error? { @@ -246,6 +265,7 @@ function GetMarketingEventbyExternalIdsTest() returns error? { @test:Config { groups: ["BASIC", "live_tests"], + enable: isLiveServer, dependsOn: [updateMarketingEventByObjectIdTest] } function GetMarketingEventbyObjectIdTest() returns error? { @@ -267,7 +287,8 @@ function GetMarketingEventbyObjectIdTest() returns error? { }; @test:Config { - groups: ["BATCH", "live_tests"] + groups: ["BATCH", "live_tests"], + enable: isLiveServer } function BatchCreateOrUpdateMarketingEventsTest() returns error? { string externalAccountId = "112233"; @@ -357,6 +378,7 @@ function BatchCreateOrUpdateMarketingEventsTest() returns error? { @test:Config { groups: ["BATCH", "live_tests"], + enable: isLiveServer, dependsOn: [BatchCreateOrUpdateMarketingEventsTest] } function BatchUpdateMarketingEventsByObjectId() returns error? { @@ -456,6 +478,7 @@ function BatchDeleteMarketingEventsByObjectId() returns error? { @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function RecordParticipantsByContactIdwithMarketingEventObjectIdsTest() returns error? { @@ -483,6 +506,7 @@ function RecordParticipantsByContactIdwithMarketingEventObjectIdsTest() returns @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function RecordParticipantsByEmailwithMarketingEventObjectIdsTest() returns error? { @@ -506,6 +530,7 @@ function RecordParticipantsByEmailwithMarketingEventObjectIdsTest() returns erro @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateOrUpdateMarketingEventTest] } function RecordParticipantsByEmailwithMarketingEventExternalIdsTest() returns error? { @@ -531,6 +556,7 @@ function RecordParticipantsByEmailwithMarketingEventExternalIdsTest() returns er @test:Config { groups: ["ATTENDEES", "live_tests"], + enable: isLiveServer, dependsOn: [CreateOrUpdateMarketingEventTest] } function RecordParticipantsByContactIdswithMarketingEventExternalIdsTest() returns error? { @@ -561,6 +587,7 @@ function RecordParticipantsByContactIdswithMarketingEventExternalIdsTest() retur @test:Config { groups: ["IDENTIFIERS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function FindAppSpecificMarketingEventByExternalEventIdsTest() returns error? { @@ -575,6 +602,7 @@ function FindAppSpecificMarketingEventByExternalEventIdsTest() returns error? { @test:Config { groups: ["IDENTIFIERS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function FindMarketingEventByExternalEventIdsTest() returns error? { @@ -589,6 +617,7 @@ function FindMarketingEventByExternalEventIdsTest() returns error? { @test:Config { groups: ["EVENT_STATUS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function MarkEventCompletedTest() returns error? { @@ -610,6 +639,7 @@ function MarkEventCompletedTest() returns error? { @test:Config { groups: ["EVENT_STATUS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function MarkEventCancelledTest() returns error? { @@ -626,6 +656,7 @@ function MarkEventCancelledTest() returns error? { @test:Config { groups: ["SUBSCRIBER_STATE", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function RecordSubStateByEmailTest() returns error? { @@ -651,6 +682,7 @@ function RecordSubStateByEmailTest() returns error? { @test:Config { groups: ["SUBSCRIBER_STATE", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function RecordSubStateByContactIdTest() returns error? { @@ -680,6 +712,7 @@ function RecordSubStateByContactIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest] } function ReadParticipationBreakdownByContactIdentifierTest() returns error? { @@ -694,6 +727,7 @@ function ReadParticipationBreakdownByContactIdentifierTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationBreakdownByExternalIdTest() returns error? { @@ -710,6 +744,7 @@ function ReadParticipationBreakdownByExternalIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationBreakdownByInternalIdTest() returns error? { @@ -724,6 +759,7 @@ function ReadParticipationBreakdownByInternalIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationCountByInternalIdTest() returns error? { @@ -739,6 +775,7 @@ function ReadParticipationCountByInternalIdTest() returns error? { @test:Config { groups: ["PARTICIPATION", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function ReadParticipationCountByExternalIdTest() returns error? { @@ -756,6 +793,7 @@ function ReadParticipationCountByExternalIdTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function AssociateListFromExternalIdsTest() returns error? { @@ -773,7 +811,7 @@ function AssociateListFromExternalIdsTest() returns error? { } @test:Config { - groups: ["LISTS", "live_tests"], + groups: ["LISTS", "live_tests", "mock_tests"], dependsOn: [CreateMarketingEventTest, CreateOrUpdateMarketingEventTest] } function AssociateListFromInternalIdsTest() returns error? { @@ -788,6 +826,7 @@ function AssociateListFromInternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [AssociateListFromInternalIdsTest] } function GetAssociatedListsFromInternalIdsTest() returns error? { @@ -800,6 +839,7 @@ function GetAssociatedListsFromInternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [AssociateListFromExternalIdsTest] } function GetAssociatedListsFromExternalIdsTest() returns error? { @@ -814,6 +854,7 @@ function GetAssociatedListsFromExternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [GetAssociatedListsFromExternalIdsTest] } function DeleteAssociatedListsfromExternalIdsTest() returns error? { @@ -831,6 +872,7 @@ function DeleteAssociatedListsfromExternalIdsTest() returns error? { @test:Config { groups: ["LISTS", "live_tests"], + enable: isLiveServer, dependsOn: [GetAssociatedListsFromInternalIdsTest] } function DeleteAssociatedListsfromInternalIdsTest() returns error? { @@ -847,6 +889,7 @@ function DeleteAssociatedListsfromInternalIdsTest() returns error? { @test:Config { groups: ["APP_SETTINGS", "live_tests"], + enable: isLiveServer, dependsOn: [GetMarketingEventbyObjectIdTest] } function SetAppSettingsTest() returns error? { @@ -870,6 +913,7 @@ function SetAppSettingsTest() returns error? { @test:Config { groups: ["APP_SETTINGS", "live_tests"], + enable: isLiveServer, dependsOn: [SetAppSettingsTest] } function GetAppSettingsTest() returns error? { @@ -886,12 +930,9 @@ function GetAppSettingsTest() returns error? { test:assertEquals(getResp?.eventDetailsUrl, "https://my.event.app/events/%s"); }; -// Delete All the Event Objects (After Group) +// Delete All the Event Objects (After Suite) -@test:AfterGroups { - value: ["live_tests"], - alwaysRun: true -} +@test:AfterSuite function DeleteMarketingEventByObjectIdTest() returns error? { // Valid ObjID @@ -910,10 +951,7 @@ function DeleteMarketingEventByObjectIdTest() returns error? { testObjId = ""; }; -@test:AfterGroups { - value: ["live_tests"], - alwaysRun: true -} +@test:AfterSuite function DeleteMarketingEventByExternalIdsTest() returns error? { string externalAccountId = "11111"; From 01af768dc28e37e8470030f9268d5df891c2201f Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 11:47:53 +0530 Subject: [PATCH 02/12] Update README and documentation to use quotes for configuration values --- README.md | 14 +++++++------- ballerina/Module.md | 14 +++++++------- ballerina/Package.md | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index babc242..931ef67 100644 --- a/README.md +++ b/README.md @@ -158,18 +158,18 @@ import ballerinax/hubspot.marketing.events as hsmevents; 1. Create a `Config.toml` file in the root directory of the Ballerina project and configure the obtained credentials in the above steps as follows: ```toml - clientId = - clientSecret = - refreshToken = + clientId = "" + clientSecret = "" + refreshToken = "" ``` >**Note (Optional):** If you want to use Set and Get Application Settings operations, you need to provide the Developer API Key in the `Config.toml` file as well. ```toml - clientId = - clientSecret = - refreshToken = - apiKey = + clientId = "" + clientSecret = "" + refreshToken = "" + apiKey = "" ``` 2. Instantiate a `hsmevents:ConnectionConfig` with the obtained credentials and initialize the connector with it. diff --git a/ballerina/Module.md b/ballerina/Module.md index 570f463..2ab077a 100644 --- a/ballerina/Module.md +++ b/ballerina/Module.md @@ -150,18 +150,18 @@ import ballerinax/hubspot.marketing.events as hsmevents; 1. Create a `Config.toml` file in the root directory of the Ballerina project and configure the obtained credentials in the above steps as follows: ```toml - clientId = - clientSecret = - refreshToken = + clientId = "" + clientSecret = "" + refreshToken = "" ``` >**Note (Optional):** If you want to use Set and Get Application Settings operations, you need to provide the Developer API Key in the `Config.toml` file as well. ```toml - clientId = - clientSecret = - refreshToken = - apiKey = + clientId = "" + clientSecret = "" + refreshToken = "" + apiKey = "" ``` 2. Instantiate a `hsmevents:ConnectionConfig` with the obtained credentials and initialize the connector with it. diff --git a/ballerina/Package.md b/ballerina/Package.md index 570f463..2ab077a 100644 --- a/ballerina/Package.md +++ b/ballerina/Package.md @@ -150,18 +150,18 @@ import ballerinax/hubspot.marketing.events as hsmevents; 1. Create a `Config.toml` file in the root directory of the Ballerina project and configure the obtained credentials in the above steps as follows: ```toml - clientId = - clientSecret = - refreshToken = + clientId = "" + clientSecret = "" + refreshToken = "" ``` >**Note (Optional):** If you want to use Set and Get Application Settings operations, you need to provide the Developer API Key in the `Config.toml` file as well. ```toml - clientId = - clientSecret = - refreshToken = - apiKey = + clientId = "" + clientSecret = "" + refreshToken = "" + apiKey = "" ``` 2. Instantiate a `hsmevents:ConnectionConfig` with the obtained credentials and initialize the connector with it. From bacf4b44a74046b2166d2170ceffc146cb1f95f8 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 13:06:44 +0530 Subject: [PATCH 03/12] Refactor oauth2/token resource to return JSON directly --- ballerina/tests/mock_server.bal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ballerina/tests/mock_server.bal b/ballerina/tests/mock_server.bal index c43c512..0598c64 100644 --- a/ballerina/tests/mock_server.bal +++ b/ballerina/tests/mock_server.bal @@ -21,13 +21,12 @@ listener http:Listener httpListener = new (localPort); http:Service mockService = service object { resource isolated function post oauth2/token(@http:Payload http:Request request) returns json { - json response = { + return { "token_type": "bearer", "refresh_token": "mock", "access_token": "mockAccessToken", "expires_in": 1800 }; - return response; } resource isolated function post events(@http:Payload MarketingEventCreateRequestParams createPayload) From 5f5961d9dc786a4f8c09265dbaa9387aa0704d15 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 13:26:13 +0530 Subject: [PATCH 04/12] [Automated] Update the toml files --- ballerina/Ballerina.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index ccd961c..f45b39b 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -5,8 +5,8 @@ name = "hubspot.marketing.events" version = "0.1.0" license = ["Apache-2.0"] authors = ["Ballerina"] -keywords = ["hubspot", "marketing", "events"] -icon = "icon.png" +keywords = [] # TODO: Add keywords +# icon = "icon.png" # TODO: Add icon repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.events" [build-options] From 790f3c7206105494d75401014d75a77b614346c5 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 13:29:52 +0530 Subject: [PATCH 05/12] add keywords --- ballerina/Ballerina.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index f45b39b..ccd961c 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -5,8 +5,8 @@ name = "hubspot.marketing.events" version = "0.1.0" license = ["Apache-2.0"] authors = ["Ballerina"] -keywords = [] # TODO: Add keywords -# icon = "icon.png" # TODO: Add icon +keywords = ["hubspot", "marketing", "events"] +icon = "icon.png" repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.events" [build-options] From aa74718f62180b740f494ec17dd3cac482246bad Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 13:49:02 +0530 Subject: [PATCH 06/12] Remove local dependencies from examples --- examples/event_participation_management/Ballerina.toml | 6 ------ examples/marketing_event_management/Ballerina.toml | 8 +------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/examples/event_participation_management/Ballerina.toml b/examples/event_participation_management/Ballerina.toml index 2735117..8ce7a58 100644 --- a/examples/event_participation_management/Ballerina.toml +++ b/examples/event_participation_management/Ballerina.toml @@ -6,9 +6,3 @@ distribution = "2201.10.0" [build-options] observabilityIncluded = true - -[[dependency]] -org = "ballerinax" -name = "hubspot.marketing.events" -version = "0.1.0" -repository = "local" diff --git a/examples/marketing_event_management/Ballerina.toml b/examples/marketing_event_management/Ballerina.toml index f575504..834965b 100644 --- a/examples/marketing_event_management/Ballerina.toml +++ b/examples/marketing_event_management/Ballerina.toml @@ -2,13 +2,7 @@ org = "wso2" name = "marketing_event_management" version = "0.1.0" -distribution = "2201.10.3" +distribution = "2201.10.0" [build-options] observabilityIncluded = true - -[[dependency]] -org = "ballerinax" -name = "hubspot.marketing.events" -version = "0.1.0" -repository = "local" From 976697af4755fb1a263f262778445137eed7c3a4 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 13:59:24 +0530 Subject: [PATCH 07/12] [Automated] Update the toml files --- ballerina/Ballerina.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index ccd961c..f45b39b 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -5,8 +5,8 @@ name = "hubspot.marketing.events" version = "0.1.0" license = ["Apache-2.0"] authors = ["Ballerina"] -keywords = ["hubspot", "marketing", "events"] -icon = "icon.png" +keywords = [] # TODO: Add keywords +# icon = "icon.png" # TODO: Add icon repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.events" [build-options] From 8ed1675e28d5b8b64b4eb7b912bfc8d9b7740e53 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 14:31:03 +0530 Subject: [PATCH 08/12] Update deleteObjectid test to handle empty ObjID case --- ballerina/tests/tests.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 1e7e412..69027eb 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -937,7 +937,7 @@ function DeleteMarketingEventByObjectIdTest() returns error? { // Valid ObjID - http:Response deleteResp = check hubspotClient->deleteObjectid(testObjId); + http:Response deleteResp = check hubspotClient->deleteObjectid(testObjId == "" ? "395700216901": testObjId); test:assertTrue(deleteResp.statusCode == 204); From eee0d8145e5bc27fbcdcc87b8c652c483f80ddc4 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 14:31:37 +0530 Subject: [PATCH 09/12] Add keywords and icon to Ballerina.toml --- ballerina/Ballerina.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index f45b39b..ccd961c 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -5,8 +5,8 @@ name = "hubspot.marketing.events" version = "0.1.0" license = ["Apache-2.0"] authors = ["Ballerina"] -keywords = [] # TODO: Add keywords -# icon = "icon.png" # TODO: Add icon +keywords = ["hubspot", "marketing", "events"] +icon = "icon.png" repository = "https://github.com/ballerina-platform/module-ballerinax-hubspot.marketing.events" [build-options] From 927704535982f28ff8eb62b866f0e7c2e4549ed2 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 14:40:14 +0530 Subject: [PATCH 10/12] Update copyright year in auto-generated files to 2025 --- ballerina/client.bal | 2 +- ballerina/types.bal | 2 +- ballerina/utils.bal | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ballerina/client.bal b/ballerina/client.bal index f63c661..3e4d625 100644 --- a/ballerina/client.bal +++ b/ballerina/client.bal @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE. DO NOT MODIFY. // This file is auto-generated by the Ballerina OpenAPI tool. -// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +// Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except diff --git a/ballerina/types.bal b/ballerina/types.bal index 7a7195c..b1e59c6 100644 --- a/ballerina/types.bal +++ b/ballerina/types.bal @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE. DO NOT MODIFY. // This file is auto-generated by the Ballerina OpenAPI tool. -// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +// Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except diff --git a/ballerina/utils.bal b/ballerina/utils.bal index 13d33ab..5d8e591 100644 --- a/ballerina/utils.bal +++ b/ballerina/utils.bal @@ -1,7 +1,7 @@ // AUTO-GENERATED FILE. DO NOT MODIFY. // This file is auto-generated by the Ballerina OpenAPI tool. -// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com). +// Copyright (c) 2025, WSO2 LLC. (http://www.wso2.com). // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except From ee22c8c91823c8a74b9410fd8e52cd50660517a5 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Thu, 16 Jan 2025 15:55:00 +0530 Subject: [PATCH 11/12] Rename hubspotClient to hubspotMarketingClient in event management examples for clarity --- examples/event_participation_management/main.bal | 12 ++++++------ examples/marketing_event_management/main.bal | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/event_participation_management/main.bal b/examples/event_participation_management/main.bal index 6467209..5ab6f53 100644 --- a/examples/event_participation_management/main.bal +++ b/examples/event_participation_management/main.bal @@ -33,7 +33,7 @@ public function main() returns error? { }; hsmevents:ConnectionConfig config = {auth}; - final hsmevents:Client hubspotClient = check new (config); + final hsmevents:Client hubspotMarketingClient = check new (config); // Step 1: Create a new event @@ -52,7 +52,7 @@ public function main() returns error? { customProperties: [] }; - hsmevents:MarketingEventDefaultResponse createResp = check hubspotClient->postEvents_create(createPayload); + hsmevents:MarketingEventDefaultResponse createResp = check hubspotMarketingClient->postEvents_create(createPayload); string eventObjId = createResp?.objectId ?: "-1"; @@ -72,7 +72,7 @@ public function main() returns error? { }; hsmevents:BatchResponseSubscriberVidResponse registerResp = check - hubspotClient->postObjectidAttendanceSubscriberstateEmailCreate(eventObjId, "register", dummyParticipants); + hubspotMarketingClient->postObjectidAttendanceSubscriberstateEmailCreate(eventObjId, "register", dummyParticipants); io:println("Participants Registered: ", registerResp?.results ?: "Failed"); @@ -81,14 +81,14 @@ public function main() returns error? { // NOTE: Changing participant state takes some time to process. The changes might not be visible immediately. http:Response attendResp = check - hubspotClient->postEventsExternaleventidSubscriberstateEmailUpsert_upsertbycontactemail( + hubspotMarketingClient->postEventsExternaleventidSubscriberstateEmailUpsert_upsertbycontactemail( "12000", "attend", dummyParticipants, externalAccountId = "11111"); io:println("Participant Status Changed: ", attendResp.statusCode == 202 ? "Success" : "Failed"); // Step 4: Get Participant Breakdown of a particular event - hsmevents:CollectionResponseWithTotalParticipationBreakdownForwardPaging participants = check hubspotClient-> + hsmevents:CollectionResponseWithTotalParticipationBreakdownForwardPaging participants = check hubspotMarketingClient-> getParticipationsExternalaccountidExternaleventidBreakdown_getparticipationsbreakdownbyexternaleventid( "11111", "12000"); @@ -98,7 +98,7 @@ public function main() returns error? { // Step 5: Delete Event - http:Response deleteResp = check hubspotClient->deleteObjectid(eventObjId); + http:Response deleteResp = check hubspotMarketingClient->deleteObjectid(eventObjId); io:println("Event Deleted: ", deleteResp.statusCode == 204 ? "Success" : "Failed"); } diff --git a/examples/marketing_event_management/main.bal b/examples/marketing_event_management/main.bal index 2f208a2..a36ff73 100644 --- a/examples/marketing_event_management/main.bal +++ b/examples/marketing_event_management/main.bal @@ -33,7 +33,7 @@ public function main() returns error? { }; hsmevents:ConnectionConfig config = {auth}; - hsmevents:Client hubspotClient = check new (config); + hsmevents:Client hubspotMarketingClient = check new (config); // Step 1: Create a new event @@ -52,7 +52,7 @@ public function main() returns error? { customProperties: [] }; - hsmevents:MarketingEventDefaultResponse createResp = check hubspotClient->postEvents_create(createPayload); + hsmevents:MarketingEventDefaultResponse createResp = check hubspotMarketingClient->postEvents_create(createPayload); string eventObjId = createResp?.objectId ?: "-1"; @@ -78,13 +78,13 @@ public function main() returns error? { }; hsmevents:MarketingEventPublicDefaultResponseV2 updateResp = check - hubspotClient->patchObjectid(eventObjId, sampleUpdatePayload); + hubspotMarketingClient->patchObjectid(eventObjId, sampleUpdatePayload); io:println("Event Updated: ", updateResp?.objectId ?: "-1"); // Step 3: Get the event - hsmevents:MarketingEventPublicDefaultResponseV2 getResp = check hubspotClient->getObjectid(eventObjId); + hsmevents:MarketingEventPublicDefaultResponseV2 getResp = check hubspotMarketingClient->getObjectid(eventObjId); io:println("Event Retrieved: \n", getResp.toJsonString()); @@ -96,13 +96,13 @@ public function main() returns error? { }; hsmevents:MarketingEventDefaultResponse completeResp = check - hubspotClient->postEventsExternaleventidComplete_complete("10000", completePayload, externalAccountId = "11111"); + hubspotMarketingClient->postEventsExternaleventidComplete_complete("10000", completePayload, externalAccountId = "11111"); io:println("Event Completed: ", completeResp?.objectId ?: "-1"); // Step 5: Delete Event - http:Response deleteResp = check hubspotClient->deleteObjectid(eventObjId); + http:Response deleteResp = check hubspotMarketingClient->deleteObjectid(eventObjId); io:println("Event Deleted: ", deleteResp.statusCode == 204 ? "Success" : "Failed"); }; From feadc37ff58cb140287e02c87768a7989315fcc5 Mon Sep 17 00:00:00 2001 From: Sadeesha Sathmina Date: Fri, 17 Jan 2025 11:24:59 +0530 Subject: [PATCH 12/12] Update test configuration to skip tests when Developer API Key is not set --- ballerina/tests/tests.bal | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/ballerina/tests/tests.bal b/ballerina/tests/tests.bal index 69027eb..f79802a 100644 --- a/ballerina/tests/tests.bal +++ b/ballerina/tests/tests.bal @@ -889,16 +889,11 @@ function DeleteAssociatedListsfromInternalIdsTest() returns error? { @test:Config { groups: ["APP_SETTINGS", "live_tests"], - enable: isLiveServer, + enable: isLiveServer && devApiKey != "-1", dependsOn: [GetMarketingEventbyObjectIdTest] } function SetAppSettingsTest() returns error? { - if devApiKey == "-1" { - log:printInfo("Developer API Key Not Found. Skipping App Setting Tests"); - return; - } - EventDetailSettingsUrl payload = { eventDetailsUrl: "https://my.event.app/events/%s" }; @@ -913,16 +908,11 @@ function SetAppSettingsTest() returns error? { @test:Config { groups: ["APP_SETTINGS", "live_tests"], - enable: isLiveServer, + enable: isLiveServer && devApiKey != "-1", dependsOn: [SetAppSettingsTest] } function GetAppSettingsTest() returns error? { - if devApiKey == "-1" { - log:printInfo("Developer API Key Not Found. Skipping App Retrieving Tests"); - return; - } - EventDetailSettings getResp = check hubspotAppSettingClient->getAppidSettings_getall(check int:fromString(appId).ensureType(int:Signed32));