Skip to content

feat(tem): add domain reputation score #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export type {
DomainLastStatusDkimRecord,
DomainLastStatusRecordStatus,
DomainLastStatusSpfRecord,
DomainReputation,
DomainReputationStatus,
DomainStatistics,
DomainStatus,
Email,
Expand Down
20 changes: 20 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type {
DomainLastStatus,
DomainLastStatusDkimRecord,
DomainLastStatusSpfRecord,
DomainReputation,
DomainStatistics,
Email,
EmailTry,
Expand All @@ -24,6 +25,22 @@ import type {
Statistics,
} from './types.gen'

const unmarshalDomainReputation = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'DomainReputation' failed as data isn't a dictionary.`,
)
}

return {
previousScore: data.previous_score,
previousScoredAt: unmarshalDate(data.previous_scored_at),
score: data.score,
scoredAt: unmarshalDate(data.scored_at),
status: data.status,
} as DomainReputation
}

const unmarshalDomainStatistics = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -72,6 +89,9 @@ export const unmarshalDomain = (data: unknown) => {
organizationId: data.organization_id,
projectId: data.project_id,
region: data.region,
reputation: data.reputation
? unmarshalDomainReputation(data.reputation)
: undefined,
revokedAt: unmarshalDate(data.revoked_at),
spfConfig: data.spf_config,
statistics: data.statistics
Expand Down
30 changes: 28 additions & 2 deletions packages/clients/src/api/tem/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ export type DomainLastStatusRecordStatus =
| 'invalid'
| 'not_found'

export type DomainReputationStatus =
| 'unknown'
| 'excellent'
| 'good'
| 'average'
| 'bad'

export type DomainStatus =
| 'unknown'
| 'checked'
Expand Down Expand Up @@ -103,6 +110,11 @@ export interface Domain {
dkimConfig: string
/** Domain's statistics. */
statistics?: DomainStatistics
/**
* Domain's reputation, available when your domain is checked and has sent
* enough emails.
*/
reputation?: DomainReputation
region: Region
}

Expand All @@ -120,7 +132,7 @@ export interface DomainLastStatus {

/** Domain last status. dkim record. */
export interface DomainLastStatusDkimRecord {
/** Status of the DKIM record's configurartion. */
/** Status of the DKIM record's configuration. */
status: DomainLastStatusRecordStatus
/** Time and date the DKIM record was last valid. */
lastValidAt?: Date
Expand All @@ -130,14 +142,28 @@ export interface DomainLastStatusDkimRecord {

/** Domain last status. spf record. */
export interface DomainLastStatusSpfRecord {
/** Status of the SPF record's configurartion. */
/** Status of the SPF record's configuration. */
status: DomainLastStatusRecordStatus
/** Time and date the SPF record was last valid. */
lastValidAt?: Date
/** An error text displays in case the record is not valid. */
error?: string
}

/** Domain. reputation. */
export interface DomainReputation {
/** Status of your domain reputation. */
status: DomainReputationStatus
/** Represent a number between 0 and 100 of your domain reputation score. */
score: number
/** Time and date the score was calculated. */
scoredAt?: Date
/** The domain reputation score previously calculated. */
previousScore?: number
/** Time and date the previous score was calculated. */
previousScoredAt?: Date
}

export interface DomainStatistics {
totalCount: number
sentCount: number
Expand Down