From e4cf78aae5b36527b7edfb7ad8b70b0405aa60d5 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 20:48:37 +0000 Subject: [PATCH] Release 0.1.0 --- .fernignore | 1 + .github/workflows/ci.yml | 51 + .gitignore | 3 + .npmignore | 9 + .prettierrc.yml | 2 + package.json | 28 + reference.md | 3612 +++++++++++++++++ src/Client.ts | 100 + src/api/errors/BadRequestError.ts | 17 + src/api/errors/InternalServerError.ts | 17 + src/api/errors/NotFoundError.ts | 17 + src/api/errors/TooManyRequestsError.ts | 17 + src/api/errors/index.ts | 4 + src/api/index.ts | 3 + .../automationJourneys/client/Client.ts | 422 ++ .../automationJourneys/client/index.ts | 1 + ...dAutomationsAutomationIdJourneysRequest.ts | 80 + ...dAutomationsAutomationIdJourneysRequest.ts | 51 + .../client/requests/index.ts | 2 + src/api/resources/automationJourneys/index.ts | 2 + ...onIdJourneysAutomationJourneyIdResponse.ts | 9 + ...ationsAutomationIdJourneysRequestStatus.ts | 16 + ...AutomationsAutomationIdJourneysResponse.ts | 17 + ...ationIdJourneysRequestDoubleOptOverride.ts | 17 + ...AutomationsAutomationIdJourneysResponse.ts | 9 + .../automationJourneys/types/index.ts | 5 + .../resources/automations/client/Client.ts | 271 ++ src/api/resources/automations/client/index.ts | 1 + ...icationsPublicationIdAutomationsRequest.ts | 48 + .../automations/client/requests/index.ts | 1 + src/api/resources/automations/index.ts | 2 + ...cationIdAutomationsAutomationIdResponse.ts | 9 + ...cationsPublicationIdAutomationsResponse.ts | 17 + src/api/resources/automations/types/index.ts | 2 + .../bulkSubscriptionUpdates/client/Client.ts | 258 ++ .../bulkSubscriptionUpdates/client/index.ts | 1 + .../bulkSubscriptionUpdates/index.ts | 2 + ...blicationIdSubcriptionUpdatesIdResponse.ts | 9 + ...ationIdSubcriptionUpdatesIdResponseData.ts | 28 + ...dSubcriptionUpdatesIdResponseDataStatus.ts | 19 + ...nIdSubcriptionUpdatesIdResponseDataType.ts | 13 + ...PublicationIdSubcriptionUpdatesResponse.ts | 10 + ...ionIdSubcriptionUpdatesResponseDataItem.ts | 28 + ...ubcriptionUpdatesResponseDataItemStatus.ts | 19 + ...dSubcriptionUpdatesResponseDataItemType.ts | 15 + .../bulkSubscriptionUpdates/types/index.ts | 8 + .../resources/customFields/client/Client.ts | 732 ++++ .../resources/customFields/client/index.ts | 1 + ...tionsPublicationIdCustomFieldsIdRequest.ts | 26 + ...cationsPublicationIdCustomFieldsRequest.ts | 47 + ...tionsPublicationIdCustomFieldsIdRequest.ts | 26 + .../customFields/client/requests/index.ts | 3 + src/api/resources/customFields/index.ts | 2 + ...ationsPublicationIdCustomFieldsResponse.ts | 7 + ...ionsPublicationIdCustomFieldsIdResponse.ts | 9 + ...PublicationIdCustomFieldsIdResponseData.ts | 12 + ...icationIdCustomFieldsIdResponseDataKind.ts | 18 + ...ationsPublicationIdCustomFieldsResponse.ts | 9 + ...blicationIdCustomFieldsResponseDataItem.ts | 12 + ...ationIdCustomFieldsResponseDataItemKind.ts | 18 + ...ionsPublicationIdCustomFieldsIdResponse.ts | 9 + ...PublicationIdCustomFieldsIdResponseData.ts | 12 + ...icationIdCustomFieldsIdResponseDataKind.ts | 18 + ...onsPublicationIdCustomFieldsRequestKind.ts | 18 + ...ationsPublicationIdCustomFieldsResponse.ts | 9 + ...nsPublicationIdCustomFieldsResponseData.ts | 12 + ...blicationIdCustomFieldsResponseDataKind.ts | 18 + ...ionsPublicationIdCustomFieldsIdResponse.ts | 9 + ...PublicationIdCustomFieldsIdResponseData.ts | 12 + ...icationIdCustomFieldsIdResponseDataKind.ts | 18 + src/api/resources/customFields/types/index.ts | 17 + .../resources/emailBlasts/client/Client.ts | 306 ++ src/api/resources/emailBlasts/client/index.ts | 1 + ...icationIdEmailBlastsEmailBlastIdRequest.ts | 43 + ...icationsPublicationIdEmailBlastsRequest.ts | 79 + .../emailBlasts/client/requests/index.ts | 2 + src/api/resources/emailBlasts/index.ts | 2 + ...mailBlastsEmailBlastIdRequestExpandItem.ts | 14 + ...cationIdEmailBlastsEmailBlastIdResponse.ts | 9 + ...ublicationIdEmailBlastsRequestDirection.ts | 10 + ...blicationIdEmailBlastsRequestExpandItem.ts | 14 + ...sPublicationIdEmailBlastsRequestOrderBy.ts | 10 + ...cationsPublicationIdEmailBlastsResponse.ts | 17 + src/api/resources/emailBlasts/types/index.ts | 6 + src/api/resources/index.ts | 32 + src/api/resources/posts/client/Client.ts | 441 ++ src/api/resources/posts/client/index.ts | 1 + .../requests/PostsGetPostsPostIdRequest.ts | 41 + .../client/requests/PostsGetPostsRequest.ts | 122 + .../resources/posts/client/requests/index.ts | 2 + src/api/resources/posts/index.ts | 2 + .../types/PostsDeletePostsPostIdResponse.ts | 5 + .../PostsGetPostsPostIdRequestExpandItem.ts | 20 + .../types/PostsGetPostsPostIdResponse.ts | 9 + .../types/PostsGetPostsRequestAudience.ts | 11 + .../types/PostsGetPostsRequestDirection.ts | 10 + .../types/PostsGetPostsRequestExpandItem.ts | 20 + .../PostsGetPostsRequestHiddenFromFeed.ts | 11 + .../types/PostsGetPostsRequestOrderBy.ts | 11 + .../types/PostsGetPostsRequestPlatform.ts | 12 + .../posts/types/PostsGetPostsRequestStatus.ts | 12 + .../posts/types/PostsGetPostsResponse.ts | 17 + src/api/resources/posts/types/index.ts | 11 + .../resources/publications/client/Client.ts | 298 ++ .../resources/publications/client/index.ts | 1 + ...ionsGetPublicationsPublicationIdRequest.ts | 39 + .../PublicationsGetPublicationsRequest.ts | 77 + .../publications/client/requests/index.ts | 2 + src/api/resources/publications/index.ts | 2 + ...onsGetPublicationsPublicationIdResponse.ts | 9 + ...icationsGetPublicationsRequestDirection.ts | 10 + ...blicationsGetPublicationsRequestOrderBy.ts | 10 + .../PublicationsGetPublicationsResponse.ts | 17 + src/api/resources/publications/types/index.ts | 4 + .../referralProgram/client/Client.ts | 159 + .../resources/referralProgram/client/index.ts | 1 + ...ublicationsPublicReferralProgramRequest.ts | 48 + .../referralProgram/client/requests/index.ts | 1 + src/api/resources/referralProgram/index.ts | 2 + ...blicationsPublicReferralProgramResponse.ts | 18 + .../resources/referralProgram/types/index.ts | 1 + src/api/resources/segments/client/Client.ts | 522 +++ src/api/resources/segments/client/index.ts | 1 + ...ublicationsPublicationIdSegmentsRequest.ts | 86 + ...cationIdSegmentsSegmentIdResultsRequest.ts | 48 + .../segments/client/requests/index.ts | 2 + src/api/resources/segments/index.ts | 2 + ...nsPublicationIdSegmentsRequestDirection.ts | 10 + ...ionsPublicationIdSegmentsRequestOrderBy.ts | 10 + ...tionsPublicationIdSegmentsRequestStatus.ts | 18 + ...cationsPublicationIdSegmentsRequestType.ts | 12 + ...blicationsPublicationIdSegmentsResponse.ts | 18 + ...sPublicationIdSegmentsSegmentIdResponse.ts | 9 + ...ationIdSegmentsSegmentIdResultsResponse.ts | 16 + src/api/resources/segments/types/index.ts | 7 + .../subscriptionTags/client/Client.ts | 154 + .../subscriptionTags/client/index.ts | 1 + ...dSubscriptionsSubscriptionIdTagsRequest.ts | 39 + .../subscriptionTags/client/requests/index.ts | 1 + src/api/resources/subscriptionTags/index.ts | 2 + ...SubscriptionsSubscriptionIdTagsResponse.ts | 9 + .../resources/subscriptionTags/types/index.ts | 1 + .../resources/subscriptions/client/Client.ts | 1454 +++++++ .../resources/subscriptions/client/index.ts | 1 + ...bscriptionsGetSubscriptionsEmailRequest.ts | 43 + .../SubscriptionsGetSubscriptionsRequest.ts | 108 + ...ionsGetSubscriptionsSubscriberIdRequest.ts | 43 + ...nsGetSubscriptionsSubscriptionIdRequest.ts | 43 + ...bscriptionsBulkActionsBulkUpdateRequest.ts | 29 + ...tchSubscriptionsBulkUpdateStatusRequest.ts | 49 + .../SubscriptionsPostSubscriptionsRequest.ts | 152 + ...bscriptionsBulkActionsBulkUpdateRequest.ts | 29 + ...PutSubscriptionsBulkUpdateStatusRequest.ts | 49 + ...nsPutSubscriptionsSubscriptionIdRequest.ts | 93 + .../subscriptions/client/requests/index.ts | 10 + src/api/resources/subscriptions/index.ts | 2 + ...sGetSubscriptionsEmailRequestExpandItem.ts | 11 + ...scriptionsGetSubscriptionsEmailResponse.ts | 12 + ...iptionsGetSubscriptionsRequestDirection.ts | 10 + ...ptionsGetSubscriptionsRequestExpandItem.ts | 11 + ...criptionsGetSubscriptionsRequestOrderBy.ts | 10 + ...scriptionsGetSubscriptionsRequestStatus.ts | 20 + ...ubscriptionsGetSubscriptionsRequestTier.ts | 11 + .../SubscriptionsGetSubscriptionsResponse.ts | 17 + ...scriptionsSubscriberIdRequestExpandItem.ts | 11 + ...onsGetSubscriptionsSubscriberIdResponse.ts | 12 + ...riptionsSubscriptionIdRequestExpandItem.ts | 11 + ...sGetSubscriptionsSubscriptionIdResponse.ts | 12 + ...tionsBulkUpdateRequestSubscriptionsItem.ts | 16 + ...equestSubscriptionsItemCustomFieldsItem.ts | 12 + ...sBulkUpdateRequestSubscriptionsItemTier.ts | 13 + ...scriptionsBulkActionsBulkUpdateResponse.ts | 9 + ...ptionsBulkActionsBulkUpdateResponseData.ts | 8 + ...iptionsBulkUpdateStatusRequestNewStatus.ts | 13 + ...chSubscriptionsBulkUpdateStatusResponse.ts | 9 + ...bscriptionsBulkUpdateStatusResponseData.ts | 8 + ...stSubscriptionsRequestDoubleOptOverride.ts | 14 + ...bscriptionsPostSubscriptionsRequestTier.ts | 13 + .../SubscriptionsPostSubscriptionsResponse.ts | 9 + ...tionsBulkUpdateRequestSubscriptionsItem.ts | 16 + ...equestSubscriptionsItemCustomFieldsItem.ts | 12 + ...sBulkUpdateRequestSubscriptionsItemTier.ts | 13 + ...scriptionsBulkActionsBulkUpdateResponse.ts | 9 + ...ptionsBulkActionsBulkUpdateResponseData.ts | 8 + ...iptionsBulkUpdateStatusRequestNewStatus.ts | 13 + ...utSubscriptionsBulkUpdateStatusResponse.ts | 9 + ...bscriptionsBulkUpdateStatusResponseData.ts | 8 + ...nsSubscriptionIdRequestCustomFieldsItem.ts | 12 + ...tSubscriptionsSubscriptionIdRequestTier.ts | 13 + ...sPutSubscriptionsSubscriptionIdResponse.ts | 12 + .../resources/subscriptions/types/index.ts | 34 + src/api/types/Automation.ts | 13 + src/api/types/AutomationJourney.ts | 22 + src/api/types/AutomationJourneyStatus.ts | 12 + src/api/types/AutomationStatus.ts | 11 + src/api/types/ClickStats.ts | 21 + src/api/types/CustomField.ts | 14 + src/api/types/CustomFieldKind.ts | 16 + src/api/types/CustomFieldValue.ts | 13 + src/api/types/EmailBlast.ts | 22 + src/api/types/EmailBlastContent.ts | 14 + src/api/types/EmailBlastContentEmail.ts | 8 + src/api/types/EmailBlastStats.ts | 15 + src/api/types/EmailBlastStatsClicksItem.ts | 12 + src/api/types/EmailBlastStatsEmail.ts | 27 + src/api/types/EmailBlastStatus.ts | 13 + src/api/types/ErrorErrorsItem.ts | 8 + src/api/types/Error_.ts | 14 + src/api/types/Milestone.ts | 18 + src/api/types/MilestoneReward.ts | 21 + src/api/types/MilestoneRewardType.ts | 13 + src/api/types/Post.ts | 50 + src/api/types/PostAudience.ts | 14 + src/api/types/PostClickStatsEmail.ts | 13 + src/api/types/PostClickStatsWeb.ts | 13 + src/api/types/PostContent.ts | 17 + src/api/types/PostContentFree.ts | 15 + src/api/types/PostContentPremium.ts | 13 + src/api/types/PostPlatform.ts | 14 + src/api/types/PostStats.ts | 17 + src/api/types/PostStatsEmail.ts | 27 + src/api/types/PostStatsWeb.ts | 13 + src/api/types/PostStatus.ts | 14 + src/api/types/Publication.ts | 17 + src/api/types/PublicationStats.ts | 36 + ...PublicationStatsActiveFreeSubscriptions.ts | 8 + ...licationStatsActivePremiumSubscriptions.ts | 8 + .../PublicationStatsActiveSubscriptions.ts | 8 + .../types/PublicationStatsAverageClickRate.ts | 8 + .../types/PublicationStatsAverageOpenRate.ts | 8 + src/api/types/PublicationStatsTotalClicked.ts | 8 + src/api/types/PublicationStatsTotalSent.ts | 8 + .../PublicationStatsTotalUniqueOpened.ts | 8 + src/api/types/Segment.ts | 25 + src/api/types/SegmentStatus.ts | 15 + src/api/types/SegmentType.ts | 14 + src/api/types/Subscription.ts | 35 + src/api/types/SubscriptionCustomFields.ts | 10 + src/api/types/SubscriptionExpandedStatus.ts | 23 + .../SubscriptionExpandedSubscriptionTier.ts | 13 + .../types/SubscriptionExpandedTagsStatus.ts | 23 + ...ubscriptionExpandedTagsSubscriptionTier.ts | 13 + .../SubscriptionExpandedTagsUtmChannel.ts | 33 + .../types/SubscriptionExpandedUtmChannel.ts | 33 + src/api/types/SubscriptionStats.ts | 15 + src/api/types/SubscriptionStatus.ts | 17 + src/api/types/SubscriptionSubscriptionTier.ts | 13 + src/api/types/SubscriptionTags.ts | 9 + src/api/types/SubscriptionUtmChannel.ts | 33 + src/api/types/index.ts | 58 + src/core/auth/BasicAuth.ts | 31 + src/core/auth/BearerToken.ts | 15 + src/core/auth/index.ts | 2 + src/core/fetcher/APIResponse.ts | 12 + src/core/fetcher/Fetcher.ts | 195 + src/core/fetcher/Supplier.ts | 11 + src/core/fetcher/getHeader.ts | 8 + src/core/fetcher/index.ts | 5 + src/core/index.ts | 4 + src/core/runtime/index.ts | 1 + src/core/runtime/runtime.ts | 112 + src/core/schemas/Schema.ts | 94 + src/core/schemas/builders/date/date.ts | 65 + src/core/schemas/builders/date/index.ts | 1 + src/core/schemas/builders/enum/enum.ts | 43 + src/core/schemas/builders/enum/index.ts | 1 + src/core/schemas/builders/index.ts | 13 + src/core/schemas/builders/lazy/index.ts | 3 + src/core/schemas/builders/lazy/lazy.ts | 34 + src/core/schemas/builders/lazy/lazyObject.ts | 20 + src/core/schemas/builders/list/index.ts | 1 + src/core/schemas/builders/list/list.ts | 74 + .../builders/literals/booleanLiteral.ts | 29 + src/core/schemas/builders/literals/index.ts | 2 + .../builders/literals/stringLiteral.ts | 29 + .../object-like/getObjectLikeUtils.ts | 79 + .../schemas/builders/object-like/index.ts | 2 + .../schemas/builders/object-like/types.ts | 11 + src/core/schemas/builders/object/index.ts | 22 + src/core/schemas/builders/object/object.ts | 333 ++ .../object/objectWithoutOptionalProperties.ts | 18 + src/core/schemas/builders/object/property.ts | 23 + src/core/schemas/builders/object/types.ts | 72 + src/core/schemas/builders/primitives/any.ts | 4 + .../schemas/builders/primitives/boolean.ts | 25 + src/core/schemas/builders/primitives/index.ts | 5 + .../schemas/builders/primitives/number.ts | 25 + .../schemas/builders/primitives/string.ts | 25 + .../schemas/builders/primitives/unknown.ts | 4 + src/core/schemas/builders/record/index.ts | 2 + src/core/schemas/builders/record/record.ts | 131 + src/core/schemas/builders/record/types.ts | 17 + .../builders/schema-utils/JsonError.ts | 9 + .../builders/schema-utils/ParseError.ts | 9 + .../builders/schema-utils/getSchemaUtils.ts | 99 + .../schemas/builders/schema-utils/index.ts | 4 + .../schema-utils/stringifyValidationErrors.ts | 8 + src/core/schemas/builders/set/index.ts | 1 + src/core/schemas/builders/set/set.ts | 43 + .../builders/undiscriminated-union/index.ts | 6 + .../builders/undiscriminated-union/types.ts | 10 + .../undiscriminatedUnion.ts | 61 + .../schemas/builders/union/discriminant.ts | 14 + src/core/schemas/builders/union/index.ts | 10 + src/core/schemas/builders/union/types.ts | 26 + src/core/schemas/builders/union/union.ts | 173 + src/core/schemas/index.ts | 2 + src/core/schemas/utils/MaybePromise.ts | 1 + .../addQuestionMarksToNullableProperties.ts | 15 + .../utils/createIdentitySchemaCreator.ts | 21 + src/core/schemas/utils/entries.ts | 3 + src/core/schemas/utils/filterObject.ts | 10 + .../utils/getErrorMessageForIncorrectType.ts | 21 + src/core/schemas/utils/isPlainObject.ts | 17 + src/core/schemas/utils/keys.ts | 3 + src/core/schemas/utils/maybeSkipValidation.ts | 39 + src/core/schemas/utils/partition.ts | 12 + src/environments.ts | 9 + src/errors/beehiivError.ts | 45 + src/errors/beehiivTimeoutError.ts | 10 + src/errors/index.ts | 2 + src/index.ts | 4 + src/serialization/index.ts | 2 + .../automationJourneys/client/index.ts | 1 + ...dAutomationsAutomationIdJourneysRequest.ts | 28 + .../client/requests/index.ts | 1 + .../resources/automationJourneys/index.ts | 2 + ...onIdJourneysAutomationJourneyIdResponse.ts | 21 + ...ationsAutomationIdJourneysRequestStatus.ts | 16 + ...AutomationsAutomationIdJourneysResponse.ts | 29 + ...ationIdJourneysRequestDoubleOptOverride.ts | 16 + ...AutomationsAutomationIdJourneysResponse.ts | 21 + .../automationJourneys/types/index.ts | 5 + .../resources/automations/index.ts | 1 + ...cationIdAutomationsAutomationIdResponse.ts | 21 + ...cationsPublicationIdAutomationsResponse.ts | 29 + .../resources/automations/types/index.ts | 2 + .../bulkSubscriptionUpdates/index.ts | 1 + ...blicationIdSubcriptionUpdatesIdResponse.ts | 21 + ...ationIdSubcriptionUpdatesIdResponseData.ts | 40 + ...dSubcriptionUpdatesIdResponseDataStatus.ts | 16 + ...nIdSubcriptionUpdatesIdResponseDataType.ts | 16 + ...PublicationIdSubcriptionUpdatesResponse.ts | 23 + ...ionIdSubcriptionUpdatesResponseDataItem.ts | 40 + ...ubcriptionUpdatesResponseDataItemStatus.ts | 16 + ...dSubcriptionUpdatesResponseDataItemType.ts | 16 + .../bulkSubscriptionUpdates/types/index.ts | 8 + .../resources/customFields/client/index.ts | 1 + ...tionsPublicationIdCustomFieldsIdRequest.ts | 20 + ...cationsPublicationIdCustomFieldsRequest.ts | 23 + ...tionsPublicationIdCustomFieldsIdRequest.ts | 20 + .../customFields/client/requests/index.ts | 3 + .../resources/customFields/index.ts | 2 + ...ationsPublicationIdCustomFieldsResponse.ts | 20 + ...ionsPublicationIdCustomFieldsIdResponse.ts | 21 + ...PublicationIdCustomFieldsIdResponseData.ts | 27 + ...icationIdCustomFieldsIdResponseDataKind.ts | 16 + ...ationsPublicationIdCustomFieldsResponse.ts | 21 + ...blicationIdCustomFieldsResponseDataItem.ts | 27 + ...ationIdCustomFieldsResponseDataItemKind.ts | 16 + ...ionsPublicationIdCustomFieldsIdResponse.ts | 21 + ...PublicationIdCustomFieldsIdResponseData.ts | 27 + ...icationIdCustomFieldsIdResponseDataKind.ts | 16 + ...onsPublicationIdCustomFieldsRequestKind.ts | 16 + ...ationsPublicationIdCustomFieldsResponse.ts | 21 + ...nsPublicationIdCustomFieldsResponseData.ts | 27 + ...blicationIdCustomFieldsResponseDataKind.ts | 16 + ...ionsPublicationIdCustomFieldsIdResponse.ts | 21 + ...PublicationIdCustomFieldsIdResponseData.ts | 27 + ...icationIdCustomFieldsIdResponseDataKind.ts | 16 + .../resources/customFields/types/index.ts | 17 + .../resources/emailBlasts/index.ts | 1 + ...mailBlastsEmailBlastIdRequestExpandItem.ts | 16 + ...cationIdEmailBlastsEmailBlastIdResponse.ts | 21 + ...ublicationIdEmailBlastsRequestDirection.ts | 16 + ...blicationIdEmailBlastsRequestExpandItem.ts | 16 + ...sPublicationIdEmailBlastsRequestOrderBy.ts | 16 + ...cationsPublicationIdEmailBlastsResponse.ts | 29 + .../resources/emailBlasts/types/index.ts | 6 + src/serialization/resources/index.ts | 26 + src/serialization/resources/posts/index.ts | 1 + .../types/PostsDeletePostsPostIdResponse.ts | 16 + .../PostsGetPostsPostIdRequestExpandItem.ts | 29 + .../types/PostsGetPostsPostIdResponse.ts | 21 + .../types/PostsGetPostsRequestAudience.ts | 16 + .../types/PostsGetPostsRequestDirection.ts | 16 + .../types/PostsGetPostsRequestExpandItem.ts | 29 + .../PostsGetPostsRequestHiddenFromFeed.ts | 16 + .../types/PostsGetPostsRequestOrderBy.ts | 16 + .../types/PostsGetPostsRequestPlatform.ts | 16 + .../posts/types/PostsGetPostsRequestStatus.ts | 16 + .../posts/types/PostsGetPostsResponse.ts | 29 + .../resources/posts/types/index.ts | 11 + .../resources/publications/index.ts | 1 + ...onsGetPublicationsPublicationIdResponse.ts | 21 + ...icationsGetPublicationsRequestDirection.ts | 16 + ...blicationsGetPublicationsRequestOrderBy.ts | 16 + .../PublicationsGetPublicationsResponse.ts | 29 + .../resources/publications/types/index.ts | 4 + .../resources/referralProgram/index.ts | 1 + ...blicationsPublicReferralProgramResponse.ts | 29 + .../resources/referralProgram/types/index.ts | 1 + ...licationsPublicationIdSegmentsSegmentId.ts | 15 + .../resources/segments/client/index.ts | 1 + src/serialization/resources/segments/index.ts | 2 + ...nsPublicationIdSegmentsRequestDirection.ts | 16 + ...ionsPublicationIdSegmentsRequestOrderBy.ts | 16 + ...tionsPublicationIdSegmentsRequestStatus.ts | 16 + ...cationsPublicationIdSegmentsRequestType.ts | 16 + ...blicationsPublicationIdSegmentsResponse.ts | 29 + ...sPublicationIdSegmentsSegmentIdResponse.ts | 21 + ...ationIdSegmentsSegmentIdResultsResponse.ts | 28 + .../resources/segments/types/index.ts | 7 + .../subscriptionTags/client/index.ts | 1 + ...dSubscriptionsSubscriptionIdTagsRequest.ts | 20 + .../subscriptionTags/client/requests/index.ts | 1 + .../resources/subscriptionTags/index.ts | 2 + ...SubscriptionsSubscriptionIdTagsResponse.ts | 21 + .../resources/subscriptionTags/types/index.ts | 1 + .../deleteSubscriptionsSubscriptionId.ts | 15 + .../resources/subscriptions/client/index.ts | 2 + ...bscriptionsBulkActionsBulkUpdateRequest.ts | 23 + ...tchSubscriptionsBulkUpdateStatusRequest.ts | 29 + .../SubscriptionsPostSubscriptionsRequest.ts | 51 + ...bscriptionsBulkActionsBulkUpdateRequest.ts | 23 + ...PutSubscriptionsBulkUpdateStatusRequest.ts | 26 + ...nsPutSubscriptionsSubscriptionIdRequest.ts | 29 + .../subscriptions/client/requests/index.ts | 6 + .../resources/subscriptions/index.ts | 2 + ...sGetSubscriptionsEmailRequestExpandItem.ts | 16 + ...scriptionsGetSubscriptionsEmailResponse.ts | 21 + ...iptionsGetSubscriptionsRequestDirection.ts | 16 + ...ptionsGetSubscriptionsRequestExpandItem.ts | 16 + ...criptionsGetSubscriptionsRequestOrderBy.ts | 16 + ...scriptionsGetSubscriptionsRequestStatus.ts | 16 + ...ubscriptionsGetSubscriptionsRequestTier.ts | 16 + .../SubscriptionsGetSubscriptionsResponse.ts | 29 + ...scriptionsSubscriberIdRequestExpandItem.ts | 16 + ...onsGetSubscriptionsSubscriberIdResponse.ts | 21 + ...riptionsSubscriptionIdRequestExpandItem.ts | 16 + ...sGetSubscriptionsSubscriptionIdResponse.ts | 21 + ...tionsBulkUpdateRequestSubscriptionsItem.ts | 35 + ...equestSubscriptionsItemCustomFieldsItem.ts | 24 + ...sBulkUpdateRequestSubscriptionsItemTier.ts | 16 + ...scriptionsBulkActionsBulkUpdateResponse.ts | 21 + ...ptionsBulkActionsBulkUpdateResponseData.ts | 20 + ...iptionsBulkUpdateStatusRequestNewStatus.ts | 16 + ...chSubscriptionsBulkUpdateStatusResponse.ts | 21 + ...bscriptionsBulkUpdateStatusResponseData.ts | 20 + ...stSubscriptionsRequestDoubleOptOverride.ts | 16 + ...bscriptionsPostSubscriptionsRequestTier.ts | 16 + .../SubscriptionsPostSubscriptionsResponse.ts | 21 + ...tionsBulkUpdateRequestSubscriptionsItem.ts | 35 + ...equestSubscriptionsItemCustomFieldsItem.ts | 24 + ...sBulkUpdateRequestSubscriptionsItemTier.ts | 16 + ...scriptionsBulkActionsBulkUpdateResponse.ts | 21 + ...ptionsBulkActionsBulkUpdateResponseData.ts | 20 + ...iptionsBulkUpdateStatusRequestNewStatus.ts | 16 + ...utSubscriptionsBulkUpdateStatusResponse.ts | 21 + ...bscriptionsBulkUpdateStatusResponseData.ts | 20 + ...nsSubscriptionIdRequestCustomFieldsItem.ts | 24 + ...tSubscriptionsSubscriptionIdRequestTier.ts | 16 + ...sPutSubscriptionsSubscriptionIdResponse.ts | 21 + .../resources/subscriptions/types/index.ts | 34 + src/serialization/types/Automation.ts | 25 + src/serialization/types/AutomationJourney.ts | 31 + .../types/AutomationJourneyStatus.ts | 16 + src/serialization/types/AutomationStatus.ts | 14 + src/serialization/types/ClickStats.ts | 33 + src/serialization/types/CustomField.ts | 23 + src/serialization/types/CustomFieldKind.ts | 14 + src/serialization/types/CustomFieldValue.ts | 22 + src/serialization/types/EmailBlast.ts | 35 + src/serialization/types/EmailBlastContent.ts | 21 + .../types/EmailBlastContentEmail.ts | 22 + src/serialization/types/EmailBlastStats.ts | 24 + .../types/EmailBlastStatsClicksItem.ts | 29 + .../types/EmailBlastStatsEmail.ts | 36 + src/serialization/types/EmailBlastStatus.ts | 14 + src/serialization/types/ErrorErrorsItem.ts | 22 + src/serialization/types/Error_.ts | 23 + src/serialization/types/Milestone.ts | 25 + src/serialization/types/MilestoneReward.ts | 29 + .../types/MilestoneRewardType.ts | 16 + src/serialization/types/Post.ts | 67 + src/serialization/types/PostAudience.ts | 14 + .../types/PostClickStatsEmail.ts | 24 + src/serialization/types/PostClickStatsWeb.ts | 24 + src/serialization/types/PostContent.ts | 22 + src/serialization/types/PostContentFree.ts | 24 + src/serialization/types/PostContentPremium.ts | 22 + src/serialization/types/PostPlatform.ts | 14 + src/serialization/types/PostStats.ts | 25 + src/serialization/types/PostStatsEmail.ts | 34 + src/serialization/types/PostStatsWeb.ts | 20 + src/serialization/types/PostStatus.ts | 14 + src/serialization/types/Publication.ts | 27 + src/serialization/types/PublicationStats.ts | 51 + ...PublicationStatsActiveFreeSubscriptions.ts | 16 + ...licationStatsActivePremiumSubscriptions.ts | 16 + .../PublicationStatsActiveSubscriptions.ts | 16 + .../types/PublicationStatsAverageClickRate.ts | 16 + .../types/PublicationStatsAverageOpenRate.ts | 16 + .../types/PublicationStatsTotalClicked.ts | 16 + .../types/PublicationStatsTotalSent.ts | 16 + .../PublicationStatsTotalUniqueOpened.ts | 16 + src/serialization/types/Segment.ts | 32 + src/serialization/types/SegmentStatus.ts | 14 + src/serialization/types/SegmentType.ts | 14 + src/serialization/types/Subscription.ts | 51 + .../types/SubscriptionCustomFields.ts | 17 + .../types/SubscriptionExpandedStatus.ts | 16 + .../SubscriptionExpandedSubscriptionTier.ts | 16 + .../types/SubscriptionExpandedTagsStatus.ts | 16 + ...ubscriptionExpandedTagsSubscriptionTier.ts | 16 + .../SubscriptionExpandedTagsUtmChannel.ts | 39 + .../types/SubscriptionExpandedUtmChannel.ts | 39 + src/serialization/types/SubscriptionStats.ts | 24 + src/serialization/types/SubscriptionStatus.ts | 16 + .../types/SubscriptionSubscriptionTier.ts | 16 + src/serialization/types/SubscriptionTags.ts | 14 + .../types/SubscriptionUtmChannel.ts | 39 + src/serialization/types/index.ts | 58 + tsconfig.json | 17 + yarn.lock | 234 ++ 525 files changed, 19305 insertions(+) create mode 100644 .fernignore create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 .prettierrc.yml create mode 100644 package.json create mode 100644 reference.md create mode 100644 src/Client.ts create mode 100644 src/api/errors/BadRequestError.ts create mode 100644 src/api/errors/InternalServerError.ts create mode 100644 src/api/errors/NotFoundError.ts create mode 100644 src/api/errors/TooManyRequestsError.ts create mode 100644 src/api/errors/index.ts create mode 100644 src/api/index.ts create mode 100644 src/api/resources/automationJourneys/client/Client.ts create mode 100644 src/api/resources/automationJourneys/client/index.ts create mode 100644 src/api/resources/automationJourneys/client/requests/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts create mode 100644 src/api/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts create mode 100644 src/api/resources/automationJourneys/client/requests/index.ts create mode 100644 src/api/resources/automationJourneys/index.ts create mode 100644 src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts create mode 100644 src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts create mode 100644 src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts create mode 100644 src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts create mode 100644 src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts create mode 100644 src/api/resources/automationJourneys/types/index.ts create mode 100644 src/api/resources/automations/client/Client.ts create mode 100644 src/api/resources/automations/client/index.ts create mode 100644 src/api/resources/automations/client/requests/AutomationsGetPublicationsPublicationIdAutomationsRequest.ts create mode 100644 src/api/resources/automations/client/requests/index.ts create mode 100644 src/api/resources/automations/index.ts create mode 100644 src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts create mode 100644 src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts create mode 100644 src/api/resources/automations/types/index.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/client/Client.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/client/index.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/index.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts create mode 100644 src/api/resources/bulkSubscriptionUpdates/types/index.ts create mode 100644 src/api/resources/customFields/client/Client.ts create mode 100644 src/api/resources/customFields/client/index.ts create mode 100644 src/api/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts create mode 100644 src/api/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts create mode 100644 src/api/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts create mode 100644 src/api/resources/customFields/client/requests/index.ts create mode 100644 src/api/resources/customFields/index.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts create mode 100644 src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts create mode 100644 src/api/resources/customFields/types/index.ts create mode 100644 src/api/resources/emailBlasts/client/Client.ts create mode 100644 src/api/resources/emailBlasts/client/index.ts create mode 100644 src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest.ts create mode 100644 src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest.ts create mode 100644 src/api/resources/emailBlasts/client/requests/index.ts create mode 100644 src/api/resources/emailBlasts/index.ts create mode 100644 src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts create mode 100644 src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts create mode 100644 src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts create mode 100644 src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts create mode 100644 src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts create mode 100644 src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts create mode 100644 src/api/resources/emailBlasts/types/index.ts create mode 100644 src/api/resources/index.ts create mode 100644 src/api/resources/posts/client/Client.ts create mode 100644 src/api/resources/posts/client/index.ts create mode 100644 src/api/resources/posts/client/requests/PostsGetPostsPostIdRequest.ts create mode 100644 src/api/resources/posts/client/requests/PostsGetPostsRequest.ts create mode 100644 src/api/resources/posts/client/requests/index.ts create mode 100644 src/api/resources/posts/index.ts create mode 100644 src/api/resources/posts/types/PostsDeletePostsPostIdResponse.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsPostIdResponse.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsRequestAudience.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsRequestDirection.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsRequestExpandItem.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsRequestOrderBy.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsRequestPlatform.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsRequestStatus.ts create mode 100644 src/api/resources/posts/types/PostsGetPostsResponse.ts create mode 100644 src/api/resources/posts/types/index.ts create mode 100644 src/api/resources/publications/client/Client.ts create mode 100644 src/api/resources/publications/client/index.ts create mode 100644 src/api/resources/publications/client/requests/PublicationsGetPublicationsPublicationIdRequest.ts create mode 100644 src/api/resources/publications/client/requests/PublicationsGetPublicationsRequest.ts create mode 100644 src/api/resources/publications/client/requests/index.ts create mode 100644 src/api/resources/publications/index.ts create mode 100644 src/api/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts create mode 100644 src/api/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts create mode 100644 src/api/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts create mode 100644 src/api/resources/publications/types/PublicationsGetPublicationsResponse.ts create mode 100644 src/api/resources/publications/types/index.ts create mode 100644 src/api/resources/referralProgram/client/Client.ts create mode 100644 src/api/resources/referralProgram/client/index.ts create mode 100644 src/api/resources/referralProgram/client/requests/ReferralProgramGetPublicationsPublicReferralProgramRequest.ts create mode 100644 src/api/resources/referralProgram/client/requests/index.ts create mode 100644 src/api/resources/referralProgram/index.ts create mode 100644 src/api/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts create mode 100644 src/api/resources/referralProgram/types/index.ts create mode 100644 src/api/resources/segments/client/Client.ts create mode 100644 src/api/resources/segments/client/index.ts create mode 100644 src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsRequest.ts create mode 100644 src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest.ts create mode 100644 src/api/resources/segments/client/requests/index.ts create mode 100644 src/api/resources/segments/index.ts create mode 100644 src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts create mode 100644 src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts create mode 100644 src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts create mode 100644 src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts create mode 100644 src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts create mode 100644 src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts create mode 100644 src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts create mode 100644 src/api/resources/segments/types/index.ts create mode 100644 src/api/resources/subscriptionTags/client/Client.ts create mode 100644 src/api/resources/subscriptionTags/client/index.ts create mode 100644 src/api/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts create mode 100644 src/api/resources/subscriptionTags/client/requests/index.ts create mode 100644 src/api/resources/subscriptionTags/index.ts create mode 100644 src/api/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts create mode 100644 src/api/resources/subscriptionTags/types/index.ts create mode 100644 src/api/resources/subscriptions/client/Client.ts create mode 100644 src/api/resources/subscriptions/client/index.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsEmailRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriberIdRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriptionIdRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts create mode 100644 src/api/resources/subscriptions/client/requests/index.ts create mode 100644 src/api/resources/subscriptions/index.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts create mode 100644 src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts create mode 100644 src/api/resources/subscriptions/types/index.ts create mode 100644 src/api/types/Automation.ts create mode 100644 src/api/types/AutomationJourney.ts create mode 100644 src/api/types/AutomationJourneyStatus.ts create mode 100644 src/api/types/AutomationStatus.ts create mode 100644 src/api/types/ClickStats.ts create mode 100644 src/api/types/CustomField.ts create mode 100644 src/api/types/CustomFieldKind.ts create mode 100644 src/api/types/CustomFieldValue.ts create mode 100644 src/api/types/EmailBlast.ts create mode 100644 src/api/types/EmailBlastContent.ts create mode 100644 src/api/types/EmailBlastContentEmail.ts create mode 100644 src/api/types/EmailBlastStats.ts create mode 100644 src/api/types/EmailBlastStatsClicksItem.ts create mode 100644 src/api/types/EmailBlastStatsEmail.ts create mode 100644 src/api/types/EmailBlastStatus.ts create mode 100644 src/api/types/ErrorErrorsItem.ts create mode 100644 src/api/types/Error_.ts create mode 100644 src/api/types/Milestone.ts create mode 100644 src/api/types/MilestoneReward.ts create mode 100644 src/api/types/MilestoneRewardType.ts create mode 100644 src/api/types/Post.ts create mode 100644 src/api/types/PostAudience.ts create mode 100644 src/api/types/PostClickStatsEmail.ts create mode 100644 src/api/types/PostClickStatsWeb.ts create mode 100644 src/api/types/PostContent.ts create mode 100644 src/api/types/PostContentFree.ts create mode 100644 src/api/types/PostContentPremium.ts create mode 100644 src/api/types/PostPlatform.ts create mode 100644 src/api/types/PostStats.ts create mode 100644 src/api/types/PostStatsEmail.ts create mode 100644 src/api/types/PostStatsWeb.ts create mode 100644 src/api/types/PostStatus.ts create mode 100644 src/api/types/Publication.ts create mode 100644 src/api/types/PublicationStats.ts create mode 100644 src/api/types/PublicationStatsActiveFreeSubscriptions.ts create mode 100644 src/api/types/PublicationStatsActivePremiumSubscriptions.ts create mode 100644 src/api/types/PublicationStatsActiveSubscriptions.ts create mode 100644 src/api/types/PublicationStatsAverageClickRate.ts create mode 100644 src/api/types/PublicationStatsAverageOpenRate.ts create mode 100644 src/api/types/PublicationStatsTotalClicked.ts create mode 100644 src/api/types/PublicationStatsTotalSent.ts create mode 100644 src/api/types/PublicationStatsTotalUniqueOpened.ts create mode 100644 src/api/types/Segment.ts create mode 100644 src/api/types/SegmentStatus.ts create mode 100644 src/api/types/SegmentType.ts create mode 100644 src/api/types/Subscription.ts create mode 100644 src/api/types/SubscriptionCustomFields.ts create mode 100644 src/api/types/SubscriptionExpandedStatus.ts create mode 100644 src/api/types/SubscriptionExpandedSubscriptionTier.ts create mode 100644 src/api/types/SubscriptionExpandedTagsStatus.ts create mode 100644 src/api/types/SubscriptionExpandedTagsSubscriptionTier.ts create mode 100644 src/api/types/SubscriptionExpandedTagsUtmChannel.ts create mode 100644 src/api/types/SubscriptionExpandedUtmChannel.ts create mode 100644 src/api/types/SubscriptionStats.ts create mode 100644 src/api/types/SubscriptionStatus.ts create mode 100644 src/api/types/SubscriptionSubscriptionTier.ts create mode 100644 src/api/types/SubscriptionTags.ts create mode 100644 src/api/types/SubscriptionUtmChannel.ts create mode 100644 src/api/types/index.ts create mode 100644 src/core/auth/BasicAuth.ts create mode 100644 src/core/auth/BearerToken.ts create mode 100644 src/core/auth/index.ts create mode 100644 src/core/fetcher/APIResponse.ts create mode 100644 src/core/fetcher/Fetcher.ts create mode 100644 src/core/fetcher/Supplier.ts create mode 100644 src/core/fetcher/getHeader.ts create mode 100644 src/core/fetcher/index.ts create mode 100644 src/core/index.ts create mode 100644 src/core/runtime/index.ts create mode 100644 src/core/runtime/runtime.ts create mode 100644 src/core/schemas/Schema.ts create mode 100644 src/core/schemas/builders/date/date.ts create mode 100644 src/core/schemas/builders/date/index.ts create mode 100644 src/core/schemas/builders/enum/enum.ts create mode 100644 src/core/schemas/builders/enum/index.ts create mode 100644 src/core/schemas/builders/index.ts create mode 100644 src/core/schemas/builders/lazy/index.ts create mode 100644 src/core/schemas/builders/lazy/lazy.ts create mode 100644 src/core/schemas/builders/lazy/lazyObject.ts create mode 100644 src/core/schemas/builders/list/index.ts create mode 100644 src/core/schemas/builders/list/list.ts create mode 100644 src/core/schemas/builders/literals/booleanLiteral.ts create mode 100644 src/core/schemas/builders/literals/index.ts create mode 100644 src/core/schemas/builders/literals/stringLiteral.ts create mode 100644 src/core/schemas/builders/object-like/getObjectLikeUtils.ts create mode 100644 src/core/schemas/builders/object-like/index.ts create mode 100644 src/core/schemas/builders/object-like/types.ts create mode 100644 src/core/schemas/builders/object/index.ts create mode 100644 src/core/schemas/builders/object/object.ts create mode 100644 src/core/schemas/builders/object/objectWithoutOptionalProperties.ts create mode 100644 src/core/schemas/builders/object/property.ts create mode 100644 src/core/schemas/builders/object/types.ts create mode 100644 src/core/schemas/builders/primitives/any.ts create mode 100644 src/core/schemas/builders/primitives/boolean.ts create mode 100644 src/core/schemas/builders/primitives/index.ts create mode 100644 src/core/schemas/builders/primitives/number.ts create mode 100644 src/core/schemas/builders/primitives/string.ts create mode 100644 src/core/schemas/builders/primitives/unknown.ts create mode 100644 src/core/schemas/builders/record/index.ts create mode 100644 src/core/schemas/builders/record/record.ts create mode 100644 src/core/schemas/builders/record/types.ts create mode 100644 src/core/schemas/builders/schema-utils/JsonError.ts create mode 100644 src/core/schemas/builders/schema-utils/ParseError.ts create mode 100644 src/core/schemas/builders/schema-utils/getSchemaUtils.ts create mode 100644 src/core/schemas/builders/schema-utils/index.ts create mode 100644 src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts create mode 100644 src/core/schemas/builders/set/index.ts create mode 100644 src/core/schemas/builders/set/set.ts create mode 100644 src/core/schemas/builders/undiscriminated-union/index.ts create mode 100644 src/core/schemas/builders/undiscriminated-union/types.ts create mode 100644 src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts create mode 100644 src/core/schemas/builders/union/discriminant.ts create mode 100644 src/core/schemas/builders/union/index.ts create mode 100644 src/core/schemas/builders/union/types.ts create mode 100644 src/core/schemas/builders/union/union.ts create mode 100644 src/core/schemas/index.ts create mode 100644 src/core/schemas/utils/MaybePromise.ts create mode 100644 src/core/schemas/utils/addQuestionMarksToNullableProperties.ts create mode 100644 src/core/schemas/utils/createIdentitySchemaCreator.ts create mode 100644 src/core/schemas/utils/entries.ts create mode 100644 src/core/schemas/utils/filterObject.ts create mode 100644 src/core/schemas/utils/getErrorMessageForIncorrectType.ts create mode 100644 src/core/schemas/utils/isPlainObject.ts create mode 100644 src/core/schemas/utils/keys.ts create mode 100644 src/core/schemas/utils/maybeSkipValidation.ts create mode 100644 src/core/schemas/utils/partition.ts create mode 100644 src/environments.ts create mode 100644 src/errors/beehiivError.ts create mode 100644 src/errors/beehiivTimeoutError.ts create mode 100644 src/errors/index.ts create mode 100644 src/index.ts create mode 100644 src/serialization/index.ts create mode 100644 src/serialization/resources/automationJourneys/client/index.ts create mode 100644 src/serialization/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts create mode 100644 src/serialization/resources/automationJourneys/client/requests/index.ts create mode 100644 src/serialization/resources/automationJourneys/index.ts create mode 100644 src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts create mode 100644 src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts create mode 100644 src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts create mode 100644 src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts create mode 100644 src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts create mode 100644 src/serialization/resources/automationJourneys/types/index.ts create mode 100644 src/serialization/resources/automations/index.ts create mode 100644 src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts create mode 100644 src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts create mode 100644 src/serialization/resources/automations/types/index.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/index.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts create mode 100644 src/serialization/resources/bulkSubscriptionUpdates/types/index.ts create mode 100644 src/serialization/resources/customFields/client/index.ts create mode 100644 src/serialization/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts create mode 100644 src/serialization/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts create mode 100644 src/serialization/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts create mode 100644 src/serialization/resources/customFields/client/requests/index.ts create mode 100644 src/serialization/resources/customFields/index.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts create mode 100644 src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts create mode 100644 src/serialization/resources/customFields/types/index.ts create mode 100644 src/serialization/resources/emailBlasts/index.ts create mode 100644 src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts create mode 100644 src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts create mode 100644 src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts create mode 100644 src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts create mode 100644 src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts create mode 100644 src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts create mode 100644 src/serialization/resources/emailBlasts/types/index.ts create mode 100644 src/serialization/resources/index.ts create mode 100644 src/serialization/resources/posts/index.ts create mode 100644 src/serialization/resources/posts/types/PostsDeletePostsPostIdResponse.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsPostIdResponse.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsRequestAudience.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsRequestDirection.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsRequestExpandItem.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsRequestOrderBy.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsRequestPlatform.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsRequestStatus.ts create mode 100644 src/serialization/resources/posts/types/PostsGetPostsResponse.ts create mode 100644 src/serialization/resources/posts/types/index.ts create mode 100644 src/serialization/resources/publications/index.ts create mode 100644 src/serialization/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts create mode 100644 src/serialization/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts create mode 100644 src/serialization/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts create mode 100644 src/serialization/resources/publications/types/PublicationsGetPublicationsResponse.ts create mode 100644 src/serialization/resources/publications/types/index.ts create mode 100644 src/serialization/resources/referralProgram/index.ts create mode 100644 src/serialization/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts create mode 100644 src/serialization/resources/referralProgram/types/index.ts create mode 100644 src/serialization/resources/segments/client/deletePublicationsPublicationIdSegmentsSegmentId.ts create mode 100644 src/serialization/resources/segments/client/index.ts create mode 100644 src/serialization/resources/segments/index.ts create mode 100644 src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts create mode 100644 src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts create mode 100644 src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts create mode 100644 src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts create mode 100644 src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts create mode 100644 src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts create mode 100644 src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts create mode 100644 src/serialization/resources/segments/types/index.ts create mode 100644 src/serialization/resources/subscriptionTags/client/index.ts create mode 100644 src/serialization/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts create mode 100644 src/serialization/resources/subscriptionTags/client/requests/index.ts create mode 100644 src/serialization/resources/subscriptionTags/index.ts create mode 100644 src/serialization/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts create mode 100644 src/serialization/resources/subscriptionTags/types/index.ts create mode 100644 src/serialization/resources/subscriptions/client/deleteSubscriptionsSubscriptionId.ts create mode 100644 src/serialization/resources/subscriptions/client/index.ts create mode 100644 src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts create mode 100644 src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts create mode 100644 src/serialization/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts create mode 100644 src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts create mode 100644 src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts create mode 100644 src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts create mode 100644 src/serialization/resources/subscriptions/client/requests/index.ts create mode 100644 src/serialization/resources/subscriptions/index.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts create mode 100644 src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts create mode 100644 src/serialization/resources/subscriptions/types/index.ts create mode 100644 src/serialization/types/Automation.ts create mode 100644 src/serialization/types/AutomationJourney.ts create mode 100644 src/serialization/types/AutomationJourneyStatus.ts create mode 100644 src/serialization/types/AutomationStatus.ts create mode 100644 src/serialization/types/ClickStats.ts create mode 100644 src/serialization/types/CustomField.ts create mode 100644 src/serialization/types/CustomFieldKind.ts create mode 100644 src/serialization/types/CustomFieldValue.ts create mode 100644 src/serialization/types/EmailBlast.ts create mode 100644 src/serialization/types/EmailBlastContent.ts create mode 100644 src/serialization/types/EmailBlastContentEmail.ts create mode 100644 src/serialization/types/EmailBlastStats.ts create mode 100644 src/serialization/types/EmailBlastStatsClicksItem.ts create mode 100644 src/serialization/types/EmailBlastStatsEmail.ts create mode 100644 src/serialization/types/EmailBlastStatus.ts create mode 100644 src/serialization/types/ErrorErrorsItem.ts create mode 100644 src/serialization/types/Error_.ts create mode 100644 src/serialization/types/Milestone.ts create mode 100644 src/serialization/types/MilestoneReward.ts create mode 100644 src/serialization/types/MilestoneRewardType.ts create mode 100644 src/serialization/types/Post.ts create mode 100644 src/serialization/types/PostAudience.ts create mode 100644 src/serialization/types/PostClickStatsEmail.ts create mode 100644 src/serialization/types/PostClickStatsWeb.ts create mode 100644 src/serialization/types/PostContent.ts create mode 100644 src/serialization/types/PostContentFree.ts create mode 100644 src/serialization/types/PostContentPremium.ts create mode 100644 src/serialization/types/PostPlatform.ts create mode 100644 src/serialization/types/PostStats.ts create mode 100644 src/serialization/types/PostStatsEmail.ts create mode 100644 src/serialization/types/PostStatsWeb.ts create mode 100644 src/serialization/types/PostStatus.ts create mode 100644 src/serialization/types/Publication.ts create mode 100644 src/serialization/types/PublicationStats.ts create mode 100644 src/serialization/types/PublicationStatsActiveFreeSubscriptions.ts create mode 100644 src/serialization/types/PublicationStatsActivePremiumSubscriptions.ts create mode 100644 src/serialization/types/PublicationStatsActiveSubscriptions.ts create mode 100644 src/serialization/types/PublicationStatsAverageClickRate.ts create mode 100644 src/serialization/types/PublicationStatsAverageOpenRate.ts create mode 100644 src/serialization/types/PublicationStatsTotalClicked.ts create mode 100644 src/serialization/types/PublicationStatsTotalSent.ts create mode 100644 src/serialization/types/PublicationStatsTotalUniqueOpened.ts create mode 100644 src/serialization/types/Segment.ts create mode 100644 src/serialization/types/SegmentStatus.ts create mode 100644 src/serialization/types/SegmentType.ts create mode 100644 src/serialization/types/Subscription.ts create mode 100644 src/serialization/types/SubscriptionCustomFields.ts create mode 100644 src/serialization/types/SubscriptionExpandedStatus.ts create mode 100644 src/serialization/types/SubscriptionExpandedSubscriptionTier.ts create mode 100644 src/serialization/types/SubscriptionExpandedTagsStatus.ts create mode 100644 src/serialization/types/SubscriptionExpandedTagsSubscriptionTier.ts create mode 100644 src/serialization/types/SubscriptionExpandedTagsUtmChannel.ts create mode 100644 src/serialization/types/SubscriptionExpandedUtmChannel.ts create mode 100644 src/serialization/types/SubscriptionStats.ts create mode 100644 src/serialization/types/SubscriptionStatus.ts create mode 100644 src/serialization/types/SubscriptionSubscriptionTier.ts create mode 100644 src/serialization/types/SubscriptionTags.ts create mode 100644 src/serialization/types/SubscriptionUtmChannel.ts create mode 100644 src/serialization/types/index.ts create mode 100644 tsconfig.json create mode 100644 yarn.lock diff --git a/.fernignore b/.fernignore new file mode 100644 index 0000000..084a8eb --- /dev/null +++ b/.fernignore @@ -0,0 +1 @@ +# Specify files that shouldn't be modified by Fern diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c78927e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: ci + +on: [push] + +jobs: + compile: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up node + uses: actions/setup-node@v3 + + - name: Compile + run: yarn && yarn build + + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up node + uses: actions/setup-node@v3 + + - name: Test + run: | + yarn + yarn fern test --command='jest --env=node' + yarn fern test --command='jest --env=jsdom' + + publish: + needs: [ compile, test ] + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up node + uses: actions/setup-node@v3 + + - name: Install dependencies + run: yarn install + + - name: Build + run: yarn build \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72271e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +node_modules +.DS_Store +/dist \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..6db0876 --- /dev/null +++ b/.npmignore @@ -0,0 +1,9 @@ +node_modules +src +tests +.gitignore +.github +.fernignore +.prettierrc.yml +tsconfig.json +yarn.lock \ No newline at end of file diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..0c06786 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,2 @@ +tabWidth: 4 +printWidth: 120 diff --git a/package.json b/package.json new file mode 100644 index 0000000..e998ffc --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "", + "version": "0.1.0", + "private": false, + "repository": "https://github.com/fern-demo/beehiiv-typescript", + "main": "./index.js", + "types": "./index.d.ts", + "scripts": { + "format": "prettier . --write --ignore-unknown", + "build": "tsc", + "prepack": "cp -rv dist/. ." + }, + "dependencies": { + "url-join": "4.0.1", + "form-data": "4.0.0", + "node-fetch": "2.7.0", + "qs": "6.11.2", + "js-base64": "3.7.2" + }, + "devDependencies": { + "@types/url-join": "4.0.1", + "@types/qs": "6.9.8", + "@types/node-fetch": "2.6.9", + "@types/node": "17.0.33", + "prettier": "2.7.1", + "typescript": "4.6.4" + } +} diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..b3474e9 --- /dev/null +++ b/reference.md @@ -0,0 +1,3612 @@ +## Publications + +
beehiiv.publications.getPublications({ ...params }) -> beehiiv.PublicationsGetPublicationsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve all publications associated with your API key. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.publications.getPublications(); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**request: `beehiiv.PublicationsGetPublicationsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Publications.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.publications.getPublicationsPublicationId(publicationId, { ...params }) -> beehiiv.PublicationsGetPublicationsPublicationIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve a single publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.publications.getPublicationsPublicationId("pub_00000000-0000-0000-0000-000000000000"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.PublicationsGetPublicationsPublicationIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Publications.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Posts + +
beehiiv.posts.getPosts(publicationId, { ...params }) -> beehiiv.PostsGetPostsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve all posts belonging to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.posts.getPosts("pub_00000000-0000-0000-0000-000000000000"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.PostsGetPostsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Posts.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.posts.getPostsPostId(postId, publicationId, { ...params }) -> beehiiv.PostsGetPostsPostIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retreive a single Post belonging to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.posts.getPostsPostId( + "post_00000000-0000-0000-0000-000000000000", + "pub_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**postId: `string`** — The prefixed ID of the post object + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.PostsGetPostsPostIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Posts.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.posts.deletePostsPostId(postId, publicationId) -> beehiiv.PostsDeletePostsPostIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Delete or Archive a post. Any post that has been confirmed will have it's status changed to `archived`. Posts in the `draft` status will be permenantly deleted. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.posts.deletePostsPostId( + "post_00000000-0000-0000-0000-000000000000", + "pub_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**postId: `string`** — The prefixed ID of the post object + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**requestOptions: `Posts.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Subscriptions + +
beehiiv.subscriptions.getSubscriptions(publicationId, { ...params }) -> beehiiv.SubscriptionsGetSubscriptionsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve all subscriptions belonging to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.getSubscriptions("pub_00000000-0000-0000-0000-000000000000", { + email: "clark@dailyplanet.com", +}); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsGetSubscriptionsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.postSubscriptions(publicationId, { ...params }) -> beehiiv.SubscriptionsPostSubscriptionsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Create new subscriptions for a publication. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.postSubscriptions("pub_00000000-0000-0000-0000-000000000000", { + email: "bruce.wayne@wayneenterprise.com", + reactivateExisting: false, + sendWelcomeEmail: false, + utmSource: "WayneEnterprise", + utmMedium: "organic", + utmCampaign: "fall_2022_promotion", + referringSite: "www.wayneenterprise.com/blog", + customFields: [ + { + name: "First Name", + value: "Bruce", + }, + { + name: "Last Name", + value: "Wayne", + }, + ], + automationIds: ["aut_00000000-0000-0000-0000-000000000000"], +}); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsPostSubscriptionsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.putSubscriptionsBulkUpdateStatus(publicationId, { ...params }) -> beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Bulk update subscriptions' Status value + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.putSubscriptionsBulkUpdateStatus("pub_00000000-0000-0000-0000-000000000000", { + subscriptionIds: ["subscription_ids"], + newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active, +}); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.patchSubscriptionsBulkUpdateStatus(publicationId, { ...params }) -> beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Bulk update subscriptions' Status value + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.patchSubscriptionsBulkUpdateStatus("pub_00000000-0000-0000-0000-000000000000", { + subscriptionIds: ["subscription_ids"], + newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active, +}); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.getSubscriptionsSubscriptionId(subscriptionId, publicationId, { ...params }) -> beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve a single subscription belonging to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.getSubscriptionsSubscriptionId( + "sub_00000000-0000-0000-0000-000000000000", + "pub_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**subscriptionId: `string`** — The prefixed ID of the subscription object + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.putSubscriptionsSubscriptionId(subscriptionId, publicationId, { ...params }) -> beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Update a subscriber + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.putSubscriptionsSubscriptionId( + "sub_00000000-0000-0000-0000-000000000000", + "pub_00000000-0000-0000-0000-000000000000", + { + tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + unsubscribe: false, + customFields: [ + { + name: "First Name", + value: "JOHN", + }, + { + name: "Birthday", + delete: true, + }, + ], + } +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**subscriptionId: `string`** — The prefixed ID of the subscription object + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.deleteSubscriptionsSubscriptionId(subscriptionId, publicationId) -> Record + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Delete a subscription. + +**This cannot be undone** All data associated with the subscription will also be deleted. We recommend unsubscribing when possible instead of deleting. + +If a premium subscription is deleted they will no longer be billed. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.deleteSubscriptionsSubscriptionId( + "sub_00000000-0000-0000-0000-000000000000", + "pub_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**subscriptionId: `string`** — The prefixed ID of the subscription object + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.getSubscriptionsSubscriberId(publicationId, subscriberId, { ...params }) -> beehiiv.SubscriptionsGetSubscriptionsSubscriberIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve a single subscription belonging to a specific subscriber in a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.getSubscriptionsSubscriberId( + "pub_00000000-0000-0000-0000-000000000000", + "00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**subscriberId: `string`** — The ID of the subscriber object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.getSubscriptionsEmail(publicationId, email, { ...params }) -> beehiiv.SubscriptionsGetSubscriptionsEmailResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve a single subscription belonging to a specific email address in a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.getSubscriptionsEmail("pub_00000000-0000-0000-0000-000000000000", "work@example.com"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**email: `string`** — The ID of the subscriber object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsGetSubscriptionsEmailRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.putSubscriptionsBulkActionsBulkUpdate(publicationId, { ...params }) -> beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Bulk update subscriptions' field values (standard fields and custom fields) + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.putSubscriptionsBulkActionsBulkUpdate("publicationId"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.subscriptions.patchSubscriptionsBulkActionsBulkUpdate(publicationId, { ...params }) -> beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Bulk update subscriptions' field values (standard fields and custom fields) + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptions.patchSubscriptionsBulkActionsBulkUpdate("publicationId"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Subscriptions.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Segments + +
beehiiv.segments.getPublicationsPublicationIdSegments(publicationId, { ...params }) -> beehiiv.SegmentsGetPublicationsPublicationIdSegmentsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve information about all segments belonging to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.segments.getPublicationsPublicationIdSegments("pub_00000000-0000-0000-0000-000000000000"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Segments.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentId(publicationId, segmentId) -> beehiiv.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve a single segment belonging to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentId( + "pub_00000000-0000-0000-0000-000000000000", + "seg_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**segmentId: `string`** — The prefixed ID of the segment object + +
+ +
+ +
+ +
+ +**requestOptions: `Segments.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.segments.deletePublicationsPublicationIdSegmentsSegmentId(publicationId, segmentId) -> Record + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Delete a segment. Deleting the segment does not effect the subscriptions in the segment. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.segments.deletePublicationsPublicationIdSegmentsSegmentId( + "pub_00000000-0000-0000-0000-000000000000", + "seg_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**segmentId: `string`** — The prefixed ID of the segment object + +
+ +
+ +
+ +
+ +**requestOptions: `Segments.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentIdResults(publicationId, segmentId, { ...params }) -> beehiiv.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +List the Subscriber Ids from the most recent calculation of a specific publication. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentIdResults( + "pub_00000000-0000-0000-0000-000000000000", + "seg_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**segmentId: `string`** — The prefixed ID of the segment object + +
+ +
+ +
+ +
+ +**request: `beehiiv.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Segments.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Email Blasts + +
beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlasts(publicationId, { ...params }) -> beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve all Email Blasts + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlasts("pub_00000000-0000-0000-0000-000000000000"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `EmailBlasts.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlastsEmailBlastId(publicationId, emailBlastId, { ...params }) -> beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve an Email Blast + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlastsEmailBlastId( + "pub_00000000-0000-0000-0000-000000000000", + "blast_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**emailBlastId: `string`** — The prefixed ID of the email blast object + +
+ +
+ +
+ +
+ +**request: `beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `EmailBlasts.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Referral Program + +
beehiiv.referralProgram.getPublicationsPublicReferralProgram(publicationId, { ...params }) -> beehiiv.ReferralProgramGetPublicationsPublicReferralProgramResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve details about the publication's referral program, including milestones and rewards. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.referralProgram.getPublicationsPublicReferralProgram("pub_00000000-0000-0000-0000-000000000000"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.ReferralProgramGetPublicationsPublicReferralProgramRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `ReferralProgram.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Custom Fields + +
beehiiv.customFields.getPublicationsPublicationIdCustomFields(publicationId) -> beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve all custom fields belonging to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.customFields.getPublicationsPublicationIdCustomFields("publicationId"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**requestOptions: `CustomFields.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.customFields.postPublicationsPublicationIdCustomFields(publicationId, { ...params }) -> beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Create a custom field on a publication, for use in subscriptions + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.customFields.postPublicationsPublicationIdCustomFields("publicationId", { + kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + display: "display", +}); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `CustomFields.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.customFields.getPublicationsPublicationIdCustomFieldsId(publicationId, id) -> beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +View a specific custom field on a publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.customFields.getPublicationsPublicationIdCustomFieldsId("publicationId", "id"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**id: `string`** — The ID of the Custom Fields object + +
+ +
+ +
+ +
+ +**requestOptions: `CustomFields.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.customFields.putPublicationsPublicationIdCustomFieldsId(publicationId, id, { ...params }) -> beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Update a custom field on a publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.customFields.putPublicationsPublicationIdCustomFieldsId("publicationId", "id"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**id: `string`** — The ID of the Custom Fields object + +
+ +
+ +
+ +
+ +**request: `beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `CustomFields.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.customFields.deletePublicationsPublicationIdCustomFields(publicationId, id) -> beehiiv.CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Delete a custom field from a publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.customFields.deletePublicationsPublicationIdCustomFields("publicationId", "id"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**id: `string`** — The ID of the Custom Fields object + +
+ +
+ +
+ +
+ +**requestOptions: `CustomFields.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.customFields.patchPublicationsPublicationIdCustomFieldsId(publicationId, id, { ...params }) -> beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Update a custom field on a publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.customFields.patchPublicationsPublicationIdCustomFieldsId("publicationId", "id"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**id: `string`** — The ID of the Custom Fields object + +
+ +
+ +
+ +
+ +**request: `beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `CustomFields.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Bulk Subscription Updates + +
beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdates(publicationId) -> beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Returns a list of Subscription Update objects for a publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdates("publicationId"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**requestOptions: `BulkSubscriptionUpdates.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdatesId(publicationId, id) -> beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Returns a single Subscription Update object for a publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdatesId("publicationId", "id"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**id: `string`** — The ID of the Subscription Update object + +
+ +
+ +
+ +
+ +**requestOptions: `BulkSubscriptionUpdates.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Automation Journeys + +
beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneys(publicationId, automationId, { ...params }) -> beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Retrieve all automation journeys associated with an automation that belongs to a specific publication + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneys( + "pub_00000000-0000-0000-0000-000000000000", + "aut_00000000-0000-0000-0000-000000000000", + { + subscriptionId: "sub_00000000-0000-0000-0000-000000000000", + email: "clark@dailyplanet.com", + } +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**automationId: `string`** — The prefixed ID of the automation object + +
+ +
+ +
+ +
+ +**request: `beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `AutomationJourneys.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.automationJourneys.postPublicationsPublicationIdAutomationsAutomationIdJourneys(publicationId, automationId, { ...params }) -> beehiiv.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Add an existing subscription to an automation flow. Requires the automation to have an active _Add by API_ trigger. + +The specified `email` or `subscription_id` will be matched against your existing subscribers. +If an existing subscriber is found, they will be enrolled immediately. + +Looking to enroll new subscribers? Use the **[Subscriptions Create](https://beehiiv.stoplight.io/docs/v2/1a77a563675ee-create)** endpoint instead and specify the `automation_ids` param. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.automationJourneys.postPublicationsPublicationIdAutomationsAutomationIdJourneys( + "pub_00000000-0000-0000-0000-000000000000", + "aut_00000000-0000-0000-0000-000000000000", + { + email: "example@example.com", + subscriptionId: "sub_00000000-0000-0000-0000-000000000000", + } +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**automationId: `string`** — The prefixed ID of the automation object + +
+ +
+ +
+ +
+ +**request: `beehiiv.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `AutomationJourneys.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyId(publicationId, automationId, automationJourneyId) -> beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse + +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyId( + "pub_00000000-0000-0000-0000-000000000000", + "aut_00000000-0000-0000-0000-000000000000", + "aj_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**automationId: `string`** — The prefixed ID of the automation object + +
+ +
+ +
+ +
+ +**automationJourneyId: `string`** — The prefixed automation journey id + +
+ +
+ +
+ +
+ +**requestOptions: `AutomationJourneys.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Automations + +
beehiiv.automations.getPublicationsPublicationIdAutomations(publicationId, { ...params }) -> beehiiv.AutomationsGetPublicationsPublicationIdAutomationsResponse + +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.automations.getPublicationsPublicationIdAutomations("pub_00000000-0000-0000-0000-000000000000"); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**request: `beehiiv.AutomationsGetPublicationsPublicationIdAutomationsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `Automations.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +
beehiiv.automations.getPublicationsPublicationIdAutomationsAutomationId(publicationId, automationId) -> beehiiv.AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse + +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.automations.getPublicationsPublicationIdAutomationsAutomationId( + "pub_00000000-0000-0000-0000-000000000000", + "aut_00000000-0000-0000-0000-000000000000" +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** — The prefixed ID of the publication object + +
+ +
+ +
+ +
+ +**automationId: `string`** — The prefixed ID of the automation object + +
+ +
+ +
+ +
+ +**requestOptions: `Automations.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
+ +## Subscription Tags + +
beehiiv.subscriptionTags.postPublicationsPublicationIdSubscriptionsSubscriptionIdTags(publicationId, subscriptionId, { ...params }) -> beehiiv.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse + +
+ +
+ +#### 📝 Description + +
+ +
+ +
+ +
+ +Create new subscription tags for a subscription. If the tag does not exist on the publication, it will be created automatically. + +
+ +
+ +
+ +
+ +#### 🔌 Usage + +
+ +
+ +
+ +
+ +```ts +await beehiiv.subscriptionTags.postPublicationsPublicationIdSubscriptionsSubscriptionIdTags( + "publicationId", + "subscriptionId", + { + tags: ["Premium"], + } +); +``` + +
+ +
+ +
+ +
+ +#### ⚙️ Parameters + +
+ +
+ +
+ +
+ +**publicationId: `string`** + +
+ +
+ +
+ +
+ +**subscriptionId: `string`** + +
+ +
+ +
+ +
+ +**request: `beehiiv.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest`** + +
+ +
+ +
+ +
+ +**requestOptions: `SubscriptionTags.RequestOptions`** + +
+ +
+ +
+ +
+ +
+ +
+
diff --git a/src/Client.ts b/src/Client.ts new file mode 100644 index 0000000..cd72c57 --- /dev/null +++ b/src/Client.ts @@ -0,0 +1,100 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "./environments"; +import * as core from "./core"; +import { Publications } from "./api/resources/publications/client/Client"; +import { Posts } from "./api/resources/posts/client/Client"; +import { Subscriptions } from "./api/resources/subscriptions/client/Client"; +import { Segments } from "./api/resources/segments/client/Client"; +import { EmailBlasts } from "./api/resources/emailBlasts/client/Client"; +import { ReferralProgram } from "./api/resources/referralProgram/client/Client"; +import { CustomFields } from "./api/resources/customFields/client/Client"; +import { BulkSubscriptionUpdates } from "./api/resources/bulkSubscriptionUpdates/client/Client"; +import { AutomationJourneys } from "./api/resources/automationJourneys/client/Client"; +import { Automations } from "./api/resources/automations/client/Client"; +import { SubscriptionTags } from "./api/resources/subscriptionTags/client/Client"; + +export declare namespace beehiivClient { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class beehiivClient { + constructor(protected readonly _options: beehiivClient.Options) {} + + protected _publications: Publications | undefined; + + public get publications(): Publications { + return (this._publications ??= new Publications(this._options)); + } + + protected _posts: Posts | undefined; + + public get posts(): Posts { + return (this._posts ??= new Posts(this._options)); + } + + protected _subscriptions: Subscriptions | undefined; + + public get subscriptions(): Subscriptions { + return (this._subscriptions ??= new Subscriptions(this._options)); + } + + protected _segments: Segments | undefined; + + public get segments(): Segments { + return (this._segments ??= new Segments(this._options)); + } + + protected _emailBlasts: EmailBlasts | undefined; + + public get emailBlasts(): EmailBlasts { + return (this._emailBlasts ??= new EmailBlasts(this._options)); + } + + protected _referralProgram: ReferralProgram | undefined; + + public get referralProgram(): ReferralProgram { + return (this._referralProgram ??= new ReferralProgram(this._options)); + } + + protected _customFields: CustomFields | undefined; + + public get customFields(): CustomFields { + return (this._customFields ??= new CustomFields(this._options)); + } + + protected _bulkSubscriptionUpdates: BulkSubscriptionUpdates | undefined; + + public get bulkSubscriptionUpdates(): BulkSubscriptionUpdates { + return (this._bulkSubscriptionUpdates ??= new BulkSubscriptionUpdates(this._options)); + } + + protected _automationJourneys: AutomationJourneys | undefined; + + public get automationJourneys(): AutomationJourneys { + return (this._automationJourneys ??= new AutomationJourneys(this._options)); + } + + protected _automations: Automations | undefined; + + public get automations(): Automations { + return (this._automations ??= new Automations(this._options)); + } + + protected _subscriptionTags: SubscriptionTags | undefined; + + public get subscriptionTags(): SubscriptionTags { + return (this._subscriptionTags ??= new SubscriptionTags(this._options)); + } +} diff --git a/src/api/errors/BadRequestError.ts b/src/api/errors/BadRequestError.ts new file mode 100644 index 0000000..d6b74c6 --- /dev/null +++ b/src/api/errors/BadRequestError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors"; +import * as beehiiv from ".."; + +export class BadRequestError extends errors.beehiivError { + constructor(body: beehiiv.Error_) { + super({ + message: "BadRequestError", + statusCode: 400, + body: body, + }); + Object.setPrototypeOf(this, BadRequestError.prototype); + } +} diff --git a/src/api/errors/InternalServerError.ts b/src/api/errors/InternalServerError.ts new file mode 100644 index 0000000..a0cb71e --- /dev/null +++ b/src/api/errors/InternalServerError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors"; +import * as beehiiv from ".."; + +export class InternalServerError extends errors.beehiivError { + constructor(body: beehiiv.Error_) { + super({ + message: "InternalServerError", + statusCode: 500, + body: body, + }); + Object.setPrototypeOf(this, InternalServerError.prototype); + } +} diff --git a/src/api/errors/NotFoundError.ts b/src/api/errors/NotFoundError.ts new file mode 100644 index 0000000..856c714 --- /dev/null +++ b/src/api/errors/NotFoundError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors"; +import * as beehiiv from ".."; + +export class NotFoundError extends errors.beehiivError { + constructor(body: beehiiv.Error_) { + super({ + message: "NotFoundError", + statusCode: 404, + body: body, + }); + Object.setPrototypeOf(this, NotFoundError.prototype); + } +} diff --git a/src/api/errors/TooManyRequestsError.ts b/src/api/errors/TooManyRequestsError.ts new file mode 100644 index 0000000..744b8d9 --- /dev/null +++ b/src/api/errors/TooManyRequestsError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors"; +import * as beehiiv from ".."; + +export class TooManyRequestsError extends errors.beehiivError { + constructor(body: beehiiv.Error_) { + super({ + message: "TooManyRequestsError", + statusCode: 429, + body: body, + }); + Object.setPrototypeOf(this, TooManyRequestsError.prototype); + } +} diff --git a/src/api/errors/index.ts b/src/api/errors/index.ts new file mode 100644 index 0000000..9c7ef25 --- /dev/null +++ b/src/api/errors/index.ts @@ -0,0 +1,4 @@ +export * from "./BadRequestError"; +export * from "./NotFoundError"; +export * from "./TooManyRequestsError"; +export * from "./InternalServerError"; diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..3006072 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1,3 @@ +export * from "./resources"; +export * from "./types"; +export * from "./errors"; diff --git a/src/api/resources/automationJourneys/client/Client.ts b/src/api/resources/automationJourneys/client/Client.ts new file mode 100644 index 0000000..3fb85fe --- /dev/null +++ b/src/api/resources/automationJourneys/client/Client.ts @@ -0,0 +1,422 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace AutomationJourneys { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class AutomationJourneys { + constructor(protected readonly _options: AutomationJourneys.Options) {} + + /** + * Retrieve all automation journeys associated with an automation that belongs to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneys("pub_00000000-0000-0000-0000-000000000000", "aut_00000000-0000-0000-0000-000000000000", { + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000", + * email: "clark@dailyplanet.com" + * }) + * + * @example + * await beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneys("string", "string", { + * status: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.InProgress, + * limit: 1, + * page: 1, + * subscriptionId: "string", + * email: "string" + * }) + */ + public async getPublicationsPublicationIdAutomationsAutomationIdJourneys( + publicationId: string, + automationId: string, + request: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest = {}, + requestOptions?: AutomationJourneys.RequestOptions + ): Promise { + const { status, limit, page, subscriptionId, email } = request; + const _queryParams: Record = {}; + if (status != null) { + _queryParams["status"] = status; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (subscriptionId != null) { + _queryParams["subscription_id"] = subscriptionId; + } + + if (email != null) { + _queryParams["email"] = email; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/automations/${automationId}/journeys` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Add an existing subscription to an automation flow. Requires the automation to have an active _Add by API_ trigger. + * + * The specified `email` or `subscription_id` will be matched against your existing subscribers. + * If an existing subscriber is found, they will be enrolled immediately. + * + * Looking to enroll new subscribers? Use the **[Subscriptions Create](https://beehiiv.stoplight.io/docs/v2/1a77a563675ee-create)** endpoint instead and specify the `automation_ids` param. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.automationJourneys.postPublicationsPublicationIdAutomationsAutomationIdJourneys("pub_00000000-0000-0000-0000-000000000000", "aut_00000000-0000-0000-0000-000000000000", { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * }) + * + * @example + * await beehiiv.automationJourneys.postPublicationsPublicationIdAutomationsAutomationIdJourneys("string", "string", { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * }) + */ + public async postPublicationsPublicationIdAutomationsAutomationIdJourneys( + publicationId: string, + automationId: string, + request: beehiiv.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest = {}, + requestOptions?: AutomationJourneys.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/automations/${automationId}/journeys` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.jsonOrThrow( + request, + { unrecognizedObjectKeys: "strip" } + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyId("pub_00000000-0000-0000-0000-000000000000", "aut_00000000-0000-0000-0000-000000000000", "aj_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.automationJourneys.getPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyId("string", "string", "string") + */ + public async getPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyId( + publicationId: string, + automationId: string, + automationJourneyId: string, + requestOptions?: AutomationJourneys.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/automations/${automationId}/journeys/${automationJourneyId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/automationJourneys/client/index.ts b/src/api/resources/automationJourneys/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/automationJourneys/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/automationJourneys/client/requests/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts b/src/api/resources/automationJourneys/client/requests/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts new file mode 100644 index 0000000..9d3ca01 --- /dev/null +++ b/src/api/resources/automationJourneys/client/requests/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts @@ -0,0 +1,80 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000", + * email: "clark@dailyplanet.com" + * } + * + * @example + * { + * status: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.InProgress, + * limit: 1, + * page: 1, + * subscriptionId: "string", + * email: "string" + * } + * + * @example + * { + * status: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.InProgress, + * limit: 1, + * page: 1, + * subscriptionId: "string", + * email: "string" + * } + * + * @example + * { + * status: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.InProgress, + * limit: 1, + * page: 1, + * subscriptionId: "string", + * email: "string" + * } + * + * @example + * { + * status: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.InProgress, + * limit: 1, + * page: 1, + * subscriptionId: "string", + * email: "string" + * } + * + * @example + * { + * status: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.InProgress, + * limit: 1, + * page: 1, + * subscriptionId: "string", + * email: "string" + * } + */ +export interface AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest { + /** + * Optionally filter the results by a status + */ + status?: beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus; + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; + /** + * Optionally filter the results by a subscription id + */ + subscriptionId?: string; + /** + * Optionally filter the results by a subscription email address.
This param must be an exact match and is case insensitive. + */ + email?: string; +} diff --git a/src/api/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts b/src/api/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts new file mode 100644 index 0000000..231ca8b --- /dev/null +++ b/src/api/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * } + * + * @example + * { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * } + * + * @example + * { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * } + * + * @example + * { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * } + * + * @example + * { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * } + * + * @example + * { + * email: "example@example.com", + * subscriptionId: "sub_00000000-0000-0000-0000-000000000000" + * } + */ +export interface AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest { + /** The email address associated with the subscription */ + email?: string; + /** The prefixed ID of the subscription */ + subscriptionId?: string; + /** Override publication double-opt settings for this subscription. */ + doubleOptOverride?: beehiiv.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride; +} diff --git a/src/api/resources/automationJourneys/client/requests/index.ts b/src/api/resources/automationJourneys/client/requests/index.ts new file mode 100644 index 0000000..1aebcd2 --- /dev/null +++ b/src/api/resources/automationJourneys/client/requests/index.ts @@ -0,0 +1,2 @@ +export { AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest } from "./AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequest"; +export { AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest } from "./AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest"; diff --git a/src/api/resources/automationJourneys/index.ts b/src/api/resources/automationJourneys/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/automationJourneys/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts b/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts new file mode 100644 index 0000000..bb1bd5c --- /dev/null +++ b/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse { + data?: beehiiv.AutomationJourney; +} diff --git a/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts b/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts new file mode 100644 index 0000000..1b263af --- /dev/null +++ b/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus = + | "in_progress" + | "completed" + | "exited_early" + | "all"; + +export const AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus = { + InProgress: "in_progress", + Completed: "completed", + ExitedEarly: "exited_early", + All: "all", +} as const; diff --git a/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts b/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts new file mode 100644 index 0000000..efa29b2 --- /dev/null +++ b/src/api/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse { + data: beehiiv.AutomationJourney[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts b/src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts new file mode 100644 index 0000000..db8e12e --- /dev/null +++ b/src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Override publication double-opt settings for this subscription. + */ +export type AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride = + | "on" + | "off" + | "not_set"; + +export const AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride = { + On: "on", + Off: "off", + NotSet: "not_set", +} as const; diff --git a/src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts b/src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts new file mode 100644 index 0000000..703e120 --- /dev/null +++ b/src/api/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse { + data?: beehiiv.AutomationJourney; +} diff --git a/src/api/resources/automationJourneys/types/index.ts b/src/api/resources/automationJourneys/types/index.ts new file mode 100644 index 0000000..b0b6c62 --- /dev/null +++ b/src/api/resources/automationJourneys/types/index.ts @@ -0,0 +1,5 @@ +export * from "./AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus"; +export * from "./AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse"; +export * from "./AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride"; +export * from "./AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse"; +export * from "./AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse"; diff --git a/src/api/resources/automations/client/Client.ts b/src/api/resources/automations/client/Client.ts new file mode 100644 index 0000000..6eebb86 --- /dev/null +++ b/src/api/resources/automations/client/Client.ts @@ -0,0 +1,271 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Automations { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class Automations { + constructor(protected readonly _options: Automations.Options) {} + + /** + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.automations.getPublicationsPublicationIdAutomations("pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.automations.getPublicationsPublicationIdAutomations("string", { + * limit: 1, + * page: 1 + * }) + */ + public async getPublicationsPublicationIdAutomations( + publicationId: string, + request: beehiiv.AutomationsGetPublicationsPublicationIdAutomationsRequest = {}, + requestOptions?: Automations.RequestOptions + ): Promise { + const { limit, page } = request; + const _queryParams: Record = {}; + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/automations` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.AutomationsGetPublicationsPublicationIdAutomationsResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.automations.getPublicationsPublicationIdAutomationsAutomationId("pub_00000000-0000-0000-0000-000000000000", "aut_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.automations.getPublicationsPublicationIdAutomationsAutomationId("string", "string") + */ + public async getPublicationsPublicationIdAutomationsAutomationId( + publicationId: string, + automationId: string, + requestOptions?: Automations.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/automations/${automationId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/automations/client/index.ts b/src/api/resources/automations/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/automations/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/automations/client/requests/AutomationsGetPublicationsPublicationIdAutomationsRequest.ts b/src/api/resources/automations/client/requests/AutomationsGetPublicationsPublicationIdAutomationsRequest.ts new file mode 100644 index 0000000..21a5a10 --- /dev/null +++ b/src/api/resources/automations/client/requests/AutomationsGetPublicationsPublicationIdAutomationsRequest.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + */ +export interface AutomationsGetPublicationsPublicationIdAutomationsRequest { + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; +} diff --git a/src/api/resources/automations/client/requests/index.ts b/src/api/resources/automations/client/requests/index.ts new file mode 100644 index 0000000..e75d193 --- /dev/null +++ b/src/api/resources/automations/client/requests/index.ts @@ -0,0 +1 @@ +export { AutomationsGetPublicationsPublicationIdAutomationsRequest } from "./AutomationsGetPublicationsPublicationIdAutomationsRequest"; diff --git a/src/api/resources/automations/index.ts b/src/api/resources/automations/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/automations/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts b/src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts new file mode 100644 index 0000000..468e91e --- /dev/null +++ b/src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse { + data?: beehiiv.Automation; +} diff --git a/src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts b/src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts new file mode 100644 index 0000000..ffaefb0 --- /dev/null +++ b/src/api/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface AutomationsGetPublicationsPublicationIdAutomationsResponse { + data?: beehiiv.Automation[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit?: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page?: number; + /** The total number of results from all pages. */ + totalResults?: number; + /** The total number of pages. */ + totalPages?: number; +} diff --git a/src/api/resources/automations/types/index.ts b/src/api/resources/automations/types/index.ts new file mode 100644 index 0000000..074798f --- /dev/null +++ b/src/api/resources/automations/types/index.ts @@ -0,0 +1,2 @@ +export * from "./AutomationsGetPublicationsPublicationIdAutomationsResponse"; +export * from "./AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse"; diff --git a/src/api/resources/bulkSubscriptionUpdates/client/Client.ts b/src/api/resources/bulkSubscriptionUpdates/client/Client.ts new file mode 100644 index 0000000..a31c13b --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/client/Client.ts @@ -0,0 +1,258 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace BulkSubscriptionUpdates { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class BulkSubscriptionUpdates { + constructor(protected readonly _options: BulkSubscriptionUpdates.Options) {} + + /** + * Returns a list of Subscription Update objects for a publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdates("publicationId") + * + * @example + * await beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdates("string") + */ + public async getPublicationsPublicationIdSubcriptionUpdates( + publicationId: string, + requestOptions?: BulkSubscriptionUpdates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/bulk_subscription_updates` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Returns a single Subscription Update object for a publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdatesId("publicationId", "id") + * + * @example + * await beehiiv.bulkSubscriptionUpdates.getPublicationsPublicationIdSubcriptionUpdatesId("string", "string") + */ + public async getPublicationsPublicationIdSubcriptionUpdatesId( + publicationId: string, + id: string, + requestOptions?: BulkSubscriptionUpdates.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/bulk_subscription_updates/${id}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/bulkSubscriptionUpdates/client/index.ts b/src/api/resources/bulkSubscriptionUpdates/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/bulkSubscriptionUpdates/index.ts b/src/api/resources/bulkSubscriptionUpdates/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts new file mode 100644 index 0000000..636bc33 --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse { + data?: beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData; +} diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts new file mode 100644 index 0000000..6b84357 --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData { + /** The ID of the update object */ + id?: string; + /** The type of update (status or bulk) */ + type?: beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType; + /** The parameters passed in for the update */ + params?: string; + /** The status of the update */ + status?: beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus; + /** The publication ID associated with this update */ + publicationId?: string; + /** If the job as a whole fails, this will detail the errors encountered */ + failureReason?: string; + /** The timestamp of the job's completion */ + completed?: number; + /** The timestamp of the job's creation */ + created?: number; + /** The timestamp of the job's update */ + updated?: number; + /** An array of errors encountered for individual updates within the job */ + errorLog?: string[]; +} diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts new file mode 100644 index 0000000..6405efa --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the update + */ +export type BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus = + | "pending" + | "processing" + | "complete" + | "failed"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus = { + Pending: "pending", + Processing: "processing", + Complete: "complete", + Failed: "failed", +} as const; diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts new file mode 100644 index 0000000..a272ff0 --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The type of update (status or bulk) + */ +export type BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType = "bulk" | "status"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType = { + Bulk: "bulk", + Status: "status", +} as const; diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts new file mode 100644 index 0000000..55fae22 --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse { + /** An array of Subscription Update objects */ + data?: beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem[]; +} diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts new file mode 100644 index 0000000..feef3e5 --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem { + /** The ID of the update object */ + id?: string; + /** The type of update (status or bulk) */ + type?: beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType; + /** The parameters passed in for the update */ + params?: string; + /** The status of the update */ + status?: beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus; + /** The publication ID associated with this update */ + publicationId?: string; + /** If the job as a whole fails, this will detail the errors encountered */ + failureReason?: string; + /** The timestamp of the job's completion */ + completed?: number; + /** The timestamp of the job's creation */ + created?: number; + /** The timestamp of the job's update */ + updated?: number; + /** An array of errors encountered for individual updates within the job */ + errorLog?: string[]; +} diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts new file mode 100644 index 0000000..360c04d --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the update + */ +export type BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus = + | "pending" + | "processing" + | "complete" + | "failed"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus = { + Pending: "pending", + Processing: "processing", + Complete: "complete", + Failed: "failed", +} as const; diff --git a/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts new file mode 100644 index 0000000..1c6985a --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The type of update (status or bulk) + */ +export type BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType = + | "status" + | "bulk"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType = { + Status: "status", + Bulk: "bulk", +} as const; diff --git a/src/api/resources/bulkSubscriptionUpdates/types/index.ts b/src/api/resources/bulkSubscriptionUpdates/types/index.ts new file mode 100644 index 0000000..2c4a36a --- /dev/null +++ b/src/api/resources/bulkSubscriptionUpdates/types/index.ts @@ -0,0 +1,8 @@ +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse"; diff --git a/src/api/resources/customFields/client/Client.ts b/src/api/resources/customFields/client/Client.ts new file mode 100644 index 0000000..963218f --- /dev/null +++ b/src/api/resources/customFields/client/Client.ts @@ -0,0 +1,732 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace CustomFields { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class CustomFields { + constructor(protected readonly _options: CustomFields.Options) {} + + /** + * Retrieve all custom fields belonging to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.customFields.getPublicationsPublicationIdCustomFields("publicationId") + * + * @example + * await beehiiv.customFields.getPublicationsPublicationIdCustomFields("string") + */ + public async getPublicationsPublicationIdCustomFields( + publicationId: string, + requestOptions?: CustomFields.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/custom_fields` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create a custom field on a publication, for use in subscriptions + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.customFields.postPublicationsPublicationIdCustomFields("publicationId", { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * }) + * + * @example + * await beehiiv.customFields.postPublicationsPublicationIdCustomFields("string", { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * }) + */ + public async postPublicationsPublicationIdCustomFields( + publicationId: string, + request: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest, + requestOptions?: CustomFields.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/custom_fields` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * View a specific custom field on a publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.customFields.getPublicationsPublicationIdCustomFieldsId("publicationId", "id") + * + * @example + * await beehiiv.customFields.getPublicationsPublicationIdCustomFieldsId("string", "string") + */ + public async getPublicationsPublicationIdCustomFieldsId( + publicationId: string, + id: string, + requestOptions?: CustomFields.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/custom_fields/${id}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update a custom field on a publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.customFields.putPublicationsPublicationIdCustomFieldsId("publicationId", "id") + * + * @example + * await beehiiv.customFields.putPublicationsPublicationIdCustomFieldsId("string", "string") + */ + public async putPublicationsPublicationIdCustomFieldsId( + publicationId: string, + id: string, + request: beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest = {}, + requestOptions?: CustomFields.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/custom_fields/${id}` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete a custom field from a publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.customFields.deletePublicationsPublicationIdCustomFields("publicationId", "id") + * + * @example + * await beehiiv.customFields.deletePublicationsPublicationIdCustomFields("string", "string") + */ + public async deletePublicationsPublicationIdCustomFields( + publicationId: string, + id: string, + requestOptions?: CustomFields.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/custom_fields/${id}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update a custom field on a publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.customFields.patchPublicationsPublicationIdCustomFieldsId("publicationId", "id") + * + * @example + * await beehiiv.customFields.patchPublicationsPublicationIdCustomFieldsId("string", "string") + */ + public async patchPublicationsPublicationIdCustomFieldsId( + publicationId: string, + id: string, + request: beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest = {}, + requestOptions?: CustomFields.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/custom_fields/${id}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.jsonOrThrow( + request, + { unrecognizedObjectKeys: "strip" } + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/customFields/client/index.ts b/src/api/resources/customFields/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/customFields/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts b/src/api/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts new file mode 100644 index 0000000..7ae21fb --- /dev/null +++ b/src/api/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + */ +export interface CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest { + display?: string; +} diff --git a/src/api/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts b/src/api/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts new file mode 100644 index 0000000..6fb9f92 --- /dev/null +++ b/src/api/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * } + * + * @example + * { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * } + * + * @example + * { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * } + * + * @example + * { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * } + * + * @example + * { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * } + * + * @example + * { + * kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.String, + * display: "display" + * } + */ +export interface CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest { + kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind; + display: string; +} diff --git a/src/api/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts b/src/api/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts new file mode 100644 index 0000000..c414f7d --- /dev/null +++ b/src/api/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + */ +export interface CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest { + display?: string; +} diff --git a/src/api/resources/customFields/client/requests/index.ts b/src/api/resources/customFields/client/requests/index.ts new file mode 100644 index 0000000..331c371 --- /dev/null +++ b/src/api/resources/customFields/client/requests/index.ts @@ -0,0 +1,3 @@ +export { CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest } from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest"; +export { CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest } from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest"; +export { CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest } from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest"; diff --git a/src/api/resources/customFields/index.ts b/src/api/resources/customFields/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/customFields/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts b/src/api/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts new file mode 100644 index 0000000..8ce72bf --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse { + message?: string; +} diff --git a/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts new file mode 100644 index 0000000..e823808 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse { + data?: beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData; +} diff --git a/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts new file mode 100644 index 0000000..e7370df --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData { + id?: string; + display?: string; + kind?: beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind; + created?: number; +} diff --git a/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts new file mode 100644 index 0000000..5c2a2c1 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind = + | "string" + | "integer" + | "boolean" + | "date" + | "datetime"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind = { + String: "string", + Integer: "integer", + Boolean: "boolean", + Date: "date", + Datetime: "datetime", +} as const; diff --git a/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts new file mode 100644 index 0000000..42add89 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse { + data?: beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem[]; +} diff --git a/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts new file mode 100644 index 0000000..497364f --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem { + id?: string; + kind?: beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind; + display?: string; + created?: number; +} diff --git a/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts new file mode 100644 index 0000000..afce18e --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind = + | "string" + | "integer" + | "boolean" + | "date" + | "datetime"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind = { + String: "string", + Integer: "integer", + Boolean: "boolean", + Date: "date", + Datetime: "datetime", +} as const; diff --git a/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts b/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts new file mode 100644 index 0000000..1ca39a7 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse { + data?: beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData; +} diff --git a/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts b/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts new file mode 100644 index 0000000..791fee0 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData { + id?: string; + display?: string; + kind?: beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind; + created?: number; +} diff --git a/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts b/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts new file mode 100644 index 0000000..e30ef60 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind = + | "string" + | "integer" + | "boolean" + | "date" + | "datetime"; + +export const CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind = { + String: "string", + Integer: "integer", + Boolean: "boolean", + Date: "date", + Datetime: "datetime", +} as const; diff --git a/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts new file mode 100644 index 0000000..13a0154 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind = + | "string" + | "integer" + | "boolean" + | "date" + | "datetime"; + +export const CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind = { + String: "string", + Integer: "integer", + Boolean: "boolean", + Date: "date", + Datetime: "datetime", +} as const; diff --git a/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts new file mode 100644 index 0000000..800940e --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse { + data?: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData; +} diff --git a/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts new file mode 100644 index 0000000..d1589fb --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData { + id: string; + kind: beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind; + display: string; + created: number; +} diff --git a/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts new file mode 100644 index 0000000..2a74ef2 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind = + | "string" + | "integer" + | "boolean" + | "date" + | "datetime"; + +export const CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind = { + String: "string", + Integer: "integer", + Boolean: "boolean", + Date: "date", + Datetime: "datetime", +} as const; diff --git a/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts b/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts new file mode 100644 index 0000000..181bb97 --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse { + data?: beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData; +} diff --git a/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts b/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts new file mode 100644 index 0000000..addb18d --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData { + id?: string; + display?: string; + kind?: beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind; + created?: number; +} diff --git a/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts b/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts new file mode 100644 index 0000000..42a101e --- /dev/null +++ b/src/api/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind = + | "string" + | "integer" + | "boolean" + | "date" + | "datetime"; + +export const CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind = { + String: "string", + Integer: "integer", + Boolean: "boolean", + Date: "date", + Datetime: "datetime", +} as const; diff --git a/src/api/resources/customFields/types/index.ts b/src/api/resources/customFields/types/index.ts new file mode 100644 index 0000000..856f6c9 --- /dev/null +++ b/src/api/resources/customFields/types/index.ts @@ -0,0 +1,17 @@ +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse"; +export * from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind"; +export * from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData"; +export * from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse"; +export * from "./CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse"; +export * from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind"; +export * from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData"; +export * from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse"; diff --git a/src/api/resources/emailBlasts/client/Client.ts b/src/api/resources/emailBlasts/client/Client.ts new file mode 100644 index 0000000..725890e --- /dev/null +++ b/src/api/resources/emailBlasts/client/Client.ts @@ -0,0 +1,306 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace EmailBlasts { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class EmailBlasts { + constructor(protected readonly _options: EmailBlasts.Options) {} + + /** + * Retrieve all Email Blasts + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlasts("pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlasts("string", { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.Stats, + * limit: 1, + * page: 1, + * direction: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.Asc, + * orderBy: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.Created + * }) + */ + public async getPublicationsPublicationIdEmailBlasts( + publicationId: string, + request: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest = {}, + requestOptions?: EmailBlasts.RequestOptions + ): Promise { + const { expand, limit, page, direction, orderBy } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (direction != null) { + _queryParams["direction"] = direction; + } + + if (orderBy != null) { + _queryParams["order_by"] = orderBy; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/email_blasts` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve an Email Blast + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlastsEmailBlastId("pub_00000000-0000-0000-0000-000000000000", "blast_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.emailBlasts.getPublicationsPublicationIdEmailBlastsEmailBlastId("string", "string", { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.Stats + * }) + */ + public async getPublicationsPublicationIdEmailBlastsEmailBlastId( + publicationId: string, + emailBlastId: string, + request: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest = {}, + requestOptions?: EmailBlasts.RequestOptions + ): Promise { + const { expand } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/email_blasts/${emailBlastId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/emailBlasts/client/index.ts b/src/api/resources/emailBlasts/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/emailBlasts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest.ts b/src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest.ts new file mode 100644 index 0000000..cfd3d5f --- /dev/null +++ b/src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest.ts @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.Stats + * } + */ +export interface EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the email blast(s)
`free_email_content` - Returns the email HTML rendered to a free reader
`premium_email_content` - Returns the email HTML rendered to a premium reader + */ + expand?: + | beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem + | beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem[]; +} diff --git a/src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest.ts b/src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest.ts new file mode 100644 index 0000000..b0ab15d --- /dev/null +++ b/src/api/resources/emailBlasts/client/requests/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest.ts @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.Stats, + * limit: 1, + * page: 1, + * direction: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.Asc, + * orderBy: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.Created + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.Stats, + * limit: 1, + * page: 1, + * direction: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.Asc, + * orderBy: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.Created + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.Stats, + * limit: 1, + * page: 1, + * direction: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.Asc, + * orderBy: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.Created + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.Stats, + * limit: 1, + * page: 1, + * direction: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.Asc, + * orderBy: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.Created + * } + * + * @example + * { + * expand: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.Stats, + * limit: 1, + * page: 1, + * direction: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.Asc, + * orderBy: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.Created + * } + */ +export interface EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the email blast(s)
`free_email_content` - Returns the email HTML rendered to a free reader
`premium_email_content` - Returns the email HTML rendered to a premium reader + */ + expand?: + | beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem + | beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem[]; + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; + /** + * The direction that the results are sorted in. Defaults to asc
`asc` - Ascending, sorts from smallest to largest.
`desc` - Descending, sorts from largest to smallest. + */ + direction?: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection; + /** + * The field that the results are sorted by. Defaults to created
`created` - The time in which the segment was first created.
`last_sent` - The time the blast was last sent. Measured in seconds since the Unix epoch. + */ + orderBy?: beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy; +} diff --git a/src/api/resources/emailBlasts/client/requests/index.ts b/src/api/resources/emailBlasts/client/requests/index.ts new file mode 100644 index 0000000..f13d58a --- /dev/null +++ b/src/api/resources/emailBlasts/client/requests/index.ts @@ -0,0 +1,2 @@ +export { EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest } from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsRequest"; +export { EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest } from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequest"; diff --git a/src/api/resources/emailBlasts/index.ts b/src/api/resources/emailBlasts/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/emailBlasts/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts new file mode 100644 index 0000000..cba505e --- /dev/null +++ b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem = + | "stats" + | "free_email_content" + | "premium_email_content"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem = { + Stats: "stats", + FreeEmailContent: "free_email_content", + PremiumEmailContent: "premium_email_content", +} as const; diff --git a/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts new file mode 100644 index 0000000..7a06f26 --- /dev/null +++ b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse { + data: beehiiv.EmailBlast; +} diff --git a/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts new file mode 100644 index 0000000..11453e3 --- /dev/null +++ b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection = "asc" | "desc"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts new file mode 100644 index 0000000..190baca --- /dev/null +++ b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem = + | "stats" + | "free_email_content" + | "premium_email_content"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem = { + Stats: "stats", + FreeEmailContent: "free_email_content", + PremiumEmailContent: "premium_email_content", +} as const; diff --git a/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts new file mode 100644 index 0000000..e154b49 --- /dev/null +++ b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy = "created" | "last_sent"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy = { + Created: "created", + LastSent: "last_sent", +} as const; diff --git a/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts new file mode 100644 index 0000000..589ad18 --- /dev/null +++ b/src/api/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse { + data: beehiiv.EmailBlast[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/emailBlasts/types/index.ts b/src/api/resources/emailBlasts/types/index.ts new file mode 100644 index 0000000..249e41c --- /dev/null +++ b/src/api/resources/emailBlasts/types/index.ts @@ -0,0 +1,6 @@ +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts new file mode 100644 index 0000000..afbea5f --- /dev/null +++ b/src/api/resources/index.ts @@ -0,0 +1,32 @@ +export * as publications from "./publications"; +export * from "./publications/types"; +export * as posts from "./posts"; +export * from "./posts/types"; +export * as subscriptions from "./subscriptions"; +export * from "./subscriptions/types"; +export * as segments from "./segments"; +export * from "./segments/types"; +export * as emailBlasts from "./emailBlasts"; +export * from "./emailBlasts/types"; +export * as referralProgram from "./referralProgram"; +export * from "./referralProgram/types"; +export * as customFields from "./customFields"; +export * from "./customFields/types"; +export * as bulkSubscriptionUpdates from "./bulkSubscriptionUpdates"; +export * from "./bulkSubscriptionUpdates/types"; +export * as automationJourneys from "./automationJourneys"; +export * from "./automationJourneys/types"; +export * as automations from "./automations"; +export * from "./automations/types"; +export * as subscriptionTags from "./subscriptionTags"; +export * from "./subscriptionTags/types"; +export * from "./publications/client/requests"; +export * from "./posts/client/requests"; +export * from "./subscriptions/client/requests"; +export * from "./segments/client/requests"; +export * from "./emailBlasts/client/requests"; +export * from "./referralProgram/client/requests"; +export * from "./customFields/client/requests"; +export * from "./automationJourneys/client/requests"; +export * from "./automations/client/requests"; +export * from "./subscriptionTags/client/requests"; diff --git a/src/api/resources/posts/client/Client.ts b/src/api/resources/posts/client/Client.ts new file mode 100644 index 0000000..38672f2 --- /dev/null +++ b/src/api/resources/posts/client/Client.ts @@ -0,0 +1,441 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Posts { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class Posts { + constructor(protected readonly _options: Posts.Options) {} + + /** + * Retrieve all posts belonging to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.posts.getPosts("pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.posts.getPosts("string", { + * expand: beehiiv.PostsGetPostsRequestExpandItem.Stats, + * audience: beehiiv.PostsGetPostsRequestAudience.Free, + * platform: beehiiv.PostsGetPostsRequestPlatform.Web, + * status: beehiiv.PostsGetPostsRequestStatus.Draft, + * contentTags: "string", + * limit: 1, + * page: 1, + * orderBy: beehiiv.PostsGetPostsRequestOrderBy.Created, + * direction: beehiiv.PostsGetPostsRequestDirection.Asc, + * hiddenFromFeed: beehiiv.PostsGetPostsRequestHiddenFromFeed.All + * }) + */ + public async getPosts( + publicationId: string, + request: beehiiv.PostsGetPostsRequest = {}, + requestOptions?: Posts.RequestOptions + ): Promise { + const { expand, audience, platform, status, contentTags, limit, page, orderBy, direction, hiddenFromFeed } = + request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + if (audience != null) { + _queryParams["audience"] = audience; + } + + if (platform != null) { + _queryParams["platform"] = platform; + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (contentTags != null) { + if (Array.isArray(contentTags)) { + _queryParams["content_tags[]"] = contentTags.map((item) => item); + } else { + _queryParams["content_tags[]"] = contentTags; + } + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (orderBy != null) { + _queryParams["order_by"] = orderBy; + } + + if (direction != null) { + _queryParams["direction"] = direction; + } + + if (hiddenFromFeed != null) { + _queryParams["hidden_from_feed"] = hiddenFromFeed; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/posts` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.PostsGetPostsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retreive a single Post belonging to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.posts.getPostsPostId("post_00000000-0000-0000-0000-000000000000", "pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.posts.getPostsPostId("string", "string", { + * expand: beehiiv.PostsGetPostsPostIdRequestExpandItem.Stats + * }) + */ + public async getPostsPostId( + postId: string, + publicationId: string, + request: beehiiv.PostsGetPostsPostIdRequest = {}, + requestOptions?: Posts.RequestOptions + ): Promise { + const { expand } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/posts/${postId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.PostsGetPostsPostIdResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete or Archive a post. Any post that has been confirmed will have it's status changed to `archived`. Posts in the `draft` status will be permenantly deleted. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.posts.deletePostsPostId("post_00000000-0000-0000-0000-000000000000", "pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.posts.deletePostsPostId("string", "string") + */ + public async deletePostsPostId( + postId: string, + publicationId: string, + requestOptions?: Posts.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/posts/${postId}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.PostsDeletePostsPostIdResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/posts/client/index.ts b/src/api/resources/posts/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/posts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/posts/client/requests/PostsGetPostsPostIdRequest.ts b/src/api/resources/posts/client/requests/PostsGetPostsPostIdRequest.ts new file mode 100644 index 0000000..d5e4bda --- /dev/null +++ b/src/api/resources/posts/client/requests/PostsGetPostsPostIdRequest.ts @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: beehiiv.PostsGetPostsPostIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsPostIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsPostIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsPostIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsPostIdRequestExpandItem.Stats + * } + */ +export interface PostsGetPostsPostIdRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the post(s)
`free_web_content` - Returns the web HTML rendered to a free reader
`free_email_content` - Returns the email HTML rendered to a free reader
`free_rss_content` - Returns the RSS feed HTML
`premium_web_content` - Returns the web HTML rendered to a premium reader
`premium_email_content` - Returns the email HTML rendered to a premium reader + */ + expand?: beehiiv.PostsGetPostsPostIdRequestExpandItem | beehiiv.PostsGetPostsPostIdRequestExpandItem[]; +} diff --git a/src/api/resources/posts/client/requests/PostsGetPostsRequest.ts b/src/api/resources/posts/client/requests/PostsGetPostsRequest.ts new file mode 100644 index 0000000..cd47a5c --- /dev/null +++ b/src/api/resources/posts/client/requests/PostsGetPostsRequest.ts @@ -0,0 +1,122 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: beehiiv.PostsGetPostsRequestExpandItem.Stats, + * audience: beehiiv.PostsGetPostsRequestAudience.Free, + * platform: beehiiv.PostsGetPostsRequestPlatform.Web, + * status: beehiiv.PostsGetPostsRequestStatus.Draft, + * contentTags: "string", + * limit: 1, + * page: 1, + * orderBy: beehiiv.PostsGetPostsRequestOrderBy.Created, + * direction: beehiiv.PostsGetPostsRequestDirection.Asc, + * hiddenFromFeed: beehiiv.PostsGetPostsRequestHiddenFromFeed.All + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsRequestExpandItem.Stats, + * audience: beehiiv.PostsGetPostsRequestAudience.Free, + * platform: beehiiv.PostsGetPostsRequestPlatform.Web, + * status: beehiiv.PostsGetPostsRequestStatus.Draft, + * contentTags: "string", + * limit: 1, + * page: 1, + * orderBy: beehiiv.PostsGetPostsRequestOrderBy.Created, + * direction: beehiiv.PostsGetPostsRequestDirection.Asc, + * hiddenFromFeed: beehiiv.PostsGetPostsRequestHiddenFromFeed.All + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsRequestExpandItem.Stats, + * audience: beehiiv.PostsGetPostsRequestAudience.Free, + * platform: beehiiv.PostsGetPostsRequestPlatform.Web, + * status: beehiiv.PostsGetPostsRequestStatus.Draft, + * contentTags: "string", + * limit: 1, + * page: 1, + * orderBy: beehiiv.PostsGetPostsRequestOrderBy.Created, + * direction: beehiiv.PostsGetPostsRequestDirection.Asc, + * hiddenFromFeed: beehiiv.PostsGetPostsRequestHiddenFromFeed.All + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsRequestExpandItem.Stats, + * audience: beehiiv.PostsGetPostsRequestAudience.Free, + * platform: beehiiv.PostsGetPostsRequestPlatform.Web, + * status: beehiiv.PostsGetPostsRequestStatus.Draft, + * contentTags: "string", + * limit: 1, + * page: 1, + * orderBy: beehiiv.PostsGetPostsRequestOrderBy.Created, + * direction: beehiiv.PostsGetPostsRequestDirection.Asc, + * hiddenFromFeed: beehiiv.PostsGetPostsRequestHiddenFromFeed.All + * } + * + * @example + * { + * expand: beehiiv.PostsGetPostsRequestExpandItem.Stats, + * audience: beehiiv.PostsGetPostsRequestAudience.Free, + * platform: beehiiv.PostsGetPostsRequestPlatform.Web, + * status: beehiiv.PostsGetPostsRequestStatus.Draft, + * contentTags: "string", + * limit: 1, + * page: 1, + * orderBy: beehiiv.PostsGetPostsRequestOrderBy.Created, + * direction: beehiiv.PostsGetPostsRequestDirection.Asc, + * hiddenFromFeed: beehiiv.PostsGetPostsRequestHiddenFromFeed.All + * } + */ +export interface PostsGetPostsRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the post(s)
`free_web_content` - Returns the web HTML rendered to a free reader
`free_email_content` - Returns the email HTML rendered to a free reader
`free_rss_content` - Returns the RSS feed HTML
`premium_web_content` - Returns the web HTML rendered to a premium reader
`premium_email_content` - Returns the email HTML rendered to a premium reader + */ + expand?: beehiiv.PostsGetPostsRequestExpandItem | beehiiv.PostsGetPostsRequestExpandItem[]; + /** + * Optionally filter the results by audience + */ + audience?: beehiiv.PostsGetPostsRequestAudience; + /** + * Optionally filter the results by platform.
`web` - Posts only published to web.
`email` - Posts only published to email.
`both` - Posts published to email and web.
`all` - Does not restrict results by platform. + */ + platform?: beehiiv.PostsGetPostsRequestPlatform; + /** + * Optionally filter the results by the status of the post.
`draft` - not been scheduled.
`confirmed` - The post will be active after the `scheduled_at`.
`archived` - The post is no longer active.
`all` - Does not restrict results by status. + */ + status?: beehiiv.PostsGetPostsRequestStatus; + /** + * Optionally filter posts by content_tags. Adding a content tag will return any post with that content tag associated to it.
Example: Filtering for `content_tags: ["sales","closing"]` will return results of posts that have _either_ sales or closing content_tags. + */ + contentTags?: string | string[]; + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; + /** + * The field that the results are sorted by. Defaults to created
`created` - The time in which the post was first created.
`publish_date` - The time the post was set to be published.
`displayed_date` - The time displayed in place of the `publish_date`. If no `displayed_date` was set, it will default to the `publish_date` + */ + orderBy?: beehiiv.PostsGetPostsRequestOrderBy; + /** + * The direction that the results are sorted in. Defaults to asc
`asc` - Ascending, sorts from smallest to largest.
`desc` - Descending, sorts from largest to smallest. + */ + direction?: beehiiv.PostsGetPostsRequestDirection; + /** + * Optionally filter the results by the `hidden_from_feed` attribute of the post.
`all` - Does not restrict results by `hidden_from_feed`.
`true` - Only return posts hidden from the feed.
`false` - Only return posts that are visible on the feed. + */ + hiddenFromFeed?: beehiiv.PostsGetPostsRequestHiddenFromFeed; +} diff --git a/src/api/resources/posts/client/requests/index.ts b/src/api/resources/posts/client/requests/index.ts new file mode 100644 index 0000000..4d1d503 --- /dev/null +++ b/src/api/resources/posts/client/requests/index.ts @@ -0,0 +1,2 @@ +export { PostsGetPostsRequest } from "./PostsGetPostsRequest"; +export { PostsGetPostsPostIdRequest } from "./PostsGetPostsPostIdRequest"; diff --git a/src/api/resources/posts/index.ts b/src/api/resources/posts/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/posts/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/posts/types/PostsDeletePostsPostIdResponse.ts b/src/api/resources/posts/types/PostsDeletePostsPostIdResponse.ts new file mode 100644 index 0000000..2a63f63 --- /dev/null +++ b/src/api/resources/posts/types/PostsDeletePostsPostIdResponse.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PostsDeletePostsPostIdResponse {} diff --git a/src/api/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts b/src/api/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts new file mode 100644 index 0000000..dc20097 --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsPostIdRequestExpandItem = + | "stats" + | "free_web_content" + | "free_email_content" + | "free_rss_content" + | "premium_web_content" + | "premium_email_content"; + +export const PostsGetPostsPostIdRequestExpandItem = { + Stats: "stats", + FreeWebContent: "free_web_content", + FreeEmailContent: "free_email_content", + FreeRssContent: "free_rss_content", + PremiumWebContent: "premium_web_content", + PremiumEmailContent: "premium_email_content", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsPostIdResponse.ts b/src/api/resources/posts/types/PostsGetPostsPostIdResponse.ts new file mode 100644 index 0000000..afd3ac3 --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsPostIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface PostsGetPostsPostIdResponse { + data: beehiiv.Post; +} diff --git a/src/api/resources/posts/types/PostsGetPostsRequestAudience.ts b/src/api/resources/posts/types/PostsGetPostsRequestAudience.ts new file mode 100644 index 0000000..52fb47f --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsRequestAudience.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsRequestAudience = "free" | "premium" | "all"; + +export const PostsGetPostsRequestAudience = { + Free: "free", + Premium: "premium", + All: "all", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsRequestDirection.ts b/src/api/resources/posts/types/PostsGetPostsRequestDirection.ts new file mode 100644 index 0000000..5111c92 --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsRequestDirection.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsRequestDirection = "asc" | "desc"; + +export const PostsGetPostsRequestDirection = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsRequestExpandItem.ts b/src/api/resources/posts/types/PostsGetPostsRequestExpandItem.ts new file mode 100644 index 0000000..6570386 --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsRequestExpandItem.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsRequestExpandItem = + | "stats" + | "free_web_content" + | "free_email_content" + | "free_rss_content" + | "premium_web_content" + | "premium_email_content"; + +export const PostsGetPostsRequestExpandItem = { + Stats: "stats", + FreeWebContent: "free_web_content", + FreeEmailContent: "free_email_content", + FreeRssContent: "free_rss_content", + PremiumWebContent: "premium_web_content", + PremiumEmailContent: "premium_email_content", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts b/src/api/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts new file mode 100644 index 0000000..77e2b2c --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsRequestHiddenFromFeed = "all" | "true" | "false"; + +export const PostsGetPostsRequestHiddenFromFeed = { + All: "all", + True: "true", + False: "false", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsRequestOrderBy.ts b/src/api/resources/posts/types/PostsGetPostsRequestOrderBy.ts new file mode 100644 index 0000000..b10fb09 --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsRequestOrderBy.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsRequestOrderBy = "created" | "publish_date" | "displayed_date"; + +export const PostsGetPostsRequestOrderBy = { + Created: "created", + PublishDate: "publish_date", + DisplayedDate: "displayed_date", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsRequestPlatform.ts b/src/api/resources/posts/types/PostsGetPostsRequestPlatform.ts new file mode 100644 index 0000000..fa0c43e --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsRequestPlatform.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsRequestPlatform = "web" | "email" | "both" | "all"; + +export const PostsGetPostsRequestPlatform = { + Web: "web", + Email: "email", + Both: "both", + All: "all", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsRequestStatus.ts b/src/api/resources/posts/types/PostsGetPostsRequestStatus.ts new file mode 100644 index 0000000..8cadcdb --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsRequestStatus.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PostsGetPostsRequestStatus = "draft" | "confirmed" | "archived" | "all"; + +export const PostsGetPostsRequestStatus = { + Draft: "draft", + Confirmed: "confirmed", + Archived: "archived", + All: "all", +} as const; diff --git a/src/api/resources/posts/types/PostsGetPostsResponse.ts b/src/api/resources/posts/types/PostsGetPostsResponse.ts new file mode 100644 index 0000000..083a8ef --- /dev/null +++ b/src/api/resources/posts/types/PostsGetPostsResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface PostsGetPostsResponse { + data: beehiiv.Post[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/posts/types/index.ts b/src/api/resources/posts/types/index.ts new file mode 100644 index 0000000..f732c8f --- /dev/null +++ b/src/api/resources/posts/types/index.ts @@ -0,0 +1,11 @@ +export * from "./PostsGetPostsRequestExpandItem"; +export * from "./PostsGetPostsRequestAudience"; +export * from "./PostsGetPostsRequestPlatform"; +export * from "./PostsGetPostsRequestStatus"; +export * from "./PostsGetPostsRequestOrderBy"; +export * from "./PostsGetPostsRequestDirection"; +export * from "./PostsGetPostsRequestHiddenFromFeed"; +export * from "./PostsGetPostsResponse"; +export * from "./PostsGetPostsPostIdRequestExpandItem"; +export * from "./PostsGetPostsPostIdResponse"; +export * from "./PostsDeletePostsPostIdResponse"; diff --git a/src/api/resources/publications/client/Client.ts b/src/api/resources/publications/client/Client.ts new file mode 100644 index 0000000..53d1f26 --- /dev/null +++ b/src/api/resources/publications/client/Client.ts @@ -0,0 +1,298 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Publications { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class Publications { + constructor(protected readonly _options: Publications.Options) {} + + /** + * Retrieve all publications associated with your API key. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.publications.getPublications() + * + * @example + * await beehiiv.publications.getPublications({ + * expand: "stats", + * limit: 1, + * page: 1, + * direction: beehiiv.PublicationsGetPublicationsRequestDirection.Asc, + * orderBy: beehiiv.PublicationsGetPublicationsRequestOrderBy.Created + * }) + */ + public async getPublications( + request: beehiiv.PublicationsGetPublicationsRequest = {}, + requestOptions?: Publications.RequestOptions + ): Promise { + const { expand, limit, page, direction, orderBy } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (direction != null) { + _queryParams["direction"] = direction; + } + + if (orderBy != null) { + _queryParams["order_by"] = orderBy; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + "publications" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.PublicationsGetPublicationsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a single publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.publications.getPublicationsPublicationId("pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.publications.getPublicationsPublicationId("string", { + * expand: "stats" + * }) + */ + public async getPublicationsPublicationId( + publicationId: string, + request: beehiiv.PublicationsGetPublicationsPublicationIdRequest = {}, + requestOptions?: Publications.RequestOptions + ): Promise { + const { expand } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.PublicationsGetPublicationsPublicationIdResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/publications/client/index.ts b/src/api/resources/publications/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/publications/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/publications/client/requests/PublicationsGetPublicationsPublicationIdRequest.ts b/src/api/resources/publications/client/requests/PublicationsGetPublicationsPublicationIdRequest.ts new file mode 100644 index 0000000..676264e --- /dev/null +++ b/src/api/resources/publications/client/requests/PublicationsGetPublicationsPublicationIdRequest.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + * + * @example + * { + * expand: "stats" + * } + * + * @example + * { + * expand: "stats" + * } + * + * @example + * { + * expand: "stats" + * } + * + * @example + * { + * expand: "stats" + * } + * + * @example + * { + * expand: "stats" + * } + */ +export interface PublicationsGetPublicationsPublicationIdRequest { + /** + * Optional list of expandable objects.
`stats` - Returns all statistics about the publication(s)
`stat_active_subscriptions` - Total number of active free and premium subscriptions
`stat_active_premium_subscriptions` - Total number of active premium/paid subscriptions
`stat_active_free_subscriptions` - Total number of active free subscriptions
`stat_average_open_rate` - The publications historical average open rate
`stat_average_click_rate` - The publications historical average click through rate
`stat_total_sent` - Total number of emails sent
`stat_total_unique_opened` - Total number of uniquely opened emails. Only counts the first open for each subscriber.
`stat_total_clicked` - The total number of links clicked from emails. + */ + expand?: "stats" | "stats"[]; +} diff --git a/src/api/resources/publications/client/requests/PublicationsGetPublicationsRequest.ts b/src/api/resources/publications/client/requests/PublicationsGetPublicationsRequest.ts new file mode 100644 index 0000000..53cc60b --- /dev/null +++ b/src/api/resources/publications/client/requests/PublicationsGetPublicationsRequest.ts @@ -0,0 +1,77 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: "stats", + * limit: 1, + * page: 1, + * direction: beehiiv.PublicationsGetPublicationsRequestDirection.Asc, + * orderBy: beehiiv.PublicationsGetPublicationsRequestOrderBy.Created + * } + * + * @example + * { + * expand: "stats", + * limit: 1, + * page: 1, + * direction: beehiiv.PublicationsGetPublicationsRequestDirection.Asc, + * orderBy: beehiiv.PublicationsGetPublicationsRequestOrderBy.Created + * } + * + * @example + * { + * expand: "stats", + * limit: 1, + * page: 1, + * direction: beehiiv.PublicationsGetPublicationsRequestDirection.Asc, + * orderBy: beehiiv.PublicationsGetPublicationsRequestOrderBy.Created + * } + * + * @example + * { + * expand: "stats", + * limit: 1, + * page: 1, + * direction: beehiiv.PublicationsGetPublicationsRequestDirection.Asc, + * orderBy: beehiiv.PublicationsGetPublicationsRequestOrderBy.Created + * } + * + * @example + * { + * expand: "stats", + * limit: 1, + * page: 1, + * direction: beehiiv.PublicationsGetPublicationsRequestDirection.Asc, + * orderBy: beehiiv.PublicationsGetPublicationsRequestOrderBy.Created + * } + */ +export interface PublicationsGetPublicationsRequest { + /** + * Optional list of expandable objects.
`stats` - Returns all statistics about the publication(s)
`stat_active_subscriptions` - Total number of active free and premium subscriptions
`stat_active_premium_subscriptions` - Total number of active premium/paid subscriptions
`stat_active_free_subscriptions` - Total number of active free subscriptions
`stat_average_open_rate` - The publications historical average open rate
`stat_average_click_rate` - The publications historical average click through rate
`stat_total_sent` - Total number of emails sent
`stat_total_unique_opened` - Total number of uniquely opened emails. Only counts the first open for each subscriber.
`stat_total_clicked` - The total number of links clicked from emails. + */ + expand?: "stats" | "stats"[]; + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; + /** + * The direction that the results are sorted in. Defaults to asc
`asc` - Ascending, sorts from smallest to largest.
`desc` - Descending, sorts from largest to smallest. + */ + direction?: beehiiv.PublicationsGetPublicationsRequestDirection; + /** + * The field that the results are sorted by. Defaults to created
`created` - The time in which the publication was first created.
`name` - The name of the publication. + */ + orderBy?: beehiiv.PublicationsGetPublicationsRequestOrderBy; +} diff --git a/src/api/resources/publications/client/requests/index.ts b/src/api/resources/publications/client/requests/index.ts new file mode 100644 index 0000000..b0be739 --- /dev/null +++ b/src/api/resources/publications/client/requests/index.ts @@ -0,0 +1,2 @@ +export { PublicationsGetPublicationsRequest } from "./PublicationsGetPublicationsRequest"; +export { PublicationsGetPublicationsPublicationIdRequest } from "./PublicationsGetPublicationsPublicationIdRequest"; diff --git a/src/api/resources/publications/index.ts b/src/api/resources/publications/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/publications/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts b/src/api/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts new file mode 100644 index 0000000..f2a1226 --- /dev/null +++ b/src/api/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface PublicationsGetPublicationsPublicationIdResponse { + data: beehiiv.Publication; +} diff --git a/src/api/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts b/src/api/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts new file mode 100644 index 0000000..13ed3c1 --- /dev/null +++ b/src/api/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PublicationsGetPublicationsRequestDirection = "asc" | "desc"; + +export const PublicationsGetPublicationsRequestDirection = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts b/src/api/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts new file mode 100644 index 0000000..93aeedd --- /dev/null +++ b/src/api/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type PublicationsGetPublicationsRequestOrderBy = "created" | "name"; + +export const PublicationsGetPublicationsRequestOrderBy = { + Created: "created", + Name: "name", +} as const; diff --git a/src/api/resources/publications/types/PublicationsGetPublicationsResponse.ts b/src/api/resources/publications/types/PublicationsGetPublicationsResponse.ts new file mode 100644 index 0000000..4c38da0 --- /dev/null +++ b/src/api/resources/publications/types/PublicationsGetPublicationsResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface PublicationsGetPublicationsResponse { + data: beehiiv.Publication[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/publications/types/index.ts b/src/api/resources/publications/types/index.ts new file mode 100644 index 0000000..6454004 --- /dev/null +++ b/src/api/resources/publications/types/index.ts @@ -0,0 +1,4 @@ +export * from "./PublicationsGetPublicationsRequestDirection"; +export * from "./PublicationsGetPublicationsRequestOrderBy"; +export * from "./PublicationsGetPublicationsResponse"; +export * from "./PublicationsGetPublicationsPublicationIdResponse"; diff --git a/src/api/resources/referralProgram/client/Client.ts b/src/api/resources/referralProgram/client/Client.ts new file mode 100644 index 0000000..adb2e0f --- /dev/null +++ b/src/api/resources/referralProgram/client/Client.ts @@ -0,0 +1,159 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace ReferralProgram { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class ReferralProgram { + constructor(protected readonly _options: ReferralProgram.Options) {} + + /** + * Retrieve details about the publication's referral program, including milestones and rewards. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.referralProgram.getPublicationsPublicReferralProgram("pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.referralProgram.getPublicationsPublicReferralProgram("string", { + * limit: 1, + * page: 1 + * }) + */ + public async getPublicationsPublicReferralProgram( + publicationId: string, + request: beehiiv.ReferralProgramGetPublicationsPublicReferralProgramRequest = {}, + requestOptions?: ReferralProgram.RequestOptions + ): Promise { + const { limit, page } = request; + const _queryParams: Record = {}; + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/referral_program` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.ReferralProgramGetPublicationsPublicReferralProgramResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/referralProgram/client/index.ts b/src/api/resources/referralProgram/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/referralProgram/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/referralProgram/client/requests/ReferralProgramGetPublicationsPublicReferralProgramRequest.ts b/src/api/resources/referralProgram/client/requests/ReferralProgramGetPublicationsPublicReferralProgramRequest.ts new file mode 100644 index 0000000..153ba3b --- /dev/null +++ b/src/api/resources/referralProgram/client/requests/ReferralProgramGetPublicationsPublicReferralProgramRequest.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + */ +export interface ReferralProgramGetPublicationsPublicReferralProgramRequest { + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; +} diff --git a/src/api/resources/referralProgram/client/requests/index.ts b/src/api/resources/referralProgram/client/requests/index.ts new file mode 100644 index 0000000..d18dc51 --- /dev/null +++ b/src/api/resources/referralProgram/client/requests/index.ts @@ -0,0 +1 @@ +export { ReferralProgramGetPublicationsPublicReferralProgramRequest } from "./ReferralProgramGetPublicationsPublicReferralProgramRequest"; diff --git a/src/api/resources/referralProgram/index.ts b/src/api/resources/referralProgram/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/referralProgram/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts b/src/api/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts new file mode 100644 index 0000000..b584fd9 --- /dev/null +++ b/src/api/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface ReferralProgramGetPublicationsPublicReferralProgramResponse { + /** A list of the milestones related to this publication's referral program. */ + data: beehiiv.Milestone[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/referralProgram/types/index.ts b/src/api/resources/referralProgram/types/index.ts new file mode 100644 index 0000000..9cab0fe --- /dev/null +++ b/src/api/resources/referralProgram/types/index.ts @@ -0,0 +1 @@ +export * from "./ReferralProgramGetPublicationsPublicReferralProgramResponse"; diff --git a/src/api/resources/segments/client/Client.ts b/src/api/resources/segments/client/Client.ts new file mode 100644 index 0000000..22562ce --- /dev/null +++ b/src/api/resources/segments/client/Client.ts @@ -0,0 +1,522 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Segments { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class Segments { + constructor(protected readonly _options: Segments.Options) {} + + /** + * Retrieve information about all segments belonging to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.segments.getPublicationsPublicationIdSegments("pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.segments.getPublicationsPublicationIdSegments("string", { + * type: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType.Dynamic, + * status: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.Pending, + * limit: 1, + * page: 1, + * orderBy: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.Created, + * direction: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.Asc + * }) + */ + public async getPublicationsPublicationIdSegments( + publicationId: string, + request: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequest = {}, + requestOptions?: Segments.RequestOptions + ): Promise { + const { type: type_, status, limit, page, orderBy, direction } = request; + const _queryParams: Record = {}; + if (type_ != null) { + _queryParams["type"] = type_; + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (orderBy != null) { + _queryParams["order_by"] = orderBy; + } + + if (direction != null) { + _queryParams["direction"] = direction; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/segments` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SegmentsGetPublicationsPublicationIdSegmentsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a single segment belonging to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentId("pub_00000000-0000-0000-0000-000000000000", "seg_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentId("string", "string") + */ + public async getPublicationsPublicationIdSegmentsSegmentId( + publicationId: string, + segmentId: string, + requestOptions?: Segments.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/segments/${segmentId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete a segment. Deleting the segment does not effect the subscriptions in the segment. + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.segments.deletePublicationsPublicationIdSegmentsSegmentId("pub_00000000-0000-0000-0000-000000000000", "seg_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.segments.deletePublicationsPublicationIdSegmentsSegmentId("string", "string") + */ + public async deletePublicationsPublicationIdSegmentsSegmentId( + publicationId: string, + segmentId: string, + requestOptions?: Segments.RequestOptions + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/segments/${segmentId}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.segments.deletePublicationsPublicationIdSegmentsSegmentId.Response.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * List the Subscriber Ids from the most recent calculation of a specific publication. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentIdResults("pub_00000000-0000-0000-0000-000000000000", "seg_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.segments.getPublicationsPublicationIdSegmentsSegmentIdResults("string", "string", { + * limit: 1, + * page: 1 + * }) + */ + public async getPublicationsPublicationIdSegmentsSegmentIdResults( + publicationId: string, + segmentId: string, + request: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest = {}, + requestOptions?: Segments.RequestOptions + ): Promise { + const { limit, page } = request; + const _queryParams: Record = {}; + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/segments/${segmentId}/results` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/segments/client/index.ts b/src/api/resources/segments/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/segments/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsRequest.ts b/src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsRequest.ts new file mode 100644 index 0000000..1e985fc --- /dev/null +++ b/src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsRequest.ts @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * type: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType.Dynamic, + * status: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.Pending, + * limit: 1, + * page: 1, + * orderBy: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.Created, + * direction: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.Asc + * } + * + * @example + * { + * type: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType.Dynamic, + * status: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.Pending, + * limit: 1, + * page: 1, + * orderBy: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.Created, + * direction: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.Asc + * } + * + * @example + * { + * type: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType.Dynamic, + * status: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.Pending, + * limit: 1, + * page: 1, + * orderBy: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.Created, + * direction: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.Asc + * } + * + * @example + * { + * type: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType.Dynamic, + * status: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.Pending, + * limit: 1, + * page: 1, + * orderBy: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.Created, + * direction: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.Asc + * } + * + * @example + * { + * type: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType.Dynamic, + * status: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.Pending, + * limit: 1, + * page: 1, + * orderBy: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.Created, + * direction: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.Asc + * } + */ +export interface SegmentsGetPublicationsPublicationIdSegmentsRequest { + /** + * Optionally filter the results by the segment's type. + */ + type?: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType; + /** + * Optionally filter the results by the segment's status. + */ + status?: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus; + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; + /** + * The field that the results are sorted by. Defaults to created
`created` - The time in which the segment was first created.
`last_calculated` - The time that the segment last completed calculation. Measured in seconds since the Unix epoch. + */ + orderBy?: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy; + /** + * The direction that the results are sorted in. Defaults to asc
`asc` - Ascending, sorts from smallest to largest.
`desc` - Descending, sorts from largest to smallest. + */ + direction?: beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection; +} diff --git a/src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest.ts b/src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest.ts new file mode 100644 index 0000000..bb6e8fd --- /dev/null +++ b/src/api/resources/segments/client/requests/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + * + * @example + * { + * limit: 1, + * page: 1 + * } + */ +export interface SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest { + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; +} diff --git a/src/api/resources/segments/client/requests/index.ts b/src/api/resources/segments/client/requests/index.ts new file mode 100644 index 0000000..f27db78 --- /dev/null +++ b/src/api/resources/segments/client/requests/index.ts @@ -0,0 +1,2 @@ +export { SegmentsGetPublicationsPublicationIdSegmentsRequest } from "./SegmentsGetPublicationsPublicationIdSegmentsRequest"; +export { SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest } from "./SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsRequest"; diff --git a/src/api/resources/segments/index.ts b/src/api/resources/segments/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/segments/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts new file mode 100644 index 0000000..ffabc96 --- /dev/null +++ b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SegmentsGetPublicationsPublicationIdSegmentsRequestDirection = "asc" | "desc"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestDirection = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts new file mode 100644 index 0000000..993029a --- /dev/null +++ b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy = "created" | "last_calculated"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy = { + Created: "created", + LastCalculated: "last_calculated", +} as const; diff --git a/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts new file mode 100644 index 0000000..06bdcdf --- /dev/null +++ b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SegmentsGetPublicationsPublicationIdSegmentsRequestStatus = + | "pending" + | "processing" + | "completed" + | "failed" + | "all"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestStatus = { + Pending: "pending", + Processing: "processing", + Completed: "completed", + Failed: "failed", + All: "all", +} as const; diff --git a/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts new file mode 100644 index 0000000..cd47ff4 --- /dev/null +++ b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SegmentsGetPublicationsPublicationIdSegmentsRequestType = "dynamic" | "static" | "manual" | "all"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestType = { + Dynamic: "dynamic", + Static: "static", + Manual: "manual", + All: "all", +} as const; diff --git a/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts new file mode 100644 index 0000000..e60ea84 --- /dev/null +++ b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SegmentsGetPublicationsPublicationIdSegmentsResponse { + /** An array of all segments. */ + data: beehiiv.Segment[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts new file mode 100644 index 0000000..73c6c28 --- /dev/null +++ b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse { + data: beehiiv.Segment; +} diff --git a/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts new file mode 100644 index 0000000..f184e4e --- /dev/null +++ b/src/api/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse { + /** An array of subscription ids */ + data: string[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/segments/types/index.ts b/src/api/resources/segments/types/index.ts new file mode 100644 index 0000000..1e5c8cb --- /dev/null +++ b/src/api/resources/segments/types/index.ts @@ -0,0 +1,7 @@ +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestType"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestStatus"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestDirection"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsResponse"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse"; diff --git a/src/api/resources/subscriptionTags/client/Client.ts b/src/api/resources/subscriptionTags/client/Client.ts new file mode 100644 index 0000000..d670f46 --- /dev/null +++ b/src/api/resources/subscriptionTags/client/Client.ts @@ -0,0 +1,154 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import * as serializers from "../../../../serialization"; +import urlJoin from "url-join"; +import * as errors from "../../../../errors"; + +export declare namespace SubscriptionTags { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class SubscriptionTags { + constructor(protected readonly _options: SubscriptionTags.Options) {} + + /** + * Create new subscription tags for a subscription. If the tag does not exist on the publication, it will be created automatically. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptionTags.postPublicationsPublicationIdSubscriptionsSubscriptionIdTags("publicationId", "subscriptionId", { + * tags: ["Premium"] + * }) + * + * @example + * await beehiiv.subscriptionTags.postPublicationsPublicationIdSubscriptionsSubscriptionIdTags("string", "string", { + * tags: ["Premium"] + * }) + */ + public async postPublicationsPublicationIdSubscriptionsSubscriptionIdTags( + publicationId: string, + subscriptionId: string, + request: beehiiv.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest = {}, + requestOptions?: SubscriptionTags.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/${subscriptionId}/tags` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.jsonOrThrow( + request, + { unrecognizedObjectKeys: "strip" } + ), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/subscriptionTags/client/index.ts b/src/api/resources/subscriptionTags/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/subscriptionTags/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts b/src/api/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts new file mode 100644 index 0000000..edcf233 --- /dev/null +++ b/src/api/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * tags: ["Premium"] + * } + * + * @example + * { + * tags: ["Premium"] + * } + * + * @example + * { + * tags: ["Premium"] + * } + * + * @example + * { + * tags: ["Premium"] + * } + * + * @example + * { + * tags: ["Premium"] + * } + * + * @example + * { + * tags: ["Premium"] + * } + */ +export interface SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest { + /** Tags that can be used to group subscribers */ + tags?: string[]; +} diff --git a/src/api/resources/subscriptionTags/client/requests/index.ts b/src/api/resources/subscriptionTags/client/requests/index.ts new file mode 100644 index 0000000..cd2410d --- /dev/null +++ b/src/api/resources/subscriptionTags/client/requests/index.ts @@ -0,0 +1 @@ +export { SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest } from "./SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest"; diff --git a/src/api/resources/subscriptionTags/index.ts b/src/api/resources/subscriptionTags/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/subscriptionTags/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts b/src/api/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts new file mode 100644 index 0000000..0d01413 --- /dev/null +++ b/src/api/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse { + data?: beehiiv.Subscription; +} diff --git a/src/api/resources/subscriptionTags/types/index.ts b/src/api/resources/subscriptionTags/types/index.ts new file mode 100644 index 0000000..e7c571b --- /dev/null +++ b/src/api/resources/subscriptionTags/types/index.ts @@ -0,0 +1 @@ +export * from "./SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse"; diff --git a/src/api/resources/subscriptions/client/Client.ts b/src/api/resources/subscriptions/client/Client.ts new file mode 100644 index 0000000..65f4811 --- /dev/null +++ b/src/api/resources/subscriptions/client/Client.ts @@ -0,0 +1,1454 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as beehiiv from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Subscriptions { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + fetcher?: core.FetchFunction; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +export class Subscriptions { + constructor(protected readonly _options: Subscriptions.Options) {} + + /** + * Retrieve all subscriptions belonging to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.getSubscriptions("pub_00000000-0000-0000-0000-000000000000", { + * email: "clark@dailyplanet.com" + * }) + * + * @example + * await beehiiv.subscriptions.getSubscriptions("string", { + * expand: beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem.Stats, + * status: beehiiv.SubscriptionsGetSubscriptionsRequestStatus.Validating, + * tier: beehiiv.SubscriptionsGetSubscriptionsRequestTier.Free, + * limit: 1, + * page: 1, + * email: "string", + * orderBy: beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy.Created, + * direction: beehiiv.SubscriptionsGetSubscriptionsRequestDirection.Asc + * }) + */ + public async getSubscriptions( + publicationId: string, + request: beehiiv.SubscriptionsGetSubscriptionsRequest = {}, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const { expand, status, tier, limit, page, email, orderBy, direction } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + if (status != null) { + _queryParams["status"] = status; + } + + if (tier != null) { + _queryParams["tier"] = tier; + } + + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (email != null) { + _queryParams["email"] = email; + } + + if (orderBy != null) { + _queryParams["order_by"] = orderBy; + } + + if (direction != null) { + _queryParams["direction"] = direction; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsGetSubscriptionsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Create new subscriptions for a publication. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.postSubscriptions("pub_00000000-0000-0000-0000-000000000000", { + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * }) + * + * @example + * await beehiiv.subscriptions.postSubscriptions("string", { + * undefined: "string", + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * }) + */ + public async postSubscriptions( + publicationId: string, + request: beehiiv.SubscriptionsPostSubscriptionsRequest, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const { undefined, ..._body } = request; + const _queryParams: Record = {}; + if (undefined != null) { + _queryParams["undefined"] = undefined; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + body: await serializers.SubscriptionsPostSubscriptionsRequest.jsonOrThrow(_body, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsPostSubscriptionsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Bulk update subscriptions' Status value + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.putSubscriptionsBulkUpdateStatus("pub_00000000-0000-0000-0000-000000000000", { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * }) + * + * @example + * await beehiiv.subscriptions.putSubscriptionsBulkUpdateStatus("string", { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * }) + */ + public async putSubscriptionsBulkUpdateStatus( + publicationId: string, + request: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequest, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Bulk update subscriptions' Status value + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.patchSubscriptionsBulkUpdateStatus("pub_00000000-0000-0000-0000-000000000000", { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * }) + * + * @example + * await beehiiv.subscriptions.patchSubscriptionsBulkUpdateStatus("string", { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * }) + */ + public async patchSubscriptionsBulkUpdateStatus( + publicationId: string, + request: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a single subscription belonging to a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.getSubscriptionsSubscriptionId("sub_00000000-0000-0000-0000-000000000000", "pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.subscriptions.getSubscriptionsSubscriptionId("string", "string", { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.Stats + * }) + */ + public async getSubscriptionsSubscriptionId( + subscriptionId: string, + publicationId: string, + request: beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequest = {}, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const { expand } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/${subscriptionId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsGetSubscriptionsSubscriptionIdResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update a subscriber + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.putSubscriptionsSubscriptionId("sub_00000000-0000-0000-0000-000000000000", "pub_00000000-0000-0000-0000-000000000000", { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * }) + * + * @example + * await beehiiv.subscriptions.putSubscriptionsSubscriptionId("string", "string", { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * }) + */ + public async putSubscriptionsSubscriptionId( + subscriptionId: string, + publicationId: string, + request: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequest = {}, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/${subscriptionId}` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.SubscriptionsPutSubscriptionsSubscriptionIdRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsPutSubscriptionsSubscriptionIdResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete a subscription. + * + * **This cannot be undone** All data associated with the subscription will also be deleted. We recommend unsubscribing when possible instead of deleting. + * + * If a premium subscription is deleted they will no longer be billed. + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.deleteSubscriptionsSubscriptionId("sub_00000000-0000-0000-0000-000000000000", "pub_00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.subscriptions.deleteSubscriptionsSubscriptionId("string", "string") + */ + public async deleteSubscriptionsSubscriptionId( + subscriptionId: string, + publicationId: string, + requestOptions?: Subscriptions.RequestOptions + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/${subscriptionId}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.subscriptions.deleteSubscriptionsSubscriptionId.Response.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a single subscription belonging to a specific subscriber in a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.getSubscriptionsSubscriberId("pub_00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000") + * + * @example + * await beehiiv.subscriptions.getSubscriptionsSubscriberId("string", "string", { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.Stats + * }) + */ + public async getSubscriptionsSubscriberId( + publicationId: string, + subscriberId: string, + request: beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequest = {}, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const { expand } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/by_subscriber_id/${subscriberId}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsGetSubscriptionsSubscriberIdResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a single subscription belonging to a specific email address in a specific publication + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.getSubscriptionsEmail("pub_00000000-0000-0000-0000-000000000000", "work@example.com") + * + * @example + * await beehiiv.subscriptions.getSubscriptionsEmail("string", "string", { + * expand: beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem.Stats + * }) + */ + public async getSubscriptionsEmail( + publicationId: string, + email: string, + request: beehiiv.SubscriptionsGetSubscriptionsEmailRequest = {}, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const { expand } = request; + const _queryParams: Record = {}; + if (expand != null) { + if (Array.isArray(expand)) { + _queryParams["expand[]"] = expand.map((item) => item); + } else { + _queryParams["expand[]"] = expand; + } + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/by_email/${email}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsGetSubscriptionsEmailResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Bulk update subscriptions' field values (standard fields and custom fields) + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.putSubscriptionsBulkActionsBulkUpdate("publicationId") + * + * @example + * await beehiiv.subscriptions.putSubscriptionsBulkActionsBulkUpdate("string") + */ + public async putSubscriptionsBulkActionsBulkUpdate( + publicationId: string, + request: beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest = {}, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/bulk_actions` + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Bulk update subscriptions' field values (standard fields and custom fields) + * @throws {@link beehiiv.BadRequestError} + * @throws {@link beehiiv.NotFoundError} + * @throws {@link beehiiv.TooManyRequestsError} + * @throws {@link beehiiv.InternalServerError} + * + * @example + * await beehiiv.subscriptions.patchSubscriptionsBulkActionsBulkUpdate("publicationId") + * + * @example + * await beehiiv.subscriptions.patchSubscriptionsBulkActionsBulkUpdate("string") + */ + public async patchSubscriptionsBulkActionsBulkUpdate( + publicationId: string, + request: beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest = {}, + requestOptions?: Subscriptions.RequestOptions + ): Promise { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.beehiivEnvironment.Default, + `publications/${publicationId}/subscriptions/bulk_actions` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "", + "X-Fern-SDK-Version": "0.1.0", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + body: await serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.parseOrThrow( + _response.body, + { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + } + ); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new beehiiv.BadRequestError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new beehiiv.NotFoundError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new beehiiv.TooManyRequestsError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 500: + throw new beehiiv.InternalServerError( + await serializers.Error_.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.beehiivError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.beehiivTimeoutError(); + case "unknown": + throw new errors.beehiivError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/subscriptions/client/index.ts b/src/api/resources/subscriptions/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/subscriptions/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsEmailRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsEmailRequest.ts new file mode 100644 index 0000000..e816d32 --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsEmailRequest.ts @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem.Stats + * } + */ +export interface SubscriptionsGetSubscriptionsEmailRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the subscription(s).
`custom_fields` - Returns an array of custom field values that have been set on the subscription.
`referrals` - Returns an array of subscriptions with limited data - `id`, `email`, and `status`. These are the subscriptions that were referred by this subscription. + */ + expand?: + | beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem + | beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem[]; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsRequest.ts new file mode 100644 index 0000000..e0e93de --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsRequest.ts @@ -0,0 +1,108 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * email: "clark@dailyplanet.com" + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem.Stats, + * status: beehiiv.SubscriptionsGetSubscriptionsRequestStatus.Validating, + * tier: beehiiv.SubscriptionsGetSubscriptionsRequestTier.Free, + * limit: 1, + * page: 1, + * email: "string", + * orderBy: beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy.Created, + * direction: beehiiv.SubscriptionsGetSubscriptionsRequestDirection.Asc + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem.Stats, + * status: beehiiv.SubscriptionsGetSubscriptionsRequestStatus.Validating, + * tier: beehiiv.SubscriptionsGetSubscriptionsRequestTier.Free, + * limit: 1, + * page: 1, + * email: "string", + * orderBy: beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy.Created, + * direction: beehiiv.SubscriptionsGetSubscriptionsRequestDirection.Asc + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem.Stats, + * status: beehiiv.SubscriptionsGetSubscriptionsRequestStatus.Validating, + * tier: beehiiv.SubscriptionsGetSubscriptionsRequestTier.Free, + * limit: 1, + * page: 1, + * email: "string", + * orderBy: beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy.Created, + * direction: beehiiv.SubscriptionsGetSubscriptionsRequestDirection.Asc + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem.Stats, + * status: beehiiv.SubscriptionsGetSubscriptionsRequestStatus.Validating, + * tier: beehiiv.SubscriptionsGetSubscriptionsRequestTier.Free, + * limit: 1, + * page: 1, + * email: "string", + * orderBy: beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy.Created, + * direction: beehiiv.SubscriptionsGetSubscriptionsRequestDirection.Asc + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem.Stats, + * status: beehiiv.SubscriptionsGetSubscriptionsRequestStatus.Validating, + * tier: beehiiv.SubscriptionsGetSubscriptionsRequestTier.Free, + * limit: 1, + * page: 1, + * email: "string", + * orderBy: beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy.Created, + * direction: beehiiv.SubscriptionsGetSubscriptionsRequestDirection.Asc + * } + */ +export interface SubscriptionsGetSubscriptionsRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the subscription(s).
`custom_fields` - Returns an array of custom field values that have been set on the subscription.
`referrals` - Returns an array of subscriptions with limited data - `id`, `email`, and `status`. These are the subscriptions that were referred by this subscription. + */ + expand?: + | beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem + | beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem[]; + /** + * Optionally filter the results by a status + */ + status?: beehiiv.SubscriptionsGetSubscriptionsRequestStatus; + /** + * Optionally filter the results by a their tier + */ + tier?: beehiiv.SubscriptionsGetSubscriptionsRequestTier; + /** + * A limit on the number of objects to be returned. The limit can range between 1 and 100, and the default is 10. + */ + limit?: number; + /** + * Pagination returns the results in pages. Each page contains the number of results specified by the `limit` (default: 10).
If not specified, results 1-10 from page 1 will be returned. + */ + page?: number; + /** + * Optional email address to find a subscription.
This param must be an exact match and is case insensitive. + */ + email?: string; + /** + * The field that the results are sorted by. Defaults to created
`created` - The time in which the subscription was first created.
`email` - The email address of the subscription. + */ + orderBy?: beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy; + /** + * The direction that the results are sorted in. Defaults to asc
`asc` - Ascending, sorts from smallest to largest.
`desc` - Descending, sorts from largest to smallest. + */ + direction?: beehiiv.SubscriptionsGetSubscriptionsRequestDirection; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriberIdRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriberIdRequest.ts new file mode 100644 index 0000000..6a08074 --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriberIdRequest.ts @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.Stats + * } + */ +export interface SubscriptionsGetSubscriptionsSubscriberIdRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the subscription(s).
`custom_fields` - Returns an array of custom field values that have been set on the subscription.
`referrals` - Returns an array of subscriptions with limited data - `id`, `email`, and `status`. These are the subscriptions that were referred by this subscription. + */ + expand?: + | beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem + | beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem[]; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriptionIdRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriptionIdRequest.ts new file mode 100644 index 0000000..d24e2ab --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsGetSubscriptionsSubscriptionIdRequest.ts @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.Stats + * } + * + * @example + * { + * expand: beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.Stats + * } + */ +export interface SubscriptionsGetSubscriptionsSubscriptionIdRequest { + /** + * Optional list of expandable objects.
`stats` - Returns statistics about the subscription(s).
`custom_fields` - Returns an array of custom field values that have been set on the subscription.
`referrals` - Returns an array of subscriptions with limited data - `id`, `email`, and `status`. These are the subscriptions that were referred by this subscription. + */ + expand?: + | beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem + | beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem[]; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts new file mode 100644 index 0000000..9b38220 --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + */ +export interface SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest { + /** An array of objects representing the subscriptions to be updated */ + subscriptions?: beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem[]; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts new file mode 100644 index 0000000..c3d622e --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts @@ -0,0 +1,49 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + */ +export interface SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest { + /** An array of prefixed subscription IDs */ + subscriptionIds: string[]; + /** The new status value to apply to these subscription IDs */ + newStatus: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts new file mode 100644 index 0000000..37a6a17 --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts @@ -0,0 +1,152 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * } + * + * @example + * { + * undefined: "string", + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * } + * + * @example + * { + * undefined: "string", + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * } + * + * @example + * { + * undefined: "string", + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * } + * + * @example + * { + * undefined: "string", + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * } + * + * @example + * { + * undefined: "string", + * email: "bruce.wayne@wayneenterprise.com", + * reactivateExisting: false, + * sendWelcomeEmail: false, + * utmSource: "WayneEnterprise", + * utmMedium: "organic", + * utmCampaign: "fall_2022_promotion", + * referringSite: "www.wayneenterprise.com/blog", + * customFields: [{ + * name: "First Name", + * value: "Bruce" + * }, { + * name: "Last Name", + * value: "Wayne" + * }], + * automationIds: ["aut_00000000-0000-0000-0000-000000000000"] + * } + */ +export interface SubscriptionsPostSubscriptionsRequest { + undefined?: string; + /** The email address of the subscription. */ + email: string; + /** Whether or not to reactivate the subscription if they have already unsubscribed. This option should be used only if the subscriber is knowingly resubscribing. */ + reactivateExisting?: boolean; + sendWelcomeEmail?: boolean; + /** The source of the subscription. */ + utmSource?: string; + /** The medium of the subscription */ + utmMedium?: string; + /** The acquisition campaign of the subscription */ + utmCampaign?: string; + /** The website that the subscriber was referred from */ + referringSite?: string; + /** This should be a subscribers referral_code. This gives referral credit for the new subscription. */ + referralCode?: string; + /** The custom fields must already exist for the publication. Any new custom fields here will be discarded. */ + customFields?: beehiiv.CustomFieldValue[]; + /** Override publication double-opt settings for this subscription. */ + doubleOptOverride?: beehiiv.SubscriptionsPostSubscriptionsRequestDoubleOptOverride; + /** The tier for this subscription. */ + tier?: beehiiv.SubscriptionsPostSubscriptionsRequestTier; + /** Enroll the subscriber into automations after their subscription has been created. Requires the automations to have an active *Add by API* trigger. */ + automationIds?: string[]; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts new file mode 100644 index 0000000..c62e8cf --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + * + * @example + * {} + */ +export interface SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest { + /** An array of objects representing the subscriptions to be updated */ + subscriptions?: beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem[]; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts new file mode 100644 index 0000000..4833d28 --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts @@ -0,0 +1,49 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + * + * @example + * { + * subscriptionIds: ["subscription_ids"], + * newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Active + * } + */ +export interface SubscriptionsPutSubscriptionsBulkUpdateStatusRequest { + /** An array of prefixed subscription IDs */ + subscriptionIds: string[]; + /** The new status value to apply to these subscription IDs */ + newStatus: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus; +} diff --git a/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts b/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts new file mode 100644 index 0000000..d6b3a67 --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts @@ -0,0 +1,93 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../../.."; + +/** + * @example + * { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * } + * + * @example + * { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * } + * + * @example + * { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * } + * + * @example + * { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * } + * + * @example + * { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * } + * + * @example + * { + * tier: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Premium, + * unsubscribe: false, + * customFields: [{ + * name: "First Name", + * value: "JOHN" + * }, { + * name: "Birthday", + * delete: true + * }] + * } + */ +export interface SubscriptionsPutSubscriptionsSubscriptionIdRequest { + /** Optional parameter to set the tier for this subscription. */ + tier?: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier; + /** Optional parameter to unsubscribe the subscriber. If they are a premium subscription, this will also end their billing. */ + unsubscribe?: boolean; + /** The custom fields must already exist for the publication. Any new custom fields here will be discarded. */ + customFields?: beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem[]; +} diff --git a/src/api/resources/subscriptions/client/requests/index.ts b/src/api/resources/subscriptions/client/requests/index.ts new file mode 100644 index 0000000..dcbb719 --- /dev/null +++ b/src/api/resources/subscriptions/client/requests/index.ts @@ -0,0 +1,10 @@ +export { SubscriptionsGetSubscriptionsRequest } from "./SubscriptionsGetSubscriptionsRequest"; +export { SubscriptionsPostSubscriptionsRequest } from "./SubscriptionsPostSubscriptionsRequest"; +export { SubscriptionsPutSubscriptionsBulkUpdateStatusRequest } from "./SubscriptionsPutSubscriptionsBulkUpdateStatusRequest"; +export { SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest } from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest"; +export { SubscriptionsGetSubscriptionsSubscriptionIdRequest } from "./SubscriptionsGetSubscriptionsSubscriptionIdRequest"; +export { SubscriptionsPutSubscriptionsSubscriptionIdRequest } from "./SubscriptionsPutSubscriptionsSubscriptionIdRequest"; +export { SubscriptionsGetSubscriptionsSubscriberIdRequest } from "./SubscriptionsGetSubscriptionsSubscriberIdRequest"; +export { SubscriptionsGetSubscriptionsEmailRequest } from "./SubscriptionsGetSubscriptionsEmailRequest"; +export { SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest } from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest"; +export { SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest } from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest"; diff --git a/src/api/resources/subscriptions/index.ts b/src/api/resources/subscriptions/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/api/resources/subscriptions/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts new file mode 100644 index 0000000..168de8c --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsEmailRequestExpandItem = "stats" | "custom_fields" | "referrals"; + +export const SubscriptionsGetSubscriptionsEmailRequestExpandItem = { + Stats: "stats", + CustomFields: "custom_fields", + Referrals: "referrals", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts new file mode 100644 index 0000000..f7e01cc --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +/** + * The requested subscription object + */ +export interface SubscriptionsGetSubscriptionsEmailResponse { + data: beehiiv.Subscription; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts new file mode 100644 index 0000000..f9e0af4 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsRequestDirection = "asc" | "desc"; + +export const SubscriptionsGetSubscriptionsRequestDirection = { + Asc: "asc", + Desc: "desc", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts new file mode 100644 index 0000000..1bf852b --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsRequestExpandItem = "stats" | "custom_fields" | "referrals"; + +export const SubscriptionsGetSubscriptionsRequestExpandItem = { + Stats: "stats", + CustomFields: "custom_fields", + Referrals: "referrals", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts new file mode 100644 index 0000000..0ccebf6 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsRequestOrderBy = "created" | "email"; + +export const SubscriptionsGetSubscriptionsRequestOrderBy = { + Created: "created", + Email: "email", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts new file mode 100644 index 0000000..9260c23 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsRequestStatus = + | "validating" + | "invalid" + | "pending" + | "active" + | "inactive" + | "all"; + +export const SubscriptionsGetSubscriptionsRequestStatus = { + Validating: "validating", + Invalid: "invalid", + Pending: "pending", + Active: "active", + Inactive: "inactive", + All: "all", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts new file mode 100644 index 0000000..ceabe48 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsRequestTier = "free" | "premium" | "all"; + +export const SubscriptionsGetSubscriptionsRequestTier = { + Free: "free", + Premium: "premium", + All: "all", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts new file mode 100644 index 0000000..43740e8 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsGetSubscriptionsResponse { + data: beehiiv.Subscription[]; + /** The limit placed on the results. If no limit was specified in the request,this defaults to 10. */ + limit: number; + /** The page number the results are from. If no page was specified in the request, this defaults to page 1. */ + page: number; + /** The total number of results from all pages. */ + totalResults: number; + /** The total number of pages. */ + totalPages: number; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts new file mode 100644 index 0000000..9a97855 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem = "stats" | "custom_fields" | "referrals"; + +export const SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem = { + Stats: "stats", + CustomFields: "custom_fields", + Referrals: "referrals", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts new file mode 100644 index 0000000..e6fc8bb --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +/** + * The requested subscription object + */ +export interface SubscriptionsGetSubscriptionsSubscriberIdResponse { + data: beehiiv.Subscription; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts new file mode 100644 index 0000000..0f6ab98 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem = "stats" | "custom_fields" | "referrals"; + +export const SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem = { + Stats: "stats", + CustomFields: "custom_fields", + Referrals: "referrals", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts new file mode 100644 index 0000000..33d093a --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +/** + * The requested subscription object + */ +export interface SubscriptionsGetSubscriptionsSubscriptionIdResponse { + data: beehiiv.Subscription; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts new file mode 100644 index 0000000..ee757ea --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem { + /** The prefixed subscription ID */ + subscriptionId: string; + /** The Tier of the Subscription (not required) */ + tier?: beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier; + /** A boolean value specifying whether to unsubscribe this subscription from the publication (not required) */ + unsubscribe?: boolean; + /** An array of custom field objects to update */ + customFields?: beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem[]; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts new file mode 100644 index 0000000..49f12b4 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem { + /** The display value of the custom field */ + display?: string; + /** The value of the custom field */ + value?: string; + /** A boolean value to specify whether to delete this custom field entry from the subscription */ + delete?: boolean; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts new file mode 100644 index 0000000..afd5a42 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The Tier of the Subscription (not required) + */ +export type SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier = "free" | "premium"; + +export const SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier = { + Free: "free", + Premium: "premium", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts new file mode 100644 index 0000000..be98807 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse { + data: beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts new file mode 100644 index 0000000..d5871d1 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData { + /** The ID of the Subscription Update object responsible for handling the update job */ + subscriptionUpdateId?: string; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts new file mode 100644 index 0000000..b5f73b1 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The new status value to apply to these subscription IDs + */ +export type SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus = "active" | "inactive"; + +export const SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus = { + Active: "active", + Inactive: "inactive", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts new file mode 100644 index 0000000..068f8f2 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse { + data: beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts new file mode 100644 index 0000000..7b26144 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData { + /** The ID of the Subscription Update object responsible for handling the update job */ + subscriptionUpdateId: string; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts b/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts new file mode 100644 index 0000000..5f901bc --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Override publication double-opt settings for this subscription. + */ +export type SubscriptionsPostSubscriptionsRequestDoubleOptOverride = "on" | "off" | "not_set"; + +export const SubscriptionsPostSubscriptionsRequestDoubleOptOverride = { + On: "on", + Off: "off", + NotSet: "not_set", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts b/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts new file mode 100644 index 0000000..42f03ec --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The tier for this subscription. + */ +export type SubscriptionsPostSubscriptionsRequestTier = "free" | "premium"; + +export const SubscriptionsPostSubscriptionsRequestTier = { + Free: "free", + Premium: "premium", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts new file mode 100644 index 0000000..8e43b83 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsPostSubscriptionsResponse { + data: beehiiv.Subscription; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts new file mode 100644 index 0000000..31d46a6 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem { + /** The prefixed subscription ID */ + subscriptionId: string; + /** The Tier of the Subscription (not required) */ + tier?: beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier; + /** A boolean value specifying whether to unsubscribe this subscription from the publication (not required) */ + unsubscribe?: boolean; + /** An array of custom field objects to update */ + customFields?: beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem[]; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts new file mode 100644 index 0000000..d49376f --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem { + /** The display value of the custom field */ + display?: string; + /** The value of the custom field */ + value?: string; + /** A boolean value to specify whether to delete this custom field entry from the subscription */ + delete?: boolean; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts new file mode 100644 index 0000000..658df62 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The Tier of the Subscription (not required) + */ +export type SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier = "free" | "premium"; + +export const SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier = { + Free: "free", + Premium: "premium", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts new file mode 100644 index 0000000..c34d0bb --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse { + data: beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts new file mode 100644 index 0000000..c2aa4e9 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData { + /** The ID of the Subscription Update object responsible for handling the update job */ + subscriptionUpdateId?: string; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts new file mode 100644 index 0000000..f8cb00d --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The new status value to apply to these subscription IDs + */ +export type SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus = "active" | "inactive"; + +export const SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus = { + Active: "active", + Inactive: "inactive", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts new file mode 100644 index 0000000..86952b9 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +export interface SubscriptionsPutSubscriptionsBulkUpdateStatusResponse { + data: beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts new file mode 100644 index 0000000..c1f0f2a --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData { + /** The ID of the Subscription Update object responsible for handling the update job */ + subscriptionUpdateId: string; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts new file mode 100644 index 0000000..802af3b --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem { + /** The name of the existing custom field */ + name?: string; + /** The value to stored for the subscription. Will be ignored if `delete: true` is included. */ + value?: string; + /** Optionally delete any value stored. If true, any passed in `value` attribute will be ignored. */ + delete?: boolean; +} diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts new file mode 100644 index 0000000..edf4002 --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Optional parameter to set the tier for this subscription. + */ +export type SubscriptionsPutSubscriptionsSubscriptionIdRequestTier = "free" | "premium"; + +export const SubscriptionsPutSubscriptionsSubscriptionIdRequestTier = { + Free: "free", + Premium: "premium", +} as const; diff --git a/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts new file mode 100644 index 0000000..0cafedd --- /dev/null +++ b/src/api/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from "../../.."; + +/** + * The updated subscription object + */ +export interface SubscriptionsPutSubscriptionsSubscriptionIdResponse { + data: beehiiv.Subscription; +} diff --git a/src/api/resources/subscriptions/types/index.ts b/src/api/resources/subscriptions/types/index.ts new file mode 100644 index 0000000..6dece38 --- /dev/null +++ b/src/api/resources/subscriptions/types/index.ts @@ -0,0 +1,34 @@ +export * from "./SubscriptionsGetSubscriptionsRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsRequestStatus"; +export * from "./SubscriptionsGetSubscriptionsRequestTier"; +export * from "./SubscriptionsGetSubscriptionsRequestOrderBy"; +export * from "./SubscriptionsGetSubscriptionsRequestDirection"; +export * from "./SubscriptionsGetSubscriptionsResponse"; +export * from "./SubscriptionsPostSubscriptionsRequestDoubleOptOverride"; +export * from "./SubscriptionsPostSubscriptionsRequestTier"; +export * from "./SubscriptionsPostSubscriptionsResponse"; +export * from "./SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus"; +export * from "./SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData"; +export * from "./SubscriptionsPutSubscriptionsBulkUpdateStatusResponse"; +export * from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus"; +export * from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData"; +export * from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse"; +export * from "./SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsSubscriptionIdResponse"; +export * from "./SubscriptionsPutSubscriptionsSubscriptionIdRequestTier"; +export * from "./SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem"; +export * from "./SubscriptionsPutSubscriptionsSubscriptionIdResponse"; +export * from "./SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsSubscriberIdResponse"; +export * from "./SubscriptionsGetSubscriptionsEmailRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsEmailResponse"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse"; diff --git a/src/api/types/Automation.ts b/src/api/types/Automation.ts new file mode 100644 index 0000000..bc237d8 --- /dev/null +++ b/src/api/types/Automation.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +export interface Automation { + /** A unique prefixed id of the automation */ + id: string; + status: beehiiv.AutomationStatus; + name: string; + description?: string; +} diff --git a/src/api/types/AutomationJourney.ts b/src/api/types/AutomationJourney.ts new file mode 100644 index 0000000..5365057 --- /dev/null +++ b/src/api/types/AutomationJourney.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * A subscribers' journey through an automation flow. + */ +export interface AutomationJourney { + /** The prefixed automation journey id */ + id: string; + /** The prefixed automation id */ + automationId: string; + /** The prefixed subscription id */ + subscriptionId: string; + status: beehiiv.AutomationJourneyStatus; + /** The time that the subscriber started their flow through the automation. Measured in seconds since the Unix epoch. */ + startedAt?: number; + /** The time that the subscriber finished their flow through the automation. Measured in seconds since the Unix epoch. */ + completedAt?: number; +} diff --git a/src/api/types/AutomationJourneyStatus.ts b/src/api/types/AutomationJourneyStatus.ts new file mode 100644 index 0000000..91ed87e --- /dev/null +++ b/src/api/types/AutomationJourneyStatus.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AutomationJourneyStatus = "initiated" | "running" | "completed" | "failed"; + +export const AutomationJourneyStatus = { + Initiated: "initiated", + Running: "running", + Completed: "completed", + Failed: "failed", +} as const; diff --git a/src/api/types/AutomationStatus.ts b/src/api/types/AutomationStatus.ts new file mode 100644 index 0000000..ca394b8 --- /dev/null +++ b/src/api/types/AutomationStatus.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AutomationStatus = "running" | "finishing" | "inactive"; + +export const AutomationStatus = { + Running: "running", + Finishing: "finishing", + Inactive: "inactive", +} as const; diff --git a/src/api/types/ClickStats.ts b/src/api/types/ClickStats.ts new file mode 100644 index 0000000..030fa50 --- /dev/null +++ b/src/api/types/ClickStats.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * Details about specific URL's click stats from a post. + */ +export interface ClickStats { + /** The URL the stats are for */ + url?: string; + /** URL stats scoped only to email recipients. Not relevant for posts published only to web */ + email?: beehiiv.PostClickStatsEmail; + /** Stats scoped only to web views. Not relevant for posts published only to email */ + web?: beehiiv.PostClickStatsWeb; + totalClicks?: number; + totalUniqueClicks?: number; + /** The percentage of clicks on the URL compared to the total number of recipients and web views */ + totalClickThroughRate?: number; +} diff --git a/src/api/types/CustomField.ts b/src/api/types/CustomField.ts new file mode 100644 index 0000000..e090a52 --- /dev/null +++ b/src/api/types/CustomField.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +export interface CustomField { + /** The name of the existing custom field */ + name?: string; + /** The type of value being stored in the custom field. */ + kind?: beehiiv.CustomFieldKind; + /** The value stored for the subscription */ + value?: string; +} diff --git a/src/api/types/CustomFieldKind.ts b/src/api/types/CustomFieldKind.ts new file mode 100644 index 0000000..540f85c --- /dev/null +++ b/src/api/types/CustomFieldKind.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The type of value being stored in the custom field. + */ +export type CustomFieldKind = "string" | "integer" | "boolean" | "date" | "datetime"; + +export const CustomFieldKind = { + String: "string", + Integer: "integer", + Boolean: "boolean", + Date: "date", + Datetime: "datetime", +} as const; diff --git a/src/api/types/CustomFieldValue.ts b/src/api/types/CustomFieldValue.ts new file mode 100644 index 0000000..ffd2260 --- /dev/null +++ b/src/api/types/CustomFieldValue.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The object required for setting custom field values on a subscription + */ +export interface CustomFieldValue { + /** The name of the existing custom field */ + name?: string; + /** The value stored for the subscription */ + value?: string; +} diff --git a/src/api/types/EmailBlast.ts b/src/api/types/EmailBlast.ts new file mode 100644 index 0000000..627488f --- /dev/null +++ b/src/api/types/EmailBlast.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +export interface EmailBlast { + /** The prefixed email blast id */ + id: string; + /** The time the blast was created. Measured in seconds since the Unix epoch */ + created: number; + /** The time the blast was last sent. Measured in seconds since the Unix epoch */ + lastSent: number; + /** The status of the blast.
`inactive` - not been scheduled.
`active` - The blast is scheduled to send. */ + status: beehiiv.EmailBlastStatus; + /** The email subject line. */ + subjectLine: string; + /** The email preview text */ + previewText: string; + stats?: beehiiv.EmailBlastStats; + content?: beehiiv.EmailBlastContent; +} diff --git a/src/api/types/EmailBlastContent.ts b/src/api/types/EmailBlastContent.ts new file mode 100644 index 0000000..26a8baf --- /dev/null +++ b/src/api/types/EmailBlastContent.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * Optional html content for an email blast. Retrievable by including any of `expand: [free_email_content, premium_email_content]` in the post request body. + * + * **Note:** Generating HTML is slow. We recommend only requesting the HTML versions you need at the time. + */ +export interface EmailBlastContent { + email?: beehiiv.EmailBlastContentEmail; +} diff --git a/src/api/types/EmailBlastContentEmail.ts b/src/api/types/EmailBlastContentEmail.ts new file mode 100644 index 0000000..3b318f7 --- /dev/null +++ b/src/api/types/EmailBlastContentEmail.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface EmailBlastContentEmail { + free?: string; + premium?: string; +} diff --git a/src/api/types/EmailBlastStats.ts b/src/api/types/EmailBlastStats.ts new file mode 100644 index 0000000..214359f --- /dev/null +++ b/src/api/types/EmailBlastStats.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * Optional list of stats for an email blast. Retrievable by including `expand: [stats]` in the email blast request body. + */ +export interface EmailBlastStats { + /** Stats scoped only to email recipients. Not relevant for posts published only to web */ + email?: beehiiv.EmailBlastStatsEmail; + /** An array of click statistics for each URL in the post */ + clicks?: beehiiv.EmailBlastStatsClicksItem[]; +} diff --git a/src/api/types/EmailBlastStatsClicksItem.ts b/src/api/types/EmailBlastStatsClicksItem.ts new file mode 100644 index 0000000..cb754c0 --- /dev/null +++ b/src/api/types/EmailBlastStatsClicksItem.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface EmailBlastStatsClicksItem { + /** The URL the stats are for */ + url?: string; + totalClicks?: number; + totalUniqueClicks?: number; + /** The percentage of clicks on the URL compared to the total number of recipients and web views */ + totalClickThroughRate?: number; +} diff --git a/src/api/types/EmailBlastStatsEmail.ts b/src/api/types/EmailBlastStatsEmail.ts new file mode 100644 index 0000000..bdcb1b7 --- /dev/null +++ b/src/api/types/EmailBlastStatsEmail.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Stats scoped only to email recipients. Not relevant for posts published only to web + */ +export interface EmailBlastStatsEmail { + /** Total number of email recipients */ + recipients?: number; + /** Total number of email opens */ + opens?: number; + /** Total number of unique email opens */ + uniqueOpens?: number; + /** The percentage of emails that have been opened */ + openRate?: number; + /** Total number of email clicks */ + clicks?: number; + /** Unique number of email clicks */ + uniqueClicks?: number; + /** The percentage of emails that have been clicked */ + clickRate?: number; + /** Total number of email unsubscribes */ + unsubscribes?: number; + /** The number of subscribers that reported this post email as spam */ + spamReports?: number; +} diff --git a/src/api/types/EmailBlastStatus.ts b/src/api/types/EmailBlastStatus.ts new file mode 100644 index 0000000..c9b30d4 --- /dev/null +++ b/src/api/types/EmailBlastStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the blast.
`inactive` - not been scheduled.
`active` - The blast is scheduled to send. + */ +export type EmailBlastStatus = "active" | "inactive"; + +export const EmailBlastStatus = { + Active: "active", + Inactive: "inactive", +} as const; diff --git a/src/api/types/ErrorErrorsItem.ts b/src/api/types/ErrorErrorsItem.ts new file mode 100644 index 0000000..512f082 --- /dev/null +++ b/src/api/types/ErrorErrorsItem.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ErrorErrorsItem { + message: string; + code: string; +} diff --git a/src/api/types/Error_.ts b/src/api/types/Error_.ts new file mode 100644 index 0000000..450c835 --- /dev/null +++ b/src/api/types/Error_.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * The top level error response. + */ +export interface Error_ { + status: string; + statusText: string; + errors: beehiiv.ErrorErrorsItem[]; +} diff --git a/src/api/types/Milestone.ts b/src/api/types/Milestone.ts new file mode 100644 index 0000000..40fcd7c --- /dev/null +++ b/src/api/types/Milestone.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * The milestone object. + */ +export interface Milestone { + /** A unique prefixed id of the milestone. */ + id: string; + /** Only available with a promo code reward type. This indicates that an email will automatically be sent when the milestone is reached containing the reward promo code. */ + autoFulfill: boolean; + /** The number of referrals needed to reach this milestone. */ + numReferrals: number; + reward: beehiiv.MilestoneReward; +} diff --git a/src/api/types/MilestoneReward.ts b/src/api/types/MilestoneReward.ts new file mode 100644 index 0000000..320fb87 --- /dev/null +++ b/src/api/types/MilestoneReward.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * The reward object. + */ +export interface MilestoneReward { + /** A unique prefixed id of the reward. */ + id: string; + /** The name given to the reward at creation. */ + name: string; + /** The description given to the name at creation. */ + description: string; + /** A URL of an image to be displayed with the reward. */ + imageUrl: string; + /** What type of reward this is.
`physical` - A product which must be sent to the subscriber.
`promo_code` - A code that is redeemable for goods or services. */ + type: beehiiv.MilestoneRewardType; +} diff --git a/src/api/types/MilestoneRewardType.ts b/src/api/types/MilestoneRewardType.ts new file mode 100644 index 0000000..7a70433 --- /dev/null +++ b/src/api/types/MilestoneRewardType.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * What type of reward this is.
`physical` - A product which must be sent to the subscriber.
`promo_code` - A code that is redeemable for goods or services. + */ +export type MilestoneRewardType = "physical" | "promo_code"; + +export const MilestoneRewardType = { + Physical: "physical", + PromoCode: "promo_code", +} as const; diff --git a/src/api/types/Post.ts b/src/api/types/Post.ts new file mode 100644 index 0000000..23b95fe --- /dev/null +++ b/src/api/types/Post.ts @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +export interface Post { + /** The prefixed post id */ + id: string; + /** The subtitle displayed in web views */ + subtitle: string; + /** The title displayed in web views */ + title: string; + /** An array of author names */ + authors: string[]; + /** The time the post was created. Measured in seconds since the Unix epoch */ + created: number; + /** The status of the post.
`draft` - not been scheduled.
`confirmed` - The post will be active after the `scheduled_at`.
`archived` - The post is no longer active. */ + status: beehiiv.PostStatus; + /** The time the post was set to be published. Measured in seconds since the Unix epoch */ + publishDate?: number; + /** The time displayed in place of the `publish_date`. Measured in seconds since the Unix epoch */ + displayedDate?: number; + /** A flag to indicate if a split test was done. Only applicable to email posts. */ + splitTested: boolean; + /** The email subject line. In cases of A/B Testing, this will be adjusted to the winning subject line. */ + subjectLine: string; + /** The email preview text */ + previewText: string; + /** The web slug where this post can be accessed. */ + slug: string; + /** The URL of the thumbnail. Defaults to the Publication logo if not set. */ + thumbnailUrl: string; + /** The full URL where this post can be accessed on the web. Only applicable if the platform is `web` or `both`. */ + webUrl: string; + /** The audience that the post is available to on the web. Only applicable if the platform is `web` or `both`. */ + audience: beehiiv.PostAudience; + /** The platform that the post is or will be published to. */ + platform: beehiiv.PostPlatform; + /** All content tags that were associated with the post. */ + contentTags: string[]; + /** Meta tag description for the post, called SEO Description in the admin UI */ + metaDefaultDescription?: string; + /** meta tag title for the post, called SEO Title in the admin UI */ + metaDefaultTitle?: string; + content?: beehiiv.PostContent; + stats?: beehiiv.PostStats; + /** A flag to indicate if the post is hidden from the website feed. */ + hiddenFromFeed: boolean; +} diff --git a/src/api/types/PostAudience.ts b/src/api/types/PostAudience.ts new file mode 100644 index 0000000..288a423 --- /dev/null +++ b/src/api/types/PostAudience.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The audience that the post is available to on the web. Only applicable if the platform is `web` or `both`. + */ +export type PostAudience = "free" | "premium" | "both"; + +export const PostAudience = { + Free: "free", + Premium: "premium", + Both: "both", +} as const; diff --git a/src/api/types/PostClickStatsEmail.ts b/src/api/types/PostClickStatsEmail.ts new file mode 100644 index 0000000..3f900a9 --- /dev/null +++ b/src/api/types/PostClickStatsEmail.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * URL stats scoped only to email recipients. Not relevant for posts published only to web + */ +export interface PostClickStatsEmail { + clicks?: number; + uniqueClicks?: number; + /** The percentage of email clicks on the URL compared to the total number of recipients */ + clickThroughRate?: number; +} diff --git a/src/api/types/PostClickStatsWeb.ts b/src/api/types/PostClickStatsWeb.ts new file mode 100644 index 0000000..5e04f8c --- /dev/null +++ b/src/api/types/PostClickStatsWeb.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Stats scoped only to web views. Not relevant for posts published only to email + */ +export interface PostClickStatsWeb { + clicks?: number; + uniqueClicks?: number; + /** The percentage of clicks on the URL compared to the total number of web views */ + clickThroughRate?: number; +} diff --git a/src/api/types/PostContent.ts b/src/api/types/PostContent.ts new file mode 100644 index 0000000..bbb9391 --- /dev/null +++ b/src/api/types/PostContent.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * Optional html content for a post. Retrievable by including any of `expand: [free_web_content, free_email_content, free_rss_content, premium_web_content, premium_email_content]` in the post request body. + * + * **Note:** Generating HTML is slow. We recommend only requesting the HTML versions you need at the time. + */ +export interface PostContent { + /** The requested free post HTML. This HTML has paywalls enforced. */ + free?: beehiiv.PostContentFree; + /** The requested premium post HTML. This HTML does not have paywalls enforced. */ + premium?: beehiiv.PostContentPremium; +} diff --git a/src/api/types/PostContentFree.ts b/src/api/types/PostContentFree.ts new file mode 100644 index 0000000..69294f6 --- /dev/null +++ b/src/api/types/PostContentFree.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The requested free post HTML. This HTML has paywalls enforced. + */ +export interface PostContentFree { + /** The web HTML rendered to a free or annonomous reader. */ + web?: string; + /** The email HTML rendered to a free reader. */ + email?: string; + /** The HTML that is rendered in RSS feeds. */ + rss?: string; +} diff --git a/src/api/types/PostContentPremium.ts b/src/api/types/PostContentPremium.ts new file mode 100644 index 0000000..f526064 --- /dev/null +++ b/src/api/types/PostContentPremium.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The requested premium post HTML. This HTML does not have paywalls enforced. + */ +export interface PostContentPremium { + /** The website HTML rendered to a free reader */ + web?: string; + /** The email HTML rendered to a premium reader */ + email?: string; +} diff --git a/src/api/types/PostPlatform.ts b/src/api/types/PostPlatform.ts new file mode 100644 index 0000000..1990db6 --- /dev/null +++ b/src/api/types/PostPlatform.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The platform that the post is or will be published to. + */ +export type PostPlatform = "web" | "email" | "both"; + +export const PostPlatform = { + Web: "web", + Email: "email", + Both: "both", +} as const; diff --git a/src/api/types/PostStats.ts b/src/api/types/PostStats.ts new file mode 100644 index 0000000..cf89894 --- /dev/null +++ b/src/api/types/PostStats.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * Optional list of stats for a post. Retrievable by including `expand: [stats]` in the post request body. + */ +export interface PostStats { + /** Stats scoped only to email recipients. Not relevant for posts published only to web */ + email?: beehiiv.PostStatsEmail; + /** Stats scoped only to web views. Not relevant for posts published only to email */ + web?: beehiiv.PostStatsWeb; + /** An array of click statistics for each URL in the post */ + clicks?: beehiiv.ClickStats[]; +} diff --git a/src/api/types/PostStatsEmail.ts b/src/api/types/PostStatsEmail.ts new file mode 100644 index 0000000..669ab29 --- /dev/null +++ b/src/api/types/PostStatsEmail.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Stats scoped only to email recipients. Not relevant for posts published only to web + */ +export interface PostStatsEmail { + /** Total number of email recipients */ + recipients?: number; + /** Total number of email opens */ + opens?: number; + /** Total number of unique email opens */ + uniqueOpens?: number; + /** The percentage of emails that have been opened */ + openRate?: number; + /** Total number of email clicks */ + clicks?: number; + /** Unique number of email clicks */ + uniqueClicks?: number; + /** The percentage of emails that have been clicked */ + clickRate?: number; + /** Total number of email unsubscribes */ + unsubscribes?: number; + /** The number of subscribers that reported this post email as spam */ + spamReports?: number; +} diff --git a/src/api/types/PostStatsWeb.ts b/src/api/types/PostStatsWeb.ts new file mode 100644 index 0000000..8c94095 --- /dev/null +++ b/src/api/types/PostStatsWeb.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Stats scoped only to web views. Not relevant for posts published only to email + */ +export interface PostStatsWeb { + /** Total number of web views */ + views?: number; + /** Total number of web clicks */ + clicks?: number; +} diff --git a/src/api/types/PostStatus.ts b/src/api/types/PostStatus.ts new file mode 100644 index 0000000..d652044 --- /dev/null +++ b/src/api/types/PostStatus.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the post.
`draft` - not been scheduled.
`confirmed` - The post will be active after the `scheduled_at`.
`archived` - The post is no longer active. + */ +export type PostStatus = "draft" | "confirmed" | "archived"; + +export const PostStatus = { + Draft: "draft", + Confirmed: "confirmed", + Archived: "archived", +} as const; diff --git a/src/api/types/Publication.ts b/src/api/types/Publication.ts new file mode 100644 index 0000000..03e6134 --- /dev/null +++ b/src/api/types/Publication.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +export interface Publication { + /** A unique prefixed id of the publication */ + id: string; + /** The name of the publication */ + name: string; + /** A boolean field indicating whether the referral program is active for this publication. */ + referralProgramEnabled: boolean; + /** The time that the publication was created. Measured in seconds since the Unix epoch */ + created: number; + stats?: beehiiv.PublicationStats; +} diff --git a/src/api/types/PublicationStats.ts b/src/api/types/PublicationStats.ts new file mode 100644 index 0000000..6e357c7 --- /dev/null +++ b/src/api/types/PublicationStats.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * Optional list of stats for a publication. Retrievable by including an `expand` array in the publication request body. Add `"stats"` to the array to retrieve all, or add individual stats (prefaced with `stat_`) to only retrieve specific ones. + * + * Examples: + * { + * "expand": ["stats"] + * } + * + * { + * "expand": ["stat_active_subscriptions", "stat_average_click_rate"] + * } + */ +export interface PublicationStats { + /** Total number of active free and premium subscriptions */ + activeSubscriptions?: beehiiv.PublicationStatsActiveSubscriptions; + /** Total number of active premium/paid subscriptions */ + activePremiumSubscriptions?: beehiiv.PublicationStatsActivePremiumSubscriptions; + /** Total number of active free subscriptions */ + activeFreeSubscriptions?: beehiiv.PublicationStatsActiveFreeSubscriptions; + /** The publications historical average open rate */ + averageOpenRate?: beehiiv.PublicationStatsAverageOpenRate; + /** The publications historical average click through rate */ + averageClickRate?: beehiiv.PublicationStatsAverageClickRate; + /** Total number of emails sent */ + totalSent?: beehiiv.PublicationStatsTotalSent; + /** Total number of uniquely opened emails. Only counts the first open for each subscriber. */ + totalUniqueOpened?: beehiiv.PublicationStatsTotalUniqueOpened; + /** The total number of links clicked from emails. */ + totalClicked?: beehiiv.PublicationStatsTotalClicked; +} diff --git a/src/api/types/PublicationStatsActiveFreeSubscriptions.ts b/src/api/types/PublicationStatsActiveFreeSubscriptions.ts new file mode 100644 index 0000000..c733826 --- /dev/null +++ b/src/api/types/PublicationStatsActiveFreeSubscriptions.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Total number of active free subscriptions + */ +export type PublicationStatsActiveFreeSubscriptions = number | boolean; diff --git a/src/api/types/PublicationStatsActivePremiumSubscriptions.ts b/src/api/types/PublicationStatsActivePremiumSubscriptions.ts new file mode 100644 index 0000000..507a743 --- /dev/null +++ b/src/api/types/PublicationStatsActivePremiumSubscriptions.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Total number of active premium/paid subscriptions + */ +export type PublicationStatsActivePremiumSubscriptions = number | boolean; diff --git a/src/api/types/PublicationStatsActiveSubscriptions.ts b/src/api/types/PublicationStatsActiveSubscriptions.ts new file mode 100644 index 0000000..9b8f863 --- /dev/null +++ b/src/api/types/PublicationStatsActiveSubscriptions.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Total number of active free and premium subscriptions + */ +export type PublicationStatsActiveSubscriptions = number | boolean; diff --git a/src/api/types/PublicationStatsAverageClickRate.ts b/src/api/types/PublicationStatsAverageClickRate.ts new file mode 100644 index 0000000..15e323d --- /dev/null +++ b/src/api/types/PublicationStatsAverageClickRate.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The publications historical average click through rate + */ +export type PublicationStatsAverageClickRate = number | boolean; diff --git a/src/api/types/PublicationStatsAverageOpenRate.ts b/src/api/types/PublicationStatsAverageOpenRate.ts new file mode 100644 index 0000000..d447809 --- /dev/null +++ b/src/api/types/PublicationStatsAverageOpenRate.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The publications historical average open rate + */ +export type PublicationStatsAverageOpenRate = number | boolean; diff --git a/src/api/types/PublicationStatsTotalClicked.ts b/src/api/types/PublicationStatsTotalClicked.ts new file mode 100644 index 0000000..0543cbf --- /dev/null +++ b/src/api/types/PublicationStatsTotalClicked.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The total number of links clicked from emails. + */ +export type PublicationStatsTotalClicked = number | boolean; diff --git a/src/api/types/PublicationStatsTotalSent.ts b/src/api/types/PublicationStatsTotalSent.ts new file mode 100644 index 0000000..8e7146b --- /dev/null +++ b/src/api/types/PublicationStatsTotalSent.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Total number of emails sent + */ +export type PublicationStatsTotalSent = number | boolean; diff --git a/src/api/types/PublicationStatsTotalUniqueOpened.ts b/src/api/types/PublicationStatsTotalUniqueOpened.ts new file mode 100644 index 0000000..3fd77fe --- /dev/null +++ b/src/api/types/PublicationStatsTotalUniqueOpened.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Total number of uniquely opened emails. Only counts the first open for each subscriber. + */ +export type PublicationStatsTotalUniqueOpened = number | boolean; diff --git a/src/api/types/Segment.ts b/src/api/types/Segment.ts new file mode 100644 index 0000000..087dd7e --- /dev/null +++ b/src/api/types/Segment.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * The segment object. To expand results, see the results endpoint. + */ +export interface Segment { + /** The prefixed ID of the Segment object. */ + id: string; + /** The name of the segment. */ + name: string; + /** The type of segment.
`dynamic` - The segment is recalculated at set intervals.
`static` - The segment is calculated once at creation.
`manual` - The segment is not calculated at all. The results are created via CSV. */ + type: beehiiv.SegmentType; + /** The time the Segment was last calculated. Measured in seconds since the Unix epoch */ + lastCalculated?: number; + /** The total number of subscriptions that belong in the segment from the last calculation. */ + totalResults: number; + /** The status of the segment's most recent calculation.
`pending` - The segment has not been calculated yet.
`processing` - The calculation is in progress, and has not completed.
`completed` - The calculation was successful.
`failed` - Something went wrong during the calculation. */ + status: beehiiv.SegmentStatus; + /** Dynamic segments are marked inactive if they haven't been used in a specific period of time. Inactive segments will not automatically be recalculated. */ + active: boolean; +} diff --git a/src/api/types/SegmentStatus.ts b/src/api/types/SegmentStatus.ts new file mode 100644 index 0000000..2f18035 --- /dev/null +++ b/src/api/types/SegmentStatus.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the segment's most recent calculation.
`pending` - The segment has not been calculated yet.
`processing` - The calculation is in progress, and has not completed.
`completed` - The calculation was successful.
`failed` - Something went wrong during the calculation. + */ +export type SegmentStatus = "pending" | "processing" | "completed" | "failed"; + +export const SegmentStatus = { + Pending: "pending", + Processing: "processing", + Completed: "completed", + Failed: "failed", +} as const; diff --git a/src/api/types/SegmentType.ts b/src/api/types/SegmentType.ts new file mode 100644 index 0000000..5e9a986 --- /dev/null +++ b/src/api/types/SegmentType.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The type of segment.
`dynamic` - The segment is recalculated at set intervals.
`static` - The segment is calculated once at creation.
`manual` - The segment is not calculated at all. The results are created via CSV. + */ +export type SegmentType = "dynamic" | "static" | "manual"; + +export const SegmentType = { + Dynamic: "dynamic", + Static: "static", + Manual: "manual", +} as const; diff --git a/src/api/types/Subscription.ts b/src/api/types/Subscription.ts new file mode 100644 index 0000000..808e4c3 --- /dev/null +++ b/src/api/types/Subscription.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * The subscription object + */ +export interface Subscription { + /** The prefixed subscription id */ + id: string; + email: string; + /** The status of the subscription.
`validating` - The email address is being validated.
`invalid` - The email address is invalid.
`pending` - The email address is valid, but the subscription is pending double opt-in.
`active` - The email was valid and the subscription is active.
`inactive` - The subscription was made inactive, possibly due to an unsubscribe.
`needs_attention` - The subscription requires approval or denial. */ + status: beehiiv.SubscriptionExpandedStatus; + /** The date the subscription was created. Measured in seconds since the Unix epoch */ + created: number; + /** The current tier of the subscription. */ + subscriptionTier: beehiiv.SubscriptionExpandedSubscriptionTier; + /** The acquisition source; where the subscriber came from */ + utmSource: string; + /** The acquisition medium; how the subscriber got to your publication */ + utmMedium: string; + /** The acquisition channel */ + utmChannel: beehiiv.SubscriptionExpandedUtmChannel; + /** The acquisition campaign */ + utmCampaign: string; + /** The website that the subscriber was referred from */ + referringSite: string; + /** The code associated to this subscriber to refer others. When a new subscription is created with this referral code, credit for the referral goes to this subscription. */ + referralCode: string; + customFields?: beehiiv.SubscriptionCustomFields; + stats?: beehiiv.SubscriptionStats; + tags?: beehiiv.SubscriptionTags; +} diff --git a/src/api/types/SubscriptionCustomFields.ts b/src/api/types/SubscriptionCustomFields.ts new file mode 100644 index 0000000..77b96a0 --- /dev/null +++ b/src/api/types/SubscriptionCustomFields.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as beehiiv from ".."; + +/** + * Optional list of custom fields for a subscription. Retrievable by including `expand: [custom_field]` in the request body. + */ +export type SubscriptionCustomFields = beehiiv.CustomField[]; diff --git a/src/api/types/SubscriptionExpandedStatus.ts b/src/api/types/SubscriptionExpandedStatus.ts new file mode 100644 index 0000000..5b877f2 --- /dev/null +++ b/src/api/types/SubscriptionExpandedStatus.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the subscription.
`validating` - The email address is being validated.
`invalid` - The email address is invalid.
`pending` - The email address is valid, but the subscription is pending double opt-in.
`active` - The email was valid and the subscription is active.
`inactive` - The subscription was made inactive, possibly due to an unsubscribe.
`needs_attention` - The subscription requires approval or denial. + */ +export type SubscriptionExpandedStatus = + | "validating" + | "invalid" + | "pending" + | "active" + | "inactive" + | "needs_attention"; + +export const SubscriptionExpandedStatus = { + Validating: "validating", + Invalid: "invalid", + Pending: "pending", + Active: "active", + Inactive: "inactive", + NeedsAttention: "needs_attention", +} as const; diff --git a/src/api/types/SubscriptionExpandedSubscriptionTier.ts b/src/api/types/SubscriptionExpandedSubscriptionTier.ts new file mode 100644 index 0000000..b09ce33 --- /dev/null +++ b/src/api/types/SubscriptionExpandedSubscriptionTier.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The current tier of the subscription. + */ +export type SubscriptionExpandedSubscriptionTier = "free" | "premium"; + +export const SubscriptionExpandedSubscriptionTier = { + Free: "free", + Premium: "premium", +} as const; diff --git a/src/api/types/SubscriptionExpandedTagsStatus.ts b/src/api/types/SubscriptionExpandedTagsStatus.ts new file mode 100644 index 0000000..d1a6173 --- /dev/null +++ b/src/api/types/SubscriptionExpandedTagsStatus.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the subscription.
`validating` - The email address is being validated.
`invalid` - The email address is invalid.
`pending` - The email address is valid, but the subscription is pending double opt-in.
`active` - The email was valid and the subscription is active.
`inactive` - The subscription was made inactive, possibly due to an unsubscribe.
`needs_attention` - The subscription requires approval or denial. + */ +export type SubscriptionExpandedTagsStatus = + | "validating" + | "invalid" + | "pending" + | "active" + | "inactive" + | "needs_attention"; + +export const SubscriptionExpandedTagsStatus = { + Validating: "validating", + Invalid: "invalid", + Pending: "pending", + Active: "active", + Inactive: "inactive", + NeedsAttention: "needs_attention", +} as const; diff --git a/src/api/types/SubscriptionExpandedTagsSubscriptionTier.ts b/src/api/types/SubscriptionExpandedTagsSubscriptionTier.ts new file mode 100644 index 0000000..42c830c --- /dev/null +++ b/src/api/types/SubscriptionExpandedTagsSubscriptionTier.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The current tier of the subscription. + */ +export type SubscriptionExpandedTagsSubscriptionTier = "free" | "premium"; + +export const SubscriptionExpandedTagsSubscriptionTier = { + Free: "free", + Premium: "premium", +} as const; diff --git a/src/api/types/SubscriptionExpandedTagsUtmChannel.ts b/src/api/types/SubscriptionExpandedTagsUtmChannel.ts new file mode 100644 index 0000000..acfb0e7 --- /dev/null +++ b/src/api/types/SubscriptionExpandedTagsUtmChannel.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The acquisition channel + */ +export type SubscriptionExpandedTagsUtmChannel = + | "" + | "website" + | "import" + | "embed" + | "api" + | "referral" + | "recommendation" + | "magic_link" + | "boost" + | "boost_send" + | "boost_direct_link"; + +export const SubscriptionExpandedTagsUtmChannel = { + Empty: "", + Website: "website", + Import: "import", + Embed: "embed", + Api: "api", + Referral: "referral", + Recommendation: "recommendation", + MagicLink: "magic_link", + Boost: "boost", + BoostSend: "boost_send", + BoostDirectLink: "boost_direct_link", +} as const; diff --git a/src/api/types/SubscriptionExpandedUtmChannel.ts b/src/api/types/SubscriptionExpandedUtmChannel.ts new file mode 100644 index 0000000..b6a1ac6 --- /dev/null +++ b/src/api/types/SubscriptionExpandedUtmChannel.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The acquisition channel + */ +export type SubscriptionExpandedUtmChannel = + | "" + | "website" + | "import" + | "embed" + | "api" + | "referral" + | "recommendation" + | "magic_link" + | "boost" + | "boost_send" + | "boost_direct_link"; + +export const SubscriptionExpandedUtmChannel = { + Empty: "", + Website: "website", + Import: "import", + Embed: "embed", + Api: "api", + Referral: "referral", + Recommendation: "recommendation", + MagicLink: "magic_link", + Boost: "boost", + BoostSend: "boost_send", + BoostDirectLink: "boost_direct_link", +} as const; diff --git a/src/api/types/SubscriptionStats.ts b/src/api/types/SubscriptionStats.ts new file mode 100644 index 0000000..7fc65cd --- /dev/null +++ b/src/api/types/SubscriptionStats.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Optional list of stats for a subscription. Retrievable by including `expand: [stats]` in the request body. + */ +export interface SubscriptionStats { + /** The total number of emails that have been sent to this subscriber */ + emailsReceived?: number; + /** The percentage of emails that the subscriber has opened */ + openRate?: number; + /** The percentage of emails that the subscriber has clicked a link in */ + clickThroughRate?: number; +} diff --git a/src/api/types/SubscriptionStatus.ts b/src/api/types/SubscriptionStatus.ts new file mode 100644 index 0000000..2170b23 --- /dev/null +++ b/src/api/types/SubscriptionStatus.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The status of the subscription.
`validating` - The email address is being validated.
`invalid` - The email address is invalid.
`pending` - The email address is valid, but the subscription is pending double opt-in.
`active` - The email was valid and the subscription is active.
`inactive` - The subscription was made inactive, possibly due to an unsubscribe.
`needs_attention` - The subscription requires approval or denial. + */ +export type SubscriptionStatus = "validating" | "invalid" | "pending" | "active" | "inactive" | "needs_attention"; + +export const SubscriptionStatus = { + Validating: "validating", + Invalid: "invalid", + Pending: "pending", + Active: "active", + Inactive: "inactive", + NeedsAttention: "needs_attention", +} as const; diff --git a/src/api/types/SubscriptionSubscriptionTier.ts b/src/api/types/SubscriptionSubscriptionTier.ts new file mode 100644 index 0000000..70f3668 --- /dev/null +++ b/src/api/types/SubscriptionSubscriptionTier.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The current tier of the subscription. + */ +export type SubscriptionSubscriptionTier = "free" | "premium"; + +export const SubscriptionSubscriptionTier = { + Free: "free", + Premium: "premium", +} as const; diff --git a/src/api/types/SubscriptionTags.ts b/src/api/types/SubscriptionTags.ts new file mode 100644 index 0000000..f93fd62 --- /dev/null +++ b/src/api/types/SubscriptionTags.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Optional list of tags form a subscription. Retrievable by including `expand: [tags]` in the request body. + * Max limit of 100 unique tags per publication. + */ +export type SubscriptionTags = string[]; diff --git a/src/api/types/SubscriptionUtmChannel.ts b/src/api/types/SubscriptionUtmChannel.ts new file mode 100644 index 0000000..29afb58 --- /dev/null +++ b/src/api/types/SubscriptionUtmChannel.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The acquisition channel + */ +export type SubscriptionUtmChannel = + | "" + | "website" + | "import" + | "embed" + | "api" + | "referral" + | "recommendation" + | "magic_link" + | "boost" + | "boost_send" + | "boost_direct_link"; + +export const SubscriptionUtmChannel = { + Empty: "", + Website: "website", + Import: "import", + Embed: "embed", + Api: "api", + Referral: "referral", + Recommendation: "recommendation", + MagicLink: "magic_link", + Boost: "boost", + BoostSend: "boost_send", + BoostDirectLink: "boost_direct_link", +} as const; diff --git a/src/api/types/index.ts b/src/api/types/index.ts new file mode 100644 index 0000000..7c45cac --- /dev/null +++ b/src/api/types/index.ts @@ -0,0 +1,58 @@ +export * from "./CustomFieldKind"; +export * from "./CustomField"; +export * from "./CustomFieldValue"; +export * from "./EmailBlastStatus"; +export * from "./EmailBlast"; +export * from "./EmailBlastContentEmail"; +export * from "./EmailBlastContent"; +export * from "./EmailBlastStatsEmail"; +export * from "./EmailBlastStatsClicksItem"; +export * from "./EmailBlastStats"; +export * from "./ErrorErrorsItem"; +export * from "./Error_"; +export * from "./Milestone"; +export * from "./MilestoneRewardType"; +export * from "./MilestoneReward"; +export * from "./SubscriptionStatus"; +export * from "./SubscriptionSubscriptionTier"; +export * from "./SubscriptionUtmChannel"; +export * from "./Subscription"; +export * from "./SubscriptionExpandedTagsStatus"; +export * from "./SubscriptionExpandedTagsSubscriptionTier"; +export * from "./SubscriptionExpandedTagsUtmChannel"; +export * from "./SubscriptionExpandedStatus"; +export * from "./SubscriptionExpandedSubscriptionTier"; +export * from "./SubscriptionExpandedUtmChannel"; +export * from "./SubscriptionCustomFields"; +export * from "./SubscriptionStats"; +export * from "./SubscriptionTags"; +export * from "./PostStatus"; +export * from "./PostAudience"; +export * from "./PostPlatform"; +export * from "./Post"; +export * from "./PostClickStatsEmail"; +export * from "./PostClickStatsWeb"; +export * from "./ClickStats"; +export * from "./PostContentFree"; +export * from "./PostContentPremium"; +export * from "./PostContent"; +export * from "./PostStatsEmail"; +export * from "./PostStatsWeb"; +export * from "./PostStats"; +export * from "./Publication"; +export * from "./PublicationStatsActiveSubscriptions"; +export * from "./PublicationStatsActivePremiumSubscriptions"; +export * from "./PublicationStatsActiveFreeSubscriptions"; +export * from "./PublicationStatsAverageOpenRate"; +export * from "./PublicationStatsAverageClickRate"; +export * from "./PublicationStatsTotalSent"; +export * from "./PublicationStatsTotalUniqueOpened"; +export * from "./PublicationStatsTotalClicked"; +export * from "./PublicationStats"; +export * from "./SegmentType"; +export * from "./SegmentStatus"; +export * from "./Segment"; +export * from "./AutomationStatus"; +export * from "./Automation"; +export * from "./AutomationJourneyStatus"; +export * from "./AutomationJourney"; diff --git a/src/core/auth/BasicAuth.ts b/src/core/auth/BasicAuth.ts new file mode 100644 index 0000000..146df21 --- /dev/null +++ b/src/core/auth/BasicAuth.ts @@ -0,0 +1,31 @@ +import { Base64 } from "js-base64"; + +export interface BasicAuth { + username: string; + password: string; +} + +const BASIC_AUTH_HEADER_PREFIX = /^Basic /i; + +export const BasicAuth = { + toAuthorizationHeader: (basicAuth: BasicAuth | undefined): string | undefined => { + if (basicAuth == null) { + return undefined; + } + const token = Base64.encode(`${basicAuth.username}:${basicAuth.password}`); + return `Basic ${token}`; + }, + fromAuthorizationHeader: (header: string): BasicAuth => { + const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, ""); + const decoded = Base64.decode(credentials); + const [username, password] = decoded.split(":", 2); + + if (username == null || password == null) { + throw new Error("Invalid basic auth"); + } + return { + username, + password, + }; + }, +}; diff --git a/src/core/auth/BearerToken.ts b/src/core/auth/BearerToken.ts new file mode 100644 index 0000000..fe987fc --- /dev/null +++ b/src/core/auth/BearerToken.ts @@ -0,0 +1,15 @@ +export type BearerToken = string; + +const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i; + +export const BearerToken = { + toAuthorizationHeader: (token: BearerToken | undefined): string | undefined => { + if (token == null) { + return undefined; + } + return `Bearer ${token}`; + }, + fromAuthorizationHeader: (header: string): BearerToken => { + return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim() as BearerToken; + }, +}; diff --git a/src/core/auth/index.ts b/src/core/auth/index.ts new file mode 100644 index 0000000..ee293b3 --- /dev/null +++ b/src/core/auth/index.ts @@ -0,0 +1,2 @@ +export { BasicAuth } from "./BasicAuth"; +export { BearerToken } from "./BearerToken"; diff --git a/src/core/fetcher/APIResponse.ts b/src/core/fetcher/APIResponse.ts new file mode 100644 index 0000000..3664d09 --- /dev/null +++ b/src/core/fetcher/APIResponse.ts @@ -0,0 +1,12 @@ +export type APIResponse = SuccessfulResponse | FailedResponse; + +export interface SuccessfulResponse { + ok: true; + body: T; + headers?: Record; +} + +export interface FailedResponse { + ok: false; + error: T; +} diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts new file mode 100644 index 0000000..c08e0fd --- /dev/null +++ b/src/core/fetcher/Fetcher.ts @@ -0,0 +1,195 @@ +import { default as FormData } from "form-data"; +import qs from "qs"; +import { RUNTIME } from "../runtime"; +import { APIResponse } from "./APIResponse"; + +export type FetchFunction = (args: Fetcher.Args) => Promise>; + +export declare namespace Fetcher { + export interface Args { + url: string; + method: string; + contentType?: string; + headers?: Record; + queryParameters?: Record; + body?: unknown; + timeoutMs?: number; + maxRetries?: number; + withCredentials?: boolean; + responseType?: "json" | "blob" | "streaming"; + } + + export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; + + export interface FailedStatusCodeError { + reason: "status-code"; + statusCode: number; + body: unknown; + } + + export interface NonJsonError { + reason: "non-json"; + statusCode: number; + rawBody: string; + } + + export interface TimeoutError { + reason: "timeout"; + } + + export interface UnknownError { + reason: "unknown"; + errorMessage: string; + } +} + +const INITIAL_RETRY_DELAY = 1; +const MAX_RETRY_DELAY = 60; +const DEFAULT_MAX_RETRIES = 2; + +async function fetcherImpl(args: Fetcher.Args): Promise> { + const headers: Record = {}; + if (args.body !== undefined && args.contentType != null) { + headers["Content-Type"] = args.contentType; + } + + if (args.headers != null) { + for (const [key, value] of Object.entries(args.headers)) { + if (value != null) { + headers[key] = value; + } + } + } + + const url = + Object.keys(args.queryParameters ?? {}).length > 0 + ? `${args.url}?${qs.stringify(args.queryParameters, { arrayFormat: "repeat" })}` + : args.url; + + let body: BodyInit | undefined = undefined; + if (args.body instanceof FormData) { + // @ts-expect-error + body = args.body; + } else if (args.body instanceof Uint8Array) { + body = args.body; + } else { + body = JSON.stringify(args.body); + } + + // In Node.js environments, the SDK always uses`node-fetch`. + // If not in Node.js the SDK uses global fetch if available, + // and falls back to node-fetch. + const fetchFn = + RUNTIME.type === "node" + ? // `.default` is required due to this issue: + // https://github.com/node-fetch/node-fetch/issues/450#issuecomment-387045223 + require("node-fetch").default + : typeof fetch == "function" + ? fetch + : require("node-fetch").default; + + const makeRequest = async (): Promise => { + const controller = new AbortController(); + let abortId = undefined; + if (args.timeoutMs != null) { + abortId = setTimeout(() => controller.abort(), args.timeoutMs); + } + const response = await fetchFn(url, { + method: args.method, + headers, + body, + signal: controller.signal, + credentials: args.withCredentials ? "include" : undefined, + }); + if (abortId != null) { + clearTimeout(abortId); + } + return response; + }; + + try { + let response = await makeRequest(); + + for (let i = 0; i < (args.maxRetries ?? DEFAULT_MAX_RETRIES); ++i) { + if ( + response.status === 408 || + response.status === 409 || + response.status === 429 || + response.status >= 500 + ) { + const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(i, 2), MAX_RETRY_DELAY); + await new Promise((resolve) => setTimeout(resolve, delay)); + response = await makeRequest(); + } else { + break; + } + } + + let body: unknown; + if (response.body != null && args.responseType === "blob") { + body = await response.blob(); + } else if (response.body != null && args.responseType === "streaming") { + body = response.body; + } else { + const text = await response.text(); + if (text.length > 0) { + try { + body = JSON.parse(text); + } catch (err) { + return { + ok: false, + error: { + reason: "non-json", + statusCode: response.status, + rawBody: text, + }, + }; + } + } + } + + if (response.status >= 200 && response.status < 400) { + return { + ok: true, + body: body as R, + headers: response.headers, + }; + } else { + return { + ok: false, + error: { + reason: "status-code", + statusCode: response.status, + body, + }, + }; + } + } catch (error) { + if (error instanceof Error && error.name === "AbortError") { + return { + ok: false, + error: { + reason: "timeout", + }, + }; + } else if (error instanceof Error) { + return { + ok: false, + error: { + reason: "unknown", + errorMessage: error.message, + }, + }; + } + + return { + ok: false, + error: { + reason: "unknown", + errorMessage: JSON.stringify(error), + }, + }; + } +} + +export const fetcher: FetchFunction = fetcherImpl; diff --git a/src/core/fetcher/Supplier.ts b/src/core/fetcher/Supplier.ts new file mode 100644 index 0000000..867c931 --- /dev/null +++ b/src/core/fetcher/Supplier.ts @@ -0,0 +1,11 @@ +export type Supplier = T | Promise | (() => T | Promise); + +export const Supplier = { + get: async (supplier: Supplier): Promise => { + if (typeof supplier === "function") { + return (supplier as () => T)(); + } else { + return supplier; + } + }, +}; diff --git a/src/core/fetcher/getHeader.ts b/src/core/fetcher/getHeader.ts new file mode 100644 index 0000000..50f922b --- /dev/null +++ b/src/core/fetcher/getHeader.ts @@ -0,0 +1,8 @@ +export function getHeader(headers: Record, header: string): string | undefined { + for (const [headerKey, headerValue] of Object.entries(headers)) { + if (headerKey.toLowerCase() === header.toLowerCase()) { + return headerValue; + } + } + return undefined; +} diff --git a/src/core/fetcher/index.ts b/src/core/fetcher/index.ts new file mode 100644 index 0000000..2d658ca --- /dev/null +++ b/src/core/fetcher/index.ts @@ -0,0 +1,5 @@ +export type { APIResponse } from "./APIResponse"; +export { fetcher } from "./Fetcher"; +export type { Fetcher, FetchFunction } from "./Fetcher"; +export { getHeader } from "./getHeader"; +export { Supplier } from "./Supplier"; diff --git a/src/core/index.ts b/src/core/index.ts new file mode 100644 index 0000000..2d20c46 --- /dev/null +++ b/src/core/index.ts @@ -0,0 +1,4 @@ +export * from "./fetcher"; +export * from "./auth"; +export * from "./runtime"; +export * as serialization from "./schemas"; diff --git a/src/core/runtime/index.ts b/src/core/runtime/index.ts new file mode 100644 index 0000000..5c76dbb --- /dev/null +++ b/src/core/runtime/index.ts @@ -0,0 +1 @@ +export { RUNTIME } from "./runtime"; diff --git a/src/core/runtime/runtime.ts b/src/core/runtime/runtime.ts new file mode 100644 index 0000000..f0692ab --- /dev/null +++ b/src/core/runtime/runtime.ts @@ -0,0 +1,112 @@ +interface DenoGlobal { + version: { + deno: string; + }; +} + +interface BunGlobal { + version: string; +} + +declare const Deno: DenoGlobal; +declare const Bun: BunGlobal; + +/** + * A constant that indicates whether the environment the code is running is a Web Browser. + */ +const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined"; + +/** + * A constant that indicates whether the environment the code is running is a Web Worker. + */ +const isWebWorker = + typeof self === "object" && + // @ts-ignore + typeof self?.importScripts === "function" && + (self.constructor?.name === "DedicatedWorkerGlobalScope" || + self.constructor?.name === "ServiceWorkerGlobalScope" || + self.constructor?.name === "SharedWorkerGlobalScope"); + +/** + * A constant that indicates whether the environment the code is running is Deno. + */ +const isDeno = + typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined"; + +/** + * A constant that indicates whether the environment the code is running is Bun.sh. + */ +const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined"; + +/** + * A constant that indicates whether the environment the code is running is Node.JS. + */ +const isNode = + typeof process !== "undefined" && + Boolean(process.version) && + Boolean(process.versions?.node) && + // Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions + !isDeno && + !isBun; + +/** + * A constant that indicates whether the environment the code is running is in React-Native. + * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js + */ +const isReactNative = typeof navigator !== "undefined" && navigator?.product === "ReactNative"; + +/** + * A constant that indicates which environment and version the SDK is running in. + */ +export const RUNTIME: Runtime = evaluateRuntime(); + +export interface Runtime { + type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown"; + version?: string; +} + +function evaluateRuntime(): Runtime { + if (isBrowser) { + return { + type: "browser", + version: window.navigator.userAgent, + }; + } + + if (isWebWorker) { + return { + type: "web-worker", + }; + } + + if (isDeno) { + return { + type: "deno", + version: Deno.version.deno, + }; + } + + if (isBun) { + return { + type: "bun", + version: Bun.version, + }; + } + + if (isNode) { + return { + type: "node", + version: process.versions.node, + }; + } + + if (isReactNative) { + return { + type: "react-native", + }; + } + + return { + type: "unknown", + }; +} diff --git a/src/core/schemas/Schema.ts b/src/core/schemas/Schema.ts new file mode 100644 index 0000000..870f373 --- /dev/null +++ b/src/core/schemas/Schema.ts @@ -0,0 +1,94 @@ +import { SchemaUtils } from "./builders"; +import { MaybePromise } from "./utils/MaybePromise"; + +export type Schema = BaseSchema & SchemaUtils; + +export type inferRaw = S extends Schema ? Raw : never; +export type inferParsed = S extends Schema ? Parsed : never; + +export interface BaseSchema { + parse: (raw: unknown, opts?: SchemaOptions) => MaybePromise>; + json: (parsed: unknown, opts?: SchemaOptions) => MaybePromise>; + getType: () => SchemaType | Promise; +} + +export const SchemaType = { + DATE: "date", + ENUM: "enum", + LIST: "list", + STRING_LITERAL: "stringLiteral", + BOOLEAN_LITERAL: "booleanLiteral", + OBJECT: "object", + ANY: "any", + BOOLEAN: "boolean", + NUMBER: "number", + STRING: "string", + UNKNOWN: "unknown", + RECORD: "record", + SET: "set", + UNION: "union", + UNDISCRIMINATED_UNION: "undiscriminatedUnion", + OPTIONAL: "optional", +} as const; +export type SchemaType = typeof SchemaType[keyof typeof SchemaType]; + +export type MaybeValid = Valid | Invalid; + +export interface Valid { + ok: true; + value: T; +} + +export interface Invalid { + ok: false; + errors: ValidationError[]; +} + +export interface ValidationError { + path: string[]; + message: string; +} + +export interface SchemaOptions { + /** + * how to handle unrecognized keys in objects + * + * @default "fail" + */ + unrecognizedObjectKeys?: "fail" | "passthrough" | "strip"; + + /** + * whether to fail when an unrecognized discriminant value is + * encountered in a union + * + * @default false + */ + allowUnrecognizedUnionMembers?: boolean; + + /** + * whether to fail when an unrecognized enum value is encountered + * + * @default false + */ + allowUnrecognizedEnumValues?: boolean; + + /** + * whether to allow data that doesn't conform to the schema. + * invalid data is passed through without transformation. + * + * when this is enabled, .parse() and .json() will always + * return `ok: true`. `.parseOrThrow()` and `.jsonOrThrow()` + * will never fail. + * + * @default false + */ + skipValidation?: boolean; + + /** + * each validation failure contains a "path" property, which is + * the breadcrumbs to the offending node in the JSON. you can supply + * a prefix that is prepended to all the errors' paths. this can be + * helpful for zurg's internal debug logging. + */ + breadcrumbsPrefix?: string[]; +} diff --git a/src/core/schemas/builders/date/date.ts b/src/core/schemas/builders/date/date.ts new file mode 100644 index 0000000..b70f24b --- /dev/null +++ b/src/core/schemas/builders/date/date.ts @@ -0,0 +1,65 @@ +import { BaseSchema, Schema, SchemaType } from "../../Schema"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; +import { getSchemaUtils } from "../schema-utils"; + +// https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime +const ISO_8601_REGEX = + /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; + +export function date(): Schema { + const baseSchema: BaseSchema = { + parse: (raw, { breadcrumbsPrefix = [] } = {}) => { + if (typeof raw !== "string") { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(raw, "string"), + }, + ], + }; + } + if (!ISO_8601_REGEX.test(raw)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(raw, "ISO 8601 date string"), + }, + ], + }; + } + return { + ok: true, + value: new Date(raw), + }; + }, + json: (date, { breadcrumbsPrefix = [] } = {}) => { + if (date instanceof Date) { + return { + ok: true, + value: date.toISOString(), + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(date, "Date object"), + }, + ], + }; + } + }, + getType: () => SchemaType.DATE, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + }; +} diff --git a/src/core/schemas/builders/date/index.ts b/src/core/schemas/builders/date/index.ts new file mode 100644 index 0000000..187b290 --- /dev/null +++ b/src/core/schemas/builders/date/index.ts @@ -0,0 +1 @@ +export { date } from "./date"; diff --git a/src/core/schemas/builders/enum/enum.ts b/src/core/schemas/builders/enum/enum.ts new file mode 100644 index 0000000..c1e24d6 --- /dev/null +++ b/src/core/schemas/builders/enum/enum.ts @@ -0,0 +1,43 @@ +import { Schema, SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; + +export function enum_(values: E): Schema { + const validValues = new Set(values); + + const schemaCreator = createIdentitySchemaCreator( + SchemaType.ENUM, + (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => { + if (typeof value !== "string") { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "string"), + }, + ], + }; + } + + if (!validValues.has(value) && !allowUnrecognizedEnumValues) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "enum"), + }, + ], + }; + } + + return { + ok: true, + value: value as U, + }; + } + ); + + return schemaCreator(); +} diff --git a/src/core/schemas/builders/enum/index.ts b/src/core/schemas/builders/enum/index.ts new file mode 100644 index 0000000..fe6faed --- /dev/null +++ b/src/core/schemas/builders/enum/index.ts @@ -0,0 +1 @@ +export { enum_ } from "./enum"; diff --git a/src/core/schemas/builders/index.ts b/src/core/schemas/builders/index.ts new file mode 100644 index 0000000..050cd2c --- /dev/null +++ b/src/core/schemas/builders/index.ts @@ -0,0 +1,13 @@ +export * from "./date"; +export * from "./enum"; +export * from "./lazy"; +export * from "./list"; +export * from "./literals"; +export * from "./object"; +export * from "./object-like"; +export * from "./primitives"; +export * from "./record"; +export * from "./schema-utils"; +export * from "./set"; +export * from "./undiscriminated-union"; +export * from "./union"; diff --git a/src/core/schemas/builders/lazy/index.ts b/src/core/schemas/builders/lazy/index.ts new file mode 100644 index 0000000..77420fb --- /dev/null +++ b/src/core/schemas/builders/lazy/index.ts @@ -0,0 +1,3 @@ +export { lazy } from "./lazy"; +export type { SchemaGetter } from "./lazy"; +export { lazyObject } from "./lazyObject"; diff --git a/src/core/schemas/builders/lazy/lazy.ts b/src/core/schemas/builders/lazy/lazy.ts new file mode 100644 index 0000000..a665472 --- /dev/null +++ b/src/core/schemas/builders/lazy/lazy.ts @@ -0,0 +1,34 @@ +import { BaseSchema, Schema } from "../../Schema"; +import { getSchemaUtils } from "../schema-utils"; + +export type SchemaGetter> = () => SchemaType | Promise; + +export function lazy(getter: SchemaGetter>): Schema { + const baseSchema = constructLazyBaseSchema(getter); + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; +} + +export function constructLazyBaseSchema( + getter: SchemaGetter> +): BaseSchema { + return { + parse: async (raw, opts) => (await getMemoizedSchema(getter)).parse(raw, opts), + json: async (parsed, opts) => (await getMemoizedSchema(getter)).json(parsed, opts), + getType: async () => (await getMemoizedSchema(getter)).getType(), + }; +} + +type MemoizedGetter> = SchemaGetter & { __zurg_memoized?: SchemaType }; + +export async function getMemoizedSchema>( + getter: SchemaGetter +): Promise { + const castedGetter = getter as MemoizedGetter; + if (castedGetter.__zurg_memoized == null) { + castedGetter.__zurg_memoized = await getter(); + } + return castedGetter.__zurg_memoized; +} diff --git a/src/core/schemas/builders/lazy/lazyObject.ts b/src/core/schemas/builders/lazy/lazyObject.ts new file mode 100644 index 0000000..e48c016 --- /dev/null +++ b/src/core/schemas/builders/lazy/lazyObject.ts @@ -0,0 +1,20 @@ +import { getObjectUtils } from "../object"; +import { getObjectLikeUtils } from "../object-like"; +import { BaseObjectSchema, ObjectSchema } from "../object/types"; +import { getSchemaUtils } from "../schema-utils"; +import { constructLazyBaseSchema, getMemoizedSchema, SchemaGetter } from "./lazy"; + +export function lazyObject(getter: SchemaGetter>): ObjectSchema { + const baseSchema: BaseObjectSchema = { + ...constructLazyBaseSchema(getter), + _getRawProperties: async () => (await getMemoizedSchema(getter))._getRawProperties(), + _getParsedProperties: async () => (await getMemoizedSchema(getter))._getParsedProperties(), + }; + + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + ...getObjectLikeUtils(baseSchema), + ...getObjectUtils(baseSchema), + }; +} diff --git a/src/core/schemas/builders/list/index.ts b/src/core/schemas/builders/list/index.ts new file mode 100644 index 0000000..25f4bcc --- /dev/null +++ b/src/core/schemas/builders/list/index.ts @@ -0,0 +1 @@ +export { list } from "./list"; diff --git a/src/core/schemas/builders/list/list.ts b/src/core/schemas/builders/list/list.ts new file mode 100644 index 0000000..b333321 --- /dev/null +++ b/src/core/schemas/builders/list/list.ts @@ -0,0 +1,74 @@ +import { BaseSchema, MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; +import { getSchemaUtils } from "../schema-utils"; + +export function list(schema: Schema): Schema { + const baseSchema: BaseSchema = { + parse: async (raw, opts) => + validateAndTransformArray(raw, (item, index) => + schema.parse(item, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `[${index}]`], + }) + ), + json: (parsed, opts) => + validateAndTransformArray(parsed, (item, index) => + schema.json(item, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `[${index}]`], + }) + ), + getType: () => SchemaType.LIST, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + }; +} + +async function validateAndTransformArray( + value: unknown, + transformItem: (item: Raw, index: number) => MaybePromise> +): Promise> { + if (!Array.isArray(value)) { + return { + ok: false, + errors: [ + { + message: getErrorMessageForIncorrectType(value, "list"), + path: [], + }, + ], + }; + } + + const maybeValidItems = await Promise.all(value.map((item, index) => transformItem(item, index))); + + return maybeValidItems.reduce>( + (acc, item) => { + if (acc.ok && item.ok) { + return { + ok: true, + value: [...acc.value, item.value], + }; + } + + const errors: ValidationError[] = []; + if (!acc.ok) { + errors.push(...acc.errors); + } + if (!item.ok) { + errors.push(...item.errors); + } + + return { + ok: false, + errors, + }; + }, + { ok: true, value: [] } + ); +} diff --git a/src/core/schemas/builders/literals/booleanLiteral.ts b/src/core/schemas/builders/literals/booleanLiteral.ts new file mode 100644 index 0000000..a83d22c --- /dev/null +++ b/src/core/schemas/builders/literals/booleanLiteral.ts @@ -0,0 +1,29 @@ +import { Schema, SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; + +export function booleanLiteral(literal: V): Schema { + const schemaCreator = createIdentitySchemaCreator( + SchemaType.BOOLEAN_LITERAL, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (value === literal) { + return { + ok: true, + value: literal, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, `${literal.toString()}`), + }, + ], + }; + } + } + ); + + return schemaCreator(); +} diff --git a/src/core/schemas/builders/literals/index.ts b/src/core/schemas/builders/literals/index.ts new file mode 100644 index 0000000..d2bf08f --- /dev/null +++ b/src/core/schemas/builders/literals/index.ts @@ -0,0 +1,2 @@ +export { stringLiteral } from "./stringLiteral"; +export { booleanLiteral } from "./booleanLiteral"; diff --git a/src/core/schemas/builders/literals/stringLiteral.ts b/src/core/schemas/builders/literals/stringLiteral.ts new file mode 100644 index 0000000..3939b76 --- /dev/null +++ b/src/core/schemas/builders/literals/stringLiteral.ts @@ -0,0 +1,29 @@ +import { Schema, SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; + +export function stringLiteral(literal: V): Schema { + const schemaCreator = createIdentitySchemaCreator( + SchemaType.STRING_LITERAL, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (value === literal) { + return { + ok: true, + value: literal, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, `"${literal}"`), + }, + ], + }; + } + } + ); + + return schemaCreator(); +} diff --git a/src/core/schemas/builders/object-like/getObjectLikeUtils.ts b/src/core/schemas/builders/object-like/getObjectLikeUtils.ts new file mode 100644 index 0000000..270ea17 --- /dev/null +++ b/src/core/schemas/builders/object-like/getObjectLikeUtils.ts @@ -0,0 +1,79 @@ +import { BaseSchema } from "../../Schema"; +import { filterObject } from "../../utils/filterObject"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { isPlainObject } from "../../utils/isPlainObject"; +import { getSchemaUtils } from "../schema-utils"; +import { ObjectLikeSchema, ObjectLikeUtils } from "./types"; + +export function getObjectLikeUtils(schema: BaseSchema): ObjectLikeUtils { + return { + withParsedProperties: (properties) => withParsedProperties(schema, properties), + }; +} + +/** + * object-like utils are defined in one file to resolve issues with circular imports + */ + +export function withParsedProperties( + objectLike: BaseSchema, + properties: { [K in keyof Properties]: Properties[K] | ((parsed: ParsedObjectShape) => Properties[K]) } +): ObjectLikeSchema { + const objectSchema: BaseSchema = { + parse: async (raw, opts) => { + const parsedObject = await objectLike.parse(raw, opts); + if (!parsedObject.ok) { + return parsedObject; + } + + const additionalProperties = Object.entries(properties).reduce>( + (processed, [key, value]) => { + return { + ...processed, + [key]: typeof value === "function" ? value(parsedObject.value) : value, + }; + }, + {} + ); + + return { + ok: true, + value: { + ...parsedObject.value, + ...(additionalProperties as Properties), + }, + }; + }, + + json: (parsed, opts) => { + if (!isPlainObject(parsed)) { + return { + ok: false, + errors: [ + { + path: opts?.breadcrumbsPrefix ?? [], + message: getErrorMessageForIncorrectType(parsed, "object"), + }, + ], + }; + } + + // strip out added properties + const addedPropertyKeys = new Set(Object.keys(properties)); + const parsedWithoutAddedProperties = filterObject( + parsed, + Object.keys(parsed).filter((key) => !addedPropertyKeys.has(key)) + ); + + return objectLike.json(parsedWithoutAddedProperties as ParsedObjectShape, opts); + }, + + getType: () => objectLike.getType(), + }; + + return { + ...objectSchema, + ...getSchemaUtils(objectSchema), + ...getObjectLikeUtils(objectSchema), + }; +} diff --git a/src/core/schemas/builders/object-like/index.ts b/src/core/schemas/builders/object-like/index.ts new file mode 100644 index 0000000..c342e72 --- /dev/null +++ b/src/core/schemas/builders/object-like/index.ts @@ -0,0 +1,2 @@ +export { getObjectLikeUtils, withParsedProperties } from "./getObjectLikeUtils"; +export type { ObjectLikeSchema, ObjectLikeUtils } from "./types"; diff --git a/src/core/schemas/builders/object-like/types.ts b/src/core/schemas/builders/object-like/types.ts new file mode 100644 index 0000000..75b3698 --- /dev/null +++ b/src/core/schemas/builders/object-like/types.ts @@ -0,0 +1,11 @@ +import { BaseSchema, Schema } from "../../Schema"; + +export type ObjectLikeSchema = Schema & + BaseSchema & + ObjectLikeUtils; + +export interface ObjectLikeUtils { + withParsedProperties: >(properties: { + [K in keyof T]: T[K] | ((parsed: Parsed) => T[K]); + }) => ObjectLikeSchema; +} diff --git a/src/core/schemas/builders/object/index.ts b/src/core/schemas/builders/object/index.ts new file mode 100644 index 0000000..e3f4388 --- /dev/null +++ b/src/core/schemas/builders/object/index.ts @@ -0,0 +1,22 @@ +export { getObjectUtils, object } from "./object"; +export { objectWithoutOptionalProperties } from "./objectWithoutOptionalProperties"; +export type { + inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas, + inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas, +} from "./objectWithoutOptionalProperties"; +export { isProperty, property } from "./property"; +export type { Property } from "./property"; +export type { + BaseObjectSchema, + inferObjectSchemaFromPropertySchemas, + inferParsedObject, + inferParsedObjectFromPropertySchemas, + inferParsedPropertySchema, + inferRawKey, + inferRawObject, + inferRawObjectFromPropertySchemas, + inferRawPropertySchema, + ObjectSchema, + ObjectUtils, + PropertySchemas, +} from "./types"; diff --git a/src/core/schemas/builders/object/object.ts b/src/core/schemas/builders/object/object.ts new file mode 100644 index 0000000..6427678 --- /dev/null +++ b/src/core/schemas/builders/object/object.ts @@ -0,0 +1,333 @@ +import { MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; +import { entries } from "../../utils/entries"; +import { filterObject } from "../../utils/filterObject"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { isPlainObject } from "../../utils/isPlainObject"; +import { keys } from "../../utils/keys"; +import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; +import { partition } from "../../utils/partition"; +import { getObjectLikeUtils } from "../object-like"; +import { getSchemaUtils } from "../schema-utils"; +import { isProperty } from "./property"; +import { + BaseObjectSchema, + inferObjectSchemaFromPropertySchemas, + inferParsedObjectFromPropertySchemas, + inferRawObjectFromPropertySchemas, + ObjectSchema, + ObjectUtils, + PropertySchemas, +} from "./types"; + +interface ObjectPropertyWithRawKey { + rawKey: string; + parsedKey: string; + valueSchema: Schema; +} + +export function object>( + schemas: T +): inferObjectSchemaFromPropertySchemas { + const baseSchema: BaseObjectSchema< + inferRawObjectFromPropertySchemas, + inferParsedObjectFromPropertySchemas + > = { + _getRawProperties: () => + Promise.resolve( + Object.entries(schemas).map(([parsedKey, propertySchema]) => + isProperty(propertySchema) ? propertySchema.rawKey : parsedKey + ) as unknown as (keyof inferRawObjectFromPropertySchemas)[] + ), + _getParsedProperties: () => + Promise.resolve(keys(schemas) as unknown as (keyof inferParsedObjectFromPropertySchemas)[]), + + parse: async (raw, opts) => { + const rawKeyToProperty: Record = {}; + const requiredKeys: string[] = []; + + for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) { + const rawKey = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey; + const valueSchema: Schema = isProperty(schemaOrObjectProperty) + ? schemaOrObjectProperty.valueSchema + : schemaOrObjectProperty; + + const property: ObjectPropertyWithRawKey = { + rawKey, + parsedKey: parsedKey as string, + valueSchema, + }; + + rawKeyToProperty[rawKey] = property; + + if (isSchemaRequired(valueSchema)) { + requiredKeys.push(rawKey); + } + } + + return validateAndTransformObject({ + value: raw, + requiredKeys, + getProperty: (rawKey) => { + const property = rawKeyToProperty[rawKey]; + if (property == null) { + return undefined; + } + return { + transformedKey: property.parsedKey, + transform: (propertyValue) => + property.valueSchema.parse(propertyValue, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), rawKey], + }), + }; + }, + unrecognizedObjectKeys: opts?.unrecognizedObjectKeys, + skipValidation: opts?.skipValidation, + breadcrumbsPrefix: opts?.breadcrumbsPrefix, + }); + }, + + json: async (parsed, opts) => { + const requiredKeys: string[] = []; + + for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) { + const valueSchema: Schema = isProperty(schemaOrObjectProperty) + ? schemaOrObjectProperty.valueSchema + : schemaOrObjectProperty; + + if (isSchemaRequired(valueSchema)) { + requiredKeys.push(parsedKey as string); + } + } + + return validateAndTransformObject({ + value: parsed, + requiredKeys, + getProperty: ( + parsedKey + ): + | { transformedKey: string; transform: (propertyValue: unknown) => MaybePromise> } + | undefined => { + const property = schemas[parsedKey as keyof T]; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (property == null) { + return undefined; + } + + if (isProperty(property)) { + return { + transformedKey: property.rawKey, + transform: (propertyValue) => + property.valueSchema.json(propertyValue, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), parsedKey], + }), + }; + } else { + return { + transformedKey: parsedKey, + transform: (propertyValue) => + property.json(propertyValue, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), parsedKey], + }), + }; + } + }, + unrecognizedObjectKeys: opts?.unrecognizedObjectKeys, + skipValidation: opts?.skipValidation, + breadcrumbsPrefix: opts?.breadcrumbsPrefix, + }); + }, + + getType: () => SchemaType.OBJECT, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + ...getObjectLikeUtils(baseSchema), + ...getObjectUtils(baseSchema), + }; +} + +async function validateAndTransformObject({ + value, + requiredKeys, + getProperty, + unrecognizedObjectKeys = "fail", + skipValidation = false, + breadcrumbsPrefix = [], +}: { + value: unknown; + requiredKeys: string[]; + getProperty: ( + preTransformedKey: string + ) => { transformedKey: string; transform: (propertyValue: unknown) => MaybePromise> } | undefined; + unrecognizedObjectKeys: "fail" | "passthrough" | "strip" | undefined; + skipValidation: boolean | undefined; + breadcrumbsPrefix: string[] | undefined; +}): Promise> { + if (!isPlainObject(value)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "object"), + }, + ], + }; + } + + const missingRequiredKeys = new Set(requiredKeys); + const errors: ValidationError[] = []; + const transformed: Record = {}; + + for (const [preTransformedKey, preTransformedItemValue] of Object.entries(value)) { + const property = getProperty(preTransformedKey); + + if (property != null) { + missingRequiredKeys.delete(preTransformedKey); + + const value = await property.transform(preTransformedItemValue); + if (value.ok) { + transformed[property.transformedKey] = value.value; + } else { + transformed[preTransformedKey] = preTransformedItemValue; + errors.push(...value.errors); + } + } else { + switch (unrecognizedObjectKeys) { + case "fail": + errors.push({ + path: [...breadcrumbsPrefix, preTransformedKey], + message: `Unexpected key "${preTransformedKey}"`, + }); + break; + case "strip": + break; + case "passthrough": + transformed[preTransformedKey] = preTransformedItemValue; + break; + } + } + } + + errors.push( + ...requiredKeys + .filter((key) => missingRequiredKeys.has(key)) + .map((key) => ({ + path: breadcrumbsPrefix, + message: `Missing required key "${key}"`, + })) + ); + + if (errors.length === 0 || skipValidation) { + return { + ok: true, + value: transformed as Transformed, + }; + } else { + return { + ok: false, + errors, + }; + } +} + +export function getObjectUtils(schema: BaseObjectSchema): ObjectUtils { + return { + extend: (extension: ObjectSchema) => { + const baseSchema: BaseObjectSchema = { + _getParsedProperties: async () => [ + ...(await schema._getParsedProperties()), + ...(await extension._getParsedProperties()), + ], + _getRawProperties: async () => [ + ...(await schema._getRawProperties()), + ...(await extension._getRawProperties()), + ], + parse: async (raw, opts) => { + return validateAndTransformExtendedObject({ + extensionKeys: await extension._getRawProperties(), + value: raw, + transformBase: (rawBase) => schema.parse(rawBase, opts), + transformExtension: (rawExtension) => extension.parse(rawExtension, opts), + }); + }, + json: async (parsed, opts) => { + return validateAndTransformExtendedObject({ + extensionKeys: await extension._getParsedProperties(), + value: parsed, + transformBase: (parsedBase) => schema.json(parsedBase, opts), + transformExtension: (parsedExtension) => extension.json(parsedExtension, opts), + }); + }, + getType: () => SchemaType.OBJECT, + }; + + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + ...getObjectLikeUtils(baseSchema), + ...getObjectUtils(baseSchema), + }; + }, + }; +} + +async function validateAndTransformExtendedObject({ + extensionKeys, + value, + transformBase, + transformExtension, +}: { + extensionKeys: (keyof PreTransformedExtension)[]; + value: unknown; + transformBase: (value: unknown) => MaybePromise>; + transformExtension: (value: unknown) => MaybePromise>; +}): Promise> { + const extensionPropertiesSet = new Set(extensionKeys); + const [extensionProperties, baseProperties] = partition(keys(value), (key) => + extensionPropertiesSet.has(key as keyof PreTransformedExtension) + ); + + const transformedBase = await transformBase(filterObject(value, baseProperties)); + const transformedExtension = await transformExtension(filterObject(value, extensionProperties)); + + if (transformedBase.ok && transformedExtension.ok) { + return { + ok: true, + value: { + ...transformedBase.value, + ...transformedExtension.value, + }, + }; + } else { + return { + ok: false, + errors: [ + ...(transformedBase.ok ? [] : transformedBase.errors), + ...(transformedExtension.ok ? [] : transformedExtension.errors), + ], + }; + } +} + +function isSchemaRequired(schema: Schema): boolean { + return !isSchemaOptional(schema); +} + +function isSchemaOptional(schema: Schema): boolean { + switch (schema.getType()) { + case SchemaType.ANY: + case SchemaType.UNKNOWN: + case SchemaType.OPTIONAL: + return true; + default: + return false; + } +} diff --git a/src/core/schemas/builders/object/objectWithoutOptionalProperties.ts b/src/core/schemas/builders/object/objectWithoutOptionalProperties.ts new file mode 100644 index 0000000..a0951f4 --- /dev/null +++ b/src/core/schemas/builders/object/objectWithoutOptionalProperties.ts @@ -0,0 +1,18 @@ +import { object } from "./object"; +import { inferParsedPropertySchema, inferRawObjectFromPropertySchemas, ObjectSchema, PropertySchemas } from "./types"; + +export function objectWithoutOptionalProperties>( + schemas: T +): inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas { + return object(schemas) as unknown as inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas; +} + +export type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas> = + ObjectSchema< + inferRawObjectFromPropertySchemas, + inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas + >; + +export type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas> = { + [K in keyof T]: inferParsedPropertySchema; +}; diff --git a/src/core/schemas/builders/object/property.ts b/src/core/schemas/builders/object/property.ts new file mode 100644 index 0000000..d245c4b --- /dev/null +++ b/src/core/schemas/builders/object/property.ts @@ -0,0 +1,23 @@ +import { Schema } from "../../Schema"; + +export function property( + rawKey: RawKey, + valueSchema: Schema +): Property { + return { + rawKey, + valueSchema, + isProperty: true, + }; +} + +export interface Property { + rawKey: RawKey; + valueSchema: Schema; + isProperty: true; +} + +export function isProperty>(maybeProperty: unknown): maybeProperty is O { + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + return (maybeProperty as O).isProperty; +} diff --git a/src/core/schemas/builders/object/types.ts b/src/core/schemas/builders/object/types.ts new file mode 100644 index 0000000..17cff4f --- /dev/null +++ b/src/core/schemas/builders/object/types.ts @@ -0,0 +1,72 @@ +import { BaseSchema, inferParsed, inferRaw, Schema } from "../../Schema"; +import { addQuestionMarksToNullableProperties } from "../../utils/addQuestionMarksToNullableProperties"; +import { ObjectLikeUtils } from "../object-like"; +import { SchemaUtils } from "../schema-utils"; +import { Property } from "./property"; + +export type ObjectSchema = BaseObjectSchema & + ObjectLikeUtils & + ObjectUtils & + SchemaUtils; + +export interface BaseObjectSchema extends BaseSchema { + _getRawProperties: () => Promise<(keyof Raw)[]>; + _getParsedProperties: () => Promise<(keyof Parsed)[]>; +} + +export interface ObjectUtils { + extend: ( + schemas: ObjectSchema + ) => ObjectSchema; +} + +export type inferRawObject> = O extends ObjectSchema ? Raw : never; + +export type inferParsedObject> = O extends ObjectSchema + ? Parsed + : never; + +export type inferObjectSchemaFromPropertySchemas> = ObjectSchema< + inferRawObjectFromPropertySchemas, + inferParsedObjectFromPropertySchemas +>; + +export type inferRawObjectFromPropertySchemas> = + addQuestionMarksToNullableProperties<{ + [ParsedKey in keyof T as inferRawKey]: inferRawPropertySchema; + }>; + +export type inferParsedObjectFromPropertySchemas> = + addQuestionMarksToNullableProperties<{ + [K in keyof T]: inferParsedPropertySchema; + }>; + +export type PropertySchemas = Record< + ParsedKeys, + Property | Schema +>; + +export type inferRawPropertySchema

| Schema> = P extends Property< + any, + infer Raw, + any +> + ? Raw + : P extends Schema + ? inferRaw

+ : never; + +export type inferParsedPropertySchema

| Schema> = P extends Property< + any, + any, + infer Parsed +> + ? Parsed + : P extends Schema + ? inferParsed

+ : never; + +export type inferRawKey< + ParsedKey extends string | number | symbol, + P extends Property | Schema +> = P extends Property ? Raw : ParsedKey; diff --git a/src/core/schemas/builders/primitives/any.ts b/src/core/schemas/builders/primitives/any.ts new file mode 100644 index 0000000..fcaeb04 --- /dev/null +++ b/src/core/schemas/builders/primitives/any.ts @@ -0,0 +1,4 @@ +import { SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; + +export const any = createIdentitySchemaCreator(SchemaType.ANY, (value) => ({ ok: true, value })); diff --git a/src/core/schemas/builders/primitives/boolean.ts b/src/core/schemas/builders/primitives/boolean.ts new file mode 100644 index 0000000..fad6056 --- /dev/null +++ b/src/core/schemas/builders/primitives/boolean.ts @@ -0,0 +1,25 @@ +import { SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; + +export const boolean = createIdentitySchemaCreator( + SchemaType.BOOLEAN, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "boolean") { + return { + ok: true, + value, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "boolean"), + }, + ], + }; + } + } +); diff --git a/src/core/schemas/builders/primitives/index.ts b/src/core/schemas/builders/primitives/index.ts new file mode 100644 index 0000000..788f941 --- /dev/null +++ b/src/core/schemas/builders/primitives/index.ts @@ -0,0 +1,5 @@ +export { any } from "./any"; +export { boolean } from "./boolean"; +export { number } from "./number"; +export { string } from "./string"; +export { unknown } from "./unknown"; diff --git a/src/core/schemas/builders/primitives/number.ts b/src/core/schemas/builders/primitives/number.ts new file mode 100644 index 0000000..c268945 --- /dev/null +++ b/src/core/schemas/builders/primitives/number.ts @@ -0,0 +1,25 @@ +import { SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; + +export const number = createIdentitySchemaCreator( + SchemaType.NUMBER, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "number") { + return { + ok: true, + value, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "number"), + }, + ], + }; + } + } +); diff --git a/src/core/schemas/builders/primitives/string.ts b/src/core/schemas/builders/primitives/string.ts new file mode 100644 index 0000000..949f1f2 --- /dev/null +++ b/src/core/schemas/builders/primitives/string.ts @@ -0,0 +1,25 @@ +import { SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; + +export const string = createIdentitySchemaCreator( + SchemaType.STRING, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "string") { + return { + ok: true, + value, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "string"), + }, + ], + }; + } + } +); diff --git a/src/core/schemas/builders/primitives/unknown.ts b/src/core/schemas/builders/primitives/unknown.ts new file mode 100644 index 0000000..4d52495 --- /dev/null +++ b/src/core/schemas/builders/primitives/unknown.ts @@ -0,0 +1,4 @@ +import { SchemaType } from "../../Schema"; +import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; + +export const unknown = createIdentitySchemaCreator(SchemaType.UNKNOWN, (value) => ({ ok: true, value })); diff --git a/src/core/schemas/builders/record/index.ts b/src/core/schemas/builders/record/index.ts new file mode 100644 index 0000000..82e25c5 --- /dev/null +++ b/src/core/schemas/builders/record/index.ts @@ -0,0 +1,2 @@ +export { record } from "./record"; +export type { BaseRecordSchema, RecordSchema } from "./types"; diff --git a/src/core/schemas/builders/record/record.ts b/src/core/schemas/builders/record/record.ts new file mode 100644 index 0000000..ac1cd22 --- /dev/null +++ b/src/core/schemas/builders/record/record.ts @@ -0,0 +1,131 @@ +import { MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; +import { entries } from "../../utils/entries"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { isPlainObject } from "../../utils/isPlainObject"; +import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; +import { getSchemaUtils } from "../schema-utils"; +import { BaseRecordSchema, RecordSchema } from "./types"; + +export function record( + keySchema: Schema, + valueSchema: Schema +): RecordSchema { + const baseSchema: BaseRecordSchema = { + parse: async (raw, opts) => { + return validateAndTransformRecord({ + value: raw, + isKeyNumeric: (await keySchema.getType()) === SchemaType.NUMBER, + transformKey: (key) => + keySchema.parse(key, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key} (key)`], + }), + transformValue: (value, key) => + valueSchema.parse(value, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key}`], + }), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, + }); + }, + json: async (parsed, opts) => { + return validateAndTransformRecord({ + value: parsed, + isKeyNumeric: (await keySchema.getType()) === SchemaType.NUMBER, + transformKey: (key) => + keySchema.json(key, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key} (key)`], + }), + transformValue: (value, key) => + valueSchema.json(value, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key}`], + }), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, + }); + }, + getType: () => SchemaType.RECORD, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + }; +} + +async function validateAndTransformRecord({ + value, + isKeyNumeric, + transformKey, + transformValue, + breadcrumbsPrefix = [], +}: { + value: unknown; + isKeyNumeric: boolean; + transformKey: (key: string | number) => MaybePromise>; + transformValue: (value: unknown, key: string | number) => MaybePromise>; + breadcrumbsPrefix: string[] | undefined; +}): Promise>> { + if (!isPlainObject(value)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "object"), + }, + ], + }; + } + + return entries(value).reduce>>>( + async (accPromise, [stringKey, value]) => { + // skip nullish keys + if (value == null) { + return accPromise; + } + + const acc = await accPromise; + + let key: string | number = stringKey; + if (isKeyNumeric) { + const numberKey = stringKey.length > 0 ? Number(stringKey) : NaN; + if (!isNaN(numberKey)) { + key = numberKey; + } + } + const transformedKey = await transformKey(key); + + const transformedValue = await transformValue(value, key); + + if (acc.ok && transformedKey.ok && transformedValue.ok) { + return { + ok: true, + value: { + ...acc.value, + [transformedKey.value]: transformedValue.value, + }, + }; + } + + const errors: ValidationError[] = []; + if (!acc.ok) { + errors.push(...acc.errors); + } + if (!transformedKey.ok) { + errors.push(...transformedKey.errors); + } + if (!transformedValue.ok) { + errors.push(...transformedValue.errors); + } + + return { + ok: false, + errors, + }; + }, + Promise.resolve({ ok: true, value: {} as Record }) + ); +} diff --git a/src/core/schemas/builders/record/types.ts b/src/core/schemas/builders/record/types.ts new file mode 100644 index 0000000..eb82cc7 --- /dev/null +++ b/src/core/schemas/builders/record/types.ts @@ -0,0 +1,17 @@ +import { BaseSchema } from "../../Schema"; +import { SchemaUtils } from "../schema-utils"; + +export type RecordSchema< + RawKey extends string | number, + RawValue, + ParsedKey extends string | number, + ParsedValue +> = BaseRecordSchema & + SchemaUtils, Record>; + +export type BaseRecordSchema< + RawKey extends string | number, + RawValue, + ParsedKey extends string | number, + ParsedValue +> = BaseSchema, Record>; diff --git a/src/core/schemas/builders/schema-utils/JsonError.ts b/src/core/schemas/builders/schema-utils/JsonError.ts new file mode 100644 index 0000000..2b89ca0 --- /dev/null +++ b/src/core/schemas/builders/schema-utils/JsonError.ts @@ -0,0 +1,9 @@ +import { ValidationError } from "../../Schema"; +import { stringifyValidationError } from "./stringifyValidationErrors"; + +export class JsonError extends Error { + constructor(public readonly errors: ValidationError[]) { + super(errors.map(stringifyValidationError).join("; ")); + Object.setPrototypeOf(this, JsonError.prototype); + } +} diff --git a/src/core/schemas/builders/schema-utils/ParseError.ts b/src/core/schemas/builders/schema-utils/ParseError.ts new file mode 100644 index 0000000..d056eb4 --- /dev/null +++ b/src/core/schemas/builders/schema-utils/ParseError.ts @@ -0,0 +1,9 @@ +import { ValidationError } from "../../Schema"; +import { stringifyValidationError } from "./stringifyValidationErrors"; + +export class ParseError extends Error { + constructor(public readonly errors: ValidationError[]) { + super(errors.map(stringifyValidationError).join("; ")); + Object.setPrototypeOf(this, ParseError.prototype); + } +} diff --git a/src/core/schemas/builders/schema-utils/getSchemaUtils.ts b/src/core/schemas/builders/schema-utils/getSchemaUtils.ts new file mode 100644 index 0000000..0c0d379 --- /dev/null +++ b/src/core/schemas/builders/schema-utils/getSchemaUtils.ts @@ -0,0 +1,99 @@ +import { BaseSchema, Schema, SchemaOptions, SchemaType } from "../../Schema"; +import { JsonError } from "./JsonError"; +import { ParseError } from "./ParseError"; + +export interface SchemaUtils { + optional: () => Schema; + transform: (transformer: SchemaTransformer) => Schema; + parseOrThrow: (raw: unknown, opts?: SchemaOptions) => Promise; + jsonOrThrow: (raw: unknown, opts?: SchemaOptions) => Promise; +} + +export interface SchemaTransformer { + transform: (parsed: Parsed) => Transformed; + untransform: (transformed: any) => Parsed; +} + +export function getSchemaUtils(schema: BaseSchema): SchemaUtils { + return { + optional: () => optional(schema), + transform: (transformer) => transform(schema, transformer), + parseOrThrow: async (raw, opts) => { + const parsed = await schema.parse(raw, opts); + if (parsed.ok) { + return parsed.value; + } + throw new ParseError(parsed.errors); + }, + jsonOrThrow: async (parsed, opts) => { + const raw = await schema.json(parsed, opts); + if (raw.ok) { + return raw.value; + } + throw new JsonError(raw.errors); + }, + }; +} + +/** + * schema utils are defined in one file to resolve issues with circular imports + */ + +export function optional( + schema: BaseSchema +): Schema { + const baseSchema: BaseSchema = { + parse: (raw, opts) => { + if (raw == null) { + return { + ok: true, + value: undefined, + }; + } + return schema.parse(raw, opts); + }, + json: (parsed, opts) => { + if (parsed == null) { + return { + ok: true, + value: null, + }; + } + return schema.json(parsed, opts); + }, + getType: () => SchemaType.OPTIONAL, + }; + + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; +} + +export function transform( + schema: BaseSchema, + transformer: SchemaTransformer +): Schema { + const baseSchema: BaseSchema = { + parse: async (raw, opts) => { + const parsed = await schema.parse(raw, opts); + if (!parsed.ok) { + return parsed; + } + return { + ok: true, + value: transformer.transform(parsed.value), + }; + }, + json: async (transformed, opts) => { + const parsed = await transformer.untransform(transformed); + return schema.json(parsed, opts); + }, + getType: () => schema.getType(), + }; + + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; +} diff --git a/src/core/schemas/builders/schema-utils/index.ts b/src/core/schemas/builders/schema-utils/index.ts new file mode 100644 index 0000000..aa04e05 --- /dev/null +++ b/src/core/schemas/builders/schema-utils/index.ts @@ -0,0 +1,4 @@ +export { getSchemaUtils, optional, transform } from "./getSchemaUtils"; +export type { SchemaUtils } from "./getSchemaUtils"; +export { JsonError } from "./JsonError"; +export { ParseError } from "./ParseError"; diff --git a/src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts b/src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts new file mode 100644 index 0000000..4160f0a --- /dev/null +++ b/src/core/schemas/builders/schema-utils/stringifyValidationErrors.ts @@ -0,0 +1,8 @@ +import { ValidationError } from "../../Schema"; + +export function stringifyValidationError(error: ValidationError): string { + if (error.path.length === 0) { + return error.message; + } + return `${error.path.join(" -> ")}: ${error.message}`; +} diff --git a/src/core/schemas/builders/set/index.ts b/src/core/schemas/builders/set/index.ts new file mode 100644 index 0000000..f3310e8 --- /dev/null +++ b/src/core/schemas/builders/set/index.ts @@ -0,0 +1 @@ +export { set } from "./set"; diff --git a/src/core/schemas/builders/set/set.ts b/src/core/schemas/builders/set/set.ts new file mode 100644 index 0000000..3113bcb --- /dev/null +++ b/src/core/schemas/builders/set/set.ts @@ -0,0 +1,43 @@ +import { BaseSchema, Schema, SchemaType } from "../../Schema"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; +import { list } from "../list"; +import { getSchemaUtils } from "../schema-utils"; + +export function set(schema: Schema): Schema> { + const listSchema = list(schema); + const baseSchema: BaseSchema> = { + parse: async (raw, opts) => { + const parsedList = await listSchema.parse(raw, opts); + if (parsedList.ok) { + return { + ok: true, + value: new Set(parsedList.value), + }; + } else { + return parsedList; + } + }, + json: async (parsed, opts) => { + if (!(parsed instanceof Set)) { + return { + ok: false, + errors: [ + { + path: opts?.breadcrumbsPrefix ?? [], + message: getErrorMessageForIncorrectType(parsed, "Set"), + }, + ], + }; + } + const jsonList = await listSchema.json([...parsed], opts); + return jsonList; + }, + getType: () => SchemaType.SET, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + }; +} diff --git a/src/core/schemas/builders/undiscriminated-union/index.ts b/src/core/schemas/builders/undiscriminated-union/index.ts new file mode 100644 index 0000000..75b71cb --- /dev/null +++ b/src/core/schemas/builders/undiscriminated-union/index.ts @@ -0,0 +1,6 @@ +export type { + inferParsedUnidiscriminatedUnionSchema, + inferRawUnidiscriminatedUnionSchema, + UndiscriminatedUnionSchema, +} from "./types"; +export { undiscriminatedUnion } from "./undiscriminatedUnion"; diff --git a/src/core/schemas/builders/undiscriminated-union/types.ts b/src/core/schemas/builders/undiscriminated-union/types.ts new file mode 100644 index 0000000..43e7108 --- /dev/null +++ b/src/core/schemas/builders/undiscriminated-union/types.ts @@ -0,0 +1,10 @@ +import { inferParsed, inferRaw, Schema } from "../../Schema"; + +export type UndiscriminatedUnionSchema = Schema< + inferRawUnidiscriminatedUnionSchema, + inferParsedUnidiscriminatedUnionSchema +>; + +export type inferRawUnidiscriminatedUnionSchema = inferRaw; + +export type inferParsedUnidiscriminatedUnionSchema = inferParsed; diff --git a/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts b/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts new file mode 100644 index 0000000..771dc6a --- /dev/null +++ b/src/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.ts @@ -0,0 +1,61 @@ +import { BaseSchema, MaybeValid, Schema, SchemaOptions, SchemaType, ValidationError } from "../../Schema"; +import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; +import { getSchemaUtils } from "../schema-utils"; +import { inferParsedUnidiscriminatedUnionSchema, inferRawUnidiscriminatedUnionSchema } from "./types"; + +export function undiscriminatedUnion, ...Schema[]]>( + schemas: Schemas +): Schema, inferParsedUnidiscriminatedUnionSchema> { + const baseSchema: BaseSchema< + inferRawUnidiscriminatedUnionSchema, + inferParsedUnidiscriminatedUnionSchema + > = { + parse: async (raw, opts) => { + return validateAndTransformUndiscriminatedUnion>( + (schema, opts) => schema.parse(raw, opts), + schemas, + opts + ); + }, + json: async (parsed, opts) => { + return validateAndTransformUndiscriminatedUnion>( + (schema, opts) => schema.json(parsed, opts), + schemas, + opts + ); + }, + getType: () => SchemaType.UNDISCRIMINATED_UNION, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + }; +} + +async function validateAndTransformUndiscriminatedUnion( + transform: (schema: Schema, opts: SchemaOptions) => MaybePromise>, + schemas: Schema[], + opts: SchemaOptions | undefined +): Promise> { + const errors: ValidationError[] = []; + for (const [index, schema] of schemas.entries()) { + const transformed = await transform(schema, { ...opts, skipValidation: false }); + if (transformed.ok) { + return transformed; + } else { + for (const error of transformed.errors) { + errors.push({ + path: error.path, + message: `[Variant ${index}] ${error.message}`, + }); + } + } + } + + return { + ok: false, + errors, + }; +} diff --git a/src/core/schemas/builders/union/discriminant.ts b/src/core/schemas/builders/union/discriminant.ts new file mode 100644 index 0000000..55065bc --- /dev/null +++ b/src/core/schemas/builders/union/discriminant.ts @@ -0,0 +1,14 @@ +export function discriminant( + parsedDiscriminant: ParsedDiscriminant, + rawDiscriminant: RawDiscriminant +): Discriminant { + return { + parsedDiscriminant, + rawDiscriminant, + }; +} + +export interface Discriminant { + parsedDiscriminant: ParsedDiscriminant; + rawDiscriminant: RawDiscriminant; +} diff --git a/src/core/schemas/builders/union/index.ts b/src/core/schemas/builders/union/index.ts new file mode 100644 index 0000000..85fc008 --- /dev/null +++ b/src/core/schemas/builders/union/index.ts @@ -0,0 +1,10 @@ +export { discriminant } from "./discriminant"; +export type { Discriminant } from "./discriminant"; +export type { + inferParsedDiscriminant, + inferParsedUnion, + inferRawDiscriminant, + inferRawUnion, + UnionSubtypes, +} from "./types"; +export { union } from "./union"; diff --git a/src/core/schemas/builders/union/types.ts b/src/core/schemas/builders/union/types.ts new file mode 100644 index 0000000..6f82c86 --- /dev/null +++ b/src/core/schemas/builders/union/types.ts @@ -0,0 +1,26 @@ +import { inferParsedObject, inferRawObject, ObjectSchema } from "../object"; +import { Discriminant } from "./discriminant"; + +export type UnionSubtypes = { + [K in DiscriminantValues]: ObjectSchema; +}; + +export type inferRawUnion, U extends UnionSubtypes> = { + [K in keyof U]: Record, K> & inferRawObject; +}[keyof U]; + +export type inferParsedUnion, U extends UnionSubtypes> = { + [K in keyof U]: Record, K> & inferParsedObject; +}[keyof U]; + +export type inferRawDiscriminant> = D extends string + ? D + : D extends Discriminant + ? Raw + : never; + +export type inferParsedDiscriminant> = D extends string + ? D + : D extends Discriminant + ? Parsed + : never; diff --git a/src/core/schemas/builders/union/union.ts b/src/core/schemas/builders/union/union.ts new file mode 100644 index 0000000..ed659be --- /dev/null +++ b/src/core/schemas/builders/union/union.ts @@ -0,0 +1,173 @@ +import { BaseSchema, MaybeValid, SchemaType } from "../../Schema"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { isPlainObject } from "../../utils/isPlainObject"; +import { keys } from "../../utils/keys"; +import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; +import { enum_ } from "../enum"; +import { ObjectSchema } from "../object"; +import { getObjectLikeUtils, ObjectLikeSchema } from "../object-like"; +import { getSchemaUtils } from "../schema-utils"; +import { Discriminant } from "./discriminant"; +import { inferParsedDiscriminant, inferParsedUnion, inferRawDiscriminant, inferRawUnion, UnionSubtypes } from "./types"; + +export function union, U extends UnionSubtypes>( + discriminant: D, + union: U +): ObjectLikeSchema, inferParsedUnion> { + const rawDiscriminant = + typeof discriminant === "string" ? discriminant : (discriminant.rawDiscriminant as inferRawDiscriminant); + const parsedDiscriminant = + typeof discriminant === "string" + ? discriminant + : (discriminant.parsedDiscriminant as inferParsedDiscriminant); + + const discriminantValueSchema = enum_(keys(union) as string[]); + + const baseSchema: BaseSchema, inferParsedUnion> = { + parse: async (raw, opts) => { + return transformAndValidateUnion({ + value: raw, + discriminant: rawDiscriminant, + transformedDiscriminant: parsedDiscriminant, + transformDiscriminantValue: (discriminantValue) => + discriminantValueSchema.parse(discriminantValue, { + allowUnrecognizedEnumValues: opts?.allowUnrecognizedUnionMembers, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), rawDiscriminant], + }), + getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue], + allowUnrecognizedUnionMembers: opts?.allowUnrecognizedUnionMembers, + transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => + additionalPropertiesSchema.parse(additionalProperties, opts), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, + }); + }, + json: async (parsed, opts) => { + return transformAndValidateUnion({ + value: parsed, + discriminant: parsedDiscriminant, + transformedDiscriminant: rawDiscriminant, + transformDiscriminantValue: (discriminantValue) => + discriminantValueSchema.json(discriminantValue, { + allowUnrecognizedEnumValues: opts?.allowUnrecognizedUnionMembers, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), parsedDiscriminant], + }), + getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue], + allowUnrecognizedUnionMembers: opts?.allowUnrecognizedUnionMembers, + transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => + additionalPropertiesSchema.json(additionalProperties, opts), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, + }); + }, + getType: () => SchemaType.UNION, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + ...getObjectLikeUtils(baseSchema), + }; +} + +async function transformAndValidateUnion< + TransformedDiscriminant extends string, + TransformedDiscriminantValue extends string, + TransformedAdditionalProperties +>({ + value, + discriminant, + transformedDiscriminant, + transformDiscriminantValue, + getAdditionalPropertiesSchema, + allowUnrecognizedUnionMembers = false, + transformAdditionalProperties, + breadcrumbsPrefix = [], +}: { + value: unknown; + discriminant: string; + transformedDiscriminant: TransformedDiscriminant; + transformDiscriminantValue: (discriminantValue: unknown) => MaybePromise>; + getAdditionalPropertiesSchema: (discriminantValue: string) => ObjectSchema | undefined; + allowUnrecognizedUnionMembers: boolean | undefined; + transformAdditionalProperties: ( + additionalProperties: unknown, + additionalPropertiesSchema: ObjectSchema + ) => MaybePromise>; + breadcrumbsPrefix: string[] | undefined; +}): Promise< + MaybeValid & TransformedAdditionalProperties> +> { + if (!isPlainObject(value)) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "object"), + }, + ], + }; + } + + const { [discriminant]: discriminantValue, ...additionalProperties } = value; + + if (discriminantValue == null) { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: `Missing discriminant ("${discriminant}")`, + }, + ], + }; + } + + const transformedDiscriminantValue = await transformDiscriminantValue(discriminantValue); + if (!transformedDiscriminantValue.ok) { + return { + ok: false, + errors: transformedDiscriminantValue.errors, + }; + } + + const additionalPropertiesSchema = getAdditionalPropertiesSchema(transformedDiscriminantValue.value); + + if (additionalPropertiesSchema == null) { + if (allowUnrecognizedUnionMembers) { + return { + ok: true, + value: { + [transformedDiscriminant]: transformedDiscriminantValue.value, + ...additionalProperties, + } as Record & TransformedAdditionalProperties, + }; + } else { + return { + ok: false, + errors: [ + { + path: [...breadcrumbsPrefix, discriminant], + message: "Unexpected discriminant value", + }, + ], + }; + } + } + + const transformedAdditionalProperties = await transformAdditionalProperties( + additionalProperties, + additionalPropertiesSchema + ); + if (!transformedAdditionalProperties.ok) { + return transformedAdditionalProperties; + } + + return { + ok: true, + value: { + [transformedDiscriminant]: discriminantValue, + ...transformedAdditionalProperties.value, + } as Record & TransformedAdditionalProperties, + }; +} diff --git a/src/core/schemas/index.ts b/src/core/schemas/index.ts new file mode 100644 index 0000000..5429d8b --- /dev/null +++ b/src/core/schemas/index.ts @@ -0,0 +1,2 @@ +export * from "./builders"; +export type { inferParsed, inferRaw, Schema, SchemaOptions } from "./Schema"; diff --git a/src/core/schemas/utils/MaybePromise.ts b/src/core/schemas/utils/MaybePromise.ts new file mode 100644 index 0000000..9cd354b --- /dev/null +++ b/src/core/schemas/utils/MaybePromise.ts @@ -0,0 +1 @@ +export type MaybePromise = T | Promise; diff --git a/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts b/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts new file mode 100644 index 0000000..4111d70 --- /dev/null +++ b/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts @@ -0,0 +1,15 @@ +export type addQuestionMarksToNullableProperties = { + [K in OptionalKeys]?: T[K]; +} & Pick>; + +export type OptionalKeys = { + [K in keyof T]-?: undefined extends T[K] + ? K + : null extends T[K] + ? K + : 1 extends (any extends T[K] ? 0 : 1) + ? never + : K; +}[keyof T]; + +export type RequiredKeys = Exclude>; diff --git a/src/core/schemas/utils/createIdentitySchemaCreator.ts b/src/core/schemas/utils/createIdentitySchemaCreator.ts new file mode 100644 index 0000000..de107cf --- /dev/null +++ b/src/core/schemas/utils/createIdentitySchemaCreator.ts @@ -0,0 +1,21 @@ +import { getSchemaUtils } from "../builders/schema-utils"; +import { BaseSchema, MaybeValid, Schema, SchemaOptions, SchemaType } from "../Schema"; +import { maybeSkipValidation } from "./maybeSkipValidation"; + +export function createIdentitySchemaCreator( + schemaType: SchemaType, + validate: (value: unknown, opts?: SchemaOptions) => MaybeValid +): () => Schema { + return () => { + const baseSchema: BaseSchema = { + parse: validate, + json: validate, + getType: () => schemaType, + }; + + return { + ...maybeSkipValidation(baseSchema), + ...getSchemaUtils(baseSchema), + }; + }; +} diff --git a/src/core/schemas/utils/entries.ts b/src/core/schemas/utils/entries.ts new file mode 100644 index 0000000..e122952 --- /dev/null +++ b/src/core/schemas/utils/entries.ts @@ -0,0 +1,3 @@ +export function entries(object: T): [keyof T, T[keyof T]][] { + return Object.entries(object) as [keyof T, T[keyof T]][]; +} diff --git a/src/core/schemas/utils/filterObject.ts b/src/core/schemas/utils/filterObject.ts new file mode 100644 index 0000000..2c25a34 --- /dev/null +++ b/src/core/schemas/utils/filterObject.ts @@ -0,0 +1,10 @@ +export function filterObject(obj: T, keysToInclude: K[]): Pick { + const keysToIncludeSet = new Set(keysToInclude); + return Object.entries(obj).reduce((acc, [key, value]) => { + if (keysToIncludeSet.has(key as K)) { + acc[key as K] = value; + } + return acc; + // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter + }, {} as Pick); +} diff --git a/src/core/schemas/utils/getErrorMessageForIncorrectType.ts b/src/core/schemas/utils/getErrorMessageForIncorrectType.ts new file mode 100644 index 0000000..438012d --- /dev/null +++ b/src/core/schemas/utils/getErrorMessageForIncorrectType.ts @@ -0,0 +1,21 @@ +export function getErrorMessageForIncorrectType(value: unknown, expectedType: string): string { + return `Expected ${expectedType}. Received ${getTypeAsString(value)}.`; +} + +function getTypeAsString(value: unknown): string { + if (Array.isArray(value)) { + return "list"; + } + if (value === null) { + return "null"; + } + switch (typeof value) { + case "string": + return `"${value}"`; + case "number": + case "boolean": + case "undefined": + return `${value}`; + } + return typeof value; +} diff --git a/src/core/schemas/utils/isPlainObject.ts b/src/core/schemas/utils/isPlainObject.ts new file mode 100644 index 0000000..db82a72 --- /dev/null +++ b/src/core/schemas/utils/isPlainObject.ts @@ -0,0 +1,17 @@ +// borrowed from https://github.com/lodash/lodash/blob/master/isPlainObject.js +export function isPlainObject(value: unknown): value is Record { + if (typeof value !== "object" || value === null) { + return false; + } + + if (Object.getPrototypeOf(value) === null) { + return true; + } + + let proto = value; + while (Object.getPrototypeOf(proto) !== null) { + proto = Object.getPrototypeOf(proto); + } + + return Object.getPrototypeOf(value) === proto; +} diff --git a/src/core/schemas/utils/keys.ts b/src/core/schemas/utils/keys.ts new file mode 100644 index 0000000..0186709 --- /dev/null +++ b/src/core/schemas/utils/keys.ts @@ -0,0 +1,3 @@ +export function keys(object: T): (keyof T)[] { + return Object.keys(object) as (keyof T)[]; +} diff --git a/src/core/schemas/utils/maybeSkipValidation.ts b/src/core/schemas/utils/maybeSkipValidation.ts new file mode 100644 index 0000000..99c02c3 --- /dev/null +++ b/src/core/schemas/utils/maybeSkipValidation.ts @@ -0,0 +1,39 @@ +import { BaseSchema, MaybeValid, SchemaOptions } from "../Schema"; +import { MaybePromise } from "./MaybePromise"; + +export function maybeSkipValidation, Raw, Parsed>(schema: S): S { + return { + ...schema, + json: transformAndMaybeSkipValidation(schema.json), + parse: transformAndMaybeSkipValidation(schema.parse), + }; +} + +function transformAndMaybeSkipValidation( + transform: (value: unknown, opts?: SchemaOptions) => MaybePromise> +): (value: unknown, opts?: SchemaOptions) => MaybePromise> { + return async (value, opts): Promise> => { + const transformed = await transform(value, opts); + const { skipValidation = false } = opts ?? {}; + if (!transformed.ok && skipValidation) { + // eslint-disable-next-line no-console + console.warn( + [ + "Failed to validate.", + ...transformed.errors.map( + (error) => + " - " + + (error.path.length > 0 ? `${error.path.join(".")}: ${error.message}` : error.message) + ), + ].join("\n") + ); + + return { + ok: true, + value: value as T, + }; + } else { + return transformed; + } + }; +} diff --git a/src/core/schemas/utils/partition.ts b/src/core/schemas/utils/partition.ts new file mode 100644 index 0000000..f58d6f3 --- /dev/null +++ b/src/core/schemas/utils/partition.ts @@ -0,0 +1,12 @@ +export function partition(items: readonly T[], predicate: (item: T) => boolean): [T[], T[]] { + const trueItems: T[] = [], + falseItems: T[] = []; + for (const item of items) { + if (predicate(item)) { + trueItems.push(item); + } else { + falseItems.push(item); + } + } + return [trueItems, falseItems]; +} diff --git a/src/environments.ts b/src/environments.ts new file mode 100644 index 0000000..6926489 --- /dev/null +++ b/src/environments.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export const beehiivEnvironment = { + Default: "https://api.beehiiv.com/v2", +} as const; + +export type beehiivEnvironment = typeof beehiivEnvironment.Default; diff --git a/src/errors/beehiivError.ts b/src/errors/beehiivError.ts new file mode 100644 index 0000000..d6354ad --- /dev/null +++ b/src/errors/beehiivError.ts @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export class beehiivError extends Error { + readonly statusCode?: number; + readonly body?: unknown; + + constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) { + super(buildMessage({ message, statusCode, body })); + Object.setPrototypeOf(this, beehiivError.prototype); + if (statusCode != null) { + this.statusCode = statusCode; + } + + if (body !== undefined) { + this.body = body; + } + } +} + +function buildMessage({ + message, + statusCode, + body, +}: { + message: string | undefined; + statusCode: number | undefined; + body: unknown | undefined; +}): string { + let lines: string[] = []; + if (message != null) { + lines.push(message); + } + + if (statusCode != null) { + lines.push(`Status code: ${statusCode.toString()}`); + } + + if (body != null) { + lines.push(`Body: ${JSON.stringify(body, undefined, 2)}`); + } + + return lines.join("\n"); +} diff --git a/src/errors/beehiivTimeoutError.ts b/src/errors/beehiivTimeoutError.ts new file mode 100644 index 0000000..351d837 --- /dev/null +++ b/src/errors/beehiivTimeoutError.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export class beehiivTimeoutError extends Error { + constructor() { + super("Timeout"); + Object.setPrototypeOf(this, beehiivTimeoutError.prototype); + } +} diff --git a/src/errors/index.ts b/src/errors/index.ts new file mode 100644 index 0000000..92061c3 --- /dev/null +++ b/src/errors/index.ts @@ -0,0 +1,2 @@ +export { beehiivError } from "./beehiivError"; +export { beehiivTimeoutError } from "./beehiivTimeoutError"; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..b3c456b --- /dev/null +++ b/src/index.ts @@ -0,0 +1,4 @@ +export * as beehiiv from "./api"; +export { beehiivClient } from "./Client"; +export { beehiivEnvironment } from "./environments"; +export { beehiivError, beehiivTimeoutError } from "./errors"; diff --git a/src/serialization/index.ts b/src/serialization/index.ts new file mode 100644 index 0000000..3e15e29 --- /dev/null +++ b/src/serialization/index.ts @@ -0,0 +1,2 @@ +export * from "./resources"; +export * from "./types"; diff --git a/src/serialization/resources/automationJourneys/client/index.ts b/src/serialization/resources/automationJourneys/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/automationJourneys/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts b/src/serialization/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts new file mode 100644 index 0000000..b6197b8 --- /dev/null +++ b/src/serialization/resources/automationJourneys/client/requests/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride } from "../../types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride"; + +export const AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest: core.serialization.Schema< + serializers.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest.Raw, + beehiiv.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest +> = core.serialization.object({ + email: core.serialization.string().optional(), + subscriptionId: core.serialization.property("subscription_id", core.serialization.string().optional()), + doubleOptOverride: core.serialization.property( + "double_opt_override", + AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.optional() + ), +}); + +export declare namespace AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest { + interface Raw { + email?: string | null; + subscription_id?: string | null; + double_opt_override?: AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.Raw | null; + } +} diff --git a/src/serialization/resources/automationJourneys/client/requests/index.ts b/src/serialization/resources/automationJourneys/client/requests/index.ts new file mode 100644 index 0000000..44573ff --- /dev/null +++ b/src/serialization/resources/automationJourneys/client/requests/index.ts @@ -0,0 +1 @@ +export { AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest } from "./AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequest"; diff --git a/src/serialization/resources/automationJourneys/index.ts b/src/serialization/resources/automationJourneys/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/serialization/resources/automationJourneys/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts b/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts new file mode 100644 index 0000000..1e396c7 --- /dev/null +++ b/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { AutomationJourney } from "../../../types/AutomationJourney"; + +export const AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse: core.serialization.ObjectSchema< + serializers.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse.Raw, + beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse +> = core.serialization.object({ + data: AutomationJourney.optional(), +}); + +export declare namespace AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse { + interface Raw { + data?: AutomationJourney.Raw | null; + } +} diff --git a/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts b/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts new file mode 100644 index 0000000..6b7b3ab --- /dev/null +++ b/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus: core.serialization.Schema< + serializers.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus.Raw, + beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus +> = core.serialization.enum_(["in_progress", "completed", "exited_early", "all"]); + +export declare namespace AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus { + type Raw = "in_progress" | "completed" | "exited_early" | "all"; +} diff --git a/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts b/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts new file mode 100644 index 0000000..be2025e --- /dev/null +++ b/src/serialization/resources/automationJourneys/types/AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { AutomationJourney } from "../../../types/AutomationJourney"; + +export const AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse: core.serialization.ObjectSchema< + serializers.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.Raw, + beehiiv.AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse +> = core.serialization.object({ + data: core.serialization.list(AutomationJourney), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse { + interface Raw { + data: AutomationJourney.Raw[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts b/src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts new file mode 100644 index 0000000..ba5042d --- /dev/null +++ b/src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride: core.serialization.Schema< + serializers.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride.Raw, + beehiiv.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride +> = core.serialization.enum_(["on", "off", "not_set"]); + +export declare namespace AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride { + type Raw = "on" | "off" | "not_set"; +} diff --git a/src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts b/src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts new file mode 100644 index 0000000..d62e6b2 --- /dev/null +++ b/src/serialization/resources/automationJourneys/types/AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { AutomationJourney } from "../../../types/AutomationJourney"; + +export const AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse: core.serialization.ObjectSchema< + serializers.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse.Raw, + beehiiv.AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse +> = core.serialization.object({ + data: AutomationJourney.optional(), +}); + +export declare namespace AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse { + interface Raw { + data?: AutomationJourney.Raw | null; + } +} diff --git a/src/serialization/resources/automationJourneys/types/index.ts b/src/serialization/resources/automationJourneys/types/index.ts new file mode 100644 index 0000000..b0b6c62 --- /dev/null +++ b/src/serialization/resources/automationJourneys/types/index.ts @@ -0,0 +1,5 @@ +export * from "./AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysRequestStatus"; +export * from "./AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysResponse"; +export * from "./AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysRequestDoubleOptOverride"; +export * from "./AutomationJourneysPostPublicationsPublicationIdAutomationsAutomationIdJourneysResponse"; +export * from "./AutomationJourneysGetPublicationsPublicationIdAutomationsAutomationIdJourneysAutomationJourneyIdResponse"; diff --git a/src/serialization/resources/automations/index.ts b/src/serialization/resources/automations/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/automations/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts b/src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts new file mode 100644 index 0000000..43895b0 --- /dev/null +++ b/src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Automation } from "../../../types/Automation"; + +export const AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse: core.serialization.ObjectSchema< + serializers.AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse.Raw, + beehiiv.AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse +> = core.serialization.object({ + data: Automation.optional(), +}); + +export declare namespace AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse { + interface Raw { + data?: Automation.Raw | null; + } +} diff --git a/src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts b/src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts new file mode 100644 index 0000000..78fd5db --- /dev/null +++ b/src/serialization/resources/automations/types/AutomationsGetPublicationsPublicationIdAutomationsResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Automation } from "../../../types/Automation"; + +export const AutomationsGetPublicationsPublicationIdAutomationsResponse: core.serialization.ObjectSchema< + serializers.AutomationsGetPublicationsPublicationIdAutomationsResponse.Raw, + beehiiv.AutomationsGetPublicationsPublicationIdAutomationsResponse +> = core.serialization.object({ + data: core.serialization.list(Automation).optional(), + limit: core.serialization.number().optional(), + page: core.serialization.number().optional(), + totalResults: core.serialization.property("total_results", core.serialization.number().optional()), + totalPages: core.serialization.property("total_pages", core.serialization.number().optional()), +}); + +export declare namespace AutomationsGetPublicationsPublicationIdAutomationsResponse { + interface Raw { + data?: Automation.Raw[] | null; + limit?: number | null; + page?: number | null; + total_results?: number | null; + total_pages?: number | null; + } +} diff --git a/src/serialization/resources/automations/types/index.ts b/src/serialization/resources/automations/types/index.ts new file mode 100644 index 0000000..074798f --- /dev/null +++ b/src/serialization/resources/automations/types/index.ts @@ -0,0 +1,2 @@ +export * from "./AutomationsGetPublicationsPublicationIdAutomationsResponse"; +export * from "./AutomationsGetPublicationsPublicationIdAutomationsAutomationIdResponse"; diff --git a/src/serialization/resources/bulkSubscriptionUpdates/index.ts b/src/serialization/resources/bulkSubscriptionUpdates/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts new file mode 100644 index 0000000..52b9a7a --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData } from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse: core.serialization.ObjectSchema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse +> = core.serialization.object({ + data: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.optional(), +}); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse { + interface Raw { + data?: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.Raw | null; + } +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts new file mode 100644 index 0000000..f36081f --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.ts @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType } from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType"; +import { BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus } from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData: core.serialization.ObjectSchema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData +> = core.serialization.object({ + id: core.serialization.string().optional(), + type: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.optional(), + params: core.serialization.string().optional(), + status: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.optional(), + publicationId: core.serialization.property("publication_id", core.serialization.string().optional()), + failureReason: core.serialization.property("failure_reason", core.serialization.string().optional()), + completed: core.serialization.number().optional(), + created: core.serialization.number().optional(), + updated: core.serialization.number().optional(), + errorLog: core.serialization.property("error_log", core.serialization.list(core.serialization.string()).optional()), +}); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData { + interface Raw { + id?: string | null; + type?: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.Raw | null; + params?: string | null; + status?: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.Raw | null; + publication_id?: string | null; + failure_reason?: string | null; + completed?: number | null; + created?: number | null; + updated?: number | null; + error_log?: string[] | null; + } +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts new file mode 100644 index 0000000..0104b03 --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus: core.serialization.Schema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus +> = core.serialization.enum_(["pending", "processing", "complete", "failed"]); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus { + type Raw = "pending" | "processing" | "complete" | "failed"; +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts new file mode 100644 index 0000000..3411e35 --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType: core.serialization.Schema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType +> = core.serialization.enum_(["bulk", "status"]); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType { + type Raw = "bulk" | "status"; +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts new file mode 100644 index 0000000..b24f6fc --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem } from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse: core.serialization.ObjectSchema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse +> = core.serialization.object({ + data: core.serialization + .list(BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem) + .optional(), +}); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse { + interface Raw { + data?: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.Raw[] | null; + } +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts new file mode 100644 index 0000000..2ceaee7 --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.ts @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType } from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType"; +import { BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus } from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem: core.serialization.ObjectSchema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem +> = core.serialization.object({ + id: core.serialization.string().optional(), + type: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.optional(), + params: core.serialization.string().optional(), + status: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.optional(), + publicationId: core.serialization.property("publication_id", core.serialization.string().optional()), + failureReason: core.serialization.property("failure_reason", core.serialization.string().optional()), + completed: core.serialization.number().optional(), + created: core.serialization.number().optional(), + updated: core.serialization.number().optional(), + errorLog: core.serialization.property("error_log", core.serialization.list(core.serialization.string()).optional()), +}); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem { + interface Raw { + id?: string | null; + type?: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.Raw | null; + params?: string | null; + status?: BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.Raw | null; + publication_id?: string | null; + failure_reason?: string | null; + completed?: number | null; + created?: number | null; + updated?: number | null; + error_log?: string[] | null; + } +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts new file mode 100644 index 0000000..9d87b30 --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus: core.serialization.Schema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus +> = core.serialization.enum_(["pending", "processing", "complete", "failed"]); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus { + type Raw = "pending" | "processing" | "complete" | "failed"; +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts new file mode 100644 index 0000000..aafb319 --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType: core.serialization.Schema< + serializers.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType.Raw, + beehiiv.BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType +> = core.serialization.enum_(["status", "bulk"]); + +export declare namespace BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType { + type Raw = "status" | "bulk"; +} diff --git a/src/serialization/resources/bulkSubscriptionUpdates/types/index.ts b/src/serialization/resources/bulkSubscriptionUpdates/types/index.ts new file mode 100644 index 0000000..2c4a36a --- /dev/null +++ b/src/serialization/resources/bulkSubscriptionUpdates/types/index.ts @@ -0,0 +1,8 @@ +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemType"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItemStatus"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponseDataItem"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesResponse"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataType"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseDataStatus"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponseData"; +export * from "./BulkSubscriptionUpdatesGetPublicationsPublicationIdSubcriptionUpdatesIdResponse"; diff --git a/src/serialization/resources/customFields/client/index.ts b/src/serialization/resources/customFields/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/customFields/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts b/src/serialization/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts new file mode 100644 index 0000000..bd72196 --- /dev/null +++ b/src/serialization/resources/customFields/client/requests/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; + +export const CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest: core.serialization.Schema< + serializers.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest.Raw, + beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest +> = core.serialization.object({ + display: core.serialization.string().optional(), +}); + +export declare namespace CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest { + interface Raw { + display?: string | null; + } +} diff --git a/src/serialization/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts b/src/serialization/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts new file mode 100644 index 0000000..e8fcde4 --- /dev/null +++ b/src/serialization/resources/customFields/client/requests/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind } from "../../types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind"; + +export const CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest: core.serialization.Schema< + serializers.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest.Raw, + beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest +> = core.serialization.object({ + kind: CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind, + display: core.serialization.string(), +}); + +export declare namespace CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest { + interface Raw { + kind: CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.Raw; + display: string; + } +} diff --git a/src/serialization/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts b/src/serialization/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts new file mode 100644 index 0000000..885bae4 --- /dev/null +++ b/src/serialization/resources/customFields/client/requests/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; + +export const CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest: core.serialization.Schema< + serializers.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest.Raw, + beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest +> = core.serialization.object({ + display: core.serialization.string().optional(), +}); + +export declare namespace CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest { + interface Raw { + display?: string | null; + } +} diff --git a/src/serialization/resources/customFields/client/requests/index.ts b/src/serialization/resources/customFields/client/requests/index.ts new file mode 100644 index 0000000..331c371 --- /dev/null +++ b/src/serialization/resources/customFields/client/requests/index.ts @@ -0,0 +1,3 @@ +export { CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest } from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsRequest"; +export { CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest } from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdRequest"; +export { CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest } from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdRequest"; diff --git a/src/serialization/resources/customFields/index.ts b/src/serialization/resources/customFields/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/serialization/resources/customFields/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/serialization/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts b/src/serialization/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts new file mode 100644 index 0000000..f091a9c --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse: core.serialization.ObjectSchema< + serializers.CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse.Raw, + beehiiv.CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse +> = core.serialization.object({ + message: core.serialization.string().optional(), +}); + +export declare namespace CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse { + interface Raw { + message?: string | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts new file mode 100644 index 0000000..5f40e1c --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData } from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse: core.serialization.ObjectSchema< + serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse.Raw, + beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse +> = core.serialization.object({ + data: CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.optional(), +}); + +export declare namespace CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse { + interface Raw { + data?: CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.Raw | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts new file mode 100644 index 0000000..fa2099c --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind } from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData: core.serialization.ObjectSchema< + serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData.Raw, + beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData +> = core.serialization.object({ + id: core.serialization.string().optional(), + display: core.serialization.string().optional(), + kind: CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.optional(), + created: core.serialization.number().optional(), +}); + +export declare namespace CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData { + interface Raw { + id?: string | null; + display?: string | null; + kind?: CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.Raw | null; + created?: number | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts new file mode 100644 index 0000000..65d316b --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind: core.serialization.Schema< + serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind.Raw, + beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind +> = core.serialization.enum_(["string", "integer", "boolean", "date", "datetime"]); + +export declare namespace CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind { + type Raw = "string" | "integer" | "boolean" | "date" | "datetime"; +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts new file mode 100644 index 0000000..e04832a --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem } from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse: core.serialization.ObjectSchema< + serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse.Raw, + beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse +> = core.serialization.object({ + data: core.serialization.list(CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem).optional(), +}); + +export declare namespace CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse { + interface Raw { + data?: CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.Raw[] | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts new file mode 100644 index 0000000..e465ca4 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind } from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem: core.serialization.ObjectSchema< + serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem.Raw, + beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem +> = core.serialization.object({ + id: core.serialization.string().optional(), + kind: CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.optional(), + display: core.serialization.string().optional(), + created: core.serialization.number().optional(), +}); + +export declare namespace CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem { + interface Raw { + id?: string | null; + kind?: CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.Raw | null; + display?: string | null; + created?: number | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts new file mode 100644 index 0000000..3bdb73d --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind: core.serialization.Schema< + serializers.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind.Raw, + beehiiv.CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind +> = core.serialization.enum_(["string", "integer", "boolean", "date", "datetime"]); + +export declare namespace CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind { + type Raw = "string" | "integer" | "boolean" | "date" | "datetime"; +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts b/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts new file mode 100644 index 0000000..6cce762 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData } from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData"; + +export const CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse: core.serialization.ObjectSchema< + serializers.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse.Raw, + beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse +> = core.serialization.object({ + data: CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.optional(), +}); + +export declare namespace CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse { + interface Raw { + data?: CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.Raw | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts b/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts new file mode 100644 index 0000000..cf41a0c --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind } from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind"; + +export const CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData: core.serialization.ObjectSchema< + serializers.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData.Raw, + beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData +> = core.serialization.object({ + id: core.serialization.string().optional(), + display: core.serialization.string().optional(), + kind: CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.optional(), + created: core.serialization.number().optional(), +}); + +export declare namespace CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData { + interface Raw { + id?: string | null; + display?: string | null; + kind?: CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.Raw | null; + created?: number | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts b/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts new file mode 100644 index 0000000..d48fc53 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind: core.serialization.Schema< + serializers.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind.Raw, + beehiiv.CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind +> = core.serialization.enum_(["string", "integer", "boolean", "date", "datetime"]); + +export declare namespace CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind { + type Raw = "string" | "integer" | "boolean" | "date" | "datetime"; +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts new file mode 100644 index 0000000..1e67f48 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind: core.serialization.Schema< + serializers.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind.Raw, + beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind +> = core.serialization.enum_(["string", "integer", "boolean", "date", "datetime"]); + +export declare namespace CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind { + type Raw = "string" | "integer" | "boolean" | "date" | "datetime"; +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts new file mode 100644 index 0000000..ee79861 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData } from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData"; + +export const CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse: core.serialization.ObjectSchema< + serializers.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse.Raw, + beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse +> = core.serialization.object({ + data: CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.optional(), +}); + +export declare namespace CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse { + interface Raw { + data?: CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.Raw | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts new file mode 100644 index 0000000..39db453 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind } from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind"; + +export const CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData: core.serialization.ObjectSchema< + serializers.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData.Raw, + beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData +> = core.serialization.object({ + id: core.serialization.string(), + kind: CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind, + display: core.serialization.string(), + created: core.serialization.number(), +}); + +export declare namespace CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData { + interface Raw { + id: string; + kind: CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.Raw; + display: string; + created: number; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts new file mode 100644 index 0000000..b2892b7 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind: core.serialization.Schema< + serializers.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind.Raw, + beehiiv.CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind +> = core.serialization.enum_(["string", "integer", "boolean", "date", "datetime"]); + +export declare namespace CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind { + type Raw = "string" | "integer" | "boolean" | "date" | "datetime"; +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts b/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts new file mode 100644 index 0000000..c161a08 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData } from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData"; + +export const CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse: core.serialization.ObjectSchema< + serializers.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse.Raw, + beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse +> = core.serialization.object({ + data: CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.optional(), +}); + +export declare namespace CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse { + interface Raw { + data?: CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.Raw | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts b/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts new file mode 100644 index 0000000..f8df368 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind } from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind"; + +export const CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData: core.serialization.ObjectSchema< + serializers.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData.Raw, + beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData +> = core.serialization.object({ + id: core.serialization.string().optional(), + display: core.serialization.string().optional(), + kind: CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.optional(), + created: core.serialization.number().optional(), +}); + +export declare namespace CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData { + interface Raw { + id?: string | null; + display?: string | null; + kind?: CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.Raw | null; + created?: number | null; + } +} diff --git a/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts b/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts new file mode 100644 index 0000000..0af6b92 --- /dev/null +++ b/src/serialization/resources/customFields/types/CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind: core.serialization.Schema< + serializers.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind.Raw, + beehiiv.CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind +> = core.serialization.enum_(["string", "integer", "boolean", "date", "datetime"]); + +export declare namespace CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind { + type Raw = "string" | "integer" | "boolean" | "date" | "datetime"; +} diff --git a/src/serialization/resources/customFields/types/index.ts b/src/serialization/resources/customFields/types/index.ts new file mode 100644 index 0000000..856f6c9 --- /dev/null +++ b/src/serialization/resources/customFields/types/index.ts @@ -0,0 +1,17 @@ +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItemKind"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponseDataItem"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsResponse"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsRequestKind"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseDataKind"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponseData"; +export * from "./CustomFieldsPostPublicationsPublicationIdCustomFieldsResponse"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseDataKind"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponseData"; +export * from "./CustomFieldsGetPublicationsPublicationIdCustomFieldsIdResponse"; +export * from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseDataKind"; +export * from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponseData"; +export * from "./CustomFieldsPutPublicationsPublicationIdCustomFieldsIdResponse"; +export * from "./CustomFieldsDeletePublicationsPublicationIdCustomFieldsResponse"; +export * from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseDataKind"; +export * from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponseData"; +export * from "./CustomFieldsPatchPublicationsPublicationIdCustomFieldsIdResponse"; diff --git a/src/serialization/resources/emailBlasts/index.ts b/src/serialization/resources/emailBlasts/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/emailBlasts/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts new file mode 100644 index 0000000..c0e09db --- /dev/null +++ b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem: core.serialization.Schema< + serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem.Raw, + beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem +> = core.serialization.enum_(["stats", "free_email_content", "premium_email_content"]); + +export declare namespace EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem { + type Raw = "stats" | "free_email_content" | "premium_email_content"; +} diff --git a/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts new file mode 100644 index 0000000..a79e17e --- /dev/null +++ b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { EmailBlast } from "../../../types/EmailBlast"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse: core.serialization.ObjectSchema< + serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse.Raw, + beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse +> = core.serialization.object({ + data: EmailBlast, +}); + +export declare namespace EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse { + interface Raw { + data: EmailBlast.Raw; + } +} diff --git a/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts new file mode 100644 index 0000000..df24cb5 --- /dev/null +++ b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection: core.serialization.Schema< + serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection.Raw, + beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection +> = core.serialization.enum_(["asc", "desc"]); + +export declare namespace EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection { + type Raw = "asc" | "desc"; +} diff --git a/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts new file mode 100644 index 0000000..43bba0e --- /dev/null +++ b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem: core.serialization.Schema< + serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem.Raw, + beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem +> = core.serialization.enum_(["stats", "free_email_content", "premium_email_content"]); + +export declare namespace EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem { + type Raw = "stats" | "free_email_content" | "premium_email_content"; +} diff --git a/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts new file mode 100644 index 0000000..447e9ae --- /dev/null +++ b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy: core.serialization.Schema< + serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy.Raw, + beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy +> = core.serialization.enum_(["created", "last_sent"]); + +export declare namespace EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy { + type Raw = "created" | "last_sent"; +} diff --git a/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts new file mode 100644 index 0000000..0591680 --- /dev/null +++ b/src/serialization/resources/emailBlasts/types/EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { EmailBlast } from "../../../types/EmailBlast"; + +export const EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse: core.serialization.ObjectSchema< + serializers.EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse.Raw, + beehiiv.EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse +> = core.serialization.object({ + data: core.serialization.list(EmailBlast), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse { + interface Raw { + data: EmailBlast.Raw[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/emailBlasts/types/index.ts b/src/serialization/resources/emailBlasts/types/index.ts new file mode 100644 index 0000000..249e41c --- /dev/null +++ b/src/serialization/resources/emailBlasts/types/index.ts @@ -0,0 +1,6 @@ +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestExpandItem"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestDirection"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsRequestOrderBy"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsResponse"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdRequestExpandItem"; +export * from "./EmailBlastsGetPublicationsPublicationIdEmailBlastsEmailBlastIdResponse"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts new file mode 100644 index 0000000..b5e13e3 --- /dev/null +++ b/src/serialization/resources/index.ts @@ -0,0 +1,26 @@ +export * as publications from "./publications"; +export * from "./publications/types"; +export * as posts from "./posts"; +export * from "./posts/types"; +export * as subscriptions from "./subscriptions"; +export * from "./subscriptions/types"; +export * as segments from "./segments"; +export * from "./segments/types"; +export * as emailBlasts from "./emailBlasts"; +export * from "./emailBlasts/types"; +export * as referralProgram from "./referralProgram"; +export * from "./referralProgram/types"; +export * as customFields from "./customFields"; +export * from "./customFields/types"; +export * as bulkSubscriptionUpdates from "./bulkSubscriptionUpdates"; +export * from "./bulkSubscriptionUpdates/types"; +export * as automationJourneys from "./automationJourneys"; +export * from "./automationJourneys/types"; +export * as automations from "./automations"; +export * from "./automations/types"; +export * as subscriptionTags from "./subscriptionTags"; +export * from "./subscriptionTags/types"; +export * from "./subscriptions/client/requests"; +export * from "./customFields/client/requests"; +export * from "./automationJourneys/client/requests"; +export * from "./subscriptionTags/client/requests"; diff --git a/src/serialization/resources/posts/index.ts b/src/serialization/resources/posts/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/posts/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/resources/posts/types/PostsDeletePostsPostIdResponse.ts b/src/serialization/resources/posts/types/PostsDeletePostsPostIdResponse.ts new file mode 100644 index 0000000..c0b31aa --- /dev/null +++ b/src/serialization/resources/posts/types/PostsDeletePostsPostIdResponse.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsDeletePostsPostIdResponse: core.serialization.ObjectSchema< + serializers.PostsDeletePostsPostIdResponse.Raw, + beehiiv.PostsDeletePostsPostIdResponse +> = core.serialization.object({}); + +export declare namespace PostsDeletePostsPostIdResponse { + interface Raw {} +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts b/src/serialization/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts new file mode 100644 index 0000000..e7c43b7 --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsPostIdRequestExpandItem.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsPostIdRequestExpandItem: core.serialization.Schema< + serializers.PostsGetPostsPostIdRequestExpandItem.Raw, + beehiiv.PostsGetPostsPostIdRequestExpandItem +> = core.serialization.enum_([ + "stats", + "free_web_content", + "free_email_content", + "free_rss_content", + "premium_web_content", + "premium_email_content", +]); + +export declare namespace PostsGetPostsPostIdRequestExpandItem { + type Raw = + | "stats" + | "free_web_content" + | "free_email_content" + | "free_rss_content" + | "premium_web_content" + | "premium_email_content"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsPostIdResponse.ts b/src/serialization/resources/posts/types/PostsGetPostsPostIdResponse.ts new file mode 100644 index 0000000..44fa66c --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsPostIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Post } from "../../../types/Post"; + +export const PostsGetPostsPostIdResponse: core.serialization.ObjectSchema< + serializers.PostsGetPostsPostIdResponse.Raw, + beehiiv.PostsGetPostsPostIdResponse +> = core.serialization.object({ + data: Post, +}); + +export declare namespace PostsGetPostsPostIdResponse { + interface Raw { + data: Post.Raw; + } +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsRequestAudience.ts b/src/serialization/resources/posts/types/PostsGetPostsRequestAudience.ts new file mode 100644 index 0000000..eea5455 --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsRequestAudience.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsRequestAudience: core.serialization.Schema< + serializers.PostsGetPostsRequestAudience.Raw, + beehiiv.PostsGetPostsRequestAudience +> = core.serialization.enum_(["free", "premium", "all"]); + +export declare namespace PostsGetPostsRequestAudience { + type Raw = "free" | "premium" | "all"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsRequestDirection.ts b/src/serialization/resources/posts/types/PostsGetPostsRequestDirection.ts new file mode 100644 index 0000000..b3e401c --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsRequestDirection.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsRequestDirection: core.serialization.Schema< + serializers.PostsGetPostsRequestDirection.Raw, + beehiiv.PostsGetPostsRequestDirection +> = core.serialization.enum_(["asc", "desc"]); + +export declare namespace PostsGetPostsRequestDirection { + type Raw = "asc" | "desc"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsRequestExpandItem.ts b/src/serialization/resources/posts/types/PostsGetPostsRequestExpandItem.ts new file mode 100644 index 0000000..a23a81b --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsRequestExpandItem.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsRequestExpandItem: core.serialization.Schema< + serializers.PostsGetPostsRequestExpandItem.Raw, + beehiiv.PostsGetPostsRequestExpandItem +> = core.serialization.enum_([ + "stats", + "free_web_content", + "free_email_content", + "free_rss_content", + "premium_web_content", + "premium_email_content", +]); + +export declare namespace PostsGetPostsRequestExpandItem { + type Raw = + | "stats" + | "free_web_content" + | "free_email_content" + | "free_rss_content" + | "premium_web_content" + | "premium_email_content"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts b/src/serialization/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts new file mode 100644 index 0000000..73fdd5b --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsRequestHiddenFromFeed.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsRequestHiddenFromFeed: core.serialization.Schema< + serializers.PostsGetPostsRequestHiddenFromFeed.Raw, + beehiiv.PostsGetPostsRequestHiddenFromFeed +> = core.serialization.enum_(["all", "true", "false"]); + +export declare namespace PostsGetPostsRequestHiddenFromFeed { + type Raw = "all" | "true" | "false"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsRequestOrderBy.ts b/src/serialization/resources/posts/types/PostsGetPostsRequestOrderBy.ts new file mode 100644 index 0000000..9a0d0a0 --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsRequestOrderBy.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsRequestOrderBy: core.serialization.Schema< + serializers.PostsGetPostsRequestOrderBy.Raw, + beehiiv.PostsGetPostsRequestOrderBy +> = core.serialization.enum_(["created", "publish_date", "displayed_date"]); + +export declare namespace PostsGetPostsRequestOrderBy { + type Raw = "created" | "publish_date" | "displayed_date"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsRequestPlatform.ts b/src/serialization/resources/posts/types/PostsGetPostsRequestPlatform.ts new file mode 100644 index 0000000..bf846b1 --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsRequestPlatform.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsRequestPlatform: core.serialization.Schema< + serializers.PostsGetPostsRequestPlatform.Raw, + beehiiv.PostsGetPostsRequestPlatform +> = core.serialization.enum_(["web", "email", "both", "all"]); + +export declare namespace PostsGetPostsRequestPlatform { + type Raw = "web" | "email" | "both" | "all"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsRequestStatus.ts b/src/serialization/resources/posts/types/PostsGetPostsRequestStatus.ts new file mode 100644 index 0000000..3a74083 --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsRequestStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PostsGetPostsRequestStatus: core.serialization.Schema< + serializers.PostsGetPostsRequestStatus.Raw, + beehiiv.PostsGetPostsRequestStatus +> = core.serialization.enum_(["draft", "confirmed", "archived", "all"]); + +export declare namespace PostsGetPostsRequestStatus { + type Raw = "draft" | "confirmed" | "archived" | "all"; +} diff --git a/src/serialization/resources/posts/types/PostsGetPostsResponse.ts b/src/serialization/resources/posts/types/PostsGetPostsResponse.ts new file mode 100644 index 0000000..3b30dec --- /dev/null +++ b/src/serialization/resources/posts/types/PostsGetPostsResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Post } from "../../../types/Post"; + +export const PostsGetPostsResponse: core.serialization.ObjectSchema< + serializers.PostsGetPostsResponse.Raw, + beehiiv.PostsGetPostsResponse +> = core.serialization.object({ + data: core.serialization.list(Post), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace PostsGetPostsResponse { + interface Raw { + data: Post.Raw[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/posts/types/index.ts b/src/serialization/resources/posts/types/index.ts new file mode 100644 index 0000000..f732c8f --- /dev/null +++ b/src/serialization/resources/posts/types/index.ts @@ -0,0 +1,11 @@ +export * from "./PostsGetPostsRequestExpandItem"; +export * from "./PostsGetPostsRequestAudience"; +export * from "./PostsGetPostsRequestPlatform"; +export * from "./PostsGetPostsRequestStatus"; +export * from "./PostsGetPostsRequestOrderBy"; +export * from "./PostsGetPostsRequestDirection"; +export * from "./PostsGetPostsRequestHiddenFromFeed"; +export * from "./PostsGetPostsResponse"; +export * from "./PostsGetPostsPostIdRequestExpandItem"; +export * from "./PostsGetPostsPostIdResponse"; +export * from "./PostsDeletePostsPostIdResponse"; diff --git a/src/serialization/resources/publications/index.ts b/src/serialization/resources/publications/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/publications/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts b/src/serialization/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts new file mode 100644 index 0000000..9fc61eb --- /dev/null +++ b/src/serialization/resources/publications/types/PublicationsGetPublicationsPublicationIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Publication } from "../../../types/Publication"; + +export const PublicationsGetPublicationsPublicationIdResponse: core.serialization.ObjectSchema< + serializers.PublicationsGetPublicationsPublicationIdResponse.Raw, + beehiiv.PublicationsGetPublicationsPublicationIdResponse +> = core.serialization.object({ + data: Publication, +}); + +export declare namespace PublicationsGetPublicationsPublicationIdResponse { + interface Raw { + data: Publication.Raw; + } +} diff --git a/src/serialization/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts b/src/serialization/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts new file mode 100644 index 0000000..7fc68b0 --- /dev/null +++ b/src/serialization/resources/publications/types/PublicationsGetPublicationsRequestDirection.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PublicationsGetPublicationsRequestDirection: core.serialization.Schema< + serializers.PublicationsGetPublicationsRequestDirection.Raw, + beehiiv.PublicationsGetPublicationsRequestDirection +> = core.serialization.enum_(["asc", "desc"]); + +export declare namespace PublicationsGetPublicationsRequestDirection { + type Raw = "asc" | "desc"; +} diff --git a/src/serialization/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts b/src/serialization/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts new file mode 100644 index 0000000..197af86 --- /dev/null +++ b/src/serialization/resources/publications/types/PublicationsGetPublicationsRequestOrderBy.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const PublicationsGetPublicationsRequestOrderBy: core.serialization.Schema< + serializers.PublicationsGetPublicationsRequestOrderBy.Raw, + beehiiv.PublicationsGetPublicationsRequestOrderBy +> = core.serialization.enum_(["created", "name"]); + +export declare namespace PublicationsGetPublicationsRequestOrderBy { + type Raw = "created" | "name"; +} diff --git a/src/serialization/resources/publications/types/PublicationsGetPublicationsResponse.ts b/src/serialization/resources/publications/types/PublicationsGetPublicationsResponse.ts new file mode 100644 index 0000000..7ff0629 --- /dev/null +++ b/src/serialization/resources/publications/types/PublicationsGetPublicationsResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Publication } from "../../../types/Publication"; + +export const PublicationsGetPublicationsResponse: core.serialization.ObjectSchema< + serializers.PublicationsGetPublicationsResponse.Raw, + beehiiv.PublicationsGetPublicationsResponse +> = core.serialization.object({ + data: core.serialization.list(Publication), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace PublicationsGetPublicationsResponse { + interface Raw { + data: Publication.Raw[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/publications/types/index.ts b/src/serialization/resources/publications/types/index.ts new file mode 100644 index 0000000..6454004 --- /dev/null +++ b/src/serialization/resources/publications/types/index.ts @@ -0,0 +1,4 @@ +export * from "./PublicationsGetPublicationsRequestDirection"; +export * from "./PublicationsGetPublicationsRequestOrderBy"; +export * from "./PublicationsGetPublicationsResponse"; +export * from "./PublicationsGetPublicationsPublicationIdResponse"; diff --git a/src/serialization/resources/referralProgram/index.ts b/src/serialization/resources/referralProgram/index.ts new file mode 100644 index 0000000..eea524d --- /dev/null +++ b/src/serialization/resources/referralProgram/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/serialization/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts b/src/serialization/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts new file mode 100644 index 0000000..e508b6b --- /dev/null +++ b/src/serialization/resources/referralProgram/types/ReferralProgramGetPublicationsPublicReferralProgramResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Milestone } from "../../../types/Milestone"; + +export const ReferralProgramGetPublicationsPublicReferralProgramResponse: core.serialization.ObjectSchema< + serializers.ReferralProgramGetPublicationsPublicReferralProgramResponse.Raw, + beehiiv.ReferralProgramGetPublicationsPublicReferralProgramResponse +> = core.serialization.object({ + data: core.serialization.list(Milestone), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace ReferralProgramGetPublicationsPublicReferralProgramResponse { + interface Raw { + data: Milestone.Raw[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/referralProgram/types/index.ts b/src/serialization/resources/referralProgram/types/index.ts new file mode 100644 index 0000000..9cab0fe --- /dev/null +++ b/src/serialization/resources/referralProgram/types/index.ts @@ -0,0 +1 @@ +export * from "./ReferralProgramGetPublicationsPublicReferralProgramResponse"; diff --git a/src/serialization/resources/segments/client/deletePublicationsPublicationIdSegmentsSegmentId.ts b/src/serialization/resources/segments/client/deletePublicationsPublicationIdSegmentsSegmentId.ts new file mode 100644 index 0000000..7ef3acd --- /dev/null +++ b/src/serialization/resources/segments/client/deletePublicationsPublicationIdSegmentsSegmentId.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as core from "../../../../core"; + +export const Response: core.serialization.Schema< + serializers.segments.deletePublicationsPublicationIdSegmentsSegmentId.Response.Raw, + Record +> = core.serialization.record(core.serialization.string(), core.serialization.unknown()); + +export declare namespace Response { + type Raw = Record; +} diff --git a/src/serialization/resources/segments/client/index.ts b/src/serialization/resources/segments/client/index.ts new file mode 100644 index 0000000..d3ccbf1 --- /dev/null +++ b/src/serialization/resources/segments/client/index.ts @@ -0,0 +1 @@ +export * as deletePublicationsPublicationIdSegmentsSegmentId from "./deletePublicationsPublicationIdSegmentsSegmentId"; diff --git a/src/serialization/resources/segments/index.ts b/src/serialization/resources/segments/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/serialization/resources/segments/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts new file mode 100644 index 0000000..9636c8e --- /dev/null +++ b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestDirection: core.serialization.Schema< + serializers.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection.Raw, + beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestDirection +> = core.serialization.enum_(["asc", "desc"]); + +export declare namespace SegmentsGetPublicationsPublicationIdSegmentsRequestDirection { + type Raw = "asc" | "desc"; +} diff --git a/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts new file mode 100644 index 0000000..6b577f2 --- /dev/null +++ b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy: core.serialization.Schema< + serializers.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy.Raw, + beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy +> = core.serialization.enum_(["created", "last_calculated"]); + +export declare namespace SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy { + type Raw = "created" | "last_calculated"; +} diff --git a/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts new file mode 100644 index 0000000..2f5cdcb --- /dev/null +++ b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestStatus: core.serialization.Schema< + serializers.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus.Raw, + beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestStatus +> = core.serialization.enum_(["pending", "processing", "completed", "failed", "all"]); + +export declare namespace SegmentsGetPublicationsPublicationIdSegmentsRequestStatus { + type Raw = "pending" | "processing" | "completed" | "failed" | "all"; +} diff --git a/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts new file mode 100644 index 0000000..44f78cb --- /dev/null +++ b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsRequestType.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SegmentsGetPublicationsPublicationIdSegmentsRequestType: core.serialization.Schema< + serializers.SegmentsGetPublicationsPublicationIdSegmentsRequestType.Raw, + beehiiv.SegmentsGetPublicationsPublicationIdSegmentsRequestType +> = core.serialization.enum_(["dynamic", "static", "manual", "all"]); + +export declare namespace SegmentsGetPublicationsPublicationIdSegmentsRequestType { + type Raw = "dynamic" | "static" | "manual" | "all"; +} diff --git a/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts new file mode 100644 index 0000000..18240d0 --- /dev/null +++ b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Segment } from "../../../types/Segment"; + +export const SegmentsGetPublicationsPublicationIdSegmentsResponse: core.serialization.ObjectSchema< + serializers.SegmentsGetPublicationsPublicationIdSegmentsResponse.Raw, + beehiiv.SegmentsGetPublicationsPublicationIdSegmentsResponse +> = core.serialization.object({ + data: core.serialization.list(Segment), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace SegmentsGetPublicationsPublicationIdSegmentsResponse { + interface Raw { + data: Segment.Raw[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts new file mode 100644 index 0000000..7534c11 --- /dev/null +++ b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Segment } from "../../../types/Segment"; + +export const SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse: core.serialization.ObjectSchema< + serializers.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse.Raw, + beehiiv.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse +> = core.serialization.object({ + data: Segment, +}); + +export declare namespace SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse { + interface Raw { + data: Segment.Raw; + } +} diff --git a/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts new file mode 100644 index 0000000..fbfde5f --- /dev/null +++ b/src/serialization/resources/segments/types/SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse: core.serialization.ObjectSchema< + serializers.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse.Raw, + beehiiv.SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse +> = core.serialization.object({ + data: core.serialization.list(core.serialization.string()), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse { + interface Raw { + data: string[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/segments/types/index.ts b/src/serialization/resources/segments/types/index.ts new file mode 100644 index 0000000..1e5c8cb --- /dev/null +++ b/src/serialization/resources/segments/types/index.ts @@ -0,0 +1,7 @@ +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestType"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestStatus"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestOrderBy"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsRequestDirection"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsResponse"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResponse"; +export * from "./SegmentsGetPublicationsPublicationIdSegmentsSegmentIdResultsResponse"; diff --git a/src/serialization/resources/subscriptionTags/client/index.ts b/src/serialization/resources/subscriptionTags/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/subscriptionTags/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts b/src/serialization/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts new file mode 100644 index 0000000..ed9a04b --- /dev/null +++ b/src/serialization/resources/subscriptionTags/client/requests/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; + +export const SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest: core.serialization.Schema< + serializers.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest.Raw, + beehiiv.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest +> = core.serialization.object({ + tags: core.serialization.list(core.serialization.string()).optional(), +}); + +export declare namespace SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest { + interface Raw { + tags?: string[] | null; + } +} diff --git a/src/serialization/resources/subscriptionTags/client/requests/index.ts b/src/serialization/resources/subscriptionTags/client/requests/index.ts new file mode 100644 index 0000000..cd2410d --- /dev/null +++ b/src/serialization/resources/subscriptionTags/client/requests/index.ts @@ -0,0 +1 @@ +export { SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest } from "./SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsRequest"; diff --git a/src/serialization/resources/subscriptionTags/index.ts b/src/serialization/resources/subscriptionTags/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/serialization/resources/subscriptionTags/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/serialization/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts b/src/serialization/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts new file mode 100644 index 0000000..d9569f7 --- /dev/null +++ b/src/serialization/resources/subscriptionTags/types/SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Subscription } from "../../../types/Subscription"; + +export const SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse: core.serialization.ObjectSchema< + serializers.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse.Raw, + beehiiv.SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse +> = core.serialization.object({ + data: Subscription.optional(), +}); + +export declare namespace SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse { + interface Raw { + data?: Subscription.Raw | null; + } +} diff --git a/src/serialization/resources/subscriptionTags/types/index.ts b/src/serialization/resources/subscriptionTags/types/index.ts new file mode 100644 index 0000000..e7c571b --- /dev/null +++ b/src/serialization/resources/subscriptionTags/types/index.ts @@ -0,0 +1 @@ +export * from "./SubscriptionTagsPostPublicationsPublicationIdSubscriptionsSubscriptionIdTagsResponse"; diff --git a/src/serialization/resources/subscriptions/client/deleteSubscriptionsSubscriptionId.ts b/src/serialization/resources/subscriptions/client/deleteSubscriptionsSubscriptionId.ts new file mode 100644 index 0000000..a2f2254 --- /dev/null +++ b/src/serialization/resources/subscriptions/client/deleteSubscriptionsSubscriptionId.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as core from "../../../../core"; + +export const Response: core.serialization.Schema< + serializers.subscriptions.deleteSubscriptionsSubscriptionId.Response.Raw, + Record +> = core.serialization.record(core.serialization.string(), core.serialization.unknown()); + +export declare namespace Response { + type Raw = Record; +} diff --git a/src/serialization/resources/subscriptions/client/index.ts b/src/serialization/resources/subscriptions/client/index.ts new file mode 100644 index 0000000..47c1b3a --- /dev/null +++ b/src/serialization/resources/subscriptions/client/index.ts @@ -0,0 +1,2 @@ +export * as deleteSubscriptionsSubscriptionId from "./deleteSubscriptionsSubscriptionId"; +export * from "./requests"; diff --git a/src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts new file mode 100644 index 0000000..c538c8a --- /dev/null +++ b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem } from "../../types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem"; + +export const SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest: core.serialization.Schema< + serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest +> = core.serialization.object({ + subscriptions: core.serialization + .list(SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem) + .optional(), +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest { + interface Raw { + subscriptions?: SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.Raw[] | null; + } +} diff --git a/src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts new file mode 100644 index 0000000..6cc0283 --- /dev/null +++ b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus } from "../../types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus"; + +export const SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest: core.serialization.Schema< + serializers.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest +> = core.serialization.object({ + subscriptionIds: core.serialization.property( + "subscription_ids", + core.serialization.list(core.serialization.string()) + ), + newStatus: core.serialization.property( + "new_status", + SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus + ), +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest { + interface Raw { + subscription_ids: string[]; + new_status: SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts new file mode 100644 index 0000000..652b873 --- /dev/null +++ b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPostSubscriptionsRequest.ts @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { CustomFieldValue } from "../../../../types/CustomFieldValue"; +import { SubscriptionsPostSubscriptionsRequestDoubleOptOverride } from "../../types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride"; +import { SubscriptionsPostSubscriptionsRequestTier } from "../../types/SubscriptionsPostSubscriptionsRequestTier"; + +export const SubscriptionsPostSubscriptionsRequest: core.serialization.Schema< + serializers.SubscriptionsPostSubscriptionsRequest.Raw, + Omit +> = core.serialization.object({ + email: core.serialization.string(), + reactivateExisting: core.serialization.property("reactivate_existing", core.serialization.boolean().optional()), + sendWelcomeEmail: core.serialization.property("send_welcome_email", core.serialization.boolean().optional()), + utmSource: core.serialization.property("utm_source", core.serialization.string().optional()), + utmMedium: core.serialization.property("utm_medium", core.serialization.string().optional()), + utmCampaign: core.serialization.property("utm_campaign", core.serialization.string().optional()), + referringSite: core.serialization.property("referring_site", core.serialization.string().optional()), + referralCode: core.serialization.property("referral_code", core.serialization.string().optional()), + customFields: core.serialization.property("custom_fields", core.serialization.list(CustomFieldValue).optional()), + doubleOptOverride: core.serialization.property( + "double_opt_override", + SubscriptionsPostSubscriptionsRequestDoubleOptOverride.optional() + ), + tier: SubscriptionsPostSubscriptionsRequestTier.optional(), + automationIds: core.serialization.property( + "automation_ids", + core.serialization.list(core.serialization.string()).optional() + ), +}); + +export declare namespace SubscriptionsPostSubscriptionsRequest { + interface Raw { + email: string; + reactivate_existing?: boolean | null; + send_welcome_email?: boolean | null; + utm_source?: string | null; + utm_medium?: string | null; + utm_campaign?: string | null; + referring_site?: string | null; + referral_code?: string | null; + custom_fields?: CustomFieldValue.Raw[] | null; + double_opt_override?: SubscriptionsPostSubscriptionsRequestDoubleOptOverride.Raw | null; + tier?: SubscriptionsPostSubscriptionsRequestTier.Raw | null; + automation_ids?: string[] | null; + } +} diff --git a/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts new file mode 100644 index 0000000..557c2f7 --- /dev/null +++ b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem } from "../../types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem"; + +export const SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest: core.serialization.Schema< + serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest +> = core.serialization.object({ + subscriptions: core.serialization + .list(SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem) + .optional(), +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest { + interface Raw { + subscriptions?: SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.Raw[] | null; + } +} diff --git a/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts new file mode 100644 index 0000000..6b22bd6 --- /dev/null +++ b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus } from "../../types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus"; + +export const SubscriptionsPutSubscriptionsBulkUpdateStatusRequest: core.serialization.Schema< + serializers.SubscriptionsPutSubscriptionsBulkUpdateStatusRequest.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequest +> = core.serialization.object({ + subscriptionIds: core.serialization.property( + "subscription_ids", + core.serialization.list(core.serialization.string()) + ), + newStatus: core.serialization.property("new_status", SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus), +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkUpdateStatusRequest { + interface Raw { + subscription_ids: string[]; + new_status: SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts new file mode 100644 index 0000000..f991360 --- /dev/null +++ b/src/serialization/resources/subscriptions/client/requests/SubscriptionsPutSubscriptionsSubscriptionIdRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as beehiiv from "../../../../../api"; +import * as core from "../../../../../core"; +import { SubscriptionsPutSubscriptionsSubscriptionIdRequestTier } from "../../types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier"; +import { SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem } from "../../types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem"; + +export const SubscriptionsPutSubscriptionsSubscriptionIdRequest: core.serialization.Schema< + serializers.SubscriptionsPutSubscriptionsSubscriptionIdRequest.Raw, + beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequest +> = core.serialization.object({ + tier: SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.optional(), + unsubscribe: core.serialization.boolean().optional(), + customFields: core.serialization.property( + "custom_fields", + core.serialization.list(SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem).optional() + ), +}); + +export declare namespace SubscriptionsPutSubscriptionsSubscriptionIdRequest { + interface Raw { + tier?: SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Raw | null; + unsubscribe?: boolean | null; + custom_fields?: SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.Raw[] | null; + } +} diff --git a/src/serialization/resources/subscriptions/client/requests/index.ts b/src/serialization/resources/subscriptions/client/requests/index.ts new file mode 100644 index 0000000..689ca6f --- /dev/null +++ b/src/serialization/resources/subscriptions/client/requests/index.ts @@ -0,0 +1,6 @@ +export { SubscriptionsPostSubscriptionsRequest } from "./SubscriptionsPostSubscriptionsRequest"; +export { SubscriptionsPutSubscriptionsBulkUpdateStatusRequest } from "./SubscriptionsPutSubscriptionsBulkUpdateStatusRequest"; +export { SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest } from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusRequest"; +export { SubscriptionsPutSubscriptionsSubscriptionIdRequest } from "./SubscriptionsPutSubscriptionsSubscriptionIdRequest"; +export { SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest } from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequest"; +export { SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest } from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequest"; diff --git a/src/serialization/resources/subscriptions/index.ts b/src/serialization/resources/subscriptions/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/serialization/resources/subscriptions/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts new file mode 100644 index 0000000..ade4de4 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailRequestExpandItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsEmailRequestExpandItem: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsEmailRequestExpandItem.Raw, + beehiiv.SubscriptionsGetSubscriptionsEmailRequestExpandItem +> = core.serialization.enum_(["stats", "custom_fields", "referrals"]); + +export declare namespace SubscriptionsGetSubscriptionsEmailRequestExpandItem { + type Raw = "stats" | "custom_fields" | "referrals"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts new file mode 100644 index 0000000..371a633 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsEmailResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Subscription } from "../../../types/Subscription"; + +export const SubscriptionsGetSubscriptionsEmailResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsGetSubscriptionsEmailResponse.Raw, + beehiiv.SubscriptionsGetSubscriptionsEmailResponse +> = core.serialization.object({ + data: Subscription, +}); + +export declare namespace SubscriptionsGetSubscriptionsEmailResponse { + interface Raw { + data: Subscription.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts new file mode 100644 index 0000000..625db6c --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestDirection.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsRequestDirection: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsRequestDirection.Raw, + beehiiv.SubscriptionsGetSubscriptionsRequestDirection +> = core.serialization.enum_(["asc", "desc"]); + +export declare namespace SubscriptionsGetSubscriptionsRequestDirection { + type Raw = "asc" | "desc"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts new file mode 100644 index 0000000..5d2b7b7 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestExpandItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsRequestExpandItem: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsRequestExpandItem.Raw, + beehiiv.SubscriptionsGetSubscriptionsRequestExpandItem +> = core.serialization.enum_(["stats", "custom_fields", "referrals"]); + +export declare namespace SubscriptionsGetSubscriptionsRequestExpandItem { + type Raw = "stats" | "custom_fields" | "referrals"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts new file mode 100644 index 0000000..3709277 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestOrderBy.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsRequestOrderBy: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsRequestOrderBy.Raw, + beehiiv.SubscriptionsGetSubscriptionsRequestOrderBy +> = core.serialization.enum_(["created", "email"]); + +export declare namespace SubscriptionsGetSubscriptionsRequestOrderBy { + type Raw = "created" | "email"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts new file mode 100644 index 0000000..4c64eed --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsRequestStatus: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsRequestStatus.Raw, + beehiiv.SubscriptionsGetSubscriptionsRequestStatus +> = core.serialization.enum_(["validating", "invalid", "pending", "active", "inactive", "all"]); + +export declare namespace SubscriptionsGetSubscriptionsRequestStatus { + type Raw = "validating" | "invalid" | "pending" | "active" | "inactive" | "all"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts new file mode 100644 index 0000000..09c676e --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsRequestTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsRequestTier: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsRequestTier.Raw, + beehiiv.SubscriptionsGetSubscriptionsRequestTier +> = core.serialization.enum_(["free", "premium", "all"]); + +export declare namespace SubscriptionsGetSubscriptionsRequestTier { + type Raw = "free" | "premium" | "all"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts new file mode 100644 index 0000000..1861ba8 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Subscription } from "../../../types/Subscription"; + +export const SubscriptionsGetSubscriptionsResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsGetSubscriptionsResponse.Raw, + beehiiv.SubscriptionsGetSubscriptionsResponse +> = core.serialization.object({ + data: core.serialization.list(Subscription), + limit: core.serialization.number(), + page: core.serialization.number(), + totalResults: core.serialization.property("total_results", core.serialization.number()), + totalPages: core.serialization.property("total_pages", core.serialization.number()), +}); + +export declare namespace SubscriptionsGetSubscriptionsResponse { + interface Raw { + data: Subscription.Raw[]; + limit: number; + page: number; + total_results: number; + total_pages: number; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts new file mode 100644 index 0000000..113b4bc --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem.Raw, + beehiiv.SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem +> = core.serialization.enum_(["stats", "custom_fields", "referrals"]); + +export declare namespace SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem { + type Raw = "stats" | "custom_fields" | "referrals"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts new file mode 100644 index 0000000..4fd6426 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriberIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Subscription } from "../../../types/Subscription"; + +export const SubscriptionsGetSubscriptionsSubscriberIdResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsGetSubscriptionsSubscriberIdResponse.Raw, + beehiiv.SubscriptionsGetSubscriptionsSubscriberIdResponse +> = core.serialization.object({ + data: Subscription, +}); + +export declare namespace SubscriptionsGetSubscriptionsSubscriberIdResponse { + interface Raw { + data: Subscription.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts new file mode 100644 index 0000000..02306b2 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem: core.serialization.Schema< + serializers.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem.Raw, + beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem +> = core.serialization.enum_(["stats", "custom_fields", "referrals"]); + +export declare namespace SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem { + type Raw = "stats" | "custom_fields" | "referrals"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts new file mode 100644 index 0000000..677a70b --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsGetSubscriptionsSubscriptionIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Subscription } from "../../../types/Subscription"; + +export const SubscriptionsGetSubscriptionsSubscriptionIdResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsGetSubscriptionsSubscriptionIdResponse.Raw, + beehiiv.SubscriptionsGetSubscriptionsSubscriptionIdResponse +> = core.serialization.object({ + data: Subscription, +}); + +export declare namespace SubscriptionsGetSubscriptionsSubscriptionIdResponse { + interface Raw { + data: Subscription.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts new file mode 100644 index 0000000..10098e1 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier } from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier"; +import { SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem } from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem"; + +export const SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem: core.serialization.ObjectSchema< + serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem +> = core.serialization.object({ + subscriptionId: core.serialization.property("subscription_id", core.serialization.string()), + tier: SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.optional(), + unsubscribe: core.serialization.boolean().optional(), + customFields: core.serialization.property( + "custom_fields", + core.serialization + .list(SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem) + .optional() + ), +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem { + interface Raw { + subscription_id: string; + tier?: SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.Raw | null; + unsubscribe?: boolean | null; + custom_fields?: + | SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.Raw[] + | null; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts new file mode 100644 index 0000000..49ce125 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem: core.serialization.ObjectSchema< + serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem +> = core.serialization.object({ + display: core.serialization.string().optional(), + value: core.serialization.string().optional(), + delete: core.serialization.boolean().optional(), +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem { + interface Raw { + display?: string | null; + value?: string | null; + delete?: boolean | null; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts new file mode 100644 index 0000000..4a9e454 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier: core.serialization.Schema< + serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier +> = core.serialization.enum_(["free", "premium"]); + +export declare namespace SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier { + type Raw = "free" | "premium"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts new file mode 100644 index 0000000..eb68b73 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData } from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData"; + +export const SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse +> = core.serialization.object({ + data: SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData, +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse { + interface Raw { + data: SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts new file mode 100644 index 0000000..cd838fc --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData: core.serialization.ObjectSchema< + serializers.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData +> = core.serialization.object({ + subscriptionUpdateId: core.serialization.property("subscription_update_id", core.serialization.string().optional()), +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData { + interface Raw { + subscription_update_id?: string | null; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts new file mode 100644 index 0000000..4933769 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus: core.serialization.Schema< + serializers.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus +> = core.serialization.enum_(["active", "inactive"]); + +export declare namespace SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus { + type Raw = "active" | "inactive"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts new file mode 100644 index 0000000..ce00288 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData } from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData"; + +export const SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse +> = core.serialization.object({ + data: SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData, +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse { + interface Raw { + data: SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts new file mode 100644 index 0000000..13491d5 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData: core.serialization.ObjectSchema< + serializers.SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData.Raw, + beehiiv.SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData +> = core.serialization.object({ + subscriptionUpdateId: core.serialization.property("subscription_update_id", core.serialization.string()), +}); + +export declare namespace SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData { + interface Raw { + subscription_update_id: string; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts new file mode 100644 index 0000000..4541db8 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestDoubleOptOverride.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPostSubscriptionsRequestDoubleOptOverride: core.serialization.Schema< + serializers.SubscriptionsPostSubscriptionsRequestDoubleOptOverride.Raw, + beehiiv.SubscriptionsPostSubscriptionsRequestDoubleOptOverride +> = core.serialization.enum_(["on", "off", "not_set"]); + +export declare namespace SubscriptionsPostSubscriptionsRequestDoubleOptOverride { + type Raw = "on" | "off" | "not_set"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts new file mode 100644 index 0000000..670a550 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsRequestTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPostSubscriptionsRequestTier: core.serialization.Schema< + serializers.SubscriptionsPostSubscriptionsRequestTier.Raw, + beehiiv.SubscriptionsPostSubscriptionsRequestTier +> = core.serialization.enum_(["free", "premium"]); + +export declare namespace SubscriptionsPostSubscriptionsRequestTier { + type Raw = "free" | "premium"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts new file mode 100644 index 0000000..7fe610b --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPostSubscriptionsResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Subscription } from "../../../types/Subscription"; + +export const SubscriptionsPostSubscriptionsResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsPostSubscriptionsResponse.Raw, + beehiiv.SubscriptionsPostSubscriptionsResponse +> = core.serialization.object({ + data: Subscription, +}); + +export declare namespace SubscriptionsPostSubscriptionsResponse { + interface Raw { + data: Subscription.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts new file mode 100644 index 0000000..bb9d1fd --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier } from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier"; +import { SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem } from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem"; + +export const SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem +> = core.serialization.object({ + subscriptionId: core.serialization.property("subscription_id", core.serialization.string()), + tier: SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.optional(), + unsubscribe: core.serialization.boolean().optional(), + customFields: core.serialization.property( + "custom_fields", + core.serialization + .list(SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem) + .optional() + ), +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem { + interface Raw { + subscription_id: string; + tier?: SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.Raw | null; + unsubscribe?: boolean | null; + custom_fields?: + | SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.Raw[] + | null; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts new file mode 100644 index 0000000..5829385 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem +> = core.serialization.object({ + display: core.serialization.string().optional(), + value: core.serialization.string().optional(), + delete: core.serialization.boolean().optional(), +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem { + interface Raw { + display?: string | null; + value?: string | null; + delete?: boolean | null; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts new file mode 100644 index 0000000..6440814 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier: core.serialization.Schema< + serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier +> = core.serialization.enum_(["free", "premium"]); + +export declare namespace SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier { + type Raw = "free" | "premium"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts new file mode 100644 index 0000000..79208b7 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData } from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData"; + +export const SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse +> = core.serialization.object({ + data: SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData, +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse { + interface Raw { + data: SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts new file mode 100644 index 0000000..1995e5c --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData +> = core.serialization.object({ + subscriptionUpdateId: core.serialization.property("subscription_update_id", core.serialization.string().optional()), +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData { + interface Raw { + subscription_update_id?: string | null; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts new file mode 100644 index 0000000..66094c2 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus: core.serialization.Schema< + serializers.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus +> = core.serialization.enum_(["active", "inactive"]); + +export declare namespace SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus { + type Raw = "active" | "inactive"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts new file mode 100644 index 0000000..8446159 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData } from "./SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData"; + +export const SubscriptionsPutSubscriptionsBulkUpdateStatusResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsBulkUpdateStatusResponse.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusResponse +> = core.serialization.object({ + data: SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData, +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkUpdateStatusResponse { + interface Raw { + data: SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts new file mode 100644 index 0000000..c547de4 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData.Raw, + beehiiv.SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData +> = core.serialization.object({ + subscriptionUpdateId: core.serialization.property("subscription_update_id", core.serialization.string()), +}); + +export declare namespace SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData { + interface Raw { + subscription_update_id: string; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts new file mode 100644 index 0000000..4415885 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem.Raw, + beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem +> = core.serialization.object({ + name: core.serialization.string().optional(), + value: core.serialization.string().optional(), + delete: core.serialization.boolean().optional(), +}); + +export declare namespace SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem { + interface Raw { + name?: string | null; + value?: string | null; + delete?: boolean | null; + } +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts new file mode 100644 index 0000000..6462426 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; + +export const SubscriptionsPutSubscriptionsSubscriptionIdRequestTier: core.serialization.Schema< + serializers.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier.Raw, + beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdRequestTier +> = core.serialization.enum_(["free", "premium"]); + +export declare namespace SubscriptionsPutSubscriptionsSubscriptionIdRequestTier { + type Raw = "free" | "premium"; +} diff --git a/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts new file mode 100644 index 0000000..94e50fb --- /dev/null +++ b/src/serialization/resources/subscriptions/types/SubscriptionsPutSubscriptionsSubscriptionIdResponse.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import * as beehiiv from "../../../../api"; +import * as core from "../../../../core"; +import { Subscription } from "../../../types/Subscription"; + +export const SubscriptionsPutSubscriptionsSubscriptionIdResponse: core.serialization.ObjectSchema< + serializers.SubscriptionsPutSubscriptionsSubscriptionIdResponse.Raw, + beehiiv.SubscriptionsPutSubscriptionsSubscriptionIdResponse +> = core.serialization.object({ + data: Subscription, +}); + +export declare namespace SubscriptionsPutSubscriptionsSubscriptionIdResponse { + interface Raw { + data: Subscription.Raw; + } +} diff --git a/src/serialization/resources/subscriptions/types/index.ts b/src/serialization/resources/subscriptions/types/index.ts new file mode 100644 index 0000000..6dece38 --- /dev/null +++ b/src/serialization/resources/subscriptions/types/index.ts @@ -0,0 +1,34 @@ +export * from "./SubscriptionsGetSubscriptionsRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsRequestStatus"; +export * from "./SubscriptionsGetSubscriptionsRequestTier"; +export * from "./SubscriptionsGetSubscriptionsRequestOrderBy"; +export * from "./SubscriptionsGetSubscriptionsRequestDirection"; +export * from "./SubscriptionsGetSubscriptionsResponse"; +export * from "./SubscriptionsPostSubscriptionsRequestDoubleOptOverride"; +export * from "./SubscriptionsPostSubscriptionsRequestTier"; +export * from "./SubscriptionsPostSubscriptionsResponse"; +export * from "./SubscriptionsPutSubscriptionsBulkUpdateStatusRequestNewStatus"; +export * from "./SubscriptionsPutSubscriptionsBulkUpdateStatusResponseData"; +export * from "./SubscriptionsPutSubscriptionsBulkUpdateStatusResponse"; +export * from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusRequestNewStatus"; +export * from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusResponseData"; +export * from "./SubscriptionsPatchSubscriptionsBulkUpdateStatusResponse"; +export * from "./SubscriptionsGetSubscriptionsSubscriptionIdRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsSubscriptionIdResponse"; +export * from "./SubscriptionsPutSubscriptionsSubscriptionIdRequestTier"; +export * from "./SubscriptionsPutSubscriptionsSubscriptionIdRequestCustomFieldsItem"; +export * from "./SubscriptionsPutSubscriptionsSubscriptionIdResponse"; +export * from "./SubscriptionsGetSubscriptionsSubscriberIdRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsSubscriberIdResponse"; +export * from "./SubscriptionsGetSubscriptionsEmailRequestExpandItem"; +export * from "./SubscriptionsGetSubscriptionsEmailResponse"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponseData"; +export * from "./SubscriptionsPutSubscriptionsBulkActionsBulkUpdateResponse"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemTier"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItemCustomFieldsItem"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateRequestSubscriptionsItem"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponseData"; +export * from "./SubscriptionsPatchSubscriptionsBulkActionsBulkUpdateResponse"; diff --git a/src/serialization/types/Automation.ts b/src/serialization/types/Automation.ts new file mode 100644 index 0000000..9ac6a56 --- /dev/null +++ b/src/serialization/types/Automation.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { AutomationStatus } from "./AutomationStatus"; + +export const Automation: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + status: AutomationStatus, + name: core.serialization.string(), + description: core.serialization.string().optional(), + }); + +export declare namespace Automation { + interface Raw { + id: string; + status: AutomationStatus.Raw; + name: string; + description?: string | null; + } +} diff --git a/src/serialization/types/AutomationJourney.ts b/src/serialization/types/AutomationJourney.ts new file mode 100644 index 0000000..fff7b7c --- /dev/null +++ b/src/serialization/types/AutomationJourney.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { AutomationJourneyStatus } from "./AutomationJourneyStatus"; + +export const AutomationJourney: core.serialization.ObjectSchema< + serializers.AutomationJourney.Raw, + beehiiv.AutomationJourney +> = core.serialization.object({ + id: core.serialization.string(), + automationId: core.serialization.property("automation_id", core.serialization.string()), + subscriptionId: core.serialization.property("subscription_id", core.serialization.string()), + status: AutomationJourneyStatus, + startedAt: core.serialization.property("started_at", core.serialization.number().optional()), + completedAt: core.serialization.property("completed_at", core.serialization.number().optional()), +}); + +export declare namespace AutomationJourney { + interface Raw { + id: string; + automation_id: string; + subscription_id: string; + status: AutomationJourneyStatus.Raw; + started_at?: number | null; + completed_at?: number | null; + } +} diff --git a/src/serialization/types/AutomationJourneyStatus.ts b/src/serialization/types/AutomationJourneyStatus.ts new file mode 100644 index 0000000..3b68ad6 --- /dev/null +++ b/src/serialization/types/AutomationJourneyStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const AutomationJourneyStatus: core.serialization.Schema< + serializers.AutomationJourneyStatus.Raw, + beehiiv.AutomationJourneyStatus +> = core.serialization.enum_(["initiated", "running", "completed", "failed"]); + +export declare namespace AutomationJourneyStatus { + type Raw = "initiated" | "running" | "completed" | "failed"; +} diff --git a/src/serialization/types/AutomationStatus.ts b/src/serialization/types/AutomationStatus.ts new file mode 100644 index 0000000..cba155c --- /dev/null +++ b/src/serialization/types/AutomationStatus.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const AutomationStatus: core.serialization.Schema = + core.serialization.enum_(["running", "finishing", "inactive"]); + +export declare namespace AutomationStatus { + type Raw = "running" | "finishing" | "inactive"; +} diff --git a/src/serialization/types/ClickStats.ts b/src/serialization/types/ClickStats.ts new file mode 100644 index 0000000..a6ec07c --- /dev/null +++ b/src/serialization/types/ClickStats.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { PostClickStatsEmail } from "./PostClickStatsEmail"; +import { PostClickStatsWeb } from "./PostClickStatsWeb"; + +export const ClickStats: core.serialization.ObjectSchema = + core.serialization.object({ + url: core.serialization.string().optional(), + email: PostClickStatsEmail.optional(), + web: PostClickStatsWeb.optional(), + totalClicks: core.serialization.property("total_clicks", core.serialization.number().optional()), + totalUniqueClicks: core.serialization.property("total_unique_clicks", core.serialization.number().optional()), + totalClickThroughRate: core.serialization.property( + "total_click_through_rate", + core.serialization.number().optional() + ), + }); + +export declare namespace ClickStats { + interface Raw { + url?: string | null; + email?: PostClickStatsEmail.Raw | null; + web?: PostClickStatsWeb.Raw | null; + total_clicks?: number | null; + total_unique_clicks?: number | null; + total_click_through_rate?: number | null; + } +} diff --git a/src/serialization/types/CustomField.ts b/src/serialization/types/CustomField.ts new file mode 100644 index 0000000..6d4371a --- /dev/null +++ b/src/serialization/types/CustomField.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { CustomFieldKind } from "./CustomFieldKind"; + +export const CustomField: core.serialization.ObjectSchema = + core.serialization.object({ + name: core.serialization.string().optional(), + kind: CustomFieldKind.optional(), + value: core.serialization.string().optional(), + }); + +export declare namespace CustomField { + interface Raw { + name?: string | null; + kind?: CustomFieldKind.Raw | null; + value?: string | null; + } +} diff --git a/src/serialization/types/CustomFieldKind.ts b/src/serialization/types/CustomFieldKind.ts new file mode 100644 index 0000000..66b3bc1 --- /dev/null +++ b/src/serialization/types/CustomFieldKind.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const CustomFieldKind: core.serialization.Schema = + core.serialization.enum_(["string", "integer", "boolean", "date", "datetime"]); + +export declare namespace CustomFieldKind { + type Raw = "string" | "integer" | "boolean" | "date" | "datetime"; +} diff --git a/src/serialization/types/CustomFieldValue.ts b/src/serialization/types/CustomFieldValue.ts new file mode 100644 index 0000000..0b2c1e0 --- /dev/null +++ b/src/serialization/types/CustomFieldValue.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const CustomFieldValue: core.serialization.ObjectSchema< + serializers.CustomFieldValue.Raw, + beehiiv.CustomFieldValue +> = core.serialization.object({ + name: core.serialization.string().optional(), + value: core.serialization.string().optional(), +}); + +export declare namespace CustomFieldValue { + interface Raw { + name?: string | null; + value?: string | null; + } +} diff --git a/src/serialization/types/EmailBlast.ts b/src/serialization/types/EmailBlast.ts new file mode 100644 index 0000000..39b1974 --- /dev/null +++ b/src/serialization/types/EmailBlast.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { EmailBlastStatus } from "./EmailBlastStatus"; +import { EmailBlastStats } from "./EmailBlastStats"; +import { EmailBlastContent } from "./EmailBlastContent"; + +export const EmailBlast: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + created: core.serialization.number(), + lastSent: core.serialization.property("last_sent", core.serialization.number()), + status: EmailBlastStatus, + subjectLine: core.serialization.property("subject_line", core.serialization.string()), + previewText: core.serialization.property("preview_text", core.serialization.string()), + stats: EmailBlastStats.optional(), + content: EmailBlastContent.optional(), + }); + +export declare namespace EmailBlast { + interface Raw { + id: string; + created: number; + last_sent: number; + status: EmailBlastStatus.Raw; + subject_line: string; + preview_text: string; + stats?: EmailBlastStats.Raw | null; + content?: EmailBlastContent.Raw | null; + } +} diff --git a/src/serialization/types/EmailBlastContent.ts b/src/serialization/types/EmailBlastContent.ts new file mode 100644 index 0000000..a34f029 --- /dev/null +++ b/src/serialization/types/EmailBlastContent.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { EmailBlastContentEmail } from "./EmailBlastContentEmail"; + +export const EmailBlastContent: core.serialization.ObjectSchema< + serializers.EmailBlastContent.Raw, + beehiiv.EmailBlastContent +> = core.serialization.object({ + email: EmailBlastContentEmail.optional(), +}); + +export declare namespace EmailBlastContent { + interface Raw { + email?: EmailBlastContentEmail.Raw | null; + } +} diff --git a/src/serialization/types/EmailBlastContentEmail.ts b/src/serialization/types/EmailBlastContentEmail.ts new file mode 100644 index 0000000..0c3efc7 --- /dev/null +++ b/src/serialization/types/EmailBlastContentEmail.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const EmailBlastContentEmail: core.serialization.ObjectSchema< + serializers.EmailBlastContentEmail.Raw, + beehiiv.EmailBlastContentEmail +> = core.serialization.object({ + free: core.serialization.string().optional(), + premium: core.serialization.string().optional(), +}); + +export declare namespace EmailBlastContentEmail { + interface Raw { + free?: string | null; + premium?: string | null; + } +} diff --git a/src/serialization/types/EmailBlastStats.ts b/src/serialization/types/EmailBlastStats.ts new file mode 100644 index 0000000..178230b --- /dev/null +++ b/src/serialization/types/EmailBlastStats.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { EmailBlastStatsEmail } from "./EmailBlastStatsEmail"; +import { EmailBlastStatsClicksItem } from "./EmailBlastStatsClicksItem"; + +export const EmailBlastStats: core.serialization.ObjectSchema< + serializers.EmailBlastStats.Raw, + beehiiv.EmailBlastStats +> = core.serialization.object({ + email: EmailBlastStatsEmail.optional(), + clicks: core.serialization.list(EmailBlastStatsClicksItem).optional(), +}); + +export declare namespace EmailBlastStats { + interface Raw { + email?: EmailBlastStatsEmail.Raw | null; + clicks?: EmailBlastStatsClicksItem.Raw[] | null; + } +} diff --git a/src/serialization/types/EmailBlastStatsClicksItem.ts b/src/serialization/types/EmailBlastStatsClicksItem.ts new file mode 100644 index 0000000..3ce3f84 --- /dev/null +++ b/src/serialization/types/EmailBlastStatsClicksItem.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const EmailBlastStatsClicksItem: core.serialization.ObjectSchema< + serializers.EmailBlastStatsClicksItem.Raw, + beehiiv.EmailBlastStatsClicksItem +> = core.serialization.object({ + url: core.serialization.string().optional(), + totalClicks: core.serialization.property("total_clicks", core.serialization.number().optional()), + totalUniqueClicks: core.serialization.property("total_unique_clicks", core.serialization.number().optional()), + totalClickThroughRate: core.serialization.property( + "total_click_through_rate", + core.serialization.number().optional() + ), +}); + +export declare namespace EmailBlastStatsClicksItem { + interface Raw { + url?: string | null; + total_clicks?: number | null; + total_unique_clicks?: number | null; + total_click_through_rate?: number | null; + } +} diff --git a/src/serialization/types/EmailBlastStatsEmail.ts b/src/serialization/types/EmailBlastStatsEmail.ts new file mode 100644 index 0000000..592bd66 --- /dev/null +++ b/src/serialization/types/EmailBlastStatsEmail.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const EmailBlastStatsEmail: core.serialization.ObjectSchema< + serializers.EmailBlastStatsEmail.Raw, + beehiiv.EmailBlastStatsEmail +> = core.serialization.object({ + recipients: core.serialization.number().optional(), + opens: core.serialization.number().optional(), + uniqueOpens: core.serialization.property("unique_opens", core.serialization.number().optional()), + openRate: core.serialization.property("open_rate", core.serialization.number().optional()), + clicks: core.serialization.number().optional(), + uniqueClicks: core.serialization.property("unique_clicks", core.serialization.number().optional()), + clickRate: core.serialization.property("click_rate", core.serialization.number().optional()), + unsubscribes: core.serialization.number().optional(), + spamReports: core.serialization.property("spam_reports", core.serialization.number().optional()), +}); + +export declare namespace EmailBlastStatsEmail { + interface Raw { + recipients?: number | null; + opens?: number | null; + unique_opens?: number | null; + open_rate?: number | null; + clicks?: number | null; + unique_clicks?: number | null; + click_rate?: number | null; + unsubscribes?: number | null; + spam_reports?: number | null; + } +} diff --git a/src/serialization/types/EmailBlastStatus.ts b/src/serialization/types/EmailBlastStatus.ts new file mode 100644 index 0000000..3ee6057 --- /dev/null +++ b/src/serialization/types/EmailBlastStatus.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const EmailBlastStatus: core.serialization.Schema = + core.serialization.enum_(["active", "inactive"]); + +export declare namespace EmailBlastStatus { + type Raw = "active" | "inactive"; +} diff --git a/src/serialization/types/ErrorErrorsItem.ts b/src/serialization/types/ErrorErrorsItem.ts new file mode 100644 index 0000000..4b65a7d --- /dev/null +++ b/src/serialization/types/ErrorErrorsItem.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const ErrorErrorsItem: core.serialization.ObjectSchema< + serializers.ErrorErrorsItem.Raw, + beehiiv.ErrorErrorsItem +> = core.serialization.object({ + message: core.serialization.string(), + code: core.serialization.string(), +}); + +export declare namespace ErrorErrorsItem { + interface Raw { + message: string; + code: string; + } +} diff --git a/src/serialization/types/Error_.ts b/src/serialization/types/Error_.ts new file mode 100644 index 0000000..e79e265 --- /dev/null +++ b/src/serialization/types/Error_.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { ErrorErrorsItem } from "./ErrorErrorsItem"; + +export const Error_: core.serialization.ObjectSchema = + core.serialization.object({ + status: core.serialization.string(), + statusText: core.serialization.string(), + errors: core.serialization.list(ErrorErrorsItem), + }); + +export declare namespace Error_ { + interface Raw { + status: string; + statusText: string; + errors: ErrorErrorsItem.Raw[]; + } +} diff --git a/src/serialization/types/Milestone.ts b/src/serialization/types/Milestone.ts new file mode 100644 index 0000000..028b1c9 --- /dev/null +++ b/src/serialization/types/Milestone.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { MilestoneReward } from "./MilestoneReward"; + +export const Milestone: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + autoFulfill: core.serialization.property("auto_fulfill", core.serialization.boolean()), + numReferrals: core.serialization.property("num_referrals", core.serialization.number()), + reward: MilestoneReward, + }); + +export declare namespace Milestone { + interface Raw { + id: string; + auto_fulfill: boolean; + num_referrals: number; + reward: MilestoneReward.Raw; + } +} diff --git a/src/serialization/types/MilestoneReward.ts b/src/serialization/types/MilestoneReward.ts new file mode 100644 index 0000000..c2a92ca --- /dev/null +++ b/src/serialization/types/MilestoneReward.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { MilestoneRewardType } from "./MilestoneRewardType"; + +export const MilestoneReward: core.serialization.ObjectSchema< + serializers.MilestoneReward.Raw, + beehiiv.MilestoneReward +> = core.serialization.object({ + id: core.serialization.string(), + name: core.serialization.string(), + description: core.serialization.string(), + imageUrl: core.serialization.property("image_url", core.serialization.string()), + type: MilestoneRewardType, +}); + +export declare namespace MilestoneReward { + interface Raw { + id: string; + name: string; + description: string; + image_url: string; + type: MilestoneRewardType.Raw; + } +} diff --git a/src/serialization/types/MilestoneRewardType.ts b/src/serialization/types/MilestoneRewardType.ts new file mode 100644 index 0000000..e485336 --- /dev/null +++ b/src/serialization/types/MilestoneRewardType.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const MilestoneRewardType: core.serialization.Schema< + serializers.MilestoneRewardType.Raw, + beehiiv.MilestoneRewardType +> = core.serialization.enum_(["physical", "promo_code"]); + +export declare namespace MilestoneRewardType { + type Raw = "physical" | "promo_code"; +} diff --git a/src/serialization/types/Post.ts b/src/serialization/types/Post.ts new file mode 100644 index 0000000..3f3e2ce --- /dev/null +++ b/src/serialization/types/Post.ts @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { PostStatus } from "./PostStatus"; +import { PostAudience } from "./PostAudience"; +import { PostPlatform } from "./PostPlatform"; +import { PostContent } from "./PostContent"; +import { PostStats } from "./PostStats"; + +export const Post: core.serialization.ObjectSchema = core.serialization.object({ + id: core.serialization.string(), + subtitle: core.serialization.string(), + title: core.serialization.string(), + authors: core.serialization.list(core.serialization.string()), + created: core.serialization.number(), + status: PostStatus, + publishDate: core.serialization.property("publish_date", core.serialization.number().optional()), + displayedDate: core.serialization.property("displayed_date", core.serialization.number().optional()), + splitTested: core.serialization.property("split_tested", core.serialization.boolean()), + subjectLine: core.serialization.property("subject_line", core.serialization.string()), + previewText: core.serialization.property("preview_text", core.serialization.string()), + slug: core.serialization.string(), + thumbnailUrl: core.serialization.property("thumbnail_url", core.serialization.string()), + webUrl: core.serialization.property("web_url", core.serialization.string()), + audience: PostAudience, + platform: PostPlatform, + contentTags: core.serialization.property("content_tags", core.serialization.list(core.serialization.string())), + metaDefaultDescription: core.serialization.property( + "meta_default_description", + core.serialization.string().optional() + ), + metaDefaultTitle: core.serialization.property("meta_default_title", core.serialization.string().optional()), + content: PostContent.optional(), + stats: PostStats.optional(), + hiddenFromFeed: core.serialization.property("hidden_from_feed", core.serialization.boolean()), +}); + +export declare namespace Post { + interface Raw { + id: string; + subtitle: string; + title: string; + authors: string[]; + created: number; + status: PostStatus.Raw; + publish_date?: number | null; + displayed_date?: number | null; + split_tested: boolean; + subject_line: string; + preview_text: string; + slug: string; + thumbnail_url: string; + web_url: string; + audience: PostAudience.Raw; + platform: PostPlatform.Raw; + content_tags: string[]; + meta_default_description?: string | null; + meta_default_title?: string | null; + content?: PostContent.Raw | null; + stats?: PostStats.Raw | null; + hidden_from_feed: boolean; + } +} diff --git a/src/serialization/types/PostAudience.ts b/src/serialization/types/PostAudience.ts new file mode 100644 index 0000000..6340531 --- /dev/null +++ b/src/serialization/types/PostAudience.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostAudience: core.serialization.Schema = + core.serialization.enum_(["free", "premium", "both"]); + +export declare namespace PostAudience { + type Raw = "free" | "premium" | "both"; +} diff --git a/src/serialization/types/PostClickStatsEmail.ts b/src/serialization/types/PostClickStatsEmail.ts new file mode 100644 index 0000000..479d798 --- /dev/null +++ b/src/serialization/types/PostClickStatsEmail.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostClickStatsEmail: core.serialization.ObjectSchema< + serializers.PostClickStatsEmail.Raw, + beehiiv.PostClickStatsEmail +> = core.serialization.object({ + clicks: core.serialization.number().optional(), + uniqueClicks: core.serialization.property("unique_clicks", core.serialization.number().optional()), + clickThroughRate: core.serialization.property("click_through_rate", core.serialization.number().optional()), +}); + +export declare namespace PostClickStatsEmail { + interface Raw { + clicks?: number | null; + unique_clicks?: number | null; + click_through_rate?: number | null; + } +} diff --git a/src/serialization/types/PostClickStatsWeb.ts b/src/serialization/types/PostClickStatsWeb.ts new file mode 100644 index 0000000..f51835f --- /dev/null +++ b/src/serialization/types/PostClickStatsWeb.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostClickStatsWeb: core.serialization.ObjectSchema< + serializers.PostClickStatsWeb.Raw, + beehiiv.PostClickStatsWeb +> = core.serialization.object({ + clicks: core.serialization.number().optional(), + uniqueClicks: core.serialization.property("unique_clicks", core.serialization.number().optional()), + clickThroughRate: core.serialization.property("click_through_rate", core.serialization.number().optional()), +}); + +export declare namespace PostClickStatsWeb { + interface Raw { + clicks?: number | null; + unique_clicks?: number | null; + click_through_rate?: number | null; + } +} diff --git a/src/serialization/types/PostContent.ts b/src/serialization/types/PostContent.ts new file mode 100644 index 0000000..341ade1 --- /dev/null +++ b/src/serialization/types/PostContent.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { PostContentFree } from "./PostContentFree"; +import { PostContentPremium } from "./PostContentPremium"; + +export const PostContent: core.serialization.ObjectSchema = + core.serialization.object({ + free: PostContentFree.optional(), + premium: PostContentPremium.optional(), + }); + +export declare namespace PostContent { + interface Raw { + free?: PostContentFree.Raw | null; + premium?: PostContentPremium.Raw | null; + } +} diff --git a/src/serialization/types/PostContentFree.ts b/src/serialization/types/PostContentFree.ts new file mode 100644 index 0000000..01920ee --- /dev/null +++ b/src/serialization/types/PostContentFree.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostContentFree: core.serialization.ObjectSchema< + serializers.PostContentFree.Raw, + beehiiv.PostContentFree +> = core.serialization.object({ + web: core.serialization.string().optional(), + email: core.serialization.string().optional(), + rss: core.serialization.string().optional(), +}); + +export declare namespace PostContentFree { + interface Raw { + web?: string | null; + email?: string | null; + rss?: string | null; + } +} diff --git a/src/serialization/types/PostContentPremium.ts b/src/serialization/types/PostContentPremium.ts new file mode 100644 index 0000000..9391ff7 --- /dev/null +++ b/src/serialization/types/PostContentPremium.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostContentPremium: core.serialization.ObjectSchema< + serializers.PostContentPremium.Raw, + beehiiv.PostContentPremium +> = core.serialization.object({ + web: core.serialization.string().optional(), + email: core.serialization.string().optional(), +}); + +export declare namespace PostContentPremium { + interface Raw { + web?: string | null; + email?: string | null; + } +} diff --git a/src/serialization/types/PostPlatform.ts b/src/serialization/types/PostPlatform.ts new file mode 100644 index 0000000..cd55e08 --- /dev/null +++ b/src/serialization/types/PostPlatform.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostPlatform: core.serialization.Schema = + core.serialization.enum_(["web", "email", "both"]); + +export declare namespace PostPlatform { + type Raw = "web" | "email" | "both"; +} diff --git a/src/serialization/types/PostStats.ts b/src/serialization/types/PostStats.ts new file mode 100644 index 0000000..f9a1172 --- /dev/null +++ b/src/serialization/types/PostStats.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { PostStatsEmail } from "./PostStatsEmail"; +import { PostStatsWeb } from "./PostStatsWeb"; +import { ClickStats } from "./ClickStats"; + +export const PostStats: core.serialization.ObjectSchema = + core.serialization.object({ + email: PostStatsEmail.optional(), + web: PostStatsWeb.optional(), + clicks: core.serialization.list(ClickStats).optional(), + }); + +export declare namespace PostStats { + interface Raw { + email?: PostStatsEmail.Raw | null; + web?: PostStatsWeb.Raw | null; + clicks?: ClickStats.Raw[] | null; + } +} diff --git a/src/serialization/types/PostStatsEmail.ts b/src/serialization/types/PostStatsEmail.ts new file mode 100644 index 0000000..570e66c --- /dev/null +++ b/src/serialization/types/PostStatsEmail.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostStatsEmail: core.serialization.ObjectSchema = + core.serialization.object({ + recipients: core.serialization.number().optional(), + opens: core.serialization.number().optional(), + uniqueOpens: core.serialization.property("unique_opens", core.serialization.number().optional()), + openRate: core.serialization.property("open_rate", core.serialization.number().optional()), + clicks: core.serialization.number().optional(), + uniqueClicks: core.serialization.property("unique_clicks", core.serialization.number().optional()), + clickRate: core.serialization.property("click_rate", core.serialization.number().optional()), + unsubscribes: core.serialization.number().optional(), + spamReports: core.serialization.property("spam_reports", core.serialization.number().optional()), + }); + +export declare namespace PostStatsEmail { + interface Raw { + recipients?: number | null; + opens?: number | null; + unique_opens?: number | null; + open_rate?: number | null; + clicks?: number | null; + unique_clicks?: number | null; + click_rate?: number | null; + unsubscribes?: number | null; + spam_reports?: number | null; + } +} diff --git a/src/serialization/types/PostStatsWeb.ts b/src/serialization/types/PostStatsWeb.ts new file mode 100644 index 0000000..0366ede --- /dev/null +++ b/src/serialization/types/PostStatsWeb.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostStatsWeb: core.serialization.ObjectSchema = + core.serialization.object({ + views: core.serialization.number().optional(), + clicks: core.serialization.number().optional(), + }); + +export declare namespace PostStatsWeb { + interface Raw { + views?: number | null; + clicks?: number | null; + } +} diff --git a/src/serialization/types/PostStatus.ts b/src/serialization/types/PostStatus.ts new file mode 100644 index 0000000..3f495f6 --- /dev/null +++ b/src/serialization/types/PostStatus.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PostStatus: core.serialization.Schema = + core.serialization.enum_(["draft", "confirmed", "archived"]); + +export declare namespace PostStatus { + type Raw = "draft" | "confirmed" | "archived"; +} diff --git a/src/serialization/types/Publication.ts b/src/serialization/types/Publication.ts new file mode 100644 index 0000000..f8b3025 --- /dev/null +++ b/src/serialization/types/Publication.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { PublicationStats } from "./PublicationStats"; + +export const Publication: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + name: core.serialization.string(), + referralProgramEnabled: core.serialization.property("referral_program_enabled", core.serialization.boolean()), + created: core.serialization.number(), + stats: PublicationStats.optional(), + }); + +export declare namespace Publication { + interface Raw { + id: string; + name: string; + referral_program_enabled: boolean; + created: number; + stats?: PublicationStats.Raw | null; + } +} diff --git a/src/serialization/types/PublicationStats.ts b/src/serialization/types/PublicationStats.ts new file mode 100644 index 0000000..8900281 --- /dev/null +++ b/src/serialization/types/PublicationStats.ts @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { PublicationStatsActiveSubscriptions } from "./PublicationStatsActiveSubscriptions"; +import { PublicationStatsActivePremiumSubscriptions } from "./PublicationStatsActivePremiumSubscriptions"; +import { PublicationStatsActiveFreeSubscriptions } from "./PublicationStatsActiveFreeSubscriptions"; +import { PublicationStatsAverageOpenRate } from "./PublicationStatsAverageOpenRate"; +import { PublicationStatsAverageClickRate } from "./PublicationStatsAverageClickRate"; +import { PublicationStatsTotalSent } from "./PublicationStatsTotalSent"; +import { PublicationStatsTotalUniqueOpened } from "./PublicationStatsTotalUniqueOpened"; +import { PublicationStatsTotalClicked } from "./PublicationStatsTotalClicked"; + +export const PublicationStats: core.serialization.ObjectSchema< + serializers.PublicationStats.Raw, + beehiiv.PublicationStats +> = core.serialization.object({ + activeSubscriptions: core.serialization.property( + "active_subscriptions", + PublicationStatsActiveSubscriptions.optional() + ), + activePremiumSubscriptions: core.serialization.property( + "active_premium_subscriptions", + PublicationStatsActivePremiumSubscriptions.optional() + ), + activeFreeSubscriptions: core.serialization.property( + "active_free_subscriptions", + PublicationStatsActiveFreeSubscriptions.optional() + ), + averageOpenRate: core.serialization.property("average_open_rate", PublicationStatsAverageOpenRate.optional()), + averageClickRate: core.serialization.property("average_click_rate", PublicationStatsAverageClickRate.optional()), + totalSent: core.serialization.property("total_sent", PublicationStatsTotalSent.optional()), + totalUniqueOpened: core.serialization.property("total_unique_opened", PublicationStatsTotalUniqueOpened.optional()), + totalClicked: core.serialization.property("total_clicked", PublicationStatsTotalClicked.optional()), +}); + +export declare namespace PublicationStats { + interface Raw { + active_subscriptions?: PublicationStatsActiveSubscriptions.Raw | null; + active_premium_subscriptions?: PublicationStatsActivePremiumSubscriptions.Raw | null; + active_free_subscriptions?: PublicationStatsActiveFreeSubscriptions.Raw | null; + average_open_rate?: PublicationStatsAverageOpenRate.Raw | null; + average_click_rate?: PublicationStatsAverageClickRate.Raw | null; + total_sent?: PublicationStatsTotalSent.Raw | null; + total_unique_opened?: PublicationStatsTotalUniqueOpened.Raw | null; + total_clicked?: PublicationStatsTotalClicked.Raw | null; + } +} diff --git a/src/serialization/types/PublicationStatsActiveFreeSubscriptions.ts b/src/serialization/types/PublicationStatsActiveFreeSubscriptions.ts new file mode 100644 index 0000000..0717e2a --- /dev/null +++ b/src/serialization/types/PublicationStatsActiveFreeSubscriptions.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsActiveFreeSubscriptions: core.serialization.Schema< + serializers.PublicationStatsActiveFreeSubscriptions.Raw, + beehiiv.PublicationStatsActiveFreeSubscriptions +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsActiveFreeSubscriptions { + type Raw = number | boolean; +} diff --git a/src/serialization/types/PublicationStatsActivePremiumSubscriptions.ts b/src/serialization/types/PublicationStatsActivePremiumSubscriptions.ts new file mode 100644 index 0000000..44dcac7 --- /dev/null +++ b/src/serialization/types/PublicationStatsActivePremiumSubscriptions.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsActivePremiumSubscriptions: core.serialization.Schema< + serializers.PublicationStatsActivePremiumSubscriptions.Raw, + beehiiv.PublicationStatsActivePremiumSubscriptions +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsActivePremiumSubscriptions { + type Raw = number | boolean; +} diff --git a/src/serialization/types/PublicationStatsActiveSubscriptions.ts b/src/serialization/types/PublicationStatsActiveSubscriptions.ts new file mode 100644 index 0000000..43a7db8 --- /dev/null +++ b/src/serialization/types/PublicationStatsActiveSubscriptions.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsActiveSubscriptions: core.serialization.Schema< + serializers.PublicationStatsActiveSubscriptions.Raw, + beehiiv.PublicationStatsActiveSubscriptions +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsActiveSubscriptions { + type Raw = number | boolean; +} diff --git a/src/serialization/types/PublicationStatsAverageClickRate.ts b/src/serialization/types/PublicationStatsAverageClickRate.ts new file mode 100644 index 0000000..020ed46 --- /dev/null +++ b/src/serialization/types/PublicationStatsAverageClickRate.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsAverageClickRate: core.serialization.Schema< + serializers.PublicationStatsAverageClickRate.Raw, + beehiiv.PublicationStatsAverageClickRate +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsAverageClickRate { + type Raw = number | boolean; +} diff --git a/src/serialization/types/PublicationStatsAverageOpenRate.ts b/src/serialization/types/PublicationStatsAverageOpenRate.ts new file mode 100644 index 0000000..c32fbe3 --- /dev/null +++ b/src/serialization/types/PublicationStatsAverageOpenRate.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsAverageOpenRate: core.serialization.Schema< + serializers.PublicationStatsAverageOpenRate.Raw, + beehiiv.PublicationStatsAverageOpenRate +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsAverageOpenRate { + type Raw = number | boolean; +} diff --git a/src/serialization/types/PublicationStatsTotalClicked.ts b/src/serialization/types/PublicationStatsTotalClicked.ts new file mode 100644 index 0000000..178bf6c --- /dev/null +++ b/src/serialization/types/PublicationStatsTotalClicked.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsTotalClicked: core.serialization.Schema< + serializers.PublicationStatsTotalClicked.Raw, + beehiiv.PublicationStatsTotalClicked +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsTotalClicked { + type Raw = number | boolean; +} diff --git a/src/serialization/types/PublicationStatsTotalSent.ts b/src/serialization/types/PublicationStatsTotalSent.ts new file mode 100644 index 0000000..2f59206 --- /dev/null +++ b/src/serialization/types/PublicationStatsTotalSent.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsTotalSent: core.serialization.Schema< + serializers.PublicationStatsTotalSent.Raw, + beehiiv.PublicationStatsTotalSent +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsTotalSent { + type Raw = number | boolean; +} diff --git a/src/serialization/types/PublicationStatsTotalUniqueOpened.ts b/src/serialization/types/PublicationStatsTotalUniqueOpened.ts new file mode 100644 index 0000000..5171759 --- /dev/null +++ b/src/serialization/types/PublicationStatsTotalUniqueOpened.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const PublicationStatsTotalUniqueOpened: core.serialization.Schema< + serializers.PublicationStatsTotalUniqueOpened.Raw, + beehiiv.PublicationStatsTotalUniqueOpened +> = core.serialization.undiscriminatedUnion([core.serialization.number(), core.serialization.boolean()]); + +export declare namespace PublicationStatsTotalUniqueOpened { + type Raw = number | boolean; +} diff --git a/src/serialization/types/Segment.ts b/src/serialization/types/Segment.ts new file mode 100644 index 0000000..1a43568 --- /dev/null +++ b/src/serialization/types/Segment.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { SegmentType } from "./SegmentType"; +import { SegmentStatus } from "./SegmentStatus"; + +export const Segment: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + name: core.serialization.string(), + type: SegmentType, + lastCalculated: core.serialization.property("last_calculated", core.serialization.number().optional()), + totalResults: core.serialization.property("total_results", core.serialization.number()), + status: SegmentStatus, + active: core.serialization.boolean(), + }); + +export declare namespace Segment { + interface Raw { + id: string; + name: string; + type: SegmentType.Raw; + last_calculated?: number | null; + total_results: number; + status: SegmentStatus.Raw; + active: boolean; + } +} diff --git a/src/serialization/types/SegmentStatus.ts b/src/serialization/types/SegmentStatus.ts new file mode 100644 index 0000000..7f0cf8b --- /dev/null +++ b/src/serialization/types/SegmentStatus.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SegmentStatus: core.serialization.Schema = + core.serialization.enum_(["pending", "processing", "completed", "failed"]); + +export declare namespace SegmentStatus { + type Raw = "pending" | "processing" | "completed" | "failed"; +} diff --git a/src/serialization/types/SegmentType.ts b/src/serialization/types/SegmentType.ts new file mode 100644 index 0000000..ef82dc3 --- /dev/null +++ b/src/serialization/types/SegmentType.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SegmentType: core.serialization.Schema = + core.serialization.enum_(["dynamic", "static", "manual"]); + +export declare namespace SegmentType { + type Raw = "dynamic" | "static" | "manual"; +} diff --git a/src/serialization/types/Subscription.ts b/src/serialization/types/Subscription.ts new file mode 100644 index 0000000..f78e408 --- /dev/null +++ b/src/serialization/types/Subscription.ts @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { SubscriptionExpandedStatus } from "./SubscriptionExpandedStatus"; +import { SubscriptionExpandedSubscriptionTier } from "./SubscriptionExpandedSubscriptionTier"; +import { SubscriptionExpandedUtmChannel } from "./SubscriptionExpandedUtmChannel"; +import { SubscriptionCustomFields } from "./SubscriptionCustomFields"; +import { SubscriptionStats } from "./SubscriptionStats"; +import { SubscriptionTags } from "./SubscriptionTags"; +import { CustomField } from "./CustomField"; + +export const Subscription: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + email: core.serialization.string(), + status: SubscriptionExpandedStatus, + created: core.serialization.number(), + subscriptionTier: core.serialization.property("subscription_tier", SubscriptionExpandedSubscriptionTier), + utmSource: core.serialization.property("utm_source", core.serialization.string()), + utmMedium: core.serialization.property("utm_medium", core.serialization.string()), + utmChannel: core.serialization.property("utm_channel", SubscriptionExpandedUtmChannel), + utmCampaign: core.serialization.property("utm_campaign", core.serialization.string()), + referringSite: core.serialization.property("referring_site", core.serialization.string()), + referralCode: core.serialization.property("referral_code", core.serialization.string()), + customFields: core.serialization.property("custom_fields", SubscriptionCustomFields.optional()), + stats: SubscriptionStats.optional(), + tags: SubscriptionTags.optional(), + }); + +export declare namespace Subscription { + interface Raw { + id: string; + email: string; + status: SubscriptionExpandedStatus.Raw; + created: number; + subscription_tier: SubscriptionExpandedSubscriptionTier.Raw; + utm_source: string; + utm_medium: string; + utm_channel: SubscriptionExpandedUtmChannel.Raw; + utm_campaign: string; + referring_site: string; + referral_code: string; + custom_fields?: SubscriptionCustomFields.Raw | null; + stats?: SubscriptionStats.Raw | null; + tags?: SubscriptionTags.Raw | null; + } +} diff --git a/src/serialization/types/SubscriptionCustomFields.ts b/src/serialization/types/SubscriptionCustomFields.ts new file mode 100644 index 0000000..87946b6 --- /dev/null +++ b/src/serialization/types/SubscriptionCustomFields.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; +import { CustomField } from "./CustomField"; + +export const SubscriptionCustomFields: core.serialization.Schema< + serializers.SubscriptionCustomFields.Raw, + beehiiv.SubscriptionCustomFields +> = core.serialization.list(CustomField); + +export declare namespace SubscriptionCustomFields { + type Raw = CustomField.Raw[]; +} diff --git a/src/serialization/types/SubscriptionExpandedStatus.ts b/src/serialization/types/SubscriptionExpandedStatus.ts new file mode 100644 index 0000000..e65416a --- /dev/null +++ b/src/serialization/types/SubscriptionExpandedStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionExpandedStatus: core.serialization.Schema< + serializers.SubscriptionExpandedStatus.Raw, + beehiiv.SubscriptionExpandedStatus +> = core.serialization.enum_(["validating", "invalid", "pending", "active", "inactive", "needs_attention"]); + +export declare namespace SubscriptionExpandedStatus { + type Raw = "validating" | "invalid" | "pending" | "active" | "inactive" | "needs_attention"; +} diff --git a/src/serialization/types/SubscriptionExpandedSubscriptionTier.ts b/src/serialization/types/SubscriptionExpandedSubscriptionTier.ts new file mode 100644 index 0000000..567be1b --- /dev/null +++ b/src/serialization/types/SubscriptionExpandedSubscriptionTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionExpandedSubscriptionTier: core.serialization.Schema< + serializers.SubscriptionExpandedSubscriptionTier.Raw, + beehiiv.SubscriptionExpandedSubscriptionTier +> = core.serialization.enum_(["free", "premium"]); + +export declare namespace SubscriptionExpandedSubscriptionTier { + type Raw = "free" | "premium"; +} diff --git a/src/serialization/types/SubscriptionExpandedTagsStatus.ts b/src/serialization/types/SubscriptionExpandedTagsStatus.ts new file mode 100644 index 0000000..4b1c08e --- /dev/null +++ b/src/serialization/types/SubscriptionExpandedTagsStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionExpandedTagsStatus: core.serialization.Schema< + serializers.SubscriptionExpandedTagsStatus.Raw, + beehiiv.SubscriptionExpandedTagsStatus +> = core.serialization.enum_(["validating", "invalid", "pending", "active", "inactive", "needs_attention"]); + +export declare namespace SubscriptionExpandedTagsStatus { + type Raw = "validating" | "invalid" | "pending" | "active" | "inactive" | "needs_attention"; +} diff --git a/src/serialization/types/SubscriptionExpandedTagsSubscriptionTier.ts b/src/serialization/types/SubscriptionExpandedTagsSubscriptionTier.ts new file mode 100644 index 0000000..b202d1a --- /dev/null +++ b/src/serialization/types/SubscriptionExpandedTagsSubscriptionTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionExpandedTagsSubscriptionTier: core.serialization.Schema< + serializers.SubscriptionExpandedTagsSubscriptionTier.Raw, + beehiiv.SubscriptionExpandedTagsSubscriptionTier +> = core.serialization.enum_(["free", "premium"]); + +export declare namespace SubscriptionExpandedTagsSubscriptionTier { + type Raw = "free" | "premium"; +} diff --git a/src/serialization/types/SubscriptionExpandedTagsUtmChannel.ts b/src/serialization/types/SubscriptionExpandedTagsUtmChannel.ts new file mode 100644 index 0000000..da1bccf --- /dev/null +++ b/src/serialization/types/SubscriptionExpandedTagsUtmChannel.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionExpandedTagsUtmChannel: core.serialization.Schema< + serializers.SubscriptionExpandedTagsUtmChannel.Raw, + beehiiv.SubscriptionExpandedTagsUtmChannel +> = core.serialization.enum_([ + "", + "website", + "import", + "embed", + "api", + "referral", + "recommendation", + "magic_link", + "boost", + "boost_send", + "boost_direct_link", +]); + +export declare namespace SubscriptionExpandedTagsUtmChannel { + type Raw = + | "" + | "website" + | "import" + | "embed" + | "api" + | "referral" + | "recommendation" + | "magic_link" + | "boost" + | "boost_send" + | "boost_direct_link"; +} diff --git a/src/serialization/types/SubscriptionExpandedUtmChannel.ts b/src/serialization/types/SubscriptionExpandedUtmChannel.ts new file mode 100644 index 0000000..8e27808 --- /dev/null +++ b/src/serialization/types/SubscriptionExpandedUtmChannel.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionExpandedUtmChannel: core.serialization.Schema< + serializers.SubscriptionExpandedUtmChannel.Raw, + beehiiv.SubscriptionExpandedUtmChannel +> = core.serialization.enum_([ + "", + "website", + "import", + "embed", + "api", + "referral", + "recommendation", + "magic_link", + "boost", + "boost_send", + "boost_direct_link", +]); + +export declare namespace SubscriptionExpandedUtmChannel { + type Raw = + | "" + | "website" + | "import" + | "embed" + | "api" + | "referral" + | "recommendation" + | "magic_link" + | "boost" + | "boost_send" + | "boost_direct_link"; +} diff --git a/src/serialization/types/SubscriptionStats.ts b/src/serialization/types/SubscriptionStats.ts new file mode 100644 index 0000000..2bd2d09 --- /dev/null +++ b/src/serialization/types/SubscriptionStats.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionStats: core.serialization.ObjectSchema< + serializers.SubscriptionStats.Raw, + beehiiv.SubscriptionStats +> = core.serialization.object({ + emailsReceived: core.serialization.property("emails_received", core.serialization.number().optional()), + openRate: core.serialization.property("open_rate", core.serialization.number().optional()), + clickThroughRate: core.serialization.property("click_through_rate", core.serialization.number().optional()), +}); + +export declare namespace SubscriptionStats { + interface Raw { + emails_received?: number | null; + open_rate?: number | null; + click_through_rate?: number | null; + } +} diff --git a/src/serialization/types/SubscriptionStatus.ts b/src/serialization/types/SubscriptionStatus.ts new file mode 100644 index 0000000..5e5fb5b --- /dev/null +++ b/src/serialization/types/SubscriptionStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionStatus: core.serialization.Schema< + serializers.SubscriptionStatus.Raw, + beehiiv.SubscriptionStatus +> = core.serialization.enum_(["validating", "invalid", "pending", "active", "inactive", "needs_attention"]); + +export declare namespace SubscriptionStatus { + type Raw = "validating" | "invalid" | "pending" | "active" | "inactive" | "needs_attention"; +} diff --git a/src/serialization/types/SubscriptionSubscriptionTier.ts b/src/serialization/types/SubscriptionSubscriptionTier.ts new file mode 100644 index 0000000..1aeb7fc --- /dev/null +++ b/src/serialization/types/SubscriptionSubscriptionTier.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionSubscriptionTier: core.serialization.Schema< + serializers.SubscriptionSubscriptionTier.Raw, + beehiiv.SubscriptionSubscriptionTier +> = core.serialization.enum_(["free", "premium"]); + +export declare namespace SubscriptionSubscriptionTier { + type Raw = "free" | "premium"; +} diff --git a/src/serialization/types/SubscriptionTags.ts b/src/serialization/types/SubscriptionTags.ts new file mode 100644 index 0000000..0c1c009 --- /dev/null +++ b/src/serialization/types/SubscriptionTags.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionTags: core.serialization.Schema = + core.serialization.list(core.serialization.string()); + +export declare namespace SubscriptionTags { + type Raw = string[]; +} diff --git a/src/serialization/types/SubscriptionUtmChannel.ts b/src/serialization/types/SubscriptionUtmChannel.ts new file mode 100644 index 0000000..566e63f --- /dev/null +++ b/src/serialization/types/SubscriptionUtmChannel.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as beehiiv from "../../api"; +import * as core from "../../core"; + +export const SubscriptionUtmChannel: core.serialization.Schema< + serializers.SubscriptionUtmChannel.Raw, + beehiiv.SubscriptionUtmChannel +> = core.serialization.enum_([ + "", + "website", + "import", + "embed", + "api", + "referral", + "recommendation", + "magic_link", + "boost", + "boost_send", + "boost_direct_link", +]); + +export declare namespace SubscriptionUtmChannel { + type Raw = + | "" + | "website" + | "import" + | "embed" + | "api" + | "referral" + | "recommendation" + | "magic_link" + | "boost" + | "boost_send" + | "boost_direct_link"; +} diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts new file mode 100644 index 0000000..7c45cac --- /dev/null +++ b/src/serialization/types/index.ts @@ -0,0 +1,58 @@ +export * from "./CustomFieldKind"; +export * from "./CustomField"; +export * from "./CustomFieldValue"; +export * from "./EmailBlastStatus"; +export * from "./EmailBlast"; +export * from "./EmailBlastContentEmail"; +export * from "./EmailBlastContent"; +export * from "./EmailBlastStatsEmail"; +export * from "./EmailBlastStatsClicksItem"; +export * from "./EmailBlastStats"; +export * from "./ErrorErrorsItem"; +export * from "./Error_"; +export * from "./Milestone"; +export * from "./MilestoneRewardType"; +export * from "./MilestoneReward"; +export * from "./SubscriptionStatus"; +export * from "./SubscriptionSubscriptionTier"; +export * from "./SubscriptionUtmChannel"; +export * from "./Subscription"; +export * from "./SubscriptionExpandedTagsStatus"; +export * from "./SubscriptionExpandedTagsSubscriptionTier"; +export * from "./SubscriptionExpandedTagsUtmChannel"; +export * from "./SubscriptionExpandedStatus"; +export * from "./SubscriptionExpandedSubscriptionTier"; +export * from "./SubscriptionExpandedUtmChannel"; +export * from "./SubscriptionCustomFields"; +export * from "./SubscriptionStats"; +export * from "./SubscriptionTags"; +export * from "./PostStatus"; +export * from "./PostAudience"; +export * from "./PostPlatform"; +export * from "./Post"; +export * from "./PostClickStatsEmail"; +export * from "./PostClickStatsWeb"; +export * from "./ClickStats"; +export * from "./PostContentFree"; +export * from "./PostContentPremium"; +export * from "./PostContent"; +export * from "./PostStatsEmail"; +export * from "./PostStatsWeb"; +export * from "./PostStats"; +export * from "./Publication"; +export * from "./PublicationStatsActiveSubscriptions"; +export * from "./PublicationStatsActivePremiumSubscriptions"; +export * from "./PublicationStatsActiveFreeSubscriptions"; +export * from "./PublicationStatsAverageOpenRate"; +export * from "./PublicationStatsAverageClickRate"; +export * from "./PublicationStatsTotalSent"; +export * from "./PublicationStatsTotalUniqueOpened"; +export * from "./PublicationStatsTotalClicked"; +export * from "./PublicationStats"; +export * from "./SegmentType"; +export * from "./SegmentStatus"; +export * from "./Segment"; +export * from "./AutomationStatus"; +export * from "./Automation"; +export * from "./AutomationJourneyStatus"; +export * from "./AutomationJourney"; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..538c94f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "extendedDiagnostics": true, + "strict": true, + "target": "ES6", + "module": "CommonJS", + "moduleResolution": "node", + "esModuleInterop": true, + "skipLibCheck": true, + "declaration": true, + "outDir": "dist", + "rootDir": "src", + "baseUrl": "src" + }, + "include": ["src"], + "exclude": [] +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..f01822d --- /dev/null +++ b/yarn.lock @@ -0,0 +1,234 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/node-fetch@2.6.9": + version "2.6.9" + resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.9.tgz#15f529d247f1ede1824f7e7acdaa192d5f28071e" + integrity sha512-bQVlnMLFJ2d35DkPNjEPmd9ueO/rh5EiaZt2bhqiSarPjZIuIV6bPQVqcrEyvNo+AfTrRGVazle1tl597w3gfA== + dependencies: + "@types/node" "*" + form-data "^4.0.0" + +"@types/node@*": + version "20.12.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.7.tgz#04080362fa3dd6c5822061aa3124f5c152cff384" + integrity sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg== + dependencies: + undici-types "~5.26.4" + +"@types/node@17.0.33": + version "17.0.33" + resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.33.tgz#3c1879b276dc63e73030bb91165e62a4509cd506" + integrity sha512-miWq2m2FiQZmaHfdZNcbpp9PuXg34W5JZ5CrJ/BaS70VuhoJENBEQybeiYSaPBRNq6KQGnjfEnc/F3PN++D+XQ== + +"@types/qs@6.9.8": + version "6.9.8" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.8.tgz#f2a7de3c107b89b441e071d5472e6b726b4adf45" + integrity sha512-u95svzDlTysU5xecFNTgfFG5RUWu1A9P0VzgpcIiGZA9iraHOdSzcxMxQ55DyeRaGCSxQi7LxXDI4rzq/MYfdg== + +"@types/url-join@4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/url-join/-/url-join-4.0.1.tgz#4989c97f969464647a8586c7252d97b449cdc045" + integrity sha512-wDXw9LEEUHyV+7UWy7U315nrJGJ7p1BzaCxDpEoLr789Dk1WDVMMlf3iBfbG2F8NdWnYyFbtTxUn2ZNbm1Q4LQ== + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +form-data@4.0.0, form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.3.tgz#b31ddfe9b0e6e9914536a6ab286426d0214f77fd" + integrity sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +hasown@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== + dependencies: + function-bind "^1.1.2" + +js-base64@3.7.2: + version "3.7.2" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.2.tgz#816d11d81a8aff241603d19ce5761e13e41d7745" + integrity sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ== + +mime-db@1.52.0: + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.12: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +node-fetch@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + +object-inspect@^1.13.1: + version "1.13.1" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" + integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== + +prettier@2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" + integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== + +qs@6.11.2: + version "6.11.2" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.2.tgz#64bea51f12c1f5da1bc01496f48ffcff7c69d7d9" + integrity sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA== + dependencies: + side-channel "^1.0.4" + +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + +side-channel@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + +typescript@4.6.4: + version "4.6.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9" + integrity sha512-9ia/jWHIEbo49HfjrLGfKbZSuWo9iTMwXO+Ca3pRsSpbsMbc7/IU8NKdCZVRRBafVPGnoJeFL76ZOAA84I9fEg== + +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + +url-join@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7" + integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA== + +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0"