Skip to content

Commit 41aa4ca

Browse files
authored
feat(domain): check if contacts are compatible with a domain or a tld (#55)
1 parent f697369 commit 41aa4ca

File tree

3 files changed

+176
-0
lines changed

3 files changed

+176
-0
lines changed

packages/clients/src/api/domain/v2beta1/api.gen.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
marshalImportRawDNSZoneRequest,
1717
marshalRefreshDNSZoneRequest,
1818
marshalRegistrarApiBuyDomainsRequest,
19+
marshalRegistrarApiCheckContactsCompatibilityRequest,
1920
marshalRegistrarApiEnableDomainDNSSECRequest,
2021
marshalRegistrarApiRegisterExternalDomainRequest,
2122
marshalRegistrarApiRenewDomainsRequest,
@@ -26,6 +27,7 @@ import {
2627
marshalUpdateDNSZoneNameserversRequest,
2728
marshalUpdateDNSZoneRecordsRequest,
2829
marshalUpdateDNSZoneRequest,
30+
unmarshalCheckContactsCompatibilityResponse,
2931
unmarshalClearDNSZoneRecordsResponse,
3032
unmarshalContact,
3133
unmarshalDNSZone,
@@ -58,6 +60,7 @@ import {
5860
unmarshalUpdateDNSZoneRecordsResponse,
5961
} from './marshalling.gen'
6062
import type {
63+
CheckContactsCompatibilityResponse,
6164
ClearDNSZoneRecordsRequest,
6265
ClearDNSZoneRecordsResponse,
6366
CloneDNSZoneRequest,
@@ -104,6 +107,7 @@ import type {
104107
RefreshDNSZoneResponse,
105108
RegisterExternalDomainResponse,
106109
RegistrarApiBuyDomainsRequest,
110+
RegistrarApiCheckContactsCompatibilityRequest,
107111
RegistrarApiDeleteExternalDomainRequest,
108112
RegistrarApiDisableDomainAutoRenewRequest,
109113
RegistrarApiDisableDomainDNSSECRequest,
@@ -896,6 +900,31 @@ export class DomainRegistrarV2Beta1GenAPI extends API {
896900
unmarshalDeleteExternalDomainResponse,
897901
)
898902

903+
/**
904+
* Check if contacts are compatible against a domain or a tld. If not, it will
905+
* return the information requiring a correction.
906+
*
907+
* @param request - The request {@link RegistrarApiCheckContactsCompatibilityRequest}
908+
* @returns A Promise of CheckContactsCompatibilityResponse
909+
*/
910+
checkContactsCompatibility = (
911+
request: Readonly<RegistrarApiCheckContactsCompatibilityRequest> = {},
912+
) =>
913+
this.client.fetch<CheckContactsCompatibilityResponse>(
914+
{
915+
body: JSON.stringify(
916+
marshalRegistrarApiCheckContactsCompatibilityRequest(
917+
request,
918+
this.client.settings,
919+
),
920+
),
921+
headers: jsonContentHeaders,
922+
method: 'POST',
923+
path: `/domain/v2beta1/check-contacts-compatibility`,
924+
},
925+
unmarshalCheckContactsCompatibilityResponse,
926+
)
927+
899928
protected pageOfListContacts = (
900929
request: Readonly<RegistrarApiListContactsRequest> = {},
901930
) =>

packages/clients/src/api/domain/v2beta1/marshalling.gen.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {
1111
import type { DefaultValues } from '../../../bridge'
1212
import type {
1313
AvailableDomain,
14+
CheckContactsCompatibilityResponse,
15+
CheckContactsCompatibilityResponseContactCheckResult,
1416
ClearDNSZoneRecordsResponse,
1517
CloneDNSZoneRequest,
1618
Contact,
@@ -82,6 +84,7 @@ import type {
8284
RefreshDNSZoneResponse,
8385
RegisterExternalDomainResponse,
8486
RegistrarApiBuyDomainsRequest,
87+
RegistrarApiCheckContactsCompatibilityRequest,
8588
RegistrarApiEnableDomainDNSSECRequest,
8689
RegistrarApiRegisterExternalDomainRequest,
8790
RegistrarApiRenewDomainsRequest,
@@ -599,6 +602,21 @@ const unmarshalAvailableDomain = (data: unknown) => {
599602
} as AvailableDomain
600603
}
601604

605+
const unmarshalCheckContactsCompatibilityResponseContactCheckResult = (
606+
data: unknown,
607+
) => {
608+
if (!isJSONObject(data)) {
609+
throw new TypeError(
610+
`Unmarshalling the type 'CheckContactsCompatibilityResponseContactCheckResult' failed as data isn't a dictionary.`,
611+
)
612+
}
613+
614+
return {
615+
compatible: data.compatible,
616+
errorMessage: data.error_message,
617+
} as CheckContactsCompatibilityResponseContactCheckResult
618+
}
619+
602620
const unmarshalContactRoles = (data: unknown) => {
603621
if (!isJSONObject(data)) {
604622
throw new TypeError(
@@ -770,6 +788,33 @@ const unmarshalTask = (data: unknown) => {
770788
} as Task
771789
}
772790

791+
export const unmarshalCheckContactsCompatibilityResponse = (data: unknown) => {
792+
if (!isJSONObject(data)) {
793+
throw new TypeError(
794+
`Unmarshalling the type 'CheckContactsCompatibilityResponse' failed as data isn't a dictionary.`,
795+
)
796+
}
797+
798+
return {
799+
administrativeCheckResult: data.administrative_check_result
800+
? unmarshalCheckContactsCompatibilityResponseContactCheckResult(
801+
data.administrative_check_result,
802+
)
803+
: undefined,
804+
compatible: data.compatible,
805+
ownerCheckResult: data.owner_check_result
806+
? unmarshalCheckContactsCompatibilityResponseContactCheckResult(
807+
data.owner_check_result,
808+
)
809+
: undefined,
810+
technicalCheckResult: data.technical_check_result
811+
? unmarshalCheckContactsCompatibilityResponseContactCheckResult(
812+
data.technical_check_result,
813+
)
814+
: undefined,
815+
} as CheckContactsCompatibilityResponse
816+
}
817+
773818
export const unmarshalClearDNSZoneRecordsResponse = (data: unknown) => {
774819
if (!isJSONObject(data)) {
775820
throw new TypeError(
@@ -1698,6 +1743,58 @@ export const marshalRegistrarApiBuyDomainsRequest = (
16981743
]),
16991744
})
17001745

1746+
export const marshalRegistrarApiCheckContactsCompatibilityRequest = (
1747+
request: RegistrarApiCheckContactsCompatibilityRequest,
1748+
defaults: DefaultValues,
1749+
): Record<string, unknown> => ({
1750+
...resolveOneOf<unknown>([
1751+
{
1752+
param: 'administrative_contact_id',
1753+
value: request.administrativeContactId,
1754+
},
1755+
{
1756+
param: 'administrative_contact',
1757+
value: request.administrativeContact
1758+
? marshalNewContact(request.administrativeContact, defaults)
1759+
: undefined,
1760+
},
1761+
]),
1762+
...resolveOneOf<unknown>([
1763+
{
1764+
param: 'owner_contact_id',
1765+
value: request.ownerContactId,
1766+
},
1767+
{
1768+
param: 'owner_contact',
1769+
value: request.ownerContact
1770+
? marshalNewContact(request.ownerContact, defaults)
1771+
: undefined,
1772+
},
1773+
]),
1774+
...resolveOneOf([
1775+
{
1776+
param: 'domain',
1777+
value: request.domain,
1778+
},
1779+
{
1780+
param: 'tld',
1781+
value: request.tld,
1782+
},
1783+
]),
1784+
...resolveOneOf<unknown>([
1785+
{
1786+
param: 'technical_contact_id',
1787+
value: request.technicalContactId,
1788+
},
1789+
{
1790+
param: 'technical_contact',
1791+
value: request.technicalContact
1792+
? marshalNewContact(request.technicalContact, defaults)
1793+
: undefined,
1794+
},
1795+
]),
1796+
})
1797+
17011798
export const marshalRegistrarApiEnableDomainDNSSECRequest = (
17021799
request: RegistrarApiEnableDomainDNSSECRequest,
17031800
defaults: DefaultValues,

packages/clients/src/api/domain/v2beta1/types.gen.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,19 @@ export interface AvailableDomain {
193193
tld?: Tld
194194
}
195195

196+
/** Check contacts compatibility response */
197+
export interface CheckContactsCompatibilityResponse {
198+
compatible: boolean
199+
ownerCheckResult?: CheckContactsCompatibilityResponseContactCheckResult
200+
administrativeCheckResult?: CheckContactsCompatibilityResponseContactCheckResult
201+
technicalCheckResult?: CheckContactsCompatibilityResponseContactCheckResult
202+
}
203+
204+
export interface CheckContactsCompatibilityResponseContactCheckResult {
205+
compatible: boolean
206+
errorMessage?: string
207+
}
208+
196209
/** Clear dns zone records response */
197210
export interface ClearDNSZoneRecordsResponse {}
198211

@@ -1074,6 +1087,43 @@ export type RegistrarApiDeleteExternalDomainRequest = {
10741087
domain: string
10751088
}
10761089

1090+
export type RegistrarApiCheckContactsCompatibilityRequest = {
1091+
/** One-of ('parameter'): at most one of 'domain', 'tld' could be set. */
1092+
domain?: string
1093+
/** One-of ('parameter'): at most one of 'domain', 'tld' could be set. */
1094+
tld?: string
1095+
/**
1096+
* One-of ('ownerContactType'): at most one of 'ownerContactId',
1097+
* 'ownerContact' could be set.
1098+
*/
1099+
ownerContactId?: string
1100+
/**
1101+
* One-of ('ownerContactType'): at most one of 'ownerContactId',
1102+
* 'ownerContact' could be set.
1103+
*/
1104+
ownerContact?: NewContact
1105+
/**
1106+
* One-of ('administrativeContactType'): at most one of
1107+
* 'administrativeContactId', 'administrativeContact' could be set.
1108+
*/
1109+
administrativeContactId?: string
1110+
/**
1111+
* One-of ('administrativeContactType'): at most one of
1112+
* 'administrativeContactId', 'administrativeContact' could be set.
1113+
*/
1114+
administrativeContact?: NewContact
1115+
/**
1116+
* One-of ('technicalContactType'): at most one of 'technicalContactId',
1117+
* 'technicalContact' could be set.
1118+
*/
1119+
technicalContactId?: string
1120+
/**
1121+
* One-of ('technicalContactType'): at most one of 'technicalContactId',
1122+
* 'technicalContact' could be set.
1123+
*/
1124+
technicalContact?: NewContact
1125+
}
1126+
10771127
export type RegistrarApiListContactsRequest = {
10781128
page?: number
10791129
pageSize?: number

0 commit comments

Comments
 (0)