|
| 1 | +// This file was automatically generated. DO NOT EDIT. |
| 2 | +// If you have any remark or suggestion do not hesitate to open an issue. |
| 3 | +import { |
| 4 | + API, |
| 5 | + enrichForPagination, |
| 6 | + unmarshalServiceInfo, |
| 7 | + urlParams, |
| 8 | + validatePathParam, |
| 9 | +} from '../../../bridge' |
| 10 | +import type { Region, ServiceInfo } from '../../../bridge' |
| 11 | +import { |
| 12 | + marshalCreateDomainRequest, |
| 13 | + marshalCreateEmailRequest, |
| 14 | + unmarshalCreateEmailResponse, |
| 15 | + unmarshalDomain, |
| 16 | + unmarshalEmail, |
| 17 | + unmarshalListDomainsResponse, |
| 18 | + unmarshalListEmailsResponse, |
| 19 | + unmarshalStatistics, |
| 20 | +} from './marshalling.gen' |
| 21 | +import type { |
| 22 | + CancelEmailRequest, |
| 23 | + CheckDomainRequest, |
| 24 | + CreateDomainRequest, |
| 25 | + CreateEmailRequest, |
| 26 | + CreateEmailResponse, |
| 27 | + Domain, |
| 28 | + Email, |
| 29 | + GetDomainRequest, |
| 30 | + GetEmailRequest, |
| 31 | + GetServiceInfoRequest, |
| 32 | + GetStatisticsRequest, |
| 33 | + ListDomainsRequest, |
| 34 | + ListDomainsResponse, |
| 35 | + ListEmailsRequest, |
| 36 | + ListEmailsResponse, |
| 37 | + RevokeDomainRequest, |
| 38 | + Statistics, |
| 39 | +} from './types.gen' |
| 40 | + |
| 41 | +const jsonContentHeaders = { |
| 42 | + 'Content-Type': 'application/json; charset=utf-8', |
| 43 | +} |
| 44 | + |
| 45 | +/** |
| 46 | + * Transactional_email. |
| 47 | + * |
| 48 | + * Tem. |
| 49 | + */ |
| 50 | +export class TransactionalEmailV1Alpha1GenAPI extends API { |
| 51 | + /** Lists the available regions of the API. */ |
| 52 | + public static readonly LOCALITIES: Region[] = ['fr-par'] |
| 53 | + |
| 54 | + getServiceInfo = (request: Readonly<GetServiceInfoRequest> = {}) => |
| 55 | + this.client.fetch<ServiceInfo>( |
| 56 | + { |
| 57 | + method: 'GET', |
| 58 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 59 | + 'region', |
| 60 | + request.region ?? this.client.settings.defaultRegion, |
| 61 | + )}`, |
| 62 | + }, |
| 63 | + unmarshalServiceInfo, |
| 64 | + ) |
| 65 | + |
| 66 | + /** |
| 67 | + * Send an email |
| 68 | + * |
| 69 | + * @param request - The request {@link CreateEmailRequest} |
| 70 | + * @returns A Promise of CreateEmailResponse |
| 71 | + */ |
| 72 | + createEmail = (request: Readonly<CreateEmailRequest>) => |
| 73 | + this.client.fetch<CreateEmailResponse>( |
| 74 | + { |
| 75 | + body: JSON.stringify( |
| 76 | + marshalCreateEmailRequest(request, this.client.settings), |
| 77 | + ), |
| 78 | + headers: jsonContentHeaders, |
| 79 | + method: 'POST', |
| 80 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 81 | + 'region', |
| 82 | + request.region ?? this.client.settings.defaultRegion, |
| 83 | + )}/emails`, |
| 84 | + }, |
| 85 | + unmarshalCreateEmailResponse, |
| 86 | + ) |
| 87 | + |
| 88 | + /** |
| 89 | + * Get information about an email |
| 90 | + * |
| 91 | + * @param request - The request {@link GetEmailRequest} |
| 92 | + * @returns A Promise of Email |
| 93 | + */ |
| 94 | + getEmail = (request: Readonly<GetEmailRequest>) => |
| 95 | + this.client.fetch<Email>( |
| 96 | + { |
| 97 | + method: 'GET', |
| 98 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 99 | + 'region', |
| 100 | + request.region ?? this.client.settings.defaultRegion, |
| 101 | + )}/emails/${validatePathParam('emailId', request.emailId)}`, |
| 102 | + }, |
| 103 | + unmarshalEmail, |
| 104 | + ) |
| 105 | + |
| 106 | + protected pageOfListEmails = (request: Readonly<ListEmailsRequest> = {}) => |
| 107 | + this.client.fetch<ListEmailsResponse>( |
| 108 | + { |
| 109 | + method: 'GET', |
| 110 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 111 | + 'region', |
| 112 | + request.region ?? this.client.settings.defaultRegion, |
| 113 | + )}/emails`, |
| 114 | + urlParams: urlParams( |
| 115 | + ['domain_id', request.domainId], |
| 116 | + ['mail_from', request.mailFrom], |
| 117 | + ['mail_to', request.mailTo], |
| 118 | + ['page', request.page], |
| 119 | + [ |
| 120 | + 'page_size', |
| 121 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 122 | + ], |
| 123 | + [ |
| 124 | + 'project_id', |
| 125 | + request.projectId ?? this.client.settings.defaultProjectId, |
| 126 | + ], |
| 127 | + ['since', request.since], |
| 128 | + ['statuses', request.statuses], |
| 129 | + ['until', request.until], |
| 130 | + ), |
| 131 | + }, |
| 132 | + unmarshalListEmailsResponse, |
| 133 | + ) |
| 134 | + |
| 135 | + /** |
| 136 | + * List emails sent from a domain and/or for a project and/or for an organization |
| 137 | + * |
| 138 | + * @param request - The request {@link ListEmailsRequest} |
| 139 | + * @returns A Promise of ListEmailsResponse |
| 140 | + */ |
| 141 | + listEmails = (request: Readonly<ListEmailsRequest> = {}) => |
| 142 | + enrichForPagination('emails', this.pageOfListEmails, request) |
| 143 | + |
| 144 | + /** |
| 145 | + * Get statistics on the email statuses |
| 146 | + * |
| 147 | + * @param request - The request {@link GetStatisticsRequest} |
| 148 | + * @returns A Promise of Statistics |
| 149 | + */ |
| 150 | + getStatistics = (request: Readonly<GetStatisticsRequest> = {}) => |
| 151 | + this.client.fetch<Statistics>( |
| 152 | + { |
| 153 | + method: 'GET', |
| 154 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 155 | + 'region', |
| 156 | + request.region ?? this.client.settings.defaultRegion, |
| 157 | + )}/statistics`, |
| 158 | + urlParams: urlParams( |
| 159 | + ['domain_id', request.domainId], |
| 160 | + ['mail_from', request.mailFrom], |
| 161 | + [ |
| 162 | + 'project_id', |
| 163 | + request.projectId ?? this.client.settings.defaultProjectId, |
| 164 | + ], |
| 165 | + ['since', request.since], |
| 166 | + ['until', request.until], |
| 167 | + ), |
| 168 | + }, |
| 169 | + unmarshalStatistics, |
| 170 | + ) |
| 171 | + |
| 172 | + /** |
| 173 | + * Try to cancel an email if it has not yet been sent |
| 174 | + * |
| 175 | + * @param request - The request {@link CancelEmailRequest} |
| 176 | + * @returns A Promise of Email |
| 177 | + */ |
| 178 | + cancelEmail = (request: Readonly<CancelEmailRequest>) => |
| 179 | + this.client.fetch<Email>( |
| 180 | + { |
| 181 | + body: '{}', |
| 182 | + headers: jsonContentHeaders, |
| 183 | + method: 'POST', |
| 184 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 185 | + 'region', |
| 186 | + request.region ?? this.client.settings.defaultRegion, |
| 187 | + )}/emails/${validatePathParam('emailId', request.emailId)}/cancel`, |
| 188 | + }, |
| 189 | + unmarshalEmail, |
| 190 | + ) |
| 191 | + |
| 192 | + /** |
| 193 | + * Register a domain in a project |
| 194 | + * |
| 195 | + * @param request - The request {@link CreateDomainRequest} |
| 196 | + * @returns A Promise of Domain |
| 197 | + */ |
| 198 | + createDomain = (request: Readonly<CreateDomainRequest>) => |
| 199 | + this.client.fetch<Domain>( |
| 200 | + { |
| 201 | + body: JSON.stringify( |
| 202 | + marshalCreateDomainRequest(request, this.client.settings), |
| 203 | + ), |
| 204 | + headers: jsonContentHeaders, |
| 205 | + method: 'POST', |
| 206 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 207 | + 'region', |
| 208 | + request.region ?? this.client.settings.defaultRegion, |
| 209 | + )}/domains`, |
| 210 | + }, |
| 211 | + unmarshalDomain, |
| 212 | + ) |
| 213 | + |
| 214 | + /** |
| 215 | + * Get information about a domain |
| 216 | + * |
| 217 | + * @param request - The request {@link GetDomainRequest} |
| 218 | + * @returns A Promise of Domain |
| 219 | + */ |
| 220 | + getDomain = (request: Readonly<GetDomainRequest>) => |
| 221 | + this.client.fetch<Domain>( |
| 222 | + { |
| 223 | + method: 'GET', |
| 224 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 225 | + 'region', |
| 226 | + request.region ?? this.client.settings.defaultRegion, |
| 227 | + )}/domains/${validatePathParam('domainId', request.domainId)}`, |
| 228 | + }, |
| 229 | + unmarshalDomain, |
| 230 | + ) |
| 231 | + |
| 232 | + protected pageOfListDomains = (request: Readonly<ListDomainsRequest> = {}) => |
| 233 | + this.client.fetch<ListDomainsResponse>( |
| 234 | + { |
| 235 | + method: 'GET', |
| 236 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 237 | + 'region', |
| 238 | + request.region ?? this.client.settings.defaultRegion, |
| 239 | + )}/domains`, |
| 240 | + urlParams: urlParams( |
| 241 | + ['page', request.page], |
| 242 | + [ |
| 243 | + 'page_size', |
| 244 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 245 | + ], |
| 246 | + [ |
| 247 | + 'project_id', |
| 248 | + request.projectId ?? this.client.settings.defaultProjectId, |
| 249 | + ], |
| 250 | + ['status', request.status], |
| 251 | + ), |
| 252 | + }, |
| 253 | + unmarshalListDomainsResponse, |
| 254 | + ) |
| 255 | + |
| 256 | + /** |
| 257 | + * List domains in a project and/or in an organization |
| 258 | + * |
| 259 | + * @param request - The request {@link ListDomainsRequest} |
| 260 | + * @returns A Promise of ListDomainsResponse |
| 261 | + */ |
| 262 | + listDomains = (request: Readonly<ListDomainsRequest> = {}) => |
| 263 | + enrichForPagination('domains', this.pageOfListDomains, request) |
| 264 | + |
| 265 | + /** |
| 266 | + * Revoke a domain |
| 267 | + * |
| 268 | + * @param request - The request {@link RevokeDomainRequest} |
| 269 | + * @returns A Promise of Domain |
| 270 | + */ |
| 271 | + revokeDomain = (request: Readonly<RevokeDomainRequest>) => |
| 272 | + this.client.fetch<Domain>( |
| 273 | + { |
| 274 | + body: '{}', |
| 275 | + headers: jsonContentHeaders, |
| 276 | + method: 'POST', |
| 277 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 278 | + 'region', |
| 279 | + request.region ?? this.client.settings.defaultRegion, |
| 280 | + )}/domains/${validatePathParam('domainId', request.domainId)}/revoke`, |
| 281 | + }, |
| 282 | + unmarshalDomain, |
| 283 | + ) |
| 284 | + |
| 285 | + /** |
| 286 | + * Ask for an immediate check of a domain (DNS check) |
| 287 | + * |
| 288 | + * @param request - The request {@link CheckDomainRequest} |
| 289 | + * @returns A Promise of Domain |
| 290 | + */ |
| 291 | + checkDomain = (request: Readonly<CheckDomainRequest>) => |
| 292 | + this.client.fetch<Domain>( |
| 293 | + { |
| 294 | + body: '{}', |
| 295 | + headers: jsonContentHeaders, |
| 296 | + method: 'POST', |
| 297 | + path: `/transactional-email/v1alpha1/regions/${validatePathParam( |
| 298 | + 'region', |
| 299 | + request.region ?? this.client.settings.defaultRegion, |
| 300 | + )}/domains/${validatePathParam('domainId', request.domainId)}/check`, |
| 301 | + }, |
| 302 | + unmarshalDomain, |
| 303 | + ) |
| 304 | +} |
0 commit comments