diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 275c94b..ca90a4a 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,35 +1,35 @@ lockVersion: 2.0.0 id: 9bfe35dd-87f6-4b74-8789-134b7aa9c364 management: - docChecksum: dd3f2cfbe8fe0d218524247e07b527e1 + docChecksum: ff2be01c58ae3e143dfc2bd5a6718ce8 docVersion: "1.0" - speakeasyVersion: 1.484.1 - generationVersion: 2.503.2 - releaseVersion: 0.1.17 - configChecksum: fa8159268cb04ff199d7f763a9ad7919 + speakeasyVersion: 1.513.4 + generationVersion: 2.545.4 + releaseVersion: 0.2.0 + configChecksum: 220e427839ac0c6755ad87719bc75f48 repoURL: https://github.com/novuhq/novu-go.git installationURL: https://github.com/novuhq/novu-go features: go: acceptHeaders: 2.81.2 additionalDependencies: 0.1.0 - constsAndDefaults: 0.1.6 - core: 3.6.12 + constsAndDefaults: 0.1.10 + core: 3.7.2 defaultEnabledRetries: 0.2.0 - deprecations: 2.81.2 + deprecations: 2.81.3 devContainers: 2.90.0 envVarSecurityUsage: 0.3.2 examples: 2.81.4 flattening: 2.81.1 - globalSecurity: 2.82.10 + globalSecurity: 2.82.11 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 globalServerURLs: 2.82.2 groups: 2.81.2 intellisenseMarkdownSupport: 0.1.0 nameOverrides: 2.81.2 - nullables: 0.1.0 - pagination: 2.82.2 + nullables: 0.1.1 + pagination: 2.82.4 responseFormat: 0.1.2 retries: 2.83.2 sdkHooks: 0.1.0 @@ -62,7 +62,6 @@ generatedFiles: - /models/components/channelcredentials.go - /models/components/channelcredentialsdto.go - /models/components/channelctatypeenum.go - - /models/components/channelpreference.go - /models/components/channelsettingsdto.go - /models/components/channeltypeenum.go - /models/components/createdsubscriberdto.go @@ -75,7 +74,6 @@ generatedFiles: - /models/components/delayregularmetadata.go - /models/components/delayscheduledmetadata.go - /models/components/deletemessageresponsedto.go - - /models/components/deletesubscriberresponsedto.go - /models/components/digestmetadatadto.go - /models/components/digestregularmetadata.go - /models/components/digesttimedconfigdto.go @@ -93,7 +91,6 @@ generatedFiles: - /models/components/fieldfilterpartdto.go - /models/components/filtertopicsresponsedto.go - /models/components/getsubscriberpreferencesdto.go - - /models/components/getsubscriberpreferencesresponsedto.go - /models/components/gettopicresponsedto.go - /models/components/globalpreferencedto.go - /models/components/httpmetadata.go @@ -119,16 +116,13 @@ generatedFiles: - /models/components/notificationstepdto.go - /models/components/notificationtrigger.go - /models/components/notificationtriggerdto.go - - /models/components/notificationtriggerresponse.go - /models/components/notificationtriggervariable.go - - /models/components/notificationtriggervariableresponse.go - /models/components/ordinalenum.go - /models/components/ordinalvalueenum.go - /models/components/overrides.go - /models/components/patchpreferencechannelsdto.go - /models/components/patchsubscriberpreferencesdto.go - /models/components/patchsubscriberrequestdto.go - - /models/components/preference.go - /models/components/preferencechannels.go - /models/components/providersidenum.go - /models/components/removesubscriberresponsedto.go @@ -143,7 +137,6 @@ generatedFiles: - /models/components/subscriberfeedresponsedto.go - /models/components/subscriberpayloaddto.go - /models/components/subscriberresponsedto.go - - /models/components/templateresponse.go - /models/components/tenantpayloaddto.go - /models/components/textalignenum.go - /models/components/timedconfig.go @@ -154,19 +147,13 @@ generatedFiles: - /models/components/triggereventresponsedto.go - /models/components/triggereventtoallrequestdto.go - /models/components/triggerrecipientstypeenum.go - - /models/components/triggerreservedvariableresponse.go - - /models/components/triggertypeenum.go - /models/components/unseencountresponse.go - /models/components/updatedsubscriberdto.go - /models/components/updateintegrationrequestdto.go - /models/components/updatesubscriberchannelrequestdto.go - - /models/components/updatesubscriberglobalpreferencesrequestdto.go - /models/components/updatesubscriberonlineflagrequestdto.go - - /models/components/updatesubscriberpreferenceglobalresponsedto.go - - /models/components/updatesubscriberpreferencerequestdto.go - - /models/components/updatesubscriberpreferenceresponsedto.go - - /models/components/updatesubscriberrequestdto.go - /models/components/workflowinfodto.go + - /models/components/workfloworiginenum.go - /models/components/workflowpreferencedto.go - /models/components/workflowresponse.go - /models/operations/eventscontrollerbroadcasteventtoall.go @@ -187,6 +174,7 @@ generatedFiles: - /models/operations/notificationscontrollergetactivitystats.go - /models/operations/notificationscontrollergetnotification.go - /models/operations/notificationscontrollerlistnotifications.go + - /models/operations/subscriberscontrollercreatesubscriber.go - /models/operations/subscriberscontrollergetsubscriber.go - /models/operations/subscriberscontrollergetsubscriberpreferences.go - /models/operations/subscriberscontrollerpatchsubscriber.go @@ -196,24 +184,16 @@ generatedFiles: - /models/operations/subscribersv1controllerbulkcreatesubscribers.go - /models/operations/subscribersv1controllerchataccessoauth.go - /models/operations/subscribersv1controllerchatoauthcallback.go - - /models/operations/subscribersv1controllercreatesubscriber.go - /models/operations/subscribersv1controllerdeletesubscribercredentials.go - /models/operations/subscribersv1controllergetnotificationsfeed.go - - /models/operations/subscribersv1controllergetsubscriber.go - - /models/operations/subscribersv1controllergetsubscriberpreferencebylevel.go - /models/operations/subscribersv1controllergetunseencount.go - - /models/operations/subscribersv1controllerlistsubscriberpreferences.go - /models/operations/subscribersv1controllerlistsubscribers.go - /models/operations/subscribersv1controllermarkactionasseen.go - /models/operations/subscribersv1controllermarkallunreadasread.go - /models/operations/subscribersv1controllermarkmessagesas.go - /models/operations/subscribersv1controllermodifysubscriberchannel.go - - /models/operations/subscribersv1controllerremovesubscriber.go - - /models/operations/subscribersv1controllerupdatesubscriber.go - /models/operations/subscribersv1controllerupdatesubscriberchannel.go - - /models/operations/subscribersv1controllerupdatesubscriberglobalpreferences.go - /models/operations/subscribersv1controllerupdatesubscriberonlineflag.go - - /models/operations/subscribersv1controllerupdatesubscriberpreference.go - /models/operations/topicscontrollerassign.go - /models/operations/topicscontrollercreatetopic.go - /models/operations/topicscontrollerdeletetopic.go @@ -257,7 +237,6 @@ generatedFiles: - docs/models/components/channelcredentials.md - docs/models/components/channelcredentialsdto.md - docs/models/components/channelctatypeenum.md - - docs/models/components/channelpreference.md - docs/models/components/channels.md - docs/models/components/channelsettingsdto.md - docs/models/components/channelsettingsdtoproviderid.md @@ -269,7 +248,6 @@ generatedFiles: - docs/models/components/createintegrationrequestdto.md - docs/models/components/createintegrationrequestdtochannel.md - docs/models/components/createsubscriberrequestdto.md - - docs/models/components/createsubscriberrequestdtodata.md - docs/models/components/createtopicrequestdto.md - docs/models/components/createtopicresponsedto.md - docs/models/components/credentialsdto.md @@ -282,8 +260,6 @@ generatedFiles: - docs/models/components/delayscheduledmetadatatype.md - docs/models/components/deletemessageresponsedto.md - docs/models/components/deletemessageresponsedtostatus.md - - docs/models/components/deletesubscriberresponsedto.md - - docs/models/components/deletesubscriberresponsedtostatus.md - docs/models/components/digestmetadatadto.md - docs/models/components/digestregularmetadata.md - docs/models/components/digestregularmetadatatype.md @@ -306,7 +282,6 @@ generatedFiles: - docs/models/components/fieldfilterpartdto.md - docs/models/components/filtertopicsresponsedto.md - docs/models/components/getsubscriberpreferencesdto.md - - docs/models/components/getsubscriberpreferencesresponsedto.md - docs/models/components/gettopicresponsedto.md - docs/models/components/globalpreferencedto.md - docs/models/components/httpmetadata.md @@ -346,12 +321,8 @@ generatedFiles: - docs/models/components/notificationstepdtometadata.md - docs/models/components/notificationtrigger.md - docs/models/components/notificationtriggerdto.md - - docs/models/components/notificationtriggerresponse.md - docs/models/components/notificationtriggertype.md - docs/models/components/notificationtriggervariable.md - - docs/models/components/notificationtriggervariableresponse.md - - docs/models/components/notificationtriggervariableresponsetype.md - - docs/models/components/notificationtriggervariableresponsevalue.md - docs/models/components/on.md - docs/models/components/one.md - docs/models/components/operator.md @@ -366,7 +337,6 @@ generatedFiles: - docs/models/components/patchsubscriberrequestdto.md - docs/models/components/patchsubscriberrequestdtodata.md - docs/models/components/payload.md - - docs/models/components/preference.md - docs/models/components/preferencechannels.md - docs/models/components/providerid.md - docs/models/components/providersidenum.md @@ -384,7 +354,6 @@ generatedFiles: - docs/models/components/subscriberfeedresponsedto.md - docs/models/components/subscriberpayloaddto.md - docs/models/components/subscriberresponsedto.md - - docs/models/components/templateresponse.md - docs/models/components/tenant.md - docs/models/components/tenantpayloaddto.md - docs/models/components/tenantpayloaddtodata.md @@ -403,9 +372,6 @@ generatedFiles: - docs/models/components/triggereventtoallrequestdtooverrides.md - docs/models/components/triggereventtoallrequestdtotenant.md - docs/models/components/triggerrecipientstypeenum.md - - docs/models/components/triggerreservedvariableresponse.md - - docs/models/components/triggerreservedvariableresponsetype.md - - docs/models/components/triggertypeenum.md - docs/models/components/type.md - docs/models/components/unit.md - docs/models/components/unseencountresponse.md @@ -413,16 +379,12 @@ generatedFiles: - docs/models/components/updateintegrationrequestdto.md - docs/models/components/updatesubscriberchannelrequestdto.md - docs/models/components/updatesubscriberchannelrequestdtoproviderid.md - - docs/models/components/updatesubscriberglobalpreferencesrequestdto.md - docs/models/components/updatesubscriberonlineflagrequestdto.md - - docs/models/components/updatesubscriberpreferenceglobalresponsedto.md - - docs/models/components/updatesubscriberpreferencerequestdto.md - - docs/models/components/updatesubscriberpreferenceresponsedto.md - - docs/models/components/updatesubscriberrequestdto.md - docs/models/components/value.md - docs/models/components/weekdays.md - docs/models/components/workflowinfodto.md - docs/models/components/workflowintegrationstatus.md + - docs/models/components/workfloworiginenum.md - docs/models/components/workflowpreferencedto.md - docs/models/components/workflowresponse.md - docs/models/components/workflowresponsedata.md @@ -465,7 +427,8 @@ generatedFiles: - docs/models/operations/notificationscontrollerlistnotificationsresponse.md - docs/models/operations/option.md - docs/models/operations/orderdirection.md - - docs/models/operations/parameter.md + - docs/models/operations/subscriberscontrollercreatesubscriberrequest.md + - docs/models/operations/subscriberscontrollercreatesubscriberresponse.md - docs/models/operations/subscriberscontrollergetsubscriberpreferencesrequest.md - docs/models/operations/subscriberscontrollergetsubscriberpreferencesresponse.md - docs/models/operations/subscriberscontrollergetsubscriberrequest.md @@ -484,20 +447,12 @@ generatedFiles: - docs/models/operations/subscribersv1controllerchataccessoauthresponse.md - docs/models/operations/subscribersv1controllerchatoauthcallbackrequest.md - docs/models/operations/subscribersv1controllerchatoauthcallbackresponse.md - - docs/models/operations/subscribersv1controllercreatesubscriberrequest.md - - docs/models/operations/subscribersv1controllercreatesubscriberresponse.md - docs/models/operations/subscribersv1controllerdeletesubscribercredentialsrequest.md - docs/models/operations/subscribersv1controllerdeletesubscribercredentialsresponse.md - docs/models/operations/subscribersv1controllergetnotificationsfeedrequest.md - docs/models/operations/subscribersv1controllergetnotificationsfeedresponse.md - - docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelrequest.md - - docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelresponse.md - - docs/models/operations/subscribersv1controllergetsubscriberrequest.md - - docs/models/operations/subscribersv1controllergetsubscriberresponse.md - docs/models/operations/subscribersv1controllergetunseencountrequest.md - docs/models/operations/subscribersv1controllergetunseencountresponse.md - - docs/models/operations/subscribersv1controllerlistsubscriberpreferencesrequest.md - - docs/models/operations/subscribersv1controllerlistsubscriberpreferencesresponse.md - docs/models/operations/subscribersv1controllerlistsubscribersrequest.md - docs/models/operations/subscribersv1controllerlistsubscribersresponse.md - docs/models/operations/subscribersv1controllerlistsubscribersresponsebody.md @@ -509,18 +464,10 @@ generatedFiles: - docs/models/operations/subscribersv1controllermarkmessagesasresponse.md - docs/models/operations/subscribersv1controllermodifysubscriberchannelrequest.md - docs/models/operations/subscribersv1controllermodifysubscriberchannelresponse.md - - docs/models/operations/subscribersv1controllerremovesubscriberrequest.md - - docs/models/operations/subscribersv1controllerremovesubscriberresponse.md - docs/models/operations/subscribersv1controllerupdatesubscriberchannelrequest.md - docs/models/operations/subscribersv1controllerupdatesubscriberchannelresponse.md - - docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesrequest.md - - docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesresponse.md - docs/models/operations/subscribersv1controllerupdatesubscriberonlineflagrequest.md - docs/models/operations/subscribersv1controllerupdatesubscriberonlineflagresponse.md - - docs/models/operations/subscribersv1controllerupdatesubscriberpreferencerequest.md - - docs/models/operations/subscribersv1controllerupdatesubscriberpreferenceresponse.md - - docs/models/operations/subscribersv1controllerupdatesubscriberrequest.md - - docs/models/operations/subscribersv1controllerupdatesubscriberresponse.md - docs/models/operations/topicscontrollerassignrequest.md - docs/models/operations/topicscontrollerassignresponse.md - docs/models/operations/topicscontrollercreatetopicrequest.md @@ -540,7 +487,6 @@ generatedFiles: - docs/sdks/authentication/README.md - docs/sdks/credentials/README.md - docs/sdks/integrations/README.md - - docs/sdks/legacy/README.md - docs/sdks/messages/README.md - docs/sdks/notifications/README.md - docs/sdks/novu/README.md @@ -567,7 +513,6 @@ generatedFiles: - internal/utils/retries.go - internal/utils/security.go - internal/utils/utils.go - - legacy.go - messages.go - models/apierrors/apierror.go - models/operations/options.go @@ -656,6 +601,7 @@ examples: parameters: query: page: 0 + limit: 10 header: {} responses: "200": @@ -845,6 +791,10 @@ examples: application/json: {"statusCode": 404, "timestamp": "2024-12-12T13:00:00Z", "path": "/api/v1/resource", "message": "Resource not found.", "ctx": {"workflowId": "some_wf_id", "stepId": "some_wf_id"}, "errorId": "abc123"} "422": application/json: {"statusCode": 404, "timestamp": "2024-12-12T13:00:00Z", "path": "/api/v1/resource", "message": "Resource not found.", "ctx": {"workflowId": "some_wf_id", "stepId": "some_wf_id"}, "errorId": "abc123", "errors": {"fieldName1": {"messages": ["Field is required", "Invalid format"], "value": "xx xx xx "}, "fieldName2": {"messages": ["Field is required", "Invalid format"], "value": "xx xx xx "}, "fieldName3": {"messages": ["Field is required", "Invalid format"], "value": "xx xx xx "}, "fieldName4": {"messages": ["Field is required", "Invalid format"], "value": "xx xx xx "}}} + "414": + application/json: {"statusCode": 404, "timestamp": "2024-12-12T13:00:00Z", "path": "/api/v1/resource", "message": "Resource not found.", "ctx": {"workflowId": "some_wf_id", "stepId": "some_wf_id"}, "errorId": "abc123"} + "500": + application/json: {"statusCode": 404, "timestamp": "2024-12-12T13:00:00Z", "path": "/api/v1/resource", "message": "Resource not found.", "ctx": {"workflowId": "some_wf_id", "stepId": "some_wf_id"}, "errorId": "abc123"} SubscribersController_getSubscriber: speakeasy-default-subscribers-controller-get-subscriber: parameters: diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 337962d..3691f2b 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -10,13 +10,15 @@ generation: useClassNamesForArrayFields: true fixes: nameResolutionDec2023: true + nameResolutionFeb2025: false parameterOrderingFeb2024: true requestResponseComponentNamesFeb2024: true + securityFeb2025: false auth: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: true go: - version: 0.1.17 + version: 0.2.0 additionalDependencies: github.com/google/uuid: v1.6.0 allowUnknownFieldsInWeakUnions: false diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 5af8747..ed3d9fb 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.484.1 +speakeasyVersion: 1.513.4 sources: novu-OAS: sourceNamespace: novu-oas - sourceRevisionDigest: sha256:4c24d7f0521c19a0dac957d4dd5d0fef332b7d5d78d3a3bdd61919c97f458985 - sourceBlobDigest: sha256:ed8d604243cb071fbd8ccd32366dc185a7381706079566388a6fb1d014368863 + sourceRevisionDigest: sha256:9fd52284a610154d1ba82d5a0bfb3e93c0f42edef9b457795d8cfc3d4cf1fb67 + sourceBlobDigest: sha256:781dfb73f9f926de61c2d4ba88d8f28089f682f79772e5b08527e1d8ac1ebe52 tags: - latest - - speakeasy-sdk-regen-1738714379 + - speakeasy-sdk-regen-1738887199 - "1.0" targets: novu: source: novu-OAS sourceNamespace: novu-oas - sourceRevisionDigest: sha256:4c24d7f0521c19a0dac957d4dd5d0fef332b7d5d78d3a3bdd61919c97f458985 - sourceBlobDigest: sha256:ed8d604243cb071fbd8ccd32366dc185a7381706079566388a6fb1d014368863 + sourceRevisionDigest: sha256:9fd52284a610154d1ba82d5a0bfb3e93c0f42edef9b457795d8cfc3d4cf1fb67 + sourceBlobDigest: sha256:781dfb73f9f926de61c2d4ba88d8f28089f682f79772e5b08527e1d8ac1ebe52 codeSamplesNamespace: novu-oas-go-code-samples - codeSamplesRevisionDigest: sha256:adef743b4471ef98f4d3b1ce1497bd385f6c1be4551a1306bdc38bd30025725e + codeSamplesRevisionDigest: sha256:cbe51c37e6fedf8b9daa69bb5e7e4fb4a70ab817dd39f5153a2fad6fe3ddc6d7 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index 0ea7a91..e562dd2 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Developer-friendly & type-safe Go SDK specifically catered to leverage Novu API. ## Summary -Novu API: Novu REST API. Please see [Api reference](https://docs.novu.co/api-reference) for more details. +Novu API: Novu REST API. Please see https://docs.novu.co/api-reference for more details. For more information about the API: [Novu Documentation](https://docs.novu.co) @@ -25,7 +25,7 @@ For more information about the API: [Novu Documentation](https://docs.novu.co) ## Table of Contents -* [github.com/novuhq/novu-go](#githubcomnovuhqnovu-go) +* [Novu's API v2 Go SDK](#novus-api-v2-go-sdk) * [SDK Installation](#sdk-installation) * [SDK Example Usage](#sdk-example-usage) * [Authentication](#authentication) @@ -36,7 +36,6 @@ For more information about the API: [Novu Documentation](https://docs.novu.co) * [Server Selection](#server-selection) * [Custom HTTP Client](#custom-http-client) * [Development](#development) - * [Maturity](#maturity) * [Contributions](#contributions) @@ -63,14 +62,13 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -114,14 +112,13 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.TriggerBulk(ctx, components.BulkTriggerEventDto{ @@ -221,14 +218,13 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.TriggerBroadcast(ctx, components.TriggerEventToAllRequestDto{ @@ -259,14 +255,13 @@ import ( "context" novugo "github.com/novuhq/novu-go" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Cancel(ctx, "", nil) @@ -301,14 +296,13 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -388,12 +382,9 @@ func main() { ### [Subscribers](docs/sdks/subscribers/README.md) * [List](docs/sdks/subscribers/README.md#list) - Get subscribers -* [Create](docs/sdks/subscribers/README.md#create) - Create subscriber -* [RetrieveLegacy](docs/sdks/subscribers/README.md#retrievelegacy) - Get subscriber -* [UpdateLegacy](docs/sdks/subscribers/README.md#updatelegacy) - Update subscriber -* [~~DeleteLegacy~~](docs/sdks/subscribers/README.md#deletelegacy) - Delete subscriber :warning: **Deprecated** * [CreateBulk](docs/sdks/subscribers/README.md#createbulk) - Bulk create subscribers * [Search](docs/sdks/subscribers/README.md#search) - Search for subscribers +* [Create](docs/sdks/subscribers/README.md#create) - Create subscriber * [Retrieve](docs/sdks/subscribers/README.md#retrieve) - Get subscriber * [Patch](docs/sdks/subscribers/README.md#patch) - Patch subscriber * [Delete](docs/sdks/subscribers/README.md#delete) - Delete subscriber @@ -422,16 +413,9 @@ func main() { #### [Subscribers.Preferences](docs/sdks/preferences/README.md) -* [~~ListLegacy~~](docs/sdks/preferences/README.md#listlegacy) - Get subscriber preferences :warning: **Deprecated** -* [~~RetrieveByLevelLegacy~~](docs/sdks/preferences/README.md#retrievebylevellegacy) - Get subscriber preferences by level :warning: **Deprecated** -* [UpdateLegacy](docs/sdks/preferences/README.md#updatelegacy) - Update subscriber preference -* [Retrieve](docs/sdks/preferences/README.md#retrieve) - Get subscriber preferences +* [List](docs/sdks/preferences/README.md#list) - Get subscriber preferences * [Update](docs/sdks/preferences/README.md#update) - Update subscriber global or workflow specific preferences -#### [Subscribers.Preferences.Legacy](docs/sdks/legacy/README.md) - -* [UpdateGlobal](docs/sdks/legacy/README.md#updateglobal) - Update subscriber global preferences - #### [Subscribers.Properties](docs/sdks/properties/README.md) * [UpdateOnlineFlag](docs/sdks/properties/README.md#updateonlineflag) - Update subscriber online status @@ -468,14 +452,13 @@ import ( "context" novugo "github.com/novuhq/novu-go" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.List(ctx, nil, nil, nil) @@ -518,14 +501,13 @@ import ( "github.com/novuhq/novu-go/retry" "log" "models/operations" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -579,7 +561,6 @@ import ( "github.com/novuhq/novu-go/models/components" "github.com/novuhq/novu-go/retry" "log" - "os" ) func main() { @@ -597,7 +578,7 @@ func main() { }, RetryConnectionErrors: false, }), - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -661,14 +642,13 @@ import ( "github.com/novuhq/novu-go/models/apierrors" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -736,10 +716,10 @@ func main() { You can override the default server globally using the `WithServerIndex(serverIndex int)` option when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: -| # | Server | -| --- | ------------------------ | -| 0 | `https://api.novu.co` | -| 1 | `https://eu.api.novu.co` | +| # | Server | Description | +| --- | ------------------------ | ----------- | +| 0 | `https://api.novu.co` | | +| 1 | `https://eu.api.novu.co` | | #### Example @@ -751,7 +731,6 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { @@ -759,7 +738,7 @@ func main() { s := novugo.New( novugo.WithServerIndex(1), - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -804,7 +783,6 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { @@ -812,7 +790,7 @@ func main() { s := novugo.New( novugo.WithServerURL("https://api.novu.co"), - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ diff --git a/RELEASES.md b/RELEASES.md index c9e24b1..eecf4e1 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -68,4 +68,14 @@ Based on: ### Generated - [go v0.1.17] . ### Releases -- [Go v0.1.17] https://github.com/novuhq/novu-go/releases/tag/v0.1.17 - . \ No newline at end of file +- [Go v0.1.17] https://github.com/novuhq/novu-go/releases/tag/v0.1.17 - . + +## 2025-03-08 00:10:44 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.513.4 (2.545.4) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.2.0] . +### Releases +- [Go v0.2.0] https://github.com/novuhq/novu-go/releases/tag/v0.2.0 - . \ No newline at end of file diff --git a/USAGE.md b/USAGE.md index 58eb3e4..57e4760 100644 --- a/USAGE.md +++ b/USAGE.md @@ -9,14 +9,13 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -60,14 +59,13 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.TriggerBulk(ctx, components.BulkTriggerEventDto{ @@ -167,14 +165,13 @@ import ( novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.TriggerBroadcast(ctx, components.TriggerEventToAllRequestDto{ @@ -205,14 +202,13 @@ import ( "context" novugo "github.com/novuhq/novu-go" "log" - "os" ) func main() { ctx := context.Background() s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Cancel(ctx, "", nil) diff --git a/authentication.go b/authentication.go index 82e2930..61e5cf2 100644 --- a/authentication.go +++ b/authentication.go @@ -27,13 +27,6 @@ func newAuthentication(sdkConfig sdkConfiguration) *Authentication { // ChatAccessOauthCallBack - Handle providers oauth redirect func (s *Authentication) ChatAccessOauthCallBack(ctx context.Context, request operations.SubscribersV1ControllerChatOauthCallbackRequest, opts ...operations.Option) (*operations.SubscribersV1ControllerChatOauthCallbackResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_chatOauthCallback", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -58,6 +51,14 @@ func (s *Authentication) ChatAccessOauthCallBack(ctx context.Context, request op return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_chatOauthCallback", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -387,13 +388,6 @@ func (s *Authentication) ChatAccessOauthCallBack(ctx context.Context, request op // ChatAccessOauth - Handle chat oauth func (s *Authentication) ChatAccessOauth(ctx context.Context, request operations.SubscribersV1ControllerChatAccessOauthRequest, opts ...operations.Option) (*operations.SubscribersV1ControllerChatAccessOauthResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_chatAccessOauth", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -417,6 +411,14 @@ func (s *Authentication) ChatAccessOauth(ctx context.Context, request operations return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_chatAccessOauth", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/credentials.go b/credentials.go index ca16674..f46ab0d 100644 --- a/credentials.go +++ b/credentials.go @@ -28,13 +28,6 @@ func newCredentials(sdkConfig sdkConfiguration) *Credentials { // Update subscriber credentials // Subscriber credentials associated to the delivery methods such as slack and push tokens. func (s *Credentials) Update(ctx context.Context, subscriberID string, updateSubscriberChannelRequestDto components.UpdateSubscriberChannelRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerUpdateSubscriberChannelResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_updateSubscriberChannel", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerUpdateSubscriberChannelRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, @@ -64,6 +57,13 @@ func (s *Credentials) Update(ctx context.Context, subscriberID string, updateSub return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_updateSubscriberChannel", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpdateSubscriberChannelRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -376,13 +376,6 @@ func (s *Credentials) Update(ctx context.Context, subscriberID string, updateSub // // This endpoint appends provided credentials and deviceTokens to the existing ones. func (s *Credentials) Append(ctx context.Context, subscriberID string, updateSubscriberChannelRequestDto components.UpdateSubscriberChannelRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerModifySubscriberChannelResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_modifySubscriberChannel", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerModifySubscriberChannelRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, @@ -412,6 +405,13 @@ func (s *Credentials) Append(ctx context.Context, subscriberID string, updateSub return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_modifySubscriberChannel", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpdateSubscriberChannelRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -722,13 +722,6 @@ func (s *Credentials) Append(ctx context.Context, subscriberID string, updateSub // Delete subscriber credentials by providerId // Delete subscriber credentials such as slack and expo tokens. func (s *Credentials) Delete(ctx context.Context, subscriberID string, providerID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerDeleteSubscriberCredentialsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_deleteSubscriberCredentials", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerDeleteSubscriberCredentialsRequest{ SubscriberID: subscriberID, ProviderID: providerID, @@ -758,6 +751,14 @@ func (s *Credentials) Delete(ctx context.Context, subscriberID string, providerI return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_deleteSubscriberCredentials", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/docs/models/components/activitynotificationtemplateresponsedto.md b/docs/models/components/activitynotificationtemplateresponsedto.md index 2991ae4..6029a57 100644 --- a/docs/models/components/activitynotificationtemplateresponsedto.md +++ b/docs/models/components/activitynotificationtemplateresponsedto.md @@ -7,4 +7,5 @@ | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | | `ID` | **string* | :heavy_minus_sign: | Unique identifier of the template | | `Name` | *string* | :heavy_check_mark: | Name of the template | +| `Origin` | [*components.WorkflowOriginEnum](../../models/components/workfloworiginenum.md) | :heavy_minus_sign: | Origin of the workflow | | `Triggers` | [][components.NotificationTriggerDto](../../models/components/notificationtriggerdto.md) | :heavy_check_mark: | Triggers of the template | \ No newline at end of file diff --git a/docs/models/components/channelpreference.md b/docs/models/components/channelpreference.md deleted file mode 100644 index 68c057b..0000000 --- a/docs/models/components/channelpreference.md +++ /dev/null @@ -1,9 +0,0 @@ -# ChannelPreference - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | -| `Type` | [components.ChannelTypeEnum](../../models/components/channeltypeenum.md) | :heavy_check_mark: | Channel type through which the message is sent | -| `Enabled` | *bool* | :heavy_check_mark: | If channel is enabled or not | \ No newline at end of file diff --git a/docs/models/components/createsubscriberrequestdto.md b/docs/models/components/createsubscriberrequestdto.md index 4a584fa..d030430 100644 --- a/docs/models/components/createsubscriberrequestdto.md +++ b/docs/models/components/createsubscriberrequestdto.md @@ -3,14 +3,14 @@ ## Fields -| Field | Type | Required | Description | -| ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -| `SubscriberID` | *string* | :heavy_check_mark: | The internal identifier you used to create this subscriber, usually correlates to the id the user in your systems | -| `Email` | **string* | :heavy_minus_sign: | The email address of the subscriber. | -| `FirstName` | **string* | :heavy_minus_sign: | The first name of the subscriber. | -| `LastName` | **string* | :heavy_minus_sign: | The last name of the subscriber. | -| `Phone` | **string* | :heavy_minus_sign: | The phone number of the subscriber. | -| `Avatar` | **string* | :heavy_minus_sign: | An HTTP URL to the profile image of your subscriber. | -| `Locale` | **string* | :heavy_minus_sign: | The locale of the subscriber. | -| `Data` | map[string][components.CreateSubscriberRequestDtoData](../../models/components/createsubscriberrequestdtodata.md) | :heavy_minus_sign: | An optional payload object that can contain any properties. | -| `Channels` | [][components.SubscriberChannelDto](../../models/components/subscriberchanneldto.md) | :heavy_minus_sign: | An optional array of subscriber channels. | \ No newline at end of file +| Field | Type | Required | Description | +| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | +| `SubscriberID` | *string* | :heavy_check_mark: | Unique identifier of the subscriber | +| `FirstName` | **string* | :heavy_minus_sign: | First name of the subscriber | +| `LastName` | **string* | :heavy_minus_sign: | Last name of the subscriber | +| `Email` | **string* | :heavy_minus_sign: | Email address of the subscriber | +| `Phone` | **string* | :heavy_minus_sign: | Phone number of the subscriber | +| `Avatar` | **string* | :heavy_minus_sign: | Avatar URL or identifier | +| `Timezone` | **string* | :heavy_minus_sign: | Timezone of the subscriber | +| `Locale` | **string* | :heavy_minus_sign: | Locale of the subscriber | +| `Data` | map[string]*any* | :heavy_minus_sign: | Additional custom data for the subscriber | \ No newline at end of file diff --git a/docs/models/components/createsubscriberrequestdtodata.md b/docs/models/components/createsubscriberrequestdtodata.md deleted file mode 100644 index 326ab0a..0000000 --- a/docs/models/components/createsubscriberrequestdtodata.md +++ /dev/null @@ -1,29 +0,0 @@ -# CreateSubscriberRequestDtoData - - -## Supported Types - -### - -```go -createSubscriberRequestDtoData := components.CreateCreateSubscriberRequestDtoDataStr(string{/* values here */}) -``` - -### - -```go -createSubscriberRequestDtoData := components.CreateCreateSubscriberRequestDtoDataArrayOfStr([]string{/* values here */}) -``` - -### - -```go -createSubscriberRequestDtoData := components.CreateCreateSubscriberRequestDtoDataBoolean(bool{/* values here */}) -``` - -### - -```go -createSubscriberRequestDtoData := components.CreateCreateSubscriberRequestDtoDataNumber(float64{/* values here */}) -``` - diff --git a/docs/models/components/deletesubscriberresponsedto.md b/docs/models/components/deletesubscriberresponsedto.md deleted file mode 100644 index 587590c..0000000 --- a/docs/models/components/deletesubscriberresponsedto.md +++ /dev/null @@ -1,9 +0,0 @@ -# DeleteSubscriberResponseDto - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | -| `Acknowledged` | *bool* | :heavy_check_mark: | A boolean stating the success of the action | -| `Status` | [components.DeleteSubscriberResponseDtoStatus](../../models/components/deletesubscriberresponsedtostatus.md) | :heavy_check_mark: | The status enum for the performed action | \ No newline at end of file diff --git a/docs/models/components/deletesubscriberresponsedtostatus.md b/docs/models/components/deletesubscriberresponsedtostatus.md deleted file mode 100644 index 0492dee..0000000 --- a/docs/models/components/deletesubscriberresponsedtostatus.md +++ /dev/null @@ -1,10 +0,0 @@ -# DeleteSubscriberResponseDtoStatus - -The status enum for the performed action - - -## Values - -| Name | Value | -| ------------------------------------------ | ------------------------------------------ | -| `DeleteSubscriberResponseDtoStatusDeleted` | deleted | \ No newline at end of file diff --git a/docs/models/components/getsubscriberpreferencesresponsedto.md b/docs/models/components/getsubscriberpreferencesresponsedto.md deleted file mode 100644 index 59a0183..0000000 --- a/docs/models/components/getsubscriberpreferencesresponsedto.md +++ /dev/null @@ -1,9 +0,0 @@ -# GetSubscriberPreferencesResponseDto - - -## Fields - -| Field | Type | Required | Description | -| --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | -| `Template` | [*components.TemplateResponse](../../models/components/templateresponse.md) | :heavy_minus_sign: | The workflow information and if it is critical or not | -| `Preference` | [components.Preference](../../models/components/preference.md) | :heavy_check_mark: | The preferences of the subscriber regarding the related workflow | \ No newline at end of file diff --git a/docs/models/components/notificationtriggerresponse.md b/docs/models/components/notificationtriggerresponse.md deleted file mode 100644 index 7871da0..0000000 --- a/docs/models/components/notificationtriggerresponse.md +++ /dev/null @@ -1,12 +0,0 @@ -# NotificationTriggerResponse - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| `Type` | [components.TriggerTypeEnum](../../models/components/triggertypeenum.md) | :heavy_check_mark: | The type of the trigger | -| `Identifier` | *string* | :heavy_check_mark: | The identifier of the trigger | -| `Variables` | [][components.NotificationTriggerVariableResponse](../../models/components/notificationtriggervariableresponse.md) | :heavy_check_mark: | The variables of the trigger | -| `SubscriberVariables` | [][components.NotificationTriggerVariableResponse](../../models/components/notificationtriggervariableresponse.md) | :heavy_minus_sign: | The subscriber variables of the trigger | -| `ReservedVariables` | [][components.TriggerReservedVariableResponse](../../models/components/triggerreservedvariableresponse.md) | :heavy_minus_sign: | The reserved variables of the trigger | \ No newline at end of file diff --git a/docs/models/components/notificationtriggervariableresponse.md b/docs/models/components/notificationtriggervariableresponse.md deleted file mode 100644 index ac80e78..0000000 --- a/docs/models/components/notificationtriggervariableresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# NotificationTriggerVariableResponse - - -## Fields - -| Field | Type | Required | Description | -| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | -| `Name` | *string* | :heavy_check_mark: | The name of the variable | -| `Value` | [*components.NotificationTriggerVariableResponseValue](../../models/components/notificationtriggervariableresponsevalue.md) | :heavy_minus_sign: | The value of the variable | -| `Type` | [*components.NotificationTriggerVariableResponseType](../../models/components/notificationtriggervariableresponsetype.md) | :heavy_minus_sign: | The type of the variable | \ No newline at end of file diff --git a/docs/models/components/notificationtriggervariableresponsetype.md b/docs/models/components/notificationtriggervariableresponsetype.md deleted file mode 100644 index 376350e..0000000 --- a/docs/models/components/notificationtriggervariableresponsetype.md +++ /dev/null @@ -1,12 +0,0 @@ -# NotificationTriggerVariableResponseType - -The type of the variable - - -## Values - -| Name | Value | -| ------------------------------------------------ | ------------------------------------------------ | -| `NotificationTriggerVariableResponseTypeString` | String | -| `NotificationTriggerVariableResponseTypeArray` | Array | -| `NotificationTriggerVariableResponseTypeBoolean` | Boolean | \ No newline at end of file diff --git a/docs/models/components/notificationtriggervariableresponsevalue.md b/docs/models/components/notificationtriggervariableresponsevalue.md deleted file mode 100644 index d47837e..0000000 --- a/docs/models/components/notificationtriggervariableresponsevalue.md +++ /dev/null @@ -1,9 +0,0 @@ -# NotificationTriggerVariableResponseValue - -The value of the variable - - -## Fields - -| Field | Type | Required | Description | -| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/docs/models/components/patchsubscriberrequestdto.md b/docs/models/components/patchsubscriberrequestdto.md index d6c56f5..34f88fb 100644 --- a/docs/models/components/patchsubscriberrequestdto.md +++ b/docs/models/components/patchsubscriberrequestdto.md @@ -5,7 +5,6 @@ | Field | Type | Required | Description | | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | -| `SubscriberID` | **string* | :heavy_minus_sign: | Unique identifier of the subscriber | | `FirstName` | **string* | :heavy_minus_sign: | First name of the subscriber | | `LastName` | **string* | :heavy_minus_sign: | Last name of the subscriber | | `Email` | **string* | :heavy_minus_sign: | Email address of the subscriber | diff --git a/docs/models/components/preference.md b/docs/models/components/preference.md deleted file mode 100644 index 972d18c..0000000 --- a/docs/models/components/preference.md +++ /dev/null @@ -1,9 +0,0 @@ -# Preference - - -## Fields - -| Field | Type | Required | Description | -| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | -| `Enabled` | *bool* | :heavy_check_mark: | Sets if the workflow is fully enabled for all channels or not for the subscriber. | -| `Channels` | [components.PreferenceChannels](../../models/components/preferencechannels.md) | :heavy_check_mark: | Subscriber preferences for the different channels regarding this workflow | \ No newline at end of file diff --git a/docs/models/components/security.md b/docs/models/components/security.md index 40e3b11..c6f983c 100644 --- a/docs/models/components/security.md +++ b/docs/models/components/security.md @@ -3,6 +3,6 @@ ## Fields -| Field | Type | Required | Description | -| ------------------ | ------------------ | ------------------ | ------------------ | -| `SecretKey` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file +| Field | Type | Required | Description | Example | +| -------------------- | -------------------- | -------------------- | -------------------- | -------------------- | +| `SecretKey` | **string* | :heavy_minus_sign: | N/A | YOUR_SECRET_KEY_HERE | \ No newline at end of file diff --git a/docs/models/components/status.md b/docs/models/components/status.md index 27a8cc4..db17c5b 100644 --- a/docs/models/components/status.md +++ b/docs/models/components/status.md @@ -12,4 +12,5 @@ Status of the trigger | `StatusNoWorkflowActiveStepsDefined` | no_workflow_active_steps_defined | | `StatusNoWorkflowStepsDefined` | no_workflow_steps_defined | | `StatusProcessed` | processed | -| `StatusNoTenantFound` | no_tenant_found | \ No newline at end of file +| `StatusNoTenantFound` | no_tenant_found | +| `StatusInvalidRecipients` | invalid_recipients | \ No newline at end of file diff --git a/docs/models/components/subscriberpayloaddto.md b/docs/models/components/subscriberpayloaddto.md index 68a76b9..0e8ce0e 100644 --- a/docs/models/components/subscriberpayloaddto.md +++ b/docs/models/components/subscriberpayloaddto.md @@ -13,4 +13,5 @@ | `Avatar` | **string* | :heavy_minus_sign: | An HTTP URL to the profile image of your subscriber. | | `Locale` | **string* | :heavy_minus_sign: | The locale of the subscriber. | | `Data` | map[string][components.Data](../../models/components/data.md) | :heavy_minus_sign: | An optional payload object that can contain any properties. | -| `Channels` | [][components.SubscriberChannelDto](../../models/components/subscriberchanneldto.md) | :heavy_minus_sign: | An optional array of subscriber channels. | \ No newline at end of file +| `Channels` | [][components.SubscriberChannelDto](../../models/components/subscriberchanneldto.md) | :heavy_minus_sign: | An optional array of subscriber channels. | +| `Timezone` | **string* | :heavy_minus_sign: | The timezone of the subscriber. | \ No newline at end of file diff --git a/docs/models/components/subscriberresponsedto.md b/docs/models/components/subscriberresponsedto.md index f4275ed..9ab1e6e 100644 --- a/docs/models/components/subscriberresponsedto.md +++ b/docs/models/components/subscriberresponsedto.md @@ -23,4 +23,5 @@ | `CreatedAt` | *string* | :heavy_check_mark: | The timestamp indicating when the subscriber was created, in ISO 8601 format. | | `UpdatedAt` | *string* | :heavy_check_mark: | The timestamp indicating when the subscriber was last updated, in ISO 8601 format. | | `V` | **float64* | :heavy_minus_sign: | The version of the subscriber document. | -| `Data` | map[string]*any* | :heavy_minus_sign: | Additional custom data for the subscriber | \ No newline at end of file +| `Data` | map[string]*any* | :heavy_minus_sign: | Additional custom data for the subscriber | +| `Timezone` | **string* | :heavy_minus_sign: | Timezone of the subscriber | \ No newline at end of file diff --git a/docs/models/components/templateresponse.md b/docs/models/components/templateresponse.md deleted file mode 100644 index 1dc9008..0000000 --- a/docs/models/components/templateresponse.md +++ /dev/null @@ -1,11 +0,0 @@ -# TemplateResponse - - -## Fields - -| Field | Type | Required | Description | -| ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | -| `ID` | *string* | :heavy_check_mark: | Unique identifier of the workflow | -| `Name` | *string* | :heavy_check_mark: | Name of the workflow | -| `Critical` | *bool* | :heavy_check_mark: | Critical templates will always be delivered to the end user and should be hidden from the subscriber preferences screen | -| `Triggers` | [][components.NotificationTriggerResponse](../../models/components/notificationtriggerresponse.md) | :heavy_check_mark: | Triggers are the events that will trigger the workflow. | \ No newline at end of file diff --git a/docs/models/components/triggerreservedvariableresponse.md b/docs/models/components/triggerreservedvariableresponse.md deleted file mode 100644 index 3c7864f..0000000 --- a/docs/models/components/triggerreservedvariableresponse.md +++ /dev/null @@ -1,9 +0,0 @@ -# TriggerReservedVariableResponse - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | -| `Type` | [components.TriggerReservedVariableResponseType](../../models/components/triggerreservedvariableresponsetype.md) | :heavy_check_mark: | The type of the reserved variable | -| `Variables` | []*string* | :heavy_check_mark: | The reserved variables of the trigger | \ No newline at end of file diff --git a/docs/models/components/triggerreservedvariableresponsetype.md b/docs/models/components/triggerreservedvariableresponsetype.md deleted file mode 100644 index 79aba6a..0000000 --- a/docs/models/components/triggerreservedvariableresponsetype.md +++ /dev/null @@ -1,11 +0,0 @@ -# TriggerReservedVariableResponseType - -The type of the reserved variable - - -## Values - -| Name | Value | -| ------------------------------------------- | ------------------------------------------- | -| `TriggerReservedVariableResponseTypeTenant` | tenant | -| `TriggerReservedVariableResponseTypeActor` | actor | \ No newline at end of file diff --git a/docs/models/components/triggertypeenum.md b/docs/models/components/triggertypeenum.md deleted file mode 100644 index 219204a..0000000 --- a/docs/models/components/triggertypeenum.md +++ /dev/null @@ -1,10 +0,0 @@ -# TriggerTypeEnum - -The type of the trigger - - -## Values - -| Name | Value | -| ---------------------- | ---------------------- | -| `TriggerTypeEnumEvent` | event | \ No newline at end of file diff --git a/docs/models/components/updatesubscriberglobalpreferencesrequestdto.md b/docs/models/components/updatesubscriberglobalpreferencesrequestdto.md deleted file mode 100644 index b80b726..0000000 --- a/docs/models/components/updatesubscriberglobalpreferencesrequestdto.md +++ /dev/null @@ -1,9 +0,0 @@ -# UpdateSubscriberGlobalPreferencesRequestDto - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | -| `Enabled` | **bool* | :heavy_minus_sign: | Enable or disable the subscriber global preferences. | -| `Preferences` | [][components.ChannelPreference](../../models/components/channelpreference.md) | :heavy_minus_sign: | The subscriber global preferences for every ChannelTypeEnum. | \ No newline at end of file diff --git a/docs/models/components/updatesubscriberpreferenceglobalresponsedto.md b/docs/models/components/updatesubscriberpreferenceglobalresponsedto.md deleted file mode 100644 index 2e1f4ce..0000000 --- a/docs/models/components/updatesubscriberpreferenceglobalresponsedto.md +++ /dev/null @@ -1,8 +0,0 @@ -# UpdateSubscriberPreferenceGlobalResponseDto - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | -| `Preference` | [components.Preference](../../models/components/preference.md) | :heavy_check_mark: | The preferences of the subscriber regarding the related workflow | \ No newline at end of file diff --git a/docs/models/components/updatesubscriberpreferencerequestdto.md b/docs/models/components/updatesubscriberpreferencerequestdto.md deleted file mode 100644 index b603a8c..0000000 --- a/docs/models/components/updatesubscriberpreferencerequestdto.md +++ /dev/null @@ -1,9 +0,0 @@ -# UpdateSubscriberPreferenceRequestDto - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | -| `Channel` | [*components.ChannelPreference](../../models/components/channelpreference.md) | :heavy_minus_sign: | Optional preferences for each channel type in the assigned workflow. | -| `Enabled` | **bool* | :heavy_minus_sign: | Indicates whether the workflow is fully enabled for all channels for the subscriber. | \ No newline at end of file diff --git a/docs/models/components/updatesubscriberpreferenceresponsedto.md b/docs/models/components/updatesubscriberpreferenceresponsedto.md deleted file mode 100644 index 0313f23..0000000 --- a/docs/models/components/updatesubscriberpreferenceresponsedto.md +++ /dev/null @@ -1,9 +0,0 @@ -# UpdateSubscriberPreferenceResponseDto - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -| `Template` | [components.TemplateResponse](../../models/components/templateresponse.md) | :heavy_check_mark: | The workflow information and if it is critical or not | -| `Preference` | [components.Preference](../../models/components/preference.md) | :heavy_check_mark: | The preferences of the subscriber regarding the related workflow | \ No newline at end of file diff --git a/docs/models/components/updatesubscriberrequestdto.md b/docs/models/components/updatesubscriberrequestdto.md deleted file mode 100644 index 9a437fe..0000000 --- a/docs/models/components/updatesubscriberrequestdto.md +++ /dev/null @@ -1,15 +0,0 @@ -# UpdateSubscriberRequestDto - - -## Fields - -| Field | Type | Required | Description | Example | -| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -| `Email` | **string* | :heavy_minus_sign: | The email address of the subscriber. | john.doe@example.com | -| `FirstName` | **string* | :heavy_minus_sign: | The first name of the subscriber. | John | -| `LastName` | **string* | :heavy_minus_sign: | The last name of the subscriber. | Doe | -| `Phone` | **string* | :heavy_minus_sign: | The phone number of the subscriber. | +1234567890 | -| `Avatar` | **string* | :heavy_minus_sign: | The avatar URL of the subscriber. | https://example.com/avatar.jpg | -| `Locale` | **string* | :heavy_minus_sign: | The locale of the subscriber, for example "en-US". | en-US | -| `Data` | map[string]*any* | :heavy_minus_sign: | Custom data associated with the subscriber. Can contain any additional properties. | {
"preferences": {
"notifications": true,
"theme": "dark"
},
"tags": [
"premium",
"newsletter"
]
} | -| `Channels` | [][components.SubscriberChannelDto](../../models/components/subscriberchanneldto.md) | :heavy_minus_sign: | An array of communication channels for the subscriber. | | \ No newline at end of file diff --git a/docs/models/components/workfloworiginenum.md b/docs/models/components/workfloworiginenum.md new file mode 100644 index 0000000..7c22d8d --- /dev/null +++ b/docs/models/components/workfloworiginenum.md @@ -0,0 +1,12 @@ +# WorkflowOriginEnum + +Origin of the workflow + + +## Values + +| Name | Value | +| ------------------------------- | ------------------------------- | +| `WorkflowOriginEnumNovuCloud` | novu-cloud | +| `WorkflowOriginEnumNovuCloudV1` | novu-cloud-v1 | +| `WorkflowOriginEnumExternal` | external | \ No newline at end of file diff --git a/docs/models/operations/notificationscontrollerlistnotificationsrequest.md b/docs/models/operations/notificationscontrollerlistnotificationsrequest.md index c0113ee..26844df 100644 --- a/docs/models/operations/notificationscontrollerlistnotificationsrequest.md +++ b/docs/models/operations/notificationscontrollerlistnotificationsrequest.md @@ -11,6 +11,7 @@ | ~~`Search`~~ | **string* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Search term (deprecated) | | `SubscriberIds` | []*string* | :heavy_minus_sign: | Array of subscriber IDs or a single subscriber ID | | `Page` | **float64* | :heavy_minus_sign: | Page number for pagination | +| `Limit` | **float64* | :heavy_minus_sign: | Limit for pagination | | `TransactionID` | **string* | :heavy_minus_sign: | Transaction ID for filtering | | `After` | **string* | :heavy_minus_sign: | Date filter for records after this timestamp | | `Before` | **string* | :heavy_minus_sign: | Date filter for records before this timestamp | diff --git a/docs/models/operations/parameter.md b/docs/models/operations/parameter.md deleted file mode 100644 index beb61db..0000000 --- a/docs/models/operations/parameter.md +++ /dev/null @@ -1,11 +0,0 @@ -# Parameter - -the preferences level to be retrieved (template / global) - - -## Values - -| Name | Value | -| ------------------- | ------------------- | -| `ParameterGlobal` | global | -| `ParameterTemplate` | template | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllercreatesubscriberrequest.md b/docs/models/operations/subscriberscontrollercreatesubscriberrequest.md similarity index 96% rename from docs/models/operations/subscribersv1controllercreatesubscriberrequest.md rename to docs/models/operations/subscriberscontrollercreatesubscriberrequest.md index bbb9245..55f9bbb 100644 --- a/docs/models/operations/subscribersv1controllercreatesubscriberrequest.md +++ b/docs/models/operations/subscriberscontrollercreatesubscriberrequest.md @@ -1,4 +1,4 @@ -# SubscribersV1ControllerCreateSubscriberRequest +# SubscribersControllerCreateSubscriberRequest ## Fields diff --git a/docs/models/operations/subscribersv1controllercreatesubscriberresponse.md b/docs/models/operations/subscriberscontrollercreatesubscriberresponse.md similarity index 97% rename from docs/models/operations/subscribersv1controllercreatesubscriberresponse.md rename to docs/models/operations/subscriberscontrollercreatesubscriberresponse.md index 7bf4708..b8b9763 100644 --- a/docs/models/operations/subscribersv1controllercreatesubscriberresponse.md +++ b/docs/models/operations/subscriberscontrollercreatesubscriberresponse.md @@ -1,4 +1,4 @@ -# SubscribersV1ControllerCreateSubscriberResponse +# SubscribersControllerCreateSubscriberResponse ## Fields diff --git a/docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelrequest.md b/docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelrequest.md deleted file mode 100644 index 1de977e..0000000 --- a/docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelrequest.md +++ /dev/null @@ -1,11 +0,0 @@ -# SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| `IncludeInactiveChannels` | **bool* | :heavy_minus_sign: | A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true | -| `PreferenceLevel` | [operations.Parameter](../../models/operations/parameter.md) | :heavy_check_mark: | the preferences level to be retrieved (template / global) | -| `SubscriberID` | *string* | :heavy_check_mark: | N/A | -| `IdempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelresponse.md b/docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelresponse.md deleted file mode 100644 index 00deed8..0000000 --- a/docs/models/operations/subscribersv1controllergetsubscriberpreferencebylevelresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `GetSubscriberPreferencesResponseDtos` | [][components.GetSubscriberPreferencesResponseDto](../../models/components/getsubscriberpreferencesresponsedto.md) | :heavy_minus_sign: | OK | -| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllergetsubscriberrequest.md b/docs/models/operations/subscribersv1controllergetsubscriberrequest.md deleted file mode 100644 index 4b20fbc..0000000 --- a/docs/models/operations/subscribersv1controllergetsubscriberrequest.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerGetSubscriberRequest - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -| `SubscriberID` | *string* | :heavy_check_mark: | N/A | -| `IncludeTopics` | **bool* | :heavy_minus_sign: | Includes the topics associated with the subscriber | -| `IdempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllergetsubscriberresponse.md b/docs/models/operations/subscribersv1controllergetsubscriberresponse.md deleted file mode 100644 index b322082..0000000 --- a/docs/models/operations/subscribersv1controllergetsubscriberresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerGetSubscriberResponse - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `SubscriberResponseDto` | [*components.SubscriberResponseDto](../../models/components/subscriberresponsedto.md) | :heavy_minus_sign: | OK | -| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerlistsubscriberpreferencesrequest.md b/docs/models/operations/subscribersv1controllerlistsubscriberpreferencesrequest.md deleted file mode 100644 index fa32ee1..0000000 --- a/docs/models/operations/subscribersv1controllerlistsubscriberpreferencesrequest.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerListSubscriberPreferencesRequest - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| `SubscriberID` | *string* | :heavy_check_mark: | N/A | -| `IncludeInactiveChannels` | **bool* | :heavy_minus_sign: | A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true | -| `IdempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerlistsubscriberpreferencesresponse.md b/docs/models/operations/subscribersv1controllerlistsubscriberpreferencesresponse.md deleted file mode 100644 index 570d747..0000000 --- a/docs/models/operations/subscribersv1controllerlistsubscriberpreferencesresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerListSubscriberPreferencesResponse - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `UpdateSubscriberPreferenceResponseDtos` | [][components.UpdateSubscriberPreferenceResponseDto](../../models/components/updatesubscriberpreferenceresponsedto.md) | :heavy_minus_sign: | OK | -| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerremovesubscriberrequest.md b/docs/models/operations/subscribersv1controllerremovesubscriberrequest.md deleted file mode 100644 index 016ed7f..0000000 --- a/docs/models/operations/subscribersv1controllerremovesubscriberrequest.md +++ /dev/null @@ -1,9 +0,0 @@ -# SubscribersV1ControllerRemoveSubscriberRequest - - -## Fields - -| Field | Type | Required | Description | -| --------------------------------- | --------------------------------- | --------------------------------- | --------------------------------- | -| `SubscriberID` | *string* | :heavy_check_mark: | N/A | -| `IdempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerremovesubscriberresponse.md b/docs/models/operations/subscribersv1controllerremovesubscriberresponse.md deleted file mode 100644 index 6420203..0000000 --- a/docs/models/operations/subscribersv1controllerremovesubscriberresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerRemoveSubscriberResponse - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | -| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `DeleteSubscriberResponseDto` | [*components.DeleteSubscriberResponseDto](../../models/components/deletesubscriberresponsedto.md) | :heavy_minus_sign: | OK | -| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesrequest.md b/docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesrequest.md deleted file mode 100644 index fdfa9a6..0000000 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesrequest.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerUpdateSubscriberGlobalPreferencesRequest - - -## Fields - -| Field | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| `SubscriberID` | *string* | :heavy_check_mark: | N/A | -| `IdempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `UpdateSubscriberGlobalPreferencesRequestDto` | [components.UpdateSubscriberGlobalPreferencesRequestDto](../../models/components/updatesubscriberglobalpreferencesrequestdto.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesresponse.md b/docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesresponse.md deleted file mode 100644 index c5def55..0000000 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse - - -## Fields - -| Field | Type | Required | Description | -| --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | -| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `UpdateSubscriberPreferenceGlobalResponseDto` | [*components.UpdateSubscriberPreferenceGlobalResponseDto](../../models/components/updatesubscriberpreferenceglobalresponsedto.md) | :heavy_minus_sign: | OK | -| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberpreferencerequest.md b/docs/models/operations/subscribersv1controllerupdatesubscriberpreferencerequest.md deleted file mode 100644 index e89a39e..0000000 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberpreferencerequest.md +++ /dev/null @@ -1,11 +0,0 @@ -# SubscribersV1ControllerUpdateSubscriberPreferenceRequest - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| `SubscriberID` | *string* | :heavy_check_mark: | N/A | -| `WorkflowID` | *string* | :heavy_check_mark: | N/A | -| `IdempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `UpdateSubscriberPreferenceRequestDto` | [components.UpdateSubscriberPreferenceRequestDto](../../models/components/updatesubscriberpreferencerequestdto.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberpreferenceresponse.md b/docs/models/operations/subscribersv1controllerupdatesubscriberpreferenceresponse.md deleted file mode 100644 index 51d2fa0..0000000 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberpreferenceresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerUpdateSubscriberPreferenceResponse - - -## Fields - -| Field | Type | Required | Description | -| --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | -| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `UpdateSubscriberPreferenceResponseDto` | [*components.UpdateSubscriberPreferenceResponseDto](../../models/components/updatesubscriberpreferenceresponsedto.md) | :heavy_minus_sign: | OK | -| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberrequest.md b/docs/models/operations/subscribersv1controllerupdatesubscriberrequest.md deleted file mode 100644 index 164bbb0..0000000 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberrequest.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerUpdateSubscriberRequest - - -## Fields - -| Field | Type | Required | Description | -| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | -| `SubscriberID` | *string* | :heavy_check_mark: | N/A | -| `IdempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `UpdateSubscriberRequestDto` | [components.UpdateSubscriberRequestDto](../../models/components/updatesubscriberrequestdto.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberresponse.md b/docs/models/operations/subscribersv1controllerupdatesubscriberresponse.md deleted file mode 100644 index 9149481..0000000 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberresponse.md +++ /dev/null @@ -1,10 +0,0 @@ -# SubscribersV1ControllerUpdateSubscriberResponse - - -## Fields - -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | -| `SubscriberResponseDto` | [*components.SubscriberResponseDto](../../models/components/subscriberresponsedto.md) | :heavy_minus_sign: | OK | -| `Headers` | map[string][]*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/docs/sdks/authentication/README.md b/docs/sdks/authentication/README.md index 820f223..58e641e 100644 --- a/docs/sdks/authentication/README.md +++ b/docs/sdks/authentication/README.md @@ -19,7 +19,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/operations" "log" @@ -27,9 +26,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Authentication.ChatAccessOauthCallBack(ctx, operations.SubscribersV1ControllerChatOauthCallbackRequest{ @@ -81,7 +80,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/operations" "log" @@ -89,9 +87,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Authentication.ChatAccessOauth(ctx, operations.SubscribersV1ControllerChatAccessOauthRequest{ diff --git a/docs/sdks/credentials/README.md b/docs/sdks/credentials/README.md index d63c033..941597d 100644 --- a/docs/sdks/credentials/README.md +++ b/docs/sdks/credentials/README.md @@ -20,7 +20,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -28,9 +27,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Credentials.Update(ctx, "", components.UpdateSubscriberChannelRequestDto{ @@ -95,7 +94,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -103,9 +101,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Credentials.Append(ctx, "", components.UpdateSubscriberChannelRequestDto{ @@ -169,16 +167,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Credentials.Delete(ctx, "", "", nil) diff --git a/docs/sdks/integrations/README.md b/docs/sdks/integrations/README.md index e67ebd8..bd7365e 100644 --- a/docs/sdks/integrations/README.md +++ b/docs/sdks/integrations/README.md @@ -26,16 +26,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Integrations.List(ctx, nil) @@ -81,7 +80,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -89,9 +87,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Integrations.Create(ctx, components.CreateIntegrationRequestDto{ @@ -141,16 +139,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Integrations.ListActive(ctx, nil) @@ -196,7 +193,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -204,9 +200,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Integrations.Update(ctx, "", components.UpdateIntegrationRequestDto{}, nil) @@ -254,16 +250,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Integrations.Delete(ctx, "", nil) @@ -310,16 +305,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Integrations.SetAsPrimary(ctx, "", nil) diff --git a/docs/sdks/legacy/README.md b/docs/sdks/legacy/README.md deleted file mode 100644 index 225225b..0000000 --- a/docs/sdks/legacy/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Legacy -(*Subscribers.Preferences.Legacy*) - -## Overview - -### Available Operations - -* [UpdateGlobal](#updateglobal) - Update subscriber global preferences - -## UpdateGlobal - -Update subscriber global preferences - -### Example Usage - -```go -package main - -import( - "context" - "os" - novugo "github.com/novuhq/novu-go" - "github.com/novuhq/novu-go/models/components" - "log" -) - -func main() { - ctx := context.Background() - - s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), - ) - - res, err := s.Subscribers.Preferences.Legacy.UpdateGlobal(ctx, "", components.UpdateSubscriberGlobalPreferencesRequestDto{}, nil) - if err != nil { - log.Fatal(err) - } - if res.UpdateSubscriberPreferenceGlobalResponseDto != nil { - // handle response - } -} -``` - -### Parameters - -| Parameter | Type | Required | Description | -| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `subscriberID` | *string* | :heavy_check_mark: | N/A | -| `updateSubscriberGlobalPreferencesRequestDto` | [components.UpdateSubscriberGlobalPreferencesRequestDto](../../models/components/updatesubscriberglobalpreferencesrequestdto.md) | :heavy_check_mark: | N/A | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse](../../models/operations/subscribersv1controllerupdatesubscriberglobalpreferencesresponse.md), error** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| apierrors.ErrorDto | 414 | application/json | -| apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json | -| apierrors.ValidationErrorDto | 422 | application/json | -| apierrors.ErrorDto | 500 | application/json | -| apierrors.APIError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/docs/sdks/messages/README.md b/docs/sdks/messages/README.md index c0ec9c2..f1641b1 100644 --- a/docs/sdks/messages/README.md +++ b/docs/sdks/messages/README.md @@ -23,7 +23,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/operations" "log" @@ -31,9 +30,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Messages.Retrieve(ctx, operations.MessagesControllerGetMessagesRequest{}) @@ -79,16 +78,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Messages.Delete(ctx, "", nil) @@ -135,16 +133,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Messages.DeleteByTransactionID(ctx, "", nil, nil) diff --git a/docs/sdks/notifications/README.md b/docs/sdks/notifications/README.md index 7d49bb8..52e0c3f 100644 --- a/docs/sdks/notifications/README.md +++ b/docs/sdks/notifications/README.md @@ -19,7 +19,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/operations" "log" @@ -27,9 +26,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Notifications.List(ctx, operations.NotificationsControllerListNotificationsRequest{}) @@ -75,16 +74,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Notifications.Retrieve(ctx, "", nil) diff --git a/docs/sdks/novu/README.md b/docs/sdks/novu/README.md index 68a2c34..7400490 100644 --- a/docs/sdks/novu/README.md +++ b/docs/sdks/novu/README.md @@ -29,7 +29,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -37,9 +36,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Trigger(ctx, components.TriggerEventRequestDto{ @@ -109,7 +108,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -117,9 +115,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.TriggerBulk(ctx, components.BulkTriggerEventDto{ @@ -243,7 +241,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -251,9 +248,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.TriggerBroadcast(ctx, components.TriggerEventToAllRequestDto{ @@ -311,16 +308,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Cancel(ctx, "", nil) diff --git a/docs/sdks/novumessages/README.md b/docs/sdks/novumessages/README.md index cd4108b..f601659 100644 --- a/docs/sdks/novumessages/README.md +++ b/docs/sdks/novumessages/README.md @@ -20,7 +20,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -28,9 +27,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Messages.MarkAllAs(ctx, "", components.MessageMarkAsRequestDto{ @@ -83,7 +82,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -91,9 +89,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Messages.MarkAll(ctx, "", components.MarkAllMessageAsRequestDto{ @@ -143,7 +141,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "github.com/novuhq/novu-go/models/operations" @@ -152,9 +149,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Messages.UpdateAsSeen(ctx, operations.SubscribersV1ControllerMarkActionAsSeenRequest{ diff --git a/docs/sdks/novunotifications/README.md b/docs/sdks/novunotifications/README.md index 24f02ea..623d81f 100644 --- a/docs/sdks/novunotifications/README.md +++ b/docs/sdks/novunotifications/README.md @@ -19,7 +19,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/operations" "log" @@ -27,9 +26,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Notifications.Feed(ctx, operations.SubscribersV1ControllerGetNotificationsFeedRequest{ @@ -78,16 +77,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Notifications.UnseenCount(ctx, "", nil, nil, nil) diff --git a/docs/sdks/novusubscribers/README.md b/docs/sdks/novusubscribers/README.md index 8f25ef7..7811abc 100644 --- a/docs/sdks/novusubscribers/README.md +++ b/docs/sdks/novusubscribers/README.md @@ -20,7 +20,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -28,9 +27,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.Subscribers.Assign(ctx, "", components.AddSubscribersRequestDto{ @@ -83,16 +82,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.Subscribers.Retrieve(ctx, "", "", nil) @@ -140,7 +138,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -148,9 +145,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.Subscribers.Remove(ctx, "", components.RemoveSubscribersRequestDto{ diff --git a/docs/sdks/preferences/README.md b/docs/sdks/preferences/README.md index 03109f5..88cba4f 100644 --- a/docs/sdks/preferences/README.md +++ b/docs/sdks/preferences/README.md @@ -5,192 +5,10 @@ ### Available Operations -* [~~ListLegacy~~](#listlegacy) - Get subscriber preferences :warning: **Deprecated** -* [~~RetrieveByLevelLegacy~~](#retrievebylevellegacy) - Get subscriber preferences by level :warning: **Deprecated** -* [UpdateLegacy](#updatelegacy) - Update subscriber preference -* [Retrieve](#retrieve) - Get subscriber preferences +* [List](#list) - Get subscriber preferences * [Update](#update) - Update subscriber global or workflow specific preferences -## ~~ListLegacy~~ - -Get subscriber preferences - -> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. - -### Example Usage - -```go -package main - -import( - "context" - "os" - novugo "github.com/novuhq/novu-go" - "log" -) - -func main() { - ctx := context.Background() - - s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), - ) - - res, err := s.Subscribers.Preferences.ListLegacy(ctx, "", nil, nil) - if err != nil { - log.Fatal(err) - } - if res.UpdateSubscriberPreferenceResponseDtos != nil { - // handle response - } -} -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `subscriberID` | *string* | :heavy_check_mark: | N/A | -| `includeInactiveChannels` | **bool* | :heavy_minus_sign: | A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.SubscribersV1ControllerListSubscriberPreferencesResponse](../../models/operations/subscribersv1controllerlistsubscriberpreferencesresponse.md), error** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| apierrors.ErrorDto | 414 | application/json | -| apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json | -| apierrors.ValidationErrorDto | 422 | application/json | -| apierrors.ErrorDto | 500 | application/json | -| apierrors.APIError | 4XX, 5XX | \*/\* | - -## ~~RetrieveByLevelLegacy~~ - -Get subscriber preferences by level - -> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. - -### Example Usage - -```go -package main - -import( - "context" - "os" - novugo "github.com/novuhq/novu-go" - "github.com/novuhq/novu-go/models/operations" - "log" -) - -func main() { - ctx := context.Background() - - s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), - ) - - res, err := s.Subscribers.Preferences.RetrieveByLevelLegacy(ctx, operations.ParameterTemplate, "", nil, nil) - if err != nil { - log.Fatal(err) - } - if res.GetSubscriberPreferencesResponseDtos != nil { - // handle response - } -} -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `preferenceLevel` | [operations.Parameter](../../models/operations/parameter.md) | :heavy_check_mark: | the preferences level to be retrieved (template / global) | -| `subscriberID` | *string* | :heavy_check_mark: | N/A | -| `includeInactiveChannels` | **bool* | :heavy_minus_sign: | A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse](../../models/operations/subscribersv1controllergetsubscriberpreferencebylevelresponse.md), error** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| apierrors.ErrorDto | 414 | application/json | -| apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json | -| apierrors.ValidationErrorDto | 422 | application/json | -| apierrors.ErrorDto | 500 | application/json | -| apierrors.APIError | 4XX, 5XX | \*/\* | - -## UpdateLegacy - -Update subscriber preference - -### Example Usage - -```go -package main - -import( - "context" - "os" - novugo "github.com/novuhq/novu-go" - "github.com/novuhq/novu-go/models/components" - "log" -) - -func main() { - ctx := context.Background() - - s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), - ) - - res, err := s.Subscribers.Preferences.UpdateLegacy(ctx, "", "", components.UpdateSubscriberPreferenceRequestDto{}, nil) - if err != nil { - log.Fatal(err) - } - if res.UpdateSubscriberPreferenceResponseDto != nil { - // handle response - } -} -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------ | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `subscriberID` | *string* | :heavy_check_mark: | N/A | -| `workflowID` | *string* | :heavy_check_mark: | N/A | -| `updateSubscriberPreferenceRequestDto` | [components.UpdateSubscriberPreferenceRequestDto](../../models/components/updatesubscriberpreferencerequestdto.md) | :heavy_check_mark: | N/A | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse](../../models/operations/subscribersv1controllerupdatesubscriberpreferenceresponse.md), error** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| apierrors.ErrorDto | 414 | application/json | -| apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json | -| apierrors.ValidationErrorDto | 422 | application/json | -| apierrors.ErrorDto | 500 | application/json | -| apierrors.APIError | 4XX, 5XX | \*/\* | - -## Retrieve +## List Get subscriber global and workflow specific preferences @@ -201,19 +19,18 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) - res, err := s.Subscribers.Preferences.Retrieve(ctx, "", nil) + res, err := s.Subscribers.Preferences.List(ctx, "", nil) if err != nil { log.Fatal(err) } @@ -257,7 +74,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -265,9 +81,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Preferences.Update(ctx, "", components.PatchSubscriberPreferencesDto{ diff --git a/docs/sdks/properties/README.md b/docs/sdks/properties/README.md index c2052be..ffefce2 100644 --- a/docs/sdks/properties/README.md +++ b/docs/sdks/properties/README.md @@ -18,7 +18,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -26,9 +25,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Properties.UpdateOnlineFlag(ctx, "", components.UpdateSubscriberOnlineFlagRequestDto{ diff --git a/docs/sdks/stats/README.md b/docs/sdks/stats/README.md index 0bf6e52..fcd214a 100644 --- a/docs/sdks/stats/README.md +++ b/docs/sdks/stats/README.md @@ -19,16 +19,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Notifications.Stats.Retrieve(ctx, nil) @@ -74,16 +73,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Notifications.Stats.Graph(ctx, nil, nil) diff --git a/docs/sdks/subscribers/README.md b/docs/sdks/subscribers/README.md index 9e59872..3686506 100644 --- a/docs/sdks/subscribers/README.md +++ b/docs/sdks/subscribers/README.md @@ -9,12 +9,9 @@ A subscriber in Novu represents someone who should receive a message. A subscrib ### Available Operations * [List](#list) - Get subscribers -* [Create](#create) - Create subscriber -* [RetrieveLegacy](#retrievelegacy) - Get subscriber -* [UpdateLegacy](#updatelegacy) - Update subscriber -* [~~DeleteLegacy~~](#deletelegacy) - Delete subscriber :warning: **Deprecated** * [CreateBulk](#createbulk) - Bulk create subscribers * [Search](#search) - Search for subscribers +* [Create](#create) - Create subscriber * [Retrieve](#retrieve) - Get subscriber * [Patch](#patch) - Patch subscriber * [Delete](#delete) - Delete subscriber @@ -30,16 +27,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.List(ctx, nil, nil, nil) @@ -88,9 +84,12 @@ func main() { | apierrors.ErrorDto | 500 | application/json | | apierrors.APIError | 4XX, 5XX | \*/\* | -## Create +## CreateBulk -Creates a subscriber entity, in the Novu platform. The subscriber will be later used to receive notifications, and access notification feeds. Communication credentials such as email, phone number, and 3 rd party credentials i.e slack tokens could be later associated to this entity. + + Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API. + The bulk API is limited to 500 subscribers per request. + ### Example Usage @@ -99,7 +98,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -107,18 +105,22 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) - res, err := s.Subscribers.Create(ctx, components.CreateSubscriberRequestDto{ - SubscriberID: "", + res, err := s.Subscribers.CreateBulk(ctx, components.BulkSubscriberCreateDto{ + Subscribers: []components.CreateSubscriberRequestDto{ + components.CreateSubscriberRequestDto{ + SubscriberID: "", + }, + }, }, nil) if err != nil { log.Fatal(err) } - if res.SubscriberResponseDto != nil { + if res.BulkCreateSubscriberResponseDto != nil { // handle response } } @@ -126,16 +128,16 @@ func main() { ### Parameters -| Parameter | Type | Required | Description | -| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `createSubscriberRequestDto` | [components.CreateSubscriberRequestDto](../../models/components/createsubscriberrequestdto.md) | :heavy_check_mark: | N/A | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `bulkSubscriberCreateDto` | [components.BulkSubscriberCreateDto](../../models/components/bulksubscribercreatedto.md) | :heavy_check_mark: | N/A | +| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | ### Response -**[*operations.SubscribersV1ControllerCreateSubscriberResponse](../../models/operations/subscribersv1controllercreatesubscriberresponse.md), error** +**[*operations.SubscribersV1ControllerBulkCreateSubscribersResponse](../../models/operations/subscribersv1controllerbulkcreatesubscribersresponse.md), error** ### Errors @@ -147,9 +149,9 @@ func main() { | apierrors.ErrorDto | 500 | application/json | | apierrors.APIError | 4XX, 5XX | \*/\* | -## RetrieveLegacy +## Search -Get subscriber by your internal id used to identify the subscriber +Search for subscribers ### Example Usage @@ -158,23 +160,23 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" + "github.com/novuhq/novu-go/models/operations" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) - res, err := s.Subscribers.RetrieveLegacy(ctx, "", nil, nil) + res, err := s.Subscribers.Search(ctx, operations.SubscribersControllerSearchSubscribersRequest{}) if err != nil { log.Fatal(err) } - if res.SubscriberResponseDto != nil { + if res.ListSubscribersResponseDto != nil { // handle response } } @@ -182,17 +184,15 @@ func main() { ### Parameters -| Parameter | Type | Required | Description | -| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `subscriberID` | *string* | :heavy_check_mark: | N/A | -| `includeTopics` | **bool* | :heavy_minus_sign: | Includes the topics associated with the subscriber | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.SubscribersControllerSearchSubscribersRequest](../../models/operations/subscriberscontrollersearchsubscribersrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | ### Response -**[*operations.SubscribersV1ControllerGetSubscriberResponse](../../models/operations/subscribersv1controllergetsubscriberresponse.md), error** +**[*operations.SubscribersControllerSearchSubscribersResponse](../../models/operations/subscriberscontrollersearchsubscribersresponse.md), error** ### Errors @@ -204,9 +204,9 @@ func main() { | apierrors.ErrorDto | 500 | application/json | | apierrors.APIError | 4XX, 5XX | \*/\* | -## UpdateLegacy +## Create -Used to update the subscriber entity with new information +Create subscriber with the given data ### Example Usage @@ -215,7 +215,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -223,28 +222,13 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) - res, err := s.Subscribers.UpdateLegacy(ctx, "", components.UpdateSubscriberRequestDto{ - Email: novugo.String("john.doe@example.com"), - FirstName: novugo.String("John"), - LastName: novugo.String("Doe"), - Phone: novugo.String("+1234567890"), - Avatar: novugo.String("https://example.com/avatar.jpg"), - Locale: novugo.String("en-US"), - Data: map[string]any{ - "preferences": map[string]any{ - "notifications": true, - "theme": "dark", - }, - "tags": []any{ - "premium", - "newsletter", - }, - }, + res, err := s.Subscribers.Create(ctx, components.CreateSubscriberRequestDto{ + SubscriberID: "", }, nil) if err != nil { log.Fatal(err) @@ -260,194 +244,13 @@ func main() { | Parameter | Type | Required | Description | | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | | `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `subscriberID` | *string* | :heavy_check_mark: | N/A | -| `updateSubscriberRequestDto` | [components.UpdateSubscriberRequestDto](../../models/components/updatesubscriberrequestdto.md) | :heavy_check_mark: | N/A | +| `createSubscriberRequestDto` | [components.CreateSubscriberRequestDto](../../models/components/createsubscriberrequestdto.md) | :heavy_check_mark: | N/A | | `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | | `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | ### Response -**[*operations.SubscribersV1ControllerUpdateSubscriberResponse](../../models/operations/subscribersv1controllerupdatesubscriberresponse.md), error** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| apierrors.ErrorDto | 414 | application/json | -| apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json | -| apierrors.ValidationErrorDto | 422 | application/json | -| apierrors.ErrorDto | 500 | application/json | -| apierrors.APIError | 4XX, 5XX | \*/\* | - -## ~~DeleteLegacy~~ - -Deletes a subscriber entity from the Novu platform - -> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. - -### Example Usage - -```go -package main - -import( - "context" - "os" - novugo "github.com/novuhq/novu-go" - "log" -) - -func main() { - ctx := context.Background() - - s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), - ) - - res, err := s.Subscribers.DeleteLegacy(ctx, "", nil) - if err != nil { - log.Fatal(err) - } - if res.DeleteSubscriberResponseDto != nil { - // handle response - } -} -``` - -### Parameters - -| Parameter | Type | Required | Description | -| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `subscriberID` | *string* | :heavy_check_mark: | N/A | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.SubscribersV1ControllerRemoveSubscriberResponse](../../models/operations/subscribersv1controllerremovesubscriberresponse.md), error** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| apierrors.ErrorDto | 414 | application/json | -| apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json | -| apierrors.ValidationErrorDto | 422 | application/json | -| apierrors.ErrorDto | 500 | application/json | -| apierrors.APIError | 4XX, 5XX | \*/\* | - -## CreateBulk - - - Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API. - The bulk API is limited to 500 subscribers per request. - - -### Example Usage - -```go -package main - -import( - "context" - "os" - novugo "github.com/novuhq/novu-go" - "github.com/novuhq/novu-go/models/components" - "log" -) - -func main() { - ctx := context.Background() - - s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), - ) - - res, err := s.Subscribers.CreateBulk(ctx, components.BulkSubscriberCreateDto{ - Subscribers: []components.CreateSubscriberRequestDto{ - components.CreateSubscriberRequestDto{ - SubscriberID: "", - }, - }, - }, nil) - if err != nil { - log.Fatal(err) - } - if res.BulkCreateSubscriberResponseDto != nil { - // handle response - } -} -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `bulkSubscriberCreateDto` | [components.BulkSubscriberCreateDto](../../models/components/bulksubscribercreatedto.md) | :heavy_check_mark: | N/A | -| `idempotencyKey` | **string* | :heavy_minus_sign: | A header for idempotency purposes | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.SubscribersV1ControllerBulkCreateSubscribersResponse](../../models/operations/subscribersv1controllerbulkcreatesubscribersresponse.md), error** - -### Errors - -| Error Type | Status Code | Content Type | -| -------------------------------------- | -------------------------------------- | -------------------------------------- | -| apierrors.ErrorDto | 414 | application/json | -| apierrors.ErrorDto | 400, 401, 403, 404, 405, 409, 413, 415 | application/json | -| apierrors.ValidationErrorDto | 422 | application/json | -| apierrors.ErrorDto | 500 | application/json | -| apierrors.APIError | 4XX, 5XX | \*/\* | - -## Search - -Search for subscribers - -### Example Usage - -```go -package main - -import( - "context" - "os" - novugo "github.com/novuhq/novu-go" - "github.com/novuhq/novu-go/models/operations" - "log" -) - -func main() { - ctx := context.Background() - - s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), - ) - - res, err := s.Subscribers.Search(ctx, operations.SubscribersControllerSearchSubscribersRequest{}) - if err != nil { - log.Fatal(err) - } - if res.ListSubscribersResponseDto != nil { - // handle response - } -} -``` - -### Parameters - -| Parameter | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------ | -| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | -| `request` | [operations.SubscribersControllerSearchSubscribersRequest](../../models/operations/subscriberscontrollersearchsubscribersrequest.md) | :heavy_check_mark: | The request object to use for the request. | -| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | - -### Response - -**[*operations.SubscribersControllerSearchSubscribersResponse](../../models/operations/subscriberscontrollersearchsubscribersresponse.md), error** +**[*operations.SubscribersControllerCreateSubscriberResponse](../../models/operations/subscriberscontrollercreatesubscriberresponse.md), error** ### Errors @@ -470,16 +273,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Retrieve(ctx, "", nil) @@ -526,7 +328,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -534,9 +335,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Patch(ctx, "", components.PatchSubscriberRequestDto{}, nil) @@ -584,16 +385,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Subscribers.Delete(ctx, "", nil) diff --git a/docs/sdks/topics/README.md b/docs/sdks/topics/README.md index 5b57afd..df9bba2 100644 --- a/docs/sdks/topics/README.md +++ b/docs/sdks/topics/README.md @@ -25,7 +25,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -33,9 +32,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.Create(ctx, components.CreateTopicRequestDto{ @@ -85,16 +84,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.List(ctx, nil, nil, novugo.String("exampleKey"), nil) @@ -143,16 +141,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.Delete(ctx, "", nil) @@ -199,16 +196,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.Retrieve(ctx, "", nil) @@ -255,7 +251,6 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "github.com/novuhq/novu-go/models/components" "log" @@ -263,9 +258,9 @@ import( func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Topics.Rename(ctx, "", components.RenameTopicRequestDto{ diff --git a/docs/sdks/webhooks/README.md b/docs/sdks/webhooks/README.md index 4140554..77cef5e 100644 --- a/docs/sdks/webhooks/README.md +++ b/docs/sdks/webhooks/README.md @@ -18,16 +18,15 @@ package main import( "context" - "os" novugo "github.com/novuhq/novu-go" "log" ) func main() { ctx := context.Background() - + s := novugo.New( - novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")), + novugo.WithSecurity("YOUR_SECRET_KEY_HERE"), ) res, err := s.Integrations.Webhooks.Retrieve(ctx, "", nil) diff --git a/integrations.go b/integrations.go index f8ad355..56caa1c 100644 --- a/integrations.go +++ b/integrations.go @@ -35,13 +35,6 @@ func newIntegrations(sdkConfig sdkConfiguration) *Integrations { // List - Get integrations // Return all the integrations the user has created for that organization. Review v.0.17.0 changelog for a breaking change func (s *Integrations) List(ctx context.Context, idempotencyKey *string, opts ...operations.Option) (*operations.IntegrationsControllerListIntegrationsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "IntegrationsController_listIntegrations", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.IntegrationsControllerListIntegrationsRequest{ IdempotencyKey: idempotencyKey, } @@ -69,6 +62,14 @@ func (s *Integrations) List(ctx context.Context, idempotencyKey *string, opts .. return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "IntegrationsController_listIntegrations", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -371,13 +372,6 @@ func (s *Integrations) List(ctx context.Context, idempotencyKey *string, opts .. // Create integration // Create an integration for the current environment the user is based on the API key provided func (s *Integrations) Create(ctx context.Context, createIntegrationRequestDto components.CreateIntegrationRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.IntegrationsControllerCreateIntegrationResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "IntegrationsController_createIntegration", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.IntegrationsControllerCreateIntegrationRequest{ IdempotencyKey: idempotencyKey, CreateIntegrationRequestDto: createIntegrationRequestDto, @@ -406,6 +400,13 @@ func (s *Integrations) Create(ctx context.Context, createIntegrationRequestDto c return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "IntegrationsController_createIntegration", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "CreateIntegrationRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -716,13 +717,6 @@ func (s *Integrations) Create(ctx context.Context, createIntegrationRequestDto c // ListActive - Get active integrations // Return all the active integrations the user has created for that organization. Review v.0.17.0 changelog for a breaking change func (s *Integrations) ListActive(ctx context.Context, idempotencyKey *string, opts ...operations.Option) (*operations.IntegrationsControllerGetActiveIntegrationsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "IntegrationsController_getActiveIntegrations", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.IntegrationsControllerGetActiveIntegrationsRequest{ IdempotencyKey: idempotencyKey, } @@ -750,6 +744,14 @@ func (s *Integrations) ListActive(ctx context.Context, idempotencyKey *string, o return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "IntegrationsController_getActiveIntegrations", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1051,13 +1053,6 @@ func (s *Integrations) ListActive(ctx context.Context, idempotencyKey *string, o // Update integration func (s *Integrations) Update(ctx context.Context, integrationID string, updateIntegrationRequestDto components.UpdateIntegrationRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.IntegrationsControllerUpdateIntegrationByIDResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "IntegrationsController_updateIntegrationById", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.IntegrationsControllerUpdateIntegrationByIDRequest{ IntegrationID: integrationID, IdempotencyKey: idempotencyKey, @@ -1087,6 +1082,13 @@ func (s *Integrations) Update(ctx context.Context, integrationID string, updateI return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "IntegrationsController_updateIntegrationById", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpdateIntegrationRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1396,13 +1398,6 @@ func (s *Integrations) Update(ctx context.Context, integrationID string, updateI // Delete integration func (s *Integrations) Delete(ctx context.Context, integrationID string, idempotencyKey *string, opts ...operations.Option) (*operations.IntegrationsControllerRemoveIntegrationResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "IntegrationsController_removeIntegration", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.IntegrationsControllerRemoveIntegrationRequest{ IntegrationID: integrationID, IdempotencyKey: idempotencyKey, @@ -1431,6 +1426,14 @@ func (s *Integrations) Delete(ctx context.Context, integrationID string, idempot return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "IntegrationsController_removeIntegration", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1732,13 +1735,6 @@ func (s *Integrations) Delete(ctx context.Context, integrationID string, idempot // SetAsPrimary - Set integration as primary func (s *Integrations) SetAsPrimary(ctx context.Context, integrationID string, idempotencyKey *string, opts ...operations.Option) (*operations.IntegrationsControllerSetIntegrationAsPrimaryResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "IntegrationsController_setIntegrationAsPrimary", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.IntegrationsControllerSetIntegrationAsPrimaryRequest{ IntegrationID: integrationID, IdempotencyKey: idempotencyKey, @@ -1767,6 +1763,14 @@ func (s *Integrations) SetAsPrimary(ctx context.Context, integrationID string, i return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "IntegrationsController_setIntegrationAsPrimary", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/internal/hooks/hooks.go b/internal/hooks/hooks.go index 8ea491a..a0b49da 100644 --- a/internal/hooks/hooks.go +++ b/internal/hooks/hooks.go @@ -24,6 +24,7 @@ type HTTPClient interface { } type HookContext struct { + BaseURL string Context context.Context OperationID string OAuth2Scopes []string diff --git a/internal/utils/form.go b/internal/utils/form.go index e2c8aef..f22e83d 100644 --- a/internal/utils/form.go +++ b/internal/utils/form.go @@ -15,11 +15,15 @@ import ( "github.com/novuhq/novu-go/types" ) -func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, getFieldName func(reflect.StructField) string) url.Values { +func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string, getFieldName func(reflect.StructField) string) url.Values { formValues := url.Values{} if isNil(objType, objValue) { + if defaultValue != nil { + formValues.Add(paramName, *defaultValue) + } + return formValues } diff --git a/internal/utils/queryparams.go b/internal/utils/queryparams.go index a4b1e13..a4021c5 100644 --- a/internal/utils/queryparams.go +++ b/internal/utils/queryparams.go @@ -65,6 +65,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur continue } + constValue := parseConstTag(fieldType) + if constValue != nil { + values.Add(qpTag.ParamName, *constValue) + continue + } + + defaultValue := parseDefaultTag(fieldType) + if globals != nil { var globalFound bool fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) @@ -91,14 +99,14 @@ func populateQueryParams(queryParams interface{}, globals interface{}, values ur } } case "form": - vals := populateFormParams(qpTag, fieldType.Type, valType, ",") + vals := populateFormParams(qpTag, fieldType.Type, valType, ",", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) } } case "pipeDelimited": - vals := populateFormParams(qpTag, fieldType.Type, valType, "|") + vals := populateFormParams(qpTag, fieldType.Type, valType, "|", defaultValue) for k, v := range vals { for _, vv := range v { values.Add(k, vv) @@ -240,8 +248,8 @@ func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, stru } } -func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string) url.Values { - return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, func(fieldType reflect.StructField) string { +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string) url.Values { + return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, defaultValue, func(fieldType reflect.StructField) string { qpTag := parseQueryParamTag(fieldType) if qpTag == nil { return "" diff --git a/internal/utils/requestbody.go b/internal/utils/requestbody.go index 78479c6..8fe01ad 100644 --- a/internal/utils/requestbody.go +++ b/internal/utils/requestbody.go @@ -292,7 +292,7 @@ func encodeFormData(fieldName string, w io.Writer, data interface{}) error { switch tag.Style { // TODO: support other styles case "form": - values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", func(sf reflect.StructField) string { + values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", nil, func(sf reflect.StructField) string { tag := parseFormTag(field) if tag == nil { return "" diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 636e030..6ffd787 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -140,6 +140,26 @@ func ValueFromEnvVar(envVar string, field interface{}) interface{} { return nil } +func parseConstTag(field reflect.StructField) *string { + value := field.Tag.Get("const") + + if value == "" { + return nil + } + + return &value +} + +func parseDefaultTag(field reflect.StructField) *string { + value := field.Tag.Get("default") + + if value == "" { + return nil + } + + return &value +} + func parseStructTag(tagKey string, field reflect.StructField) map[string]string { tag := field.Tag.Get(tagKey) if tag == "" { diff --git a/legacy.go b/legacy.go deleted file mode 100644 index b7c2862..0000000 --- a/legacy.go +++ /dev/null @@ -1,371 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package novugo - -import ( - "bytes" - "context" - "fmt" - "github.com/novuhq/novu-go/internal/hooks" - "github.com/novuhq/novu-go/internal/utils" - "github.com/novuhq/novu-go/models/apierrors" - "github.com/novuhq/novu-go/models/components" - "github.com/novuhq/novu-go/models/operations" - "github.com/novuhq/novu-go/retry" - "net/http" -) - -type Legacy struct { - sdkConfiguration sdkConfiguration -} - -func newLegacy(sdkConfig sdkConfiguration) *Legacy { - return &Legacy{ - sdkConfiguration: sdkConfig, - } -} - -// UpdateGlobal - Update subscriber global preferences -func (s *Legacy) UpdateGlobal(ctx context.Context, subscriberID string, updateSubscriberGlobalPreferencesRequestDto components.UpdateSubscriberGlobalPreferencesRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_updateSubscriberGlobalPreferences", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerUpdateSubscriberGlobalPreferencesRequest{ - SubscriberID: subscriberID, - IdempotencyKey: idempotencyKey, - UpdateSubscriberGlobalPreferencesRequestDto: updateSubscriberGlobalPreferencesRequestDto, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/subscribers/{subscriberId}/preferences", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpdateSubscriberGlobalPreferencesRequestDto", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - utils.PopulateHeaders(ctx, req, request, nil) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 1000, - MaxInterval: 30000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "408", - "409", - "429", - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil { - copyBody, err := req.GetBody() - if err != nil { - return nil, err - } - req.Body = copyBody - } - - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "405", "409", "413", "414", "415", "422", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse{ - HTTPMeta: components.HTTPMetadata{ - Request: req, - Response: httpRes, - }, - } - - switch { - case httpRes.StatusCode == 200: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out components.UpdateSubscriberPreferenceGlobalResponseDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.UpdateSubscriberPreferenceGlobalResponseDto = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 414: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 405: - fallthrough - case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 413: - fallthrough - case httpRes.StatusCode == 415: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 422: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ValidationErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 429: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode == 500: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 503: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} diff --git a/messages.go b/messages.go index 2cb6983..7fa48c0 100644 --- a/messages.go +++ b/messages.go @@ -32,13 +32,6 @@ func newMessages(sdkConfig sdkConfiguration) *Messages { // Retrieve - Get messages // Returns a list of messages, could paginate using the `page` query parameter func (s *Messages) Retrieve(ctx context.Context, request operations.MessagesControllerGetMessagesRequest, opts ...operations.Option) (*operations.MessagesControllerGetMessagesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "MessagesController_getMessages", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -62,6 +55,14 @@ func (s *Messages) Retrieve(ctx context.Context, request operations.MessagesCont return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "MessagesController_getMessages", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -368,13 +369,6 @@ func (s *Messages) Retrieve(ctx context.Context, request operations.MessagesCont // Delete message // Deletes a message entity from the Novu platform func (s *Messages) Delete(ctx context.Context, messageID string, idempotencyKey *string, opts ...operations.Option) (*operations.MessagesControllerDeleteMessageResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "MessagesController_deleteMessage", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.MessagesControllerDeleteMessageRequest{ MessageID: messageID, IdempotencyKey: idempotencyKey, @@ -403,6 +397,14 @@ func (s *Messages) Delete(ctx context.Context, messageID string, idempotencyKey return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "MessagesController_deleteMessage", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -705,13 +707,6 @@ func (s *Messages) Delete(ctx context.Context, messageID string, idempotencyKey // DeleteByTransactionID - Delete messages by transactionId // Deletes messages entity from the Novu platform using TransactionId of message func (s *Messages) DeleteByTransactionID(ctx context.Context, transactionID string, channel *operations.Channel, idempotencyKey *string, opts ...operations.Option) (*operations.MessagesControllerDeleteMessagesByTransactionIDResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "MessagesController_deleteMessagesByTransactionId", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.MessagesControllerDeleteMessagesByTransactionIDRequest{ Channel: channel, TransactionID: transactionID, @@ -741,6 +736,14 @@ func (s *Messages) DeleteByTransactionID(ctx context.Context, transactionID stri return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "MessagesController_deleteMessagesByTransactionId", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/models/components/activitynotificationtemplateresponsedto.go b/models/components/activitynotificationtemplateresponsedto.go index a6134aa..d5b6b14 100644 --- a/models/components/activitynotificationtemplateresponsedto.go +++ b/models/components/activitynotificationtemplateresponsedto.go @@ -7,6 +7,8 @@ type ActivityNotificationTemplateResponseDto struct { ID *string `json:"_id,omitempty"` // Name of the template Name string `json:"name"` + // Origin of the workflow + Origin *WorkflowOriginEnum `json:"origin,omitempty"` // Triggers of the template Triggers []NotificationTriggerDto `json:"triggers"` } @@ -25,6 +27,13 @@ func (o *ActivityNotificationTemplateResponseDto) GetName() string { return o.Name } +func (o *ActivityNotificationTemplateResponseDto) GetOrigin() *WorkflowOriginEnum { + if o == nil { + return nil + } + return o.Origin +} + func (o *ActivityNotificationTemplateResponseDto) GetTriggers() []NotificationTriggerDto { if o == nil { return []NotificationTriggerDto{} diff --git a/models/components/channelpreference.go b/models/components/channelpreference.go deleted file mode 100644 index cc95fd7..0000000 --- a/models/components/channelpreference.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type ChannelPreference struct { - // Channel type through which the message is sent - Type ChannelTypeEnum `json:"type"` - // If channel is enabled or not - Enabled bool `json:"enabled"` -} - -func (o *ChannelPreference) GetType() ChannelTypeEnum { - if o == nil { - return ChannelTypeEnum("") - } - return o.Type -} - -func (o *ChannelPreference) GetEnabled() bool { - if o == nil { - return false - } - return o.Enabled -} diff --git a/models/components/createsubscriberrequestdto.go b/models/components/createsubscriberrequestdto.go index 9e9f8ef..55f99d5 100644 --- a/models/components/createsubscriberrequestdto.go +++ b/models/components/createsubscriberrequestdto.go @@ -2,138 +2,25 @@ package components -import ( - "errors" - "fmt" - "github.com/novuhq/novu-go/internal/utils" -) - -type CreateSubscriberRequestDtoDataType string - -const ( - CreateSubscriberRequestDtoDataTypeStr CreateSubscriberRequestDtoDataType = "str" - CreateSubscriberRequestDtoDataTypeArrayOfStr CreateSubscriberRequestDtoDataType = "arrayOfStr" - CreateSubscriberRequestDtoDataTypeBoolean CreateSubscriberRequestDtoDataType = "boolean" - CreateSubscriberRequestDtoDataTypeNumber CreateSubscriberRequestDtoDataType = "number" -) - -type CreateSubscriberRequestDtoData struct { - Str *string `queryParam:"inline"` - ArrayOfStr []string `queryParam:"inline"` - Boolean *bool `queryParam:"inline"` - Number *float64 `queryParam:"inline"` - - Type CreateSubscriberRequestDtoDataType -} - -func CreateCreateSubscriberRequestDtoDataStr(str string) CreateSubscriberRequestDtoData { - typ := CreateSubscriberRequestDtoDataTypeStr - - return CreateSubscriberRequestDtoData{ - Str: &str, - Type: typ, - } -} - -func CreateCreateSubscriberRequestDtoDataArrayOfStr(arrayOfStr []string) CreateSubscriberRequestDtoData { - typ := CreateSubscriberRequestDtoDataTypeArrayOfStr - - return CreateSubscriberRequestDtoData{ - ArrayOfStr: arrayOfStr, - Type: typ, - } -} - -func CreateCreateSubscriberRequestDtoDataBoolean(boolean bool) CreateSubscriberRequestDtoData { - typ := CreateSubscriberRequestDtoDataTypeBoolean - - return CreateSubscriberRequestDtoData{ - Boolean: &boolean, - Type: typ, - } -} - -func CreateCreateSubscriberRequestDtoDataNumber(number float64) CreateSubscriberRequestDtoData { - typ := CreateSubscriberRequestDtoDataTypeNumber - - return CreateSubscriberRequestDtoData{ - Number: &number, - Type: typ, - } -} - -func (u *CreateSubscriberRequestDtoData) UnmarshalJSON(data []byte) error { - - var str string = "" - if err := utils.UnmarshalJSON(data, &str, "", true, true); err == nil { - u.Str = &str - u.Type = CreateSubscriberRequestDtoDataTypeStr - return nil - } - - var arrayOfStr []string = []string{} - if err := utils.UnmarshalJSON(data, &arrayOfStr, "", true, true); err == nil { - u.ArrayOfStr = arrayOfStr - u.Type = CreateSubscriberRequestDtoDataTypeArrayOfStr - return nil - } - - var boolean bool = false - if err := utils.UnmarshalJSON(data, &boolean, "", true, true); err == nil { - u.Boolean = &boolean - u.Type = CreateSubscriberRequestDtoDataTypeBoolean - return nil - } - - var number float64 = float64(0) - if err := utils.UnmarshalJSON(data, &number, "", true, true); err == nil { - u.Number = &number - u.Type = CreateSubscriberRequestDtoDataTypeNumber - return nil - } - - return fmt.Errorf("could not unmarshal `%s` into any supported union types for CreateSubscriberRequestDtoData", string(data)) -} - -func (u CreateSubscriberRequestDtoData) MarshalJSON() ([]byte, error) { - if u.Str != nil { - return utils.MarshalJSON(u.Str, "", true) - } - - if u.ArrayOfStr != nil { - return utils.MarshalJSON(u.ArrayOfStr, "", true) - } - - if u.Boolean != nil { - return utils.MarshalJSON(u.Boolean, "", true) - } - - if u.Number != nil { - return utils.MarshalJSON(u.Number, "", true) - } - - return nil, errors.New("could not marshal union type CreateSubscriberRequestDtoData: all fields are null") -} - type CreateSubscriberRequestDto struct { - // The internal identifier you used to create this subscriber, usually correlates to the id the user in your systems + // Unique identifier of the subscriber SubscriberID string `json:"subscriberId"` - // The email address of the subscriber. - Email *string `json:"email,omitempty"` - // The first name of the subscriber. + // First name of the subscriber FirstName *string `json:"firstName,omitempty"` - // The last name of the subscriber. + // Last name of the subscriber LastName *string `json:"lastName,omitempty"` - // The phone number of the subscriber. + // Email address of the subscriber + Email *string `json:"email,omitempty"` + // Phone number of the subscriber Phone *string `json:"phone,omitempty"` - // An HTTP URL to the profile image of your subscriber. + // Avatar URL or identifier Avatar *string `json:"avatar,omitempty"` - // The locale of the subscriber. + // Timezone of the subscriber + Timezone *string `json:"timezone,omitempty"` + // Locale of the subscriber Locale *string `json:"locale,omitempty"` - // An optional payload object that can contain any properties. - Data map[string]CreateSubscriberRequestDtoData `json:"data,omitempty"` - // An optional array of subscriber channels. - Channels []SubscriberChannelDto `json:"channels,omitempty"` + // Additional custom data for the subscriber + Data map[string]any `json:"data,omitempty"` } func (o *CreateSubscriberRequestDto) GetSubscriberID() string { @@ -143,25 +30,25 @@ func (o *CreateSubscriberRequestDto) GetSubscriberID() string { return o.SubscriberID } -func (o *CreateSubscriberRequestDto) GetEmail() *string { +func (o *CreateSubscriberRequestDto) GetFirstName() *string { if o == nil { return nil } - return o.Email + return o.FirstName } -func (o *CreateSubscriberRequestDto) GetFirstName() *string { +func (o *CreateSubscriberRequestDto) GetLastName() *string { if o == nil { return nil } - return o.FirstName + return o.LastName } -func (o *CreateSubscriberRequestDto) GetLastName() *string { +func (o *CreateSubscriberRequestDto) GetEmail() *string { if o == nil { return nil } - return o.LastName + return o.Email } func (o *CreateSubscriberRequestDto) GetPhone() *string { @@ -178,23 +65,23 @@ func (o *CreateSubscriberRequestDto) GetAvatar() *string { return o.Avatar } -func (o *CreateSubscriberRequestDto) GetLocale() *string { +func (o *CreateSubscriberRequestDto) GetTimezone() *string { if o == nil { return nil } - return o.Locale + return o.Timezone } -func (o *CreateSubscriberRequestDto) GetData() map[string]CreateSubscriberRequestDtoData { +func (o *CreateSubscriberRequestDto) GetLocale() *string { if o == nil { return nil } - return o.Data + return o.Locale } -func (o *CreateSubscriberRequestDto) GetChannels() []SubscriberChannelDto { +func (o *CreateSubscriberRequestDto) GetData() map[string]any { if o == nil { return nil } - return o.Channels + return o.Data } diff --git a/models/components/deletesubscriberresponsedto.go b/models/components/deletesubscriberresponsedto.go deleted file mode 100644 index 604a551..0000000 --- a/models/components/deletesubscriberresponsedto.go +++ /dev/null @@ -1,53 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -import ( - "encoding/json" - "fmt" -) - -// DeleteSubscriberResponseDtoStatus - The status enum for the performed action -type DeleteSubscriberResponseDtoStatus string - -const ( - DeleteSubscriberResponseDtoStatusDeleted DeleteSubscriberResponseDtoStatus = "deleted" -) - -func (e DeleteSubscriberResponseDtoStatus) ToPointer() *DeleteSubscriberResponseDtoStatus { - return &e -} -func (e *DeleteSubscriberResponseDtoStatus) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "deleted": - *e = DeleteSubscriberResponseDtoStatus(v) - return nil - default: - return fmt.Errorf("invalid value for DeleteSubscriberResponseDtoStatus: %v", v) - } -} - -type DeleteSubscriberResponseDto struct { - // A boolean stating the success of the action - Acknowledged bool `json:"acknowledged"` - // The status enum for the performed action - Status DeleteSubscriberResponseDtoStatus `json:"status"` -} - -func (o *DeleteSubscriberResponseDto) GetAcknowledged() bool { - if o == nil { - return false - } - return o.Acknowledged -} - -func (o *DeleteSubscriberResponseDto) GetStatus() DeleteSubscriberResponseDtoStatus { - if o == nil { - return DeleteSubscriberResponseDtoStatus("") - } - return o.Status -} diff --git a/models/components/getsubscriberpreferencesresponsedto.go b/models/components/getsubscriberpreferencesresponsedto.go deleted file mode 100644 index 9b34587..0000000 --- a/models/components/getsubscriberpreferencesresponsedto.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type GetSubscriberPreferencesResponseDto struct { - // The workflow information and if it is critical or not - Template *TemplateResponse `json:"template,omitempty"` - // The preferences of the subscriber regarding the related workflow - Preference Preference `json:"preference"` -} - -func (o *GetSubscriberPreferencesResponseDto) GetTemplate() *TemplateResponse { - if o == nil { - return nil - } - return o.Template -} - -func (o *GetSubscriberPreferencesResponseDto) GetPreference() Preference { - if o == nil { - return Preference{} - } - return o.Preference -} diff --git a/models/components/notificationtriggerresponse.go b/models/components/notificationtriggerresponse.go deleted file mode 100644 index 00e2aee..0000000 --- a/models/components/notificationtriggerresponse.go +++ /dev/null @@ -1,51 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type NotificationTriggerResponse struct { - // The type of the trigger - Type TriggerTypeEnum `json:"type"` - // The identifier of the trigger - Identifier string `json:"identifier"` - // The variables of the trigger - Variables []NotificationTriggerVariableResponse `json:"variables"` - // The subscriber variables of the trigger - SubscriberVariables []NotificationTriggerVariableResponse `json:"subscriberVariables,omitempty"` - // The reserved variables of the trigger - ReservedVariables []TriggerReservedVariableResponse `json:"reservedVariables,omitempty"` -} - -func (o *NotificationTriggerResponse) GetType() TriggerTypeEnum { - if o == nil { - return TriggerTypeEnum("") - } - return o.Type -} - -func (o *NotificationTriggerResponse) GetIdentifier() string { - if o == nil { - return "" - } - return o.Identifier -} - -func (o *NotificationTriggerResponse) GetVariables() []NotificationTriggerVariableResponse { - if o == nil { - return []NotificationTriggerVariableResponse{} - } - return o.Variables -} - -func (o *NotificationTriggerResponse) GetSubscriberVariables() []NotificationTriggerVariableResponse { - if o == nil { - return nil - } - return o.SubscriberVariables -} - -func (o *NotificationTriggerResponse) GetReservedVariables() []TriggerReservedVariableResponse { - if o == nil { - return nil - } - return o.ReservedVariables -} diff --git a/models/components/notificationtriggervariableresponse.go b/models/components/notificationtriggervariableresponse.go deleted file mode 100644 index f2f027d..0000000 --- a/models/components/notificationtriggervariableresponse.go +++ /dev/null @@ -1,72 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -import ( - "encoding/json" - "fmt" -) - -// NotificationTriggerVariableResponseValue - The value of the variable -type NotificationTriggerVariableResponseValue struct { -} - -// NotificationTriggerVariableResponseType - The type of the variable -type NotificationTriggerVariableResponseType string - -const ( - NotificationTriggerVariableResponseTypeString NotificationTriggerVariableResponseType = "String" - NotificationTriggerVariableResponseTypeArray NotificationTriggerVariableResponseType = "Array" - NotificationTriggerVariableResponseTypeBoolean NotificationTriggerVariableResponseType = "Boolean" -) - -func (e NotificationTriggerVariableResponseType) ToPointer() *NotificationTriggerVariableResponseType { - return &e -} -func (e *NotificationTriggerVariableResponseType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "String": - fallthrough - case "Array": - fallthrough - case "Boolean": - *e = NotificationTriggerVariableResponseType(v) - return nil - default: - return fmt.Errorf("invalid value for NotificationTriggerVariableResponseType: %v", v) - } -} - -type NotificationTriggerVariableResponse struct { - // The name of the variable - Name string `json:"name"` - // The value of the variable - Value *NotificationTriggerVariableResponseValue `json:"value,omitempty"` - // The type of the variable - Type *NotificationTriggerVariableResponseType `json:"type,omitempty"` -} - -func (o *NotificationTriggerVariableResponse) GetName() string { - if o == nil { - return "" - } - return o.Name -} - -func (o *NotificationTriggerVariableResponse) GetValue() *NotificationTriggerVariableResponseValue { - if o == nil { - return nil - } - return o.Value -} - -func (o *NotificationTriggerVariableResponse) GetType() *NotificationTriggerVariableResponseType { - if o == nil { - return nil - } - return o.Type -} diff --git a/models/components/patchsubscriberrequestdto.go b/models/components/patchsubscriberrequestdto.go index 62bccfd..4125c2b 100644 --- a/models/components/patchsubscriberrequestdto.go +++ b/models/components/patchsubscriberrequestdto.go @@ -7,8 +7,6 @@ type PatchSubscriberRequestDtoData struct { } type PatchSubscriberRequestDto struct { - // Unique identifier of the subscriber - SubscriberID *string `json:"subscriberId,omitempty"` // First name of the subscriber FirstName *string `json:"firstName,omitempty"` // Last name of the subscriber @@ -27,13 +25,6 @@ type PatchSubscriberRequestDto struct { Data *PatchSubscriberRequestDtoData `json:"data,omitempty"` } -func (o *PatchSubscriberRequestDto) GetSubscriberID() *string { - if o == nil { - return nil - } - return o.SubscriberID -} - func (o *PatchSubscriberRequestDto) GetFirstName() *string { if o == nil { return nil diff --git a/models/components/preference.go b/models/components/preference.go deleted file mode 100644 index 3219bf5..0000000 --- a/models/components/preference.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type Preference struct { - // Sets if the workflow is fully enabled for all channels or not for the subscriber. - Enabled bool `json:"enabled"` - // Subscriber preferences for the different channels regarding this workflow - Channels PreferenceChannels `json:"channels"` -} - -func (o *Preference) GetEnabled() bool { - if o == nil { - return false - } - return o.Enabled -} - -func (o *Preference) GetChannels() PreferenceChannels { - if o == nil { - return PreferenceChannels{} - } - return o.Channels -} diff --git a/models/components/subscriberpayloaddto.go b/models/components/subscriberpayloaddto.go index 20f9522..084321a 100644 --- a/models/components/subscriberpayloaddto.go +++ b/models/components/subscriberpayloaddto.go @@ -134,6 +134,8 @@ type SubscriberPayloadDto struct { Data map[string]Data `json:"data,omitempty"` // An optional array of subscriber channels. Channels []SubscriberChannelDto `json:"channels,omitempty"` + // The timezone of the subscriber. + Timezone *string `json:"timezone,omitempty"` } func (o *SubscriberPayloadDto) GetSubscriberID() string { @@ -198,3 +200,10 @@ func (o *SubscriberPayloadDto) GetChannels() []SubscriberChannelDto { } return o.Channels } + +func (o *SubscriberPayloadDto) GetTimezone() *string { + if o == nil { + return nil + } + return o.Timezone +} diff --git a/models/components/subscriberresponsedto.go b/models/components/subscriberresponsedto.go index ac4a0a3..208f96e 100644 --- a/models/components/subscriberresponsedto.go +++ b/models/components/subscriberresponsedto.go @@ -43,6 +43,8 @@ type SubscriberResponseDto struct { V *float64 `json:"__v,omitempty"` // Additional custom data for the subscriber Data map[string]any `json:"data,omitempty"` + // Timezone of the subscriber + Timezone *string `json:"timezone,omitempty"` } func (o *SubscriberResponseDto) GetID() *string { @@ -177,3 +179,10 @@ func (o *SubscriberResponseDto) GetData() map[string]any { } return o.Data } + +func (o *SubscriberResponseDto) GetTimezone() *string { + if o == nil { + return nil + } + return o.Timezone +} diff --git a/models/components/templateresponse.go b/models/components/templateresponse.go deleted file mode 100644 index d1816d1..0000000 --- a/models/components/templateresponse.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type TemplateResponse struct { - // Unique identifier of the workflow - ID string `json:"_id"` - // Name of the workflow - Name string `json:"name"` - // Critical templates will always be delivered to the end user and should be hidden from the subscriber preferences screen - Critical bool `json:"critical"` - // Triggers are the events that will trigger the workflow. - Triggers []NotificationTriggerResponse `json:"triggers"` -} - -func (o *TemplateResponse) GetID() string { - if o == nil { - return "" - } - return o.ID -} - -func (o *TemplateResponse) GetName() string { - if o == nil { - return "" - } - return o.Name -} - -func (o *TemplateResponse) GetCritical() bool { - if o == nil { - return false - } - return o.Critical -} - -func (o *TemplateResponse) GetTriggers() []NotificationTriggerResponse { - if o == nil { - return []NotificationTriggerResponse{} - } - return o.Triggers -} diff --git a/models/components/triggereventresponsedto.go b/models/components/triggereventresponsedto.go index dbd4fc6..f144caf 100644 --- a/models/components/triggereventresponsedto.go +++ b/models/components/triggereventresponsedto.go @@ -17,6 +17,7 @@ const ( StatusNoWorkflowStepsDefined Status = "no_workflow_steps_defined" StatusProcessed Status = "processed" StatusNoTenantFound Status = "no_tenant_found" + StatusInvalidRecipients Status = "invalid_recipients" ) func (e Status) ToPointer() *Status { @@ -39,6 +40,8 @@ func (e *Status) UnmarshalJSON(data []byte) error { case "processed": fallthrough case "no_tenant_found": + fallthrough + case "invalid_recipients": *e = Status(v) return nil default: diff --git a/models/components/triggerreservedvariableresponse.go b/models/components/triggerreservedvariableresponse.go deleted file mode 100644 index 55b9d00..0000000 --- a/models/components/triggerreservedvariableresponse.go +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -import ( - "encoding/json" - "fmt" -) - -// TriggerReservedVariableResponseType - The type of the reserved variable -type TriggerReservedVariableResponseType string - -const ( - TriggerReservedVariableResponseTypeTenant TriggerReservedVariableResponseType = "tenant" - TriggerReservedVariableResponseTypeActor TriggerReservedVariableResponseType = "actor" -) - -func (e TriggerReservedVariableResponseType) ToPointer() *TriggerReservedVariableResponseType { - return &e -} -func (e *TriggerReservedVariableResponseType) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "tenant": - fallthrough - case "actor": - *e = TriggerReservedVariableResponseType(v) - return nil - default: - return fmt.Errorf("invalid value for TriggerReservedVariableResponseType: %v", v) - } -} - -type TriggerReservedVariableResponse struct { - // The type of the reserved variable - Type TriggerReservedVariableResponseType `json:"type"` - // The reserved variables of the trigger - Variables []string `json:"variables"` -} - -func (o *TriggerReservedVariableResponse) GetType() TriggerReservedVariableResponseType { - if o == nil { - return TriggerReservedVariableResponseType("") - } - return o.Type -} - -func (o *TriggerReservedVariableResponse) GetVariables() []string { - if o == nil { - return []string{} - } - return o.Variables -} diff --git a/models/components/triggertypeenum.go b/models/components/triggertypeenum.go deleted file mode 100644 index bd00dc7..0000000 --- a/models/components/triggertypeenum.go +++ /dev/null @@ -1,32 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -import ( - "encoding/json" - "fmt" -) - -// TriggerTypeEnum - The type of the trigger -type TriggerTypeEnum string - -const ( - TriggerTypeEnumEvent TriggerTypeEnum = "event" -) - -func (e TriggerTypeEnum) ToPointer() *TriggerTypeEnum { - return &e -} -func (e *TriggerTypeEnum) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "event": - *e = TriggerTypeEnum(v) - return nil - default: - return fmt.Errorf("invalid value for TriggerTypeEnum: %v", v) - } -} diff --git a/models/components/updatesubscriberglobalpreferencesrequestdto.go b/models/components/updatesubscriberglobalpreferencesrequestdto.go deleted file mode 100644 index 83c332b..0000000 --- a/models/components/updatesubscriberglobalpreferencesrequestdto.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type UpdateSubscriberGlobalPreferencesRequestDto struct { - // Enable or disable the subscriber global preferences. - Enabled *bool `json:"enabled,omitempty"` - // The subscriber global preferences for every ChannelTypeEnum. - Preferences []ChannelPreference `json:"preferences,omitempty"` -} - -func (o *UpdateSubscriberGlobalPreferencesRequestDto) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} - -func (o *UpdateSubscriberGlobalPreferencesRequestDto) GetPreferences() []ChannelPreference { - if o == nil { - return nil - } - return o.Preferences -} diff --git a/models/components/updatesubscriberpreferenceglobalresponsedto.go b/models/components/updatesubscriberpreferenceglobalresponsedto.go deleted file mode 100644 index 77a891d..0000000 --- a/models/components/updatesubscriberpreferenceglobalresponsedto.go +++ /dev/null @@ -1,15 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type UpdateSubscriberPreferenceGlobalResponseDto struct { - // The preferences of the subscriber regarding the related workflow - Preference Preference `json:"preference"` -} - -func (o *UpdateSubscriberPreferenceGlobalResponseDto) GetPreference() Preference { - if o == nil { - return Preference{} - } - return o.Preference -} diff --git a/models/components/updatesubscriberpreferencerequestdto.go b/models/components/updatesubscriberpreferencerequestdto.go deleted file mode 100644 index 87825c7..0000000 --- a/models/components/updatesubscriberpreferencerequestdto.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type UpdateSubscriberPreferenceRequestDto struct { - // Optional preferences for each channel type in the assigned workflow. - Channel *ChannelPreference `json:"channel,omitempty"` - // Indicates whether the workflow is fully enabled for all channels for the subscriber. - Enabled *bool `json:"enabled,omitempty"` -} - -func (o *UpdateSubscriberPreferenceRequestDto) GetChannel() *ChannelPreference { - if o == nil { - return nil - } - return o.Channel -} - -func (o *UpdateSubscriberPreferenceRequestDto) GetEnabled() *bool { - if o == nil { - return nil - } - return o.Enabled -} diff --git a/models/components/updatesubscriberpreferenceresponsedto.go b/models/components/updatesubscriberpreferenceresponsedto.go deleted file mode 100644 index bdbca5d..0000000 --- a/models/components/updatesubscriberpreferenceresponsedto.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type UpdateSubscriberPreferenceResponseDto struct { - // The workflow information and if it is critical or not - Template TemplateResponse `json:"template"` - // The preferences of the subscriber regarding the related workflow - Preference Preference `json:"preference"` -} - -func (o *UpdateSubscriberPreferenceResponseDto) GetTemplate() TemplateResponse { - if o == nil { - return TemplateResponse{} - } - return o.Template -} - -func (o *UpdateSubscriberPreferenceResponseDto) GetPreference() Preference { - if o == nil { - return Preference{} - } - return o.Preference -} diff --git a/models/components/updatesubscriberrequestdto.go b/models/components/updatesubscriberrequestdto.go deleted file mode 100644 index b6903e5..0000000 --- a/models/components/updatesubscriberrequestdto.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package components - -type UpdateSubscriberRequestDto struct { - // The email address of the subscriber. - Email *string `json:"email,omitempty"` - // The first name of the subscriber. - FirstName *string `json:"firstName,omitempty"` - // The last name of the subscriber. - LastName *string `json:"lastName,omitempty"` - // The phone number of the subscriber. - Phone *string `json:"phone,omitempty"` - // The avatar URL of the subscriber. - Avatar *string `json:"avatar,omitempty"` - // The locale of the subscriber, for example "en-US". - Locale *string `json:"locale,omitempty"` - // Custom data associated with the subscriber. Can contain any additional properties. - Data map[string]any `json:"data,omitempty"` - // An array of communication channels for the subscriber. - Channels []SubscriberChannelDto `json:"channels,omitempty"` -} - -func (o *UpdateSubscriberRequestDto) GetEmail() *string { - if o == nil { - return nil - } - return o.Email -} - -func (o *UpdateSubscriberRequestDto) GetFirstName() *string { - if o == nil { - return nil - } - return o.FirstName -} - -func (o *UpdateSubscriberRequestDto) GetLastName() *string { - if o == nil { - return nil - } - return o.LastName -} - -func (o *UpdateSubscriberRequestDto) GetPhone() *string { - if o == nil { - return nil - } - return o.Phone -} - -func (o *UpdateSubscriberRequestDto) GetAvatar() *string { - if o == nil { - return nil - } - return o.Avatar -} - -func (o *UpdateSubscriberRequestDto) GetLocale() *string { - if o == nil { - return nil - } - return o.Locale -} - -func (o *UpdateSubscriberRequestDto) GetData() map[string]any { - if o == nil { - return nil - } - return o.Data -} - -func (o *UpdateSubscriberRequestDto) GetChannels() []SubscriberChannelDto { - if o == nil { - return nil - } - return o.Channels -} diff --git a/models/components/workfloworiginenum.go b/models/components/workfloworiginenum.go new file mode 100644 index 0000000..cf08091 --- /dev/null +++ b/models/components/workfloworiginenum.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" +) + +// WorkflowOriginEnum - Origin of the workflow +type WorkflowOriginEnum string + +const ( + WorkflowOriginEnumNovuCloud WorkflowOriginEnum = "novu-cloud" + WorkflowOriginEnumNovuCloudV1 WorkflowOriginEnum = "novu-cloud-v1" + WorkflowOriginEnumExternal WorkflowOriginEnum = "external" +) + +func (e WorkflowOriginEnum) ToPointer() *WorkflowOriginEnum { + return &e +} +func (e *WorkflowOriginEnum) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "novu-cloud": + fallthrough + case "novu-cloud-v1": + fallthrough + case "external": + *e = WorkflowOriginEnum(v) + return nil + default: + return fmt.Errorf("invalid value for WorkflowOriginEnum: %v", v) + } +} diff --git a/models/operations/notificationscontrollerlistnotifications.go b/models/operations/notificationscontrollerlistnotifications.go index 7767c42..de8555e 100644 --- a/models/operations/notificationscontrollerlistnotifications.go +++ b/models/operations/notificationscontrollerlistnotifications.go @@ -22,6 +22,8 @@ type NotificationsControllerListNotificationsRequest struct { SubscriberIds []string `queryParam:"style=form,explode=true,name=subscriberIds"` // Page number for pagination Page *float64 `default:"0" queryParam:"style=form,explode=true,name=page"` + // Limit for pagination + Limit *float64 `default:"10" queryParam:"style=form,explode=true,name=limit"` // Transaction ID for filtering TransactionID *string `queryParam:"style=form,explode=true,name=transactionId"` // Date filter for records after this timestamp @@ -85,6 +87,13 @@ func (o *NotificationsControllerListNotificationsRequest) GetPage() *float64 { return o.Page } +func (o *NotificationsControllerListNotificationsRequest) GetLimit() *float64 { + if o == nil { + return nil + } + return o.Limit +} + func (o *NotificationsControllerListNotificationsRequest) GetTransactionID() *string { if o == nil { return nil diff --git a/models/operations/subscribersv1controllercreatesubscriber.go b/models/operations/subscriberscontrollercreatesubscriber.go similarity index 59% rename from models/operations/subscribersv1controllercreatesubscriber.go rename to models/operations/subscriberscontrollercreatesubscriber.go index cec26df..2154b7b 100644 --- a/models/operations/subscribersv1controllercreatesubscriber.go +++ b/models/operations/subscriberscontrollercreatesubscriber.go @@ -6,48 +6,48 @@ import ( "github.com/novuhq/novu-go/models/components" ) -type SubscribersV1ControllerCreateSubscriberRequest struct { +type SubscribersControllerCreateSubscriberRequest struct { // A header for idempotency purposes IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` CreateSubscriberRequestDto components.CreateSubscriberRequestDto `request:"mediaType=application/json"` } -func (o *SubscribersV1ControllerCreateSubscriberRequest) GetIdempotencyKey() *string { +func (o *SubscribersControllerCreateSubscriberRequest) GetIdempotencyKey() *string { if o == nil { return nil } return o.IdempotencyKey } -func (o *SubscribersV1ControllerCreateSubscriberRequest) GetCreateSubscriberRequestDto() components.CreateSubscriberRequestDto { +func (o *SubscribersControllerCreateSubscriberRequest) GetCreateSubscriberRequestDto() components.CreateSubscriberRequestDto { if o == nil { return components.CreateSubscriberRequestDto{} } return o.CreateSubscriberRequestDto } -type SubscribersV1ControllerCreateSubscriberResponse struct { +type SubscribersControllerCreateSubscriberResponse struct { HTTPMeta components.HTTPMetadata `json:"-"` // Created SubscriberResponseDto *components.SubscriberResponseDto Headers map[string][]string } -func (o *SubscribersV1ControllerCreateSubscriberResponse) GetHTTPMeta() components.HTTPMetadata { +func (o *SubscribersControllerCreateSubscriberResponse) GetHTTPMeta() components.HTTPMetadata { if o == nil { return components.HTTPMetadata{} } return o.HTTPMeta } -func (o *SubscribersV1ControllerCreateSubscriberResponse) GetSubscriberResponseDto() *components.SubscriberResponseDto { +func (o *SubscribersControllerCreateSubscriberResponse) GetSubscriberResponseDto() *components.SubscriberResponseDto { if o == nil { return nil } return o.SubscriberResponseDto } -func (o *SubscribersV1ControllerCreateSubscriberResponse) GetHeaders() map[string][]string { +func (o *SubscribersControllerCreateSubscriberResponse) GetHeaders() map[string][]string { if o == nil { return map[string][]string{} } diff --git a/models/operations/subscribersv1controllergetsubscriber.go b/models/operations/subscribersv1controllergetsubscriber.go deleted file mode 100644 index 722f9f3..0000000 --- a/models/operations/subscribersv1controllergetsubscriber.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/novuhq/novu-go/models/components" -) - -type SubscribersV1ControllerGetSubscriberRequest struct { - SubscriberID string `pathParam:"style=simple,explode=false,name=subscriberId"` - // Includes the topics associated with the subscriber - IncludeTopics *bool `queryParam:"style=form,explode=true,name=includeTopics"` - // A header for idempotency purposes - IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` -} - -func (o *SubscribersV1ControllerGetSubscriberRequest) GetSubscriberID() string { - if o == nil { - return "" - } - return o.SubscriberID -} - -func (o *SubscribersV1ControllerGetSubscriberRequest) GetIncludeTopics() *bool { - if o == nil { - return nil - } - return o.IncludeTopics -} - -func (o *SubscribersV1ControllerGetSubscriberRequest) GetIdempotencyKey() *string { - if o == nil { - return nil - } - return o.IdempotencyKey -} - -type SubscribersV1ControllerGetSubscriberResponse struct { - HTTPMeta components.HTTPMetadata `json:"-"` - // OK - SubscriberResponseDto *components.SubscriberResponseDto - Headers map[string][]string -} - -func (o *SubscribersV1ControllerGetSubscriberResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta -} - -func (o *SubscribersV1ControllerGetSubscriberResponse) GetSubscriberResponseDto() *components.SubscriberResponseDto { - if o == nil { - return nil - } - return o.SubscriberResponseDto -} - -func (o *SubscribersV1ControllerGetSubscriberResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} diff --git a/models/operations/subscribersv1controllergetsubscriberpreferencebylevel.go b/models/operations/subscribersv1controllergetsubscriberpreferencebylevel.go deleted file mode 100644 index b14f95d..0000000 --- a/models/operations/subscribersv1controllergetsubscriberpreferencebylevel.go +++ /dev/null @@ -1,102 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "encoding/json" - "fmt" - "github.com/novuhq/novu-go/models/components" -) - -// Parameter - the preferences level to be retrieved (template / global) -type Parameter string - -const ( - ParameterGlobal Parameter = "global" - ParameterTemplate Parameter = "template" -) - -func (e Parameter) ToPointer() *Parameter { - return &e -} -func (e *Parameter) UnmarshalJSON(data []byte) error { - var v string - if err := json.Unmarshal(data, &v); err != nil { - return err - } - switch v { - case "global": - fallthrough - case "template": - *e = Parameter(v) - return nil - default: - return fmt.Errorf("invalid value for Parameter: %v", v) - } -} - -type SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest struct { - // A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true - IncludeInactiveChannels *bool `queryParam:"style=form,explode=true,name=includeInactiveChannels"` - // the preferences level to be retrieved (template / global) - PreferenceLevel Parameter `pathParam:"style=simple,explode=false,name=parameter"` - SubscriberID string `pathParam:"style=simple,explode=false,name=subscriberId"` - // A header for idempotency purposes - IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` -} - -func (o *SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest) GetIncludeInactiveChannels() *bool { - if o == nil { - return nil - } - return o.IncludeInactiveChannels -} - -func (o *SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest) GetPreferenceLevel() Parameter { - if o == nil { - return Parameter("") - } - return o.PreferenceLevel -} - -func (o *SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest) GetSubscriberID() string { - if o == nil { - return "" - } - return o.SubscriberID -} - -func (o *SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest) GetIdempotencyKey() *string { - if o == nil { - return nil - } - return o.IdempotencyKey -} - -type SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse struct { - HTTPMeta components.HTTPMetadata `json:"-"` - // OK - GetSubscriberPreferencesResponseDtos []components.GetSubscriberPreferencesResponseDto - Headers map[string][]string -} - -func (o *SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta -} - -func (o *SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse) GetGetSubscriberPreferencesResponseDtos() []components.GetSubscriberPreferencesResponseDto { - if o == nil { - return nil - } - return o.GetSubscriberPreferencesResponseDtos -} - -func (o *SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} diff --git a/models/operations/subscribersv1controllerlistsubscriberpreferences.go b/models/operations/subscribersv1controllerlistsubscriberpreferences.go deleted file mode 100644 index 4a30a0a..0000000 --- a/models/operations/subscribersv1controllerlistsubscriberpreferences.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/novuhq/novu-go/models/components" -) - -type SubscribersV1ControllerListSubscriberPreferencesRequest struct { - SubscriberID string `pathParam:"style=simple,explode=false,name=subscriberId"` - // A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true - IncludeInactiveChannels *bool `queryParam:"style=form,explode=true,name=includeInactiveChannels"` - // A header for idempotency purposes - IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` -} - -func (o *SubscribersV1ControllerListSubscriberPreferencesRequest) GetSubscriberID() string { - if o == nil { - return "" - } - return o.SubscriberID -} - -func (o *SubscribersV1ControllerListSubscriberPreferencesRequest) GetIncludeInactiveChannels() *bool { - if o == nil { - return nil - } - return o.IncludeInactiveChannels -} - -func (o *SubscribersV1ControllerListSubscriberPreferencesRequest) GetIdempotencyKey() *string { - if o == nil { - return nil - } - return o.IdempotencyKey -} - -type SubscribersV1ControllerListSubscriberPreferencesResponse struct { - HTTPMeta components.HTTPMetadata `json:"-"` - // OK - UpdateSubscriberPreferenceResponseDtos []components.UpdateSubscriberPreferenceResponseDto - Headers map[string][]string -} - -func (o *SubscribersV1ControllerListSubscriberPreferencesResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta -} - -func (o *SubscribersV1ControllerListSubscriberPreferencesResponse) GetUpdateSubscriberPreferenceResponseDtos() []components.UpdateSubscriberPreferenceResponseDto { - if o == nil { - return nil - } - return o.UpdateSubscriberPreferenceResponseDtos -} - -func (o *SubscribersV1ControllerListSubscriberPreferencesResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} diff --git a/models/operations/subscribersv1controllerremovesubscriber.go b/models/operations/subscribersv1controllerremovesubscriber.go deleted file mode 100644 index ce8952e..0000000 --- a/models/operations/subscribersv1controllerremovesubscriber.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/novuhq/novu-go/models/components" -) - -type SubscribersV1ControllerRemoveSubscriberRequest struct { - SubscriberID string `pathParam:"style=simple,explode=false,name=subscriberId"` - // A header for idempotency purposes - IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` -} - -func (o *SubscribersV1ControllerRemoveSubscriberRequest) GetSubscriberID() string { - if o == nil { - return "" - } - return o.SubscriberID -} - -func (o *SubscribersV1ControllerRemoveSubscriberRequest) GetIdempotencyKey() *string { - if o == nil { - return nil - } - return o.IdempotencyKey -} - -type SubscribersV1ControllerRemoveSubscriberResponse struct { - HTTPMeta components.HTTPMetadata `json:"-"` - // OK - DeleteSubscriberResponseDto *components.DeleteSubscriberResponseDto - Headers map[string][]string -} - -func (o *SubscribersV1ControllerRemoveSubscriberResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta -} - -func (o *SubscribersV1ControllerRemoveSubscriberResponse) GetDeleteSubscriberResponseDto() *components.DeleteSubscriberResponseDto { - if o == nil { - return nil - } - return o.DeleteSubscriberResponseDto -} - -func (o *SubscribersV1ControllerRemoveSubscriberResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} diff --git a/models/operations/subscribersv1controllerupdatesubscriber.go b/models/operations/subscribersv1controllerupdatesubscriber.go deleted file mode 100644 index 4e64afe..0000000 --- a/models/operations/subscribersv1controllerupdatesubscriber.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/novuhq/novu-go/models/components" -) - -type SubscribersV1ControllerUpdateSubscriberRequest struct { - SubscriberID string `pathParam:"style=simple,explode=false,name=subscriberId"` - // A header for idempotency purposes - IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` - UpdateSubscriberRequestDto components.UpdateSubscriberRequestDto `request:"mediaType=application/json"` -} - -func (o *SubscribersV1ControllerUpdateSubscriberRequest) GetSubscriberID() string { - if o == nil { - return "" - } - return o.SubscriberID -} - -func (o *SubscribersV1ControllerUpdateSubscriberRequest) GetIdempotencyKey() *string { - if o == nil { - return nil - } - return o.IdempotencyKey -} - -func (o *SubscribersV1ControllerUpdateSubscriberRequest) GetUpdateSubscriberRequestDto() components.UpdateSubscriberRequestDto { - if o == nil { - return components.UpdateSubscriberRequestDto{} - } - return o.UpdateSubscriberRequestDto -} - -type SubscribersV1ControllerUpdateSubscriberResponse struct { - HTTPMeta components.HTTPMetadata `json:"-"` - // OK - SubscriberResponseDto *components.SubscriberResponseDto - Headers map[string][]string -} - -func (o *SubscribersV1ControllerUpdateSubscriberResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta -} - -func (o *SubscribersV1ControllerUpdateSubscriberResponse) GetSubscriberResponseDto() *components.SubscriberResponseDto { - if o == nil { - return nil - } - return o.SubscriberResponseDto -} - -func (o *SubscribersV1ControllerUpdateSubscriberResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} diff --git a/models/operations/subscribersv1controllerupdatesubscriberglobalpreferences.go b/models/operations/subscribersv1controllerupdatesubscriberglobalpreferences.go deleted file mode 100644 index ffbe2ab..0000000 --- a/models/operations/subscribersv1controllerupdatesubscriberglobalpreferences.go +++ /dev/null @@ -1,63 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/novuhq/novu-go/models/components" -) - -type SubscribersV1ControllerUpdateSubscriberGlobalPreferencesRequest struct { - SubscriberID string `pathParam:"style=simple,explode=false,name=subscriberId"` - // A header for idempotency purposes - IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` - UpdateSubscriberGlobalPreferencesRequestDto components.UpdateSubscriberGlobalPreferencesRequestDto `request:"mediaType=application/json"` -} - -func (o *SubscribersV1ControllerUpdateSubscriberGlobalPreferencesRequest) GetSubscriberID() string { - if o == nil { - return "" - } - return o.SubscriberID -} - -func (o *SubscribersV1ControllerUpdateSubscriberGlobalPreferencesRequest) GetIdempotencyKey() *string { - if o == nil { - return nil - } - return o.IdempotencyKey -} - -func (o *SubscribersV1ControllerUpdateSubscriberGlobalPreferencesRequest) GetUpdateSubscriberGlobalPreferencesRequestDto() components.UpdateSubscriberGlobalPreferencesRequestDto { - if o == nil { - return components.UpdateSubscriberGlobalPreferencesRequestDto{} - } - return o.UpdateSubscriberGlobalPreferencesRequestDto -} - -type SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse struct { - HTTPMeta components.HTTPMetadata `json:"-"` - // OK - UpdateSubscriberPreferenceGlobalResponseDto *components.UpdateSubscriberPreferenceGlobalResponseDto - Headers map[string][]string -} - -func (o *SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta -} - -func (o *SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse) GetUpdateSubscriberPreferenceGlobalResponseDto() *components.UpdateSubscriberPreferenceGlobalResponseDto { - if o == nil { - return nil - } - return o.UpdateSubscriberPreferenceGlobalResponseDto -} - -func (o *SubscribersV1ControllerUpdateSubscriberGlobalPreferencesResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} diff --git a/models/operations/subscribersv1controllerupdatesubscriberpreference.go b/models/operations/subscribersv1controllerupdatesubscriberpreference.go deleted file mode 100644 index 36763fd..0000000 --- a/models/operations/subscribersv1controllerupdatesubscriberpreference.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. - -package operations - -import ( - "github.com/novuhq/novu-go/models/components" -) - -type SubscribersV1ControllerUpdateSubscriberPreferenceRequest struct { - SubscriberID string `pathParam:"style=simple,explode=false,name=subscriberId"` - WorkflowID string `pathParam:"style=simple,explode=false,name=parameter"` - // A header for idempotency purposes - IdempotencyKey *string `header:"style=simple,explode=false,name=idempotency-key"` - UpdateSubscriberPreferenceRequestDto components.UpdateSubscriberPreferenceRequestDto `request:"mediaType=application/json"` -} - -func (o *SubscribersV1ControllerUpdateSubscriberPreferenceRequest) GetSubscriberID() string { - if o == nil { - return "" - } - return o.SubscriberID -} - -func (o *SubscribersV1ControllerUpdateSubscriberPreferenceRequest) GetWorkflowID() string { - if o == nil { - return "" - } - return o.WorkflowID -} - -func (o *SubscribersV1ControllerUpdateSubscriberPreferenceRequest) GetIdempotencyKey() *string { - if o == nil { - return nil - } - return o.IdempotencyKey -} - -func (o *SubscribersV1ControllerUpdateSubscriberPreferenceRequest) GetUpdateSubscriberPreferenceRequestDto() components.UpdateSubscriberPreferenceRequestDto { - if o == nil { - return components.UpdateSubscriberPreferenceRequestDto{} - } - return o.UpdateSubscriberPreferenceRequestDto -} - -type SubscribersV1ControllerUpdateSubscriberPreferenceResponse struct { - HTTPMeta components.HTTPMetadata `json:"-"` - // OK - UpdateSubscriberPreferenceResponseDto *components.UpdateSubscriberPreferenceResponseDto - Headers map[string][]string -} - -func (o *SubscribersV1ControllerUpdateSubscriberPreferenceResponse) GetHTTPMeta() components.HTTPMetadata { - if o == nil { - return components.HTTPMetadata{} - } - return o.HTTPMeta -} - -func (o *SubscribersV1ControllerUpdateSubscriberPreferenceResponse) GetUpdateSubscriberPreferenceResponseDto() *components.UpdateSubscriberPreferenceResponseDto { - if o == nil { - return nil - } - return o.UpdateSubscriberPreferenceResponseDto -} - -func (o *SubscribersV1ControllerUpdateSubscriberPreferenceResponse) GetHeaders() map[string][]string { - if o == nil { - return map[string][]string{} - } - return o.Headers -} diff --git a/notifications.go b/notifications.go index e6c22a9..7910517 100644 --- a/notifications.go +++ b/notifications.go @@ -31,13 +31,6 @@ func newNotifications(sdkConfig sdkConfiguration) *Notifications { // List - Get notifications func (s *Notifications) List(ctx context.Context, request operations.NotificationsControllerListNotificationsRequest, opts ...operations.Option) (*operations.NotificationsControllerListNotificationsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "NotificationsController_listNotifications", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -61,6 +54,14 @@ func (s *Notifications) List(ctx context.Context, request operations.Notificatio return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "NotificationsController_listNotifications", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -366,13 +367,6 @@ func (s *Notifications) List(ctx context.Context, request operations.Notificatio // Retrieve - Get notification func (s *Notifications) Retrieve(ctx context.Context, notificationID string, idempotencyKey *string, opts ...operations.Option) (*operations.NotificationsControllerGetNotificationResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "NotificationsController_getNotification", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.NotificationsControllerGetNotificationRequest{ NotificationID: notificationID, IdempotencyKey: idempotencyKey, @@ -401,6 +395,14 @@ func (s *Notifications) Retrieve(ctx context.Context, notificationID string, ide return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "NotificationsController_getNotification", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/novu.go b/novu.go index 387879e..7264950 100644 --- a/novu.go +++ b/novu.go @@ -171,9 +171,9 @@ func New(opts ...SDKOption) *Novu { sdkConfiguration: sdkConfiguration{ Language: "go", OpenAPIDocVersion: "1.0", - SDKVersion: "0.1.17", - GenVersion: "2.503.2", - UserAgent: "speakeasy-sdk/go 0.1.17 2.503.2 1.0 github.com/novuhq/novu-go", + SDKVersion: "0.2.0", + GenVersion: "2.545.4", + UserAgent: "speakeasy-sdk/go 0.2.0 2.545.4 1.0 github.com/novuhq/novu-go", Hooks: hooks.New(), }, } @@ -219,13 +219,6 @@ func New(opts ...SDKOption) *Novu { // The trigger identifier is used to match the particular workflow associated with it. // Additional information can be passed according the body interface below. func (s *Novu) Trigger(ctx context.Context, triggerEventRequestDto components.TriggerEventRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.EventsControllerTriggerResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "EventsController_trigger", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.EventsControllerTriggerRequest{ IdempotencyKey: idempotencyKey, TriggerEventRequestDto: triggerEventRequestDto, @@ -254,6 +247,13 @@ func (s *Novu) Trigger(ctx context.Context, triggerEventRequestDto components.Tr return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "EventsController_trigger", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "TriggerEventRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -566,13 +566,6 @@ func (s *Novu) Trigger(ctx context.Context, triggerEventRequestDto components.Tr // Using this endpoint you can trigger multiple events at once, to avoid multiple calls to the API. // The bulk API is limited to 100 events per request. func (s *Novu) TriggerBulk(ctx context.Context, bulkTriggerEventDto components.BulkTriggerEventDto, idempotencyKey *string, opts ...operations.Option) (*operations.EventsControllerTriggerBulkResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "EventsController_triggerBulk", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.EventsControllerTriggerBulkRequest{ IdempotencyKey: idempotencyKey, BulkTriggerEventDto: bulkTriggerEventDto, @@ -601,6 +594,13 @@ func (s *Novu) TriggerBulk(ctx context.Context, bulkTriggerEventDto components.B return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "EventsController_triggerBulk", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "BulkTriggerEventDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -913,13 +913,6 @@ func (s *Novu) TriggerBulk(ctx context.Context, bulkTriggerEventDto components.B // // In the future could be used to trigger events to a subset of subscribers based on defined filters. func (s *Novu) TriggerBroadcast(ctx context.Context, triggerEventToAllRequestDto components.TriggerEventToAllRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.EventsControllerBroadcastEventToAllResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "EventsController_broadcastEventToAll", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.EventsControllerBroadcastEventToAllRequest{ IdempotencyKey: idempotencyKey, TriggerEventToAllRequestDto: triggerEventToAllRequestDto, @@ -948,6 +941,13 @@ func (s *Novu) TriggerBroadcast(ctx context.Context, triggerEventToAllRequestDto return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "EventsController_broadcastEventToAll", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "TriggerEventToAllRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -1262,13 +1262,6 @@ func (s *Novu) TriggerBroadcast(ctx context.Context, triggerEventToAllRequestDto // Using a previously generated transactionId during the event trigger, // will cancel any active or pending workflows. This is useful to cancel active digests, delays etc... func (s *Novu) Cancel(ctx context.Context, transactionID string, idempotencyKey *string, opts ...operations.Option) (*operations.EventsControllerCancelResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "EventsController_cancel", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.EventsControllerCancelRequest{ TransactionID: transactionID, IdempotencyKey: idempotencyKey, @@ -1297,6 +1290,14 @@ func (s *Novu) Cancel(ctx context.Context, transactionID string, idempotencyKey return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "EventsController_cancel", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/novumessages.go b/novumessages.go index b0995b9..873de09 100644 --- a/novumessages.go +++ b/novumessages.go @@ -27,13 +27,6 @@ func newNovuMessages(sdkConfig sdkConfiguration) *NovuMessages { // MarkAllAs - Mark a subscriber messages as seen, read, unseen or unread func (s *NovuMessages) MarkAllAs(ctx context.Context, subscriberID string, messageMarkAsRequestDto components.MessageMarkAsRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerMarkMessagesAsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_markMessagesAs", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerMarkMessagesAsRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, @@ -63,6 +56,13 @@ func (s *NovuMessages) MarkAllAs(ctx context.Context, subscriberID string, messa return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_markMessagesAs", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "MessageMarkAsRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -372,13 +372,6 @@ func (s *NovuMessages) MarkAllAs(ctx context.Context, subscriberID string, messa // MarkAll - Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed. func (s *NovuMessages) MarkAll(ctx context.Context, subscriberID string, markAllMessageAsRequestDto components.MarkAllMessageAsRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerMarkAllUnreadAsReadResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_markAllUnreadAsRead", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerMarkAllUnreadAsReadRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, @@ -408,6 +401,13 @@ func (s *NovuMessages) MarkAll(ctx context.Context, subscriberID string, markAll return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_markAllUnreadAsRead", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "MarkAllMessageAsRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -717,13 +717,6 @@ func (s *NovuMessages) MarkAll(ctx context.Context, subscriberID string, markAll // UpdateAsSeen - Mark message action as seen func (s *NovuMessages) UpdateAsSeen(ctx context.Context, request operations.SubscribersV1ControllerMarkActionAsSeenRequest, opts ...operations.Option) (*operations.SubscribersV1ControllerMarkActionAsSeenResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_markActionAsSeen", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -747,6 +740,13 @@ func (s *NovuMessages) UpdateAsSeen(ctx context.Context, request operations.Subs return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_markActionAsSeen", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "MarkMessageActionAsSeenDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err diff --git a/novunotifications.go b/novunotifications.go index d5f1946..4e28c2d 100644 --- a/novunotifications.go +++ b/novunotifications.go @@ -27,13 +27,6 @@ func newNovuNotifications(sdkConfig sdkConfiguration) *NovuNotifications { // Feed - Get in-app notification feed for a particular subscriber func (s *NovuNotifications) Feed(ctx context.Context, request operations.SubscribersV1ControllerGetNotificationsFeedRequest, opts ...operations.Option) (*operations.SubscribersV1ControllerGetNotificationsFeedResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_getNotificationsFeed", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -57,6 +50,14 @@ func (s *NovuNotifications) Feed(ctx context.Context, request operations.Subscri return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_getNotificationsFeed", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -362,13 +363,6 @@ func (s *NovuNotifications) Feed(ctx context.Context, request operations.Subscri // UnseenCount - Get the unseen in-app notifications count for subscribers feed func (s *NovuNotifications) UnseenCount(ctx context.Context, subscriberID string, seen *bool, limit *float64, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerGetUnseenCountResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_getUnseenCount", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerGetUnseenCountRequest{ SubscriberID: subscriberID, Seen: seen, @@ -399,6 +393,14 @@ func (s *NovuNotifications) UnseenCount(ctx context.Context, subscriberID string return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_getUnseenCount", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/novusubscribers.go b/novusubscribers.go index 462246a..663b18e 100644 --- a/novusubscribers.go +++ b/novusubscribers.go @@ -28,13 +28,6 @@ func newNovuSubscribers(sdkConfig sdkConfiguration) *NovuSubscribers { // Assign - Subscribers addition // Add subscribers to a topic by key func (s *NovuSubscribers) Assign(ctx context.Context, topicKey string, addSubscribersRequestDto components.AddSubscribersRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerAssignResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_assign", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerAssignRequest{ TopicKey: topicKey, IdempotencyKey: idempotencyKey, @@ -64,6 +57,13 @@ func (s *NovuSubscribers) Assign(ctx context.Context, topicKey string, addSubscr return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_assign", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "AddSubscribersRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -374,13 +374,6 @@ func (s *NovuSubscribers) Assign(ctx context.Context, topicKey string, addSubscr // Retrieve - Check topic subscriber // Check if a subscriber belongs to a certain topic func (s *NovuSubscribers) Retrieve(ctx context.Context, externalSubscriberID string, topicKey string, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerGetTopicSubscriberResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_getTopicSubscriber", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerGetTopicSubscriberRequest{ ExternalSubscriberID: externalSubscriberID, TopicKey: topicKey, @@ -410,6 +403,14 @@ func (s *NovuSubscribers) Retrieve(ctx context.Context, externalSubscriberID str return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_getTopicSubscriber", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -712,13 +713,6 @@ func (s *NovuSubscribers) Retrieve(ctx context.Context, externalSubscriberID str // Remove - Subscribers removal // Remove subscribers from a topic func (s *NovuSubscribers) Remove(ctx context.Context, topicKey string, removeSubscribersRequestDto components.RemoveSubscribersRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerRemoveSubscribersResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_removeSubscribers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerRemoveSubscribersRequest{ TopicKey: topicKey, IdempotencyKey: idempotencyKey, @@ -748,6 +742,13 @@ func (s *NovuSubscribers) Remove(ctx context.Context, topicKey string, removeSub return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_removeSubscribers", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RemoveSubscribersRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err diff --git a/preferences.go b/preferences.go index a048fdd..d538a34 100644 --- a/preferences.go +++ b/preferences.go @@ -16,1061 +16,18 @@ import ( ) type Preferences struct { - Legacy *Legacy - - sdkConfiguration sdkConfiguration -} - -func newPreferences(sdkConfig sdkConfiguration) *Preferences { - return &Preferences{ - sdkConfiguration: sdkConfig, - Legacy: newLegacy(sdkConfig), - } -} - -// ListLegacy - Get subscriber preferences -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -func (s *Preferences) ListLegacy(ctx context.Context, subscriberID string, includeInactiveChannels *bool, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerListSubscriberPreferencesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_listSubscriberPreferences", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerListSubscriberPreferencesRequest{ - SubscriberID: subscriberID, - IncludeInactiveChannels: includeInactiveChannels, - IdempotencyKey: idempotencyKey, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/subscribers/{subscriberId}/preferences", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - - utils.PopulateHeaders(ctx, req, request, nil) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 1000, - MaxInterval: 30000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "408", - "409", - "429", - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil { - copyBody, err := req.GetBody() - if err != nil { - return nil, err - } - req.Body = copyBody - } - - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "405", "409", "413", "414", "415", "422", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SubscribersV1ControllerListSubscriberPreferencesResponse{ - HTTPMeta: components.HTTPMetadata{ - Request: req, - Response: httpRes, - }, - } - - switch { - case httpRes.StatusCode == 200: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []components.UpdateSubscriberPreferenceResponseDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.UpdateSubscriberPreferenceResponseDtos = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 414: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 405: - fallthrough - case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 413: - fallthrough - case httpRes.StatusCode == 415: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 422: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ValidationErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 429: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode == 500: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 503: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// RetrieveByLevelLegacy - Get subscriber preferences by level -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -func (s *Preferences) RetrieveByLevelLegacy(ctx context.Context, preferenceLevel operations.Parameter, subscriberID string, includeInactiveChannels *bool, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_getSubscriberPreferenceByLevel", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest{ - IncludeInactiveChannels: includeInactiveChannels, - PreferenceLevel: preferenceLevel, - SubscriberID: subscriberID, - IdempotencyKey: idempotencyKey, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/subscribers/{subscriberId}/preferences/{parameter}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - - utils.PopulateHeaders(ctx, req, request, nil) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 1000, - MaxInterval: 30000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "408", - "409", - "429", - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil { - copyBody, err := req.GetBody() - if err != nil { - return nil, err - } - req.Body = copyBody - } - - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "405", "409", "413", "414", "415", "422", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SubscribersV1ControllerGetSubscriberPreferenceByLevelResponse{ - HTTPMeta: components.HTTPMetadata{ - Request: req, - Response: httpRes, - }, - } - - switch { - case httpRes.StatusCode == 200: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out []components.GetSubscriberPreferencesResponseDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.GetSubscriberPreferencesResponseDtos = out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 414: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 405: - fallthrough - case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 413: - fallthrough - case httpRes.StatusCode == 415: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 422: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ValidationErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 429: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode == 500: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 503: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// UpdateLegacy - Update subscriber preference -func (s *Preferences) UpdateLegacy(ctx context.Context, subscriberID string, workflowID string, updateSubscriberPreferenceRequestDto components.UpdateSubscriberPreferenceRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_updateSubscriberPreference", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerUpdateSubscriberPreferenceRequest{ - SubscriberID: subscriberID, - WorkflowID: workflowID, - IdempotencyKey: idempotencyKey, - UpdateSubscriberPreferenceRequestDto: updateSubscriberPreferenceRequestDto, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/subscribers/{subscriberId}/preferences/{parameter}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpdateSubscriberPreferenceRequestDto", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - utils.PopulateHeaders(ctx, req, request, nil) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 1000, - MaxInterval: 30000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "408", - "409", - "429", - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil { - copyBody, err := req.GetBody() - if err != nil { - return nil, err - } - req.Body = copyBody - } - - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "405", "409", "413", "414", "415", "422", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse{ - HTTPMeta: components.HTTPMetadata{ - Request: req, - Response: httpRes, - }, - } - - switch { - case httpRes.StatusCode == 200: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out components.UpdateSubscriberPreferenceResponseDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.UpdateSubscriberPreferenceResponseDto = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 414: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 405: - fallthrough - case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 413: - fallthrough - case httpRes.StatusCode == 415: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 422: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ValidationErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 429: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode == 500: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } + sdkConfiguration sdkConfiguration +} - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 503: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) +func newPreferences(sdkConfig sdkConfiguration) *Preferences { + return &Preferences{ + sdkConfiguration: sdkConfig, } - - return res, nil - } -// Retrieve - Get subscriber preferences +// List - Get subscriber preferences // Get subscriber global and workflow specific preferences -func (s *Preferences) Retrieve(ctx context.Context, subscriberID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerGetSubscriberPreferencesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersController_getSubscriberPreferences", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - +func (s *Preferences) List(ctx context.Context, subscriberID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerGetSubscriberPreferencesResponse, error) { request := operations.SubscribersControllerGetSubscriberPreferencesRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, @@ -1099,6 +56,14 @@ func (s *Preferences) Retrieve(ctx context.Context, subscriberID string, idempot return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersController_getSubscriberPreferences", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1401,13 +366,6 @@ func (s *Preferences) Retrieve(ctx context.Context, subscriberID string, idempot // Update subscriber global or workflow specific preferences // Update subscriber global or workflow specific preferences func (s *Preferences) Update(ctx context.Context, subscriberID string, patchSubscriberPreferencesDto components.PatchSubscriberPreferencesDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerUpdateSubscriberPreferencesResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersController_updateSubscriberPreferences", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersControllerUpdateSubscriberPreferencesRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, @@ -1437,6 +395,13 @@ func (s *Preferences) Update(ctx context.Context, subscriberID string, patchSubs return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersController_updateSubscriberPreferences", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "PatchSubscriberPreferencesDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err diff --git a/properties.go b/properties.go index f2f4e61..7330d72 100644 --- a/properties.go +++ b/properties.go @@ -28,13 +28,6 @@ func newProperties(sdkConfig sdkConfiguration) *Properties { // UpdateOnlineFlag - Update subscriber online status // Used to update the subscriber isOnline flag. func (s *Properties) UpdateOnlineFlag(ctx context.Context, subscriberID string, updateSubscriberOnlineFlagRequestDto components.UpdateSubscriberOnlineFlagRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerUpdateSubscriberOnlineFlagResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_updateSubscriberOnlineFlag", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerUpdateSubscriberOnlineFlagRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, @@ -64,6 +57,13 @@ func (s *Properties) UpdateOnlineFlag(ctx context.Context, subscriberID string, return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_updateSubscriberOnlineFlag", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpdateSubscriberOnlineFlagRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err diff --git a/stats.go b/stats.go index 62b1d33..81c8800 100644 --- a/stats.go +++ b/stats.go @@ -28,13 +28,6 @@ func newStats(sdkConfig sdkConfiguration) *Stats { // Retrieve - Get notification statistics func (s *Stats) Retrieve(ctx context.Context, idempotencyKey *string, opts ...operations.Option) (*operations.NotificationsControllerGetActivityStatsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "NotificationsController_getActivityStats", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.NotificationsControllerGetActivityStatsRequest{ IdempotencyKey: idempotencyKey, } @@ -62,6 +55,14 @@ func (s *Stats) Retrieve(ctx context.Context, idempotencyKey *string, opts ...op return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "NotificationsController_getActivityStats", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -363,13 +364,6 @@ func (s *Stats) Retrieve(ctx context.Context, idempotencyKey *string, opts ...op // Graph - Get notification graph statistics func (s *Stats) Graph(ctx context.Context, days *float64, idempotencyKey *string, opts ...operations.Option) (*operations.NotificationsControllerGetActivityGraphStatsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "NotificationsController_getActivityGraphStats", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.NotificationsControllerGetActivityGraphStatsRequest{ Days: days, IdempotencyKey: idempotencyKey, @@ -398,6 +392,14 @@ func (s *Stats) Graph(ctx context.Context, days *float64, idempotencyKey *string return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "NotificationsController_getActivityGraphStats", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/subscribers.go b/subscribers.go index 2881614..54fe9b0 100644 --- a/subscribers.go +++ b/subscribers.go @@ -23,10 +23,10 @@ import ( type Subscribers struct { Credentials *Credentials Properties *Properties - Preferences *Preferences Notifications *NovuNotifications Messages *NovuMessages Authentication *Authentication + Preferences *Preferences sdkConfiguration sdkConfiguration } @@ -36,23 +36,16 @@ func newSubscribers(sdkConfig sdkConfiguration) *Subscribers { sdkConfiguration: sdkConfig, Credentials: newCredentials(sdkConfig), Properties: newProperties(sdkConfig), - Preferences: newPreferences(sdkConfig), Notifications: newNovuNotifications(sdkConfig), Messages: newNovuMessages(sdkConfig), Authentication: newAuthentication(sdkConfig), + Preferences: newPreferences(sdkConfig), } } // List - Get subscribers // Returns a list of subscribers, could paginated using the `page` and `limit` query parameter func (s *Subscribers) List(ctx context.Context, page *float64, limit *float64, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerListSubscribersResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_listSubscribers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.SubscribersV1ControllerListSubscribersRequest{ Page: page, Limit: limit, @@ -82,6 +75,14 @@ func (s *Subscribers) List(ctx context.Context, page *float64, limit *float64, i return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_listSubscribers", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -431,19 +432,14 @@ func (s *Subscribers) List(ctx context.Context, page *float64, limit *float64, i } -// Create subscriber -// Creates a subscriber entity, in the Novu platform. The subscriber will be later used to receive notifications, and access notification feeds. Communication credentials such as email, phone number, and 3 rd party credentials i.e slack tokens could be later associated to this entity. -func (s *Subscribers) Create(ctx context.Context, createSubscriberRequestDto components.CreateSubscriberRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerCreateSubscriberResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_createSubscriber", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerCreateSubscriberRequest{ - IdempotencyKey: idempotencyKey, - CreateSubscriberRequestDto: createSubscriberRequestDto, +// CreateBulk - Bulk create subscribers +// +// Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API. +// The bulk API is limited to 500 subscribers per request. +func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto components.BulkSubscriberCreateDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerBulkCreateSubscribersResponse, error) { + request := operations.SubscribersV1ControllerBulkCreateSubscribersRequest{ + IdempotencyKey: idempotencyKey, + BulkSubscriberCreateDto: bulkSubscriberCreateDto, } o := operations.Options{} @@ -464,12 +460,19 @@ func (s *Subscribers) Create(ctx context.Context, createSubscriberRequestDto com } else { baseURL = *o.ServerURL } - opURL, err := url.JoinPath(baseURL, "/v1/subscribers") + opURL, err := url.JoinPath(baseURL, "/v1/subscribers/bulk") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "CreateSubscriberRequestDto", "json", `request:"mediaType=application/json"`) + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersV1Controller_bulkCreateSubscribers", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "BulkSubscriberCreateDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err } @@ -603,7 +606,7 @@ func (s *Subscribers) Create(ctx context.Context, createSubscriberRequestDto com } } - res := &operations.SubscribersV1ControllerCreateSubscriberResponse{ + res := &operations.SubscribersV1ControllerBulkCreateSubscribersResponse{ HTTPMeta: components.HTTPMetadata{ Request: req, Response: httpRes, @@ -621,12 +624,12 @@ func (s *Subscribers) Create(ctx context.Context, createSubscriberRequestDto com return nil, err } - var out components.SubscriberResponseDto + var out components.BulkCreateSubscriberResponseDto if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.SubscriberResponseDto = &out + res.BulkCreateSubscriberResponseDto = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { @@ -776,22 +779,8 @@ func (s *Subscribers) Create(ctx context.Context, createSubscriberRequestDto com } -// RetrieveLegacy - Get subscriber -// Get subscriber by your internal id used to identify the subscriber -func (s *Subscribers) RetrieveLegacy(ctx context.Context, subscriberID string, includeTopics *bool, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerGetSubscriberResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_getSubscriber", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerGetSubscriberRequest{ - SubscriberID: subscriberID, - IncludeTopics: includeTopics, - IdempotencyKey: idempotencyKey, - } - +// Search for subscribers +func (s *Subscribers) Search(ctx context.Context, request operations.SubscribersControllerSearchSubscribersRequest, opts ...operations.Option) (*operations.SubscribersControllerSearchSubscribersResponse, error) { o := operations.Options{} supportedOptions := []string{ operations.SupportedOptionRetries, @@ -810,11 +799,19 @@ func (s *Subscribers) RetrieveLegacy(ctx context.Context, subscriberID string, i } else { baseURL = *o.ServerURL } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/subscribers/{subscriberId}", request, nil) + opURL, err := url.JoinPath(baseURL, "/v2/subscribers") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersController_searchSubscribers", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -945,7 +942,7 @@ func (s *Subscribers) RetrieveLegacy(ctx context.Context, subscriberID string, i } } - res := &operations.SubscribersV1ControllerGetSubscriberResponse{ + res := &operations.SubscribersControllerSearchSubscribersResponse{ HTTPMeta: components.HTTPMetadata{ Request: req, Response: httpRes, @@ -963,12 +960,12 @@ func (s *Subscribers) RetrieveLegacy(ctx context.Context, subscriberID string, i return nil, err } - var out components.SubscriberResponseDto + var out components.ListSubscribersResponseDto if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.SubscriberResponseDto = &out + res.ListSubscribersResponseDto = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { @@ -1118,20 +1115,12 @@ func (s *Subscribers) RetrieveLegacy(ctx context.Context, subscriberID string, i } -// UpdateLegacy - Update subscriber -// Used to update the subscriber entity with new information -func (s *Subscribers) UpdateLegacy(ctx context.Context, subscriberID string, updateSubscriberRequestDto components.UpdateSubscriberRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerUpdateSubscriberResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_updateSubscriber", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerUpdateSubscriberRequest{ - SubscriberID: subscriberID, +// Create subscriber +// Create subscriber with the given data +func (s *Subscribers) Create(ctx context.Context, createSubscriberRequestDto components.CreateSubscriberRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerCreateSubscriberResponse, error) { + request := operations.SubscribersControllerCreateSubscriberRequest{ IdempotencyKey: idempotencyKey, - UpdateSubscriberRequestDto: updateSubscriberRequestDto, + CreateSubscriberRequestDto: createSubscriberRequestDto, } o := operations.Options{} @@ -1152,12 +1141,19 @@ func (s *Subscribers) UpdateLegacy(ctx context.Context, subscriberID string, upd } else { baseURL = *o.ServerURL } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/subscribers/{subscriberId}", request, nil) + opURL, err := url.JoinPath(baseURL, "/v2/subscribers") if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "UpdateSubscriberRequestDto", "json", `request:"mediaType=application/json"`) + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersController_createSubscriber", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "CreateSubscriberRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err } @@ -1173,7 +1169,7 @@ func (s *Subscribers) UpdateLegacy(ctx context.Context, subscriberID string, upd defer cancel() } - req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } @@ -1291,7 +1287,7 @@ func (s *Subscribers) UpdateLegacy(ctx context.Context, subscriberID string, upd } } - res := &operations.SubscribersV1ControllerUpdateSubscriberResponse{ + res := &operations.SubscribersControllerCreateSubscriberResponse{ HTTPMeta: components.HTTPMetadata{ Request: req, Response: httpRes, @@ -1299,7 +1295,7 @@ func (s *Subscribers) UpdateLegacy(ctx context.Context, subscriberID string, upd } switch { - case httpRes.StatusCode == 200: + case httpRes.StatusCode == 201: res.Headers = httpRes.Header switch { @@ -1464,19 +1460,10 @@ func (s *Subscribers) UpdateLegacy(ctx context.Context, subscriberID string, upd } -// DeleteLegacy - Delete subscriber -// Deletes a subscriber entity from the Novu platform -// -// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. -func (s *Subscribers) DeleteLegacy(ctx context.Context, subscriberID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerRemoveSubscriberResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_removeSubscriber", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerRemoveSubscriberRequest{ +// Retrieve - Get subscriber +// Get subscriber by your internal id used to identify the subscriber +func (s *Subscribers) Retrieve(ctx context.Context, subscriberID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerGetSubscriberResponse, error) { + request := operations.SubscribersControllerGetSubscriberRequest{ SubscriberID: subscriberID, IdempotencyKey: idempotencyKey, } @@ -1499,11 +1486,19 @@ func (s *Subscribers) DeleteLegacy(ctx context.Context, subscriberID string, ide } else { baseURL = *o.ServerURL } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v1/subscribers/{subscriberId}", request, nil) + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/subscribers/{subscriberId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersController_getSubscriber", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1515,7 +1510,7 @@ func (s *Subscribers) DeleteLegacy(ctx context.Context, subscriberID string, ide defer cancel() } - req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } @@ -1630,7 +1625,7 @@ func (s *Subscribers) DeleteLegacy(ctx context.Context, subscriberID string, ide } } - res := &operations.SubscribersV1ControllerRemoveSubscriberResponse{ + res := &operations.SubscribersControllerGetSubscriberResponse{ HTTPMeta: components.HTTPMetadata{ Request: req, Response: httpRes, @@ -1648,12 +1643,12 @@ func (s *Subscribers) DeleteLegacy(ctx context.Context, subscriberID string, ide return nil, err } - var out components.DeleteSubscriberResponseDto + var out components.SubscriberResponseDto if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.DeleteSubscriberResponseDto = &out + res.SubscriberResponseDto = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { @@ -1803,21 +1798,13 @@ func (s *Subscribers) DeleteLegacy(ctx context.Context, subscriberID string, ide } -// CreateBulk - Bulk create subscribers -// -// Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API. -// The bulk API is limited to 500 subscribers per request. -func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto components.BulkSubscriberCreateDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersV1ControllerBulkCreateSubscribersResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersV1Controller_bulkCreateSubscribers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersV1ControllerBulkCreateSubscribersRequest{ - IdempotencyKey: idempotencyKey, - BulkSubscriberCreateDto: bulkSubscriberCreateDto, +// Patch subscriber +// Patch subscriber by your internal id used to identify the subscriber +func (s *Subscribers) Patch(ctx context.Context, subscriberID string, patchSubscriberRequestDto components.PatchSubscriberRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerPatchSubscriberResponse, error) { + request := operations.SubscribersControllerPatchSubscriberRequest{ + SubscriberID: subscriberID, + IdempotencyKey: idempotencyKey, + PatchSubscriberRequestDto: patchSubscriberRequestDto, } o := operations.Options{} @@ -1838,12 +1825,19 @@ func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto co } else { baseURL = *o.ServerURL } - opURL, err := url.JoinPath(baseURL, "/v1/subscribers/bulk") + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/subscribers/{subscriberId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "BulkSubscriberCreateDto", "json", `request:"mediaType=application/json"`) + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "SubscribersController_patchSubscriber", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "PatchSubscriberRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err } @@ -1859,7 +1853,7 @@ func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto co defer cancel() } - req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) if err != nil { return nil, fmt.Errorf("error creating request: %w", err) } @@ -1977,7 +1971,7 @@ func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto co } } - res := &operations.SubscribersV1ControllerBulkCreateSubscribersResponse{ + res := &operations.SubscribersControllerPatchSubscriberResponse{ HTTPMeta: components.HTTPMetadata{ Request: req, Response: httpRes, @@ -1985,7 +1979,7 @@ func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto co } switch { - case httpRes.StatusCode == 201: + case httpRes.StatusCode == 200: res.Headers = httpRes.Header switch { @@ -1995,12 +1989,12 @@ func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto co return nil, err } - var out components.BulkCreateSubscriberResponseDto + var out components.SubscriberResponseDto if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.BulkCreateSubscriberResponseDto = &out + res.SubscriberResponseDto = &out default: rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { @@ -2150,13 +2144,12 @@ func (s *Subscribers) CreateBulk(ctx context.Context, bulkSubscriberCreateDto co } -// Search for subscribers -func (s *Subscribers) Search(ctx context.Context, request operations.SubscribersControllerSearchSubscribersRequest, opts ...operations.Option) (*operations.SubscribersControllerSearchSubscribersResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersController_searchSubscribers", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, +// Delete subscriber +// Deletes a subscriber entity from the Novu platform +func (s *Subscribers) Delete(ctx context.Context, subscriberID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerRemoveSubscriberResponse, error) { + request := operations.SubscribersControllerRemoveSubscriberRequest{ + SubscriberID: subscriberID, + IdempotencyKey: idempotencyKey, } o := operations.Options{} @@ -2177,1035 +2170,19 @@ func (s *Subscribers) Search(ctx context.Context, request operations.Subscribers } else { baseURL = *o.ServerURL } - opURL, err := url.JoinPath(baseURL, "/v2/subscribers") + opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/subscribers/{subscriberId}", request, nil) if err != nil { return nil, fmt.Errorf("error generating URL: %w", err) } - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - - utils.PopulateHeaders(ctx, req, request, nil) - - if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { - return nil, fmt.Errorf("error populating query params: %w", err) - } - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 1000, - MaxInterval: 30000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "408", - "409", - "429", - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil { - copyBody, err := req.GetBody() - if err != nil { - return nil, err - } - req.Body = copyBody - } - - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "405", "409", "413", "414", "415", "422", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SubscribersControllerSearchSubscribersResponse{ - HTTPMeta: components.HTTPMetadata{ - Request: req, - Response: httpRes, - }, - } - - switch { - case httpRes.StatusCode == 200: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out components.ListSubscribersResponseDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.ListSubscribersResponseDto = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 414: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 405: - fallthrough - case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 413: - fallthrough - case httpRes.StatusCode == 415: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 422: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ValidationErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 429: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode == 500: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 503: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// Retrieve - Get subscriber -// Get subscriber by your internal id used to identify the subscriber -func (s *Subscribers) Retrieve(ctx context.Context, subscriberID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerGetSubscriberResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersController_getSubscriber", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersControllerGetSubscriberRequest{ - SubscriberID: subscriberID, - IdempotencyKey: idempotencyKey, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/subscribers/{subscriberId}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - - utils.PopulateHeaders(ctx, req, request, nil) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 1000, - MaxInterval: 30000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "408", - "409", - "429", - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil { - copyBody, err := req.GetBody() - if err != nil { - return nil, err - } - req.Body = copyBody - } - - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "405", "409", "413", "414", "415", "422", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SubscribersControllerGetSubscriberResponse{ - HTTPMeta: components.HTTPMetadata{ - Request: req, - Response: httpRes, - }, - } - - switch { - case httpRes.StatusCode == 200: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out components.SubscriberResponseDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.SubscriberResponseDto = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 414: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 405: - fallthrough - case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 413: - fallthrough - case httpRes.StatusCode == 415: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 422: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ValidationErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 429: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode == 500: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 503: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// Patch subscriber -// Patch subscriber by your internal id used to identify the subscriber -func (s *Subscribers) Patch(ctx context.Context, subscriberID string, patchSubscriberRequestDto components.PatchSubscriberRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerPatchSubscriberResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "SubscribersController_patchSubscriber", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - - request := operations.SubscribersControllerPatchSubscriberRequest{ - SubscriberID: subscriberID, - IdempotencyKey: idempotencyKey, - PatchSubscriberRequestDto: patchSubscriberRequestDto, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/subscribers/{subscriberId}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - - bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "PatchSubscriberRequestDto", "json", `request:"mediaType=application/json"`) - if err != nil { - return nil, err - } - - timeout := o.Timeout - if timeout == nil { - timeout = s.sdkConfiguration.Timeout - } - - if timeout != nil { - var cancel context.CancelFunc - ctx, cancel = context.WithTimeout(ctx, *timeout) - defer cancel() - } - - req, err := http.NewRequestWithContext(ctx, "PATCH", opURL, bodyReader) - if err != nil { - return nil, fmt.Errorf("error creating request: %w", err) - } - req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) - if reqContentType != "" { - req.Header.Set("Content-Type", reqContentType) - } - - utils.PopulateHeaders(ctx, req, request, nil) - - if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { - return nil, err - } - - for k, v := range o.SetHeaders { - req.Header.Set(k, v) - } - - globalRetryConfig := s.sdkConfiguration.RetryConfig - retryConfig := o.Retries - if retryConfig == nil { - if globalRetryConfig != nil { - retryConfig = globalRetryConfig - } else { - retryConfig = &retry.Config{ - Strategy: "backoff", Backoff: &retry.BackoffStrategy{ - InitialInterval: 1000, - MaxInterval: 30000, - Exponent: 1.5, - MaxElapsedTime: 3600000, - }, - RetryConnectionErrors: true, - } - } - } - - var httpRes *http.Response - if retryConfig != nil { - httpRes, err = utils.Retry(ctx, utils.Retries{ - Config: retryConfig, - StatusCodes: []string{ - "408", - "409", - "429", - "5XX", - }, - }, func() (*http.Response, error) { - if req.Body != nil { - copyBody, err := req.GetBody() - if err != nil { - return nil, err - } - req.Body = copyBody - } - - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { - return nil, err - } - - return nil, retry.Permanent(err) - } - - httpRes, err := s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - } - return httpRes, err - }) - - if err != nil { - return nil, err - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } else { - req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) - if err != nil { - return nil, err - } - - httpRes, err = s.sdkConfiguration.Client.Do(req) - if err != nil || httpRes == nil { - if err != nil { - err = fmt.Errorf("error sending request: %w", err) - } else { - err = fmt.Errorf("error sending request: no response") - } - - _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) - return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "403", "404", "405", "409", "413", "414", "415", "422", "429", "4XX", "500", "503", "5XX"}, httpRes.StatusCode) { - _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) - if err != nil { - return nil, err - } else if _httpRes != nil { - httpRes = _httpRes - } - } else { - httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) - if err != nil { - return nil, err - } - } - } - - res := &operations.SubscribersControllerPatchSubscriberResponse{ - HTTPMeta: components.HTTPMetadata{ - Request: req, - Response: httpRes, - }, - } - - switch { - case httpRes.StatusCode == 200: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out components.SubscriberResponseDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - res.SubscriberResponseDto = &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 414: - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 400: - fallthrough - case httpRes.StatusCode == 401: - fallthrough - case httpRes.StatusCode == 403: - fallthrough - case httpRes.StatusCode == 404: - fallthrough - case httpRes.StatusCode == 405: - fallthrough - case httpRes.StatusCode == 409: - fallthrough - case httpRes.StatusCode == 413: - fallthrough - case httpRes.StatusCode == 415: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 422: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ValidationErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 429: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode == 500: - res.Headers = httpRes.Header - - switch { - case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - - var out apierrors.ErrorDto - if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { - return nil, err - } - - return nil, &out - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) - } - case httpRes.StatusCode == 503: - res.Headers = httpRes.Header - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) - default: - rawBody, err := utils.ConsumeRawBody(httpRes) - if err != nil { - return nil, err - } - return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) - } - - return res, nil - -} - -// Delete subscriber -// Deletes a subscriber entity from the Novu platform -func (s *Subscribers) Delete(ctx context.Context, subscriberID string, idempotencyKey *string, opts ...operations.Option) (*operations.SubscribersControllerRemoveSubscriberResponse, error) { hookCtx := hooks.HookContext{ + BaseURL: baseURL, Context: ctx, OperationID: "SubscribersController_removeSubscriber", OAuth2Scopes: []string{}, SecuritySource: s.sdkConfiguration.Security, } - request := operations.SubscribersControllerRemoveSubscriberRequest{ - SubscriberID: subscriberID, - IdempotencyKey: idempotencyKey, - } - - o := operations.Options{} - supportedOptions := []string{ - operations.SupportedOptionRetries, - operations.SupportedOptionTimeout, - } - - for _, opt := range opts { - if err := opt(&o, supportedOptions...); err != nil { - return nil, fmt.Errorf("error applying option: %w", err) - } - } - - var baseURL string - if o.ServerURL == nil { - baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) - } else { - baseURL = *o.ServerURL - } - opURL, err := utils.GenerateURL(ctx, baseURL, "/v2/subscribers/{subscriberId}", request, nil) - if err != nil { - return nil, fmt.Errorf("error generating URL: %w", err) - } - timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout diff --git a/topics.go b/topics.go index 859f17d..f661b33 100644 --- a/topics.go +++ b/topics.go @@ -35,13 +35,6 @@ func newTopics(sdkConfig sdkConfiguration) *Topics { // Create - Topic creation // Create a topic func (s *Topics) Create(ctx context.Context, createTopicRequestDto components.CreateTopicRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerCreateTopicResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_createTopic", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerCreateTopicRequest{ IdempotencyKey: idempotencyKey, CreateTopicRequestDto: createTopicRequestDto, @@ -70,6 +63,13 @@ func (s *Topics) Create(ctx context.Context, createTopicRequestDto components.Cr return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_createTopic", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "CreateTopicRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err @@ -380,13 +380,6 @@ func (s *Topics) Create(ctx context.Context, createTopicRequestDto components.Cr // List - Get topic list filtered // Returns a list of topics that can be paginated using the `page` query parameter and filtered by the topic key with the `key` query parameter func (s *Topics) List(ctx context.Context, page *int64, pageSize *int64, key *string, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerListTopicsResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_listTopics", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerListTopicsRequest{ Page: page, PageSize: pageSize, @@ -417,6 +410,14 @@ func (s *Topics) List(ctx context.Context, page *int64, pageSize *int64, key *st return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_listTopics", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -723,13 +724,6 @@ func (s *Topics) List(ctx context.Context, page *int64, pageSize *int64, key *st // Delete topic // Delete a topic by its topic key if it has no subscribers func (s *Topics) Delete(ctx context.Context, topicKey string, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerDeleteTopicResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_deleteTopic", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerDeleteTopicRequest{ TopicKey: topicKey, IdempotencyKey: idempotencyKey, @@ -758,6 +752,14 @@ func (s *Topics) Delete(ctx context.Context, topicKey string, idempotencyKey *st return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_deleteTopic", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1040,13 +1042,6 @@ func (s *Topics) Delete(ctx context.Context, topicKey string, idempotencyKey *st // Retrieve - Get topic // Get a topic by its topic key func (s *Topics) Retrieve(ctx context.Context, topicKey string, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerGetTopicResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_getTopic", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerGetTopicRequest{ TopicKey: topicKey, IdempotencyKey: idempotencyKey, @@ -1075,6 +1070,14 @@ func (s *Topics) Retrieve(ctx context.Context, topicKey string, idempotencyKey * return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_getTopic", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout @@ -1377,13 +1380,6 @@ func (s *Topics) Retrieve(ctx context.Context, topicKey string, idempotencyKey * // Rename a topic // Rename a topic by providing a new name func (s *Topics) Rename(ctx context.Context, topicKey string, renameTopicRequestDto components.RenameTopicRequestDto, idempotencyKey *string, opts ...operations.Option) (*operations.TopicsControllerRenameTopicResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "TopicsController_renameTopic", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.TopicsControllerRenameTopicRequest{ TopicKey: topicKey, IdempotencyKey: idempotencyKey, @@ -1413,6 +1409,13 @@ func (s *Topics) Rename(ctx context.Context, topicKey string, renameTopicRequest return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "TopicsController_renameTopic", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "RenameTopicRequestDto", "json", `request:"mediaType=application/json"`) if err != nil { return nil, err diff --git a/webhooks.go b/webhooks.go index 67dbcfd..2cbcb1a 100644 --- a/webhooks.go +++ b/webhooks.go @@ -28,13 +28,6 @@ func newWebhooks(sdkConfig sdkConfiguration) *Webhooks { // Retrieve - Get webhook support status for provider // Return the status of the webhook for this provider, if it is supported or if it is not based on a boolean value func (s *Webhooks) Retrieve(ctx context.Context, providerOrIntegrationID string, idempotencyKey *string, opts ...operations.Option) (*operations.IntegrationsControllerGetWebhookSupportStatusResponse, error) { - hookCtx := hooks.HookContext{ - Context: ctx, - OperationID: "IntegrationsController_getWebhookSupportStatus", - OAuth2Scopes: []string{}, - SecuritySource: s.sdkConfiguration.Security, - } - request := operations.IntegrationsControllerGetWebhookSupportStatusRequest{ ProviderOrIntegrationID: providerOrIntegrationID, IdempotencyKey: idempotencyKey, @@ -63,6 +56,14 @@ func (s *Webhooks) Retrieve(ctx context.Context, providerOrIntegrationID string, return nil, fmt.Errorf("error generating URL: %w", err) } + hookCtx := hooks.HookContext{ + BaseURL: baseURL, + Context: ctx, + OperationID: "IntegrationsController_getWebhookSupportStatus", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + timeout := o.Timeout if timeout == nil { timeout = s.sdkConfiguration.Timeout