@@ -8,16 +8,13 @@ import {
88 waitForResource ,
99} from '../../../bridge'
1010import type { Region as ScwRegion , WaitForOptions } from '../../../bridge'
11- import {
12- DOMAIN_TRANSIENT_STATUSES ,
13- EMAIL_TRANSIENT_STATUSES ,
14- } from './content.gen'
1511import {
1612 marshalBulkCreateBlocklistsRequest ,
1713 marshalCreateDomainRequest ,
1814 marshalCreateEmailRequest ,
1915 marshalCreateWebhookRequest ,
2016 marshalUpdateDomainRequest ,
17+ marshalUpdateOfferSubscriptionRequest ,
2118 marshalUpdateProjectSettingsRequest ,
2219 marshalUpdateWebhookRequest ,
2320 unmarshalBulkCreateBlocklistsResponse ,
@@ -28,8 +25,13 @@ import {
2825 unmarshalListBlocklistsResponse ,
2926 unmarshalListDomainsResponse ,
3027 unmarshalListEmailsResponse ,
28+ unmarshalListOfferSubscriptionsResponse ,
29+ unmarshalListOffersResponse ,
30+ unmarshalListPoolsResponse ,
3131 unmarshalListWebhookEventsResponse ,
3232 unmarshalListWebhooksResponse ,
33+ unmarshalOfferSubscription ,
34+ unmarshalProjectConsumption ,
3335 unmarshalProjectSettings ,
3436 unmarshalStatistics ,
3537 unmarshalWebhook ,
@@ -51,6 +53,7 @@ import type {
5153 GetDomainLastStatusRequest ,
5254 GetDomainRequest ,
5355 GetEmailRequest ,
56+ GetProjectConsumptionRequest ,
5457 GetProjectSettingsRequest ,
5558 GetStatisticsRequest ,
5659 GetWebhookRequest ,
@@ -60,14 +63,23 @@ import type {
6063 ListDomainsResponse ,
6164 ListEmailsRequest ,
6265 ListEmailsResponse ,
66+ ListOfferSubscriptionsRequest ,
67+ ListOfferSubscriptionsResponse ,
68+ ListOffersRequest ,
69+ ListOffersResponse ,
70+ ListPoolsRequest ,
71+ ListPoolsResponse ,
6372 ListWebhookEventsRequest ,
6473 ListWebhookEventsResponse ,
6574 ListWebhooksRequest ,
6675 ListWebhooksResponse ,
76+ OfferSubscription ,
77+ ProjectConsumption ,
6778 ProjectSettings ,
6879 RevokeDomainRequest ,
6980 Statistics ,
7081 UpdateDomainRequest ,
82+ UpdateOfferSubscriptionRequest ,
7183 UpdateProjectSettingsRequest ,
7284 UpdateWebhookRequest ,
7385 Webhook ,
@@ -137,8 +149,7 @@ export class API extends ParentAPI {
137149 ) =>
138150 waitForResource (
139151 options ?. stop ??
140- ( res =>
141- Promise . resolve ( ! EMAIL_TRANSIENT_STATUSES . includes ( res . status ) ) ) ,
152+ ( res => Promise . resolve ( ! EmailStatus . includes ( res . status ) ) ) ,
142153 this . getEmail ,
143154 request ,
144155 options ,
@@ -279,8 +290,7 @@ export class API extends ParentAPI {
279290 ) =>
280291 waitForResource (
281292 options ?. stop ??
282- ( res =>
283- Promise . resolve ( ! DOMAIN_TRANSIENT_STATUSES . includes ( res . status ) ) ) ,
293+ ( res => Promise . resolve ( ! DomainStatus . includes ( res . status ) ) ) ,
284294 this . getDomain ,
285295 request ,
286296 options ,
@@ -624,4 +634,115 @@ export class API extends ParentAPI {
624634 method : 'DELETE' ,
625635 path : `/transactional-email/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /blocklists/${ validatePathParam ( 'blocklistId' , request . blocklistId ) } ` ,
626636 } )
637+
638+ /**
639+ * Get information about subscribed offers. Retrieve information about the
640+ * offers you are subscribed to using the `project_id` and `region`
641+ * parameters.
642+ *
643+ * @param request - The request {@link ListOfferSubscriptionsRequest}
644+ * @returns A Promise of ListOfferSubscriptionsResponse
645+ */
646+ listOfferSubscriptions = (
647+ request : Readonly < ListOfferSubscriptionsRequest > = { } ,
648+ ) =>
649+ this . client . fetch < ListOfferSubscriptionsResponse > (
650+ {
651+ method : 'GET' ,
652+ path : `/transactional-email/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /offer-subscriptions` ,
653+ urlParams : urlParams ( [
654+ 'project_id' ,
655+ request . projectId ?? this . client . settings . defaultProjectId ,
656+ ] ) ,
657+ } ,
658+ unmarshalListOfferSubscriptionsResponse ,
659+ )
660+
661+ /**
662+ * Update a subscribed offer.
663+ *
664+ * @param request - The request {@link UpdateOfferSubscriptionRequest}
665+ * @returns A Promise of OfferSubscription
666+ */
667+ updateOfferSubscription = (
668+ request : Readonly < UpdateOfferSubscriptionRequest > = { } ,
669+ ) =>
670+ this . client . fetch < OfferSubscription > (
671+ {
672+ body : JSON . stringify (
673+ marshalUpdateOfferSubscriptionRequest ( request , this . client . settings ) ,
674+ ) ,
675+ headers : jsonContentHeaders ,
676+ method : 'PATCH' ,
677+ path : `/transactional-email/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /offer-subscriptions` ,
678+ } ,
679+ unmarshalOfferSubscription ,
680+ )
681+
682+ /**
683+ * List the available offers.. Retrieve the list of the available and
684+ * free-of-charge offers you can subscribe to.
685+ *
686+ * @param request - The request {@link ListOffersRequest}
687+ * @returns A Promise of ListOffersResponse
688+ */
689+ listOffers = ( request : Readonly < ListOffersRequest > = { } ) =>
690+ this . client . fetch < ListOffersResponse > (
691+ {
692+ method : 'GET' ,
693+ path : `/transactional-email/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /offers` ,
694+ } ,
695+ unmarshalListOffersResponse ,
696+ )
697+
698+ protected pageOfListPools = ( request : Readonly < ListPoolsRequest > = { } ) =>
699+ this . client . fetch < ListPoolsResponse > (
700+ {
701+ method : 'GET' ,
702+ path : `/transactional-email/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /pools` ,
703+ urlParams : urlParams (
704+ [ 'page' , request . page ] ,
705+ [
706+ 'page_size' ,
707+ request . pageSize ?? this . client . settings . defaultPageSize ,
708+ ] ,
709+ [
710+ 'project_id' ,
711+ request . projectId ?? this . client . settings . defaultProjectId ,
712+ ] ,
713+ ) ,
714+ } ,
715+ unmarshalListPoolsResponse ,
716+ )
717+
718+ /**
719+ * Get information about a sending pool.. Retrieve information about a sending
720+ * pool, including its creation status and configuration parameters.
721+ *
722+ * @param request - The request {@link ListPoolsRequest}
723+ * @returns A Promise of ListPoolsResponse
724+ */
725+ listPools = ( request : Readonly < ListPoolsRequest > = { } ) =>
726+ enrichForPagination ( 'pools' , this . pageOfListPools , request )
727+
728+ /**
729+ * Get project resource consumption.. Get project resource consumption.
730+ *
731+ * @param request - The request {@link GetProjectConsumptionRequest}
732+ * @returns A Promise of ProjectConsumption
733+ */
734+ getProjectConsumption = (
735+ request : Readonly < GetProjectConsumptionRequest > = { } ,
736+ ) =>
737+ this . client . fetch < ProjectConsumption > (
738+ {
739+ method : 'GET' ,
740+ path : `/transactional-email/v1alpha1/regions/${ validatePathParam ( 'region' , request . region ?? this . client . settings . defaultRegion ) } /project-consumption` ,
741+ urlParams : urlParams ( [
742+ 'project_id' ,
743+ request . projectId ?? this . client . settings . defaultProjectId ,
744+ ] ) ,
745+ } ,
746+ unmarshalProjectConsumption ,
747+ )
627748}
0 commit comments