|
| 1 | +package com.nylas.models |
| 2 | + |
| 3 | +import com.squareup.moshi.Json |
| 4 | + |
| 5 | +/** |
| 6 | + * DNS verification types accepted by the Manage Domains API. |
| 7 | + */ |
| 8 | +enum class DomainVerificationType { |
| 9 | + @Json(name = "ownership") |
| 10 | + OWNERSHIP, |
| 11 | + |
| 12 | + @Json(name = "mx") |
| 13 | + MX, |
| 14 | + |
| 15 | + @Json(name = "spf") |
| 16 | + SPF, |
| 17 | + |
| 18 | + @Json(name = "dkim") |
| 19 | + DKIM, |
| 20 | + |
| 21 | + @Json(name = "feedback") |
| 22 | + FEEDBACK, |
| 23 | + |
| 24 | + @Json(name = "dmarc") |
| 25 | + DMARC, |
| 26 | + |
| 27 | + @Json(name = "arc") |
| 28 | + ARC, |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | + * DNS verification types accepted by Manage Domains verification requests. |
| 33 | + */ |
| 34 | +enum class DomainVerificationRequestType { |
| 35 | + @Json(name = "ownership") |
| 36 | + OWNERSHIP, |
| 37 | + |
| 38 | + @Json(name = "mx") |
| 39 | + MX, |
| 40 | + |
| 41 | + @Json(name = "spf") |
| 42 | + SPF, |
| 43 | + |
| 44 | + @Json(name = "dkim") |
| 45 | + DKIM, |
| 46 | + |
| 47 | + @Json(name = "feedback") |
| 48 | + FEEDBACK, |
| 49 | +} |
| 50 | + |
| 51 | +/** |
| 52 | + * Status values returned by domain DNS verification attempts. |
| 53 | + */ |
| 54 | +enum class DomainVerificationStatus { |
| 55 | + @Json(name = "pending") |
| 56 | + PENDING, |
| 57 | + |
| 58 | + @Json(name = "done") |
| 59 | + DONE, |
| 60 | + |
| 61 | + @Json(name = "failed") |
| 62 | + FAILED, |
| 63 | +} |
| 64 | + |
| 65 | +/** |
| 66 | + * Class representation of a domain DNS verification request. |
| 67 | + */ |
| 68 | +data class DomainVerificationRequest( |
| 69 | + @Json(name = "type") |
| 70 | + val type: DomainVerificationRequestType, |
| 71 | + @Json(name = "options") |
| 72 | + val options: Map<String, Any>? = null, |
| 73 | +) { |
| 74 | + /** |
| 75 | + * Builder for [DomainVerificationRequest]. |
| 76 | + */ |
| 77 | + data class Builder(private val type: DomainVerificationRequestType) { |
| 78 | + private var options: Map<String, Any>? = null |
| 79 | + |
| 80 | + /** |
| 81 | + * Set verification options. |
| 82 | + * @param options Verification options. |
| 83 | + * @return This builder. |
| 84 | + */ |
| 85 | + fun options(options: Map<String, Any>?) = apply { this.options = options } |
| 86 | + |
| 87 | + /** |
| 88 | + * Build the [DomainVerificationRequest]. |
| 89 | + * @return The built [DomainVerificationRequest]. |
| 90 | + */ |
| 91 | + fun build() = DomainVerificationRequest(type, options) |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +/** |
| 96 | + * Class representation of a verification attempt returned by the API. |
| 97 | + */ |
| 98 | +data class DomainVerificationAttempt( |
| 99 | + @Json(name = "type") |
| 100 | + val type: DomainVerificationType? = null, |
| 101 | + @Json(name = "options") |
| 102 | + val options: Map<String, Any>? = null, |
| 103 | +) |
| 104 | + |
| 105 | +/** |
| 106 | + * Class representation of a domain verification result. |
| 107 | + */ |
| 108 | +data class DomainVerificationResult( |
| 109 | + @Json(name = "domain_id") |
| 110 | + val domainId: String? = null, |
| 111 | + @Json(name = "attempt") |
| 112 | + val attempt: DomainVerificationAttempt? = null, |
| 113 | + @Json(name = "status") |
| 114 | + val status: DomainVerificationStatus? = null, |
| 115 | + @Json(name = "created_at") |
| 116 | + val createdAt: Long? = null, |
| 117 | + @Json(name = "expires_at") |
| 118 | + val expiresAt: Long? = null, |
| 119 | + @Json(name = "details") |
| 120 | + val details: Map<String, Any>? = null, |
| 121 | + @Json(name = "message") |
| 122 | + val message: String? = null, |
| 123 | +) |
0 commit comments