Fixed MoshiX json serialization/generated classes.
This commit is contained in:
parent
dc7781db38
commit
a878289779
@ -36,7 +36,7 @@ plugins {
|
|||||||
// There are several issues with KSP.
|
// There are several issues with KSP.
|
||||||
// 1) It runs on every compile (it's not cached)
|
// 1) It runs on every compile (it's not cached)
|
||||||
// 2) It is not possible to (at last I don't know) how to run this via IntelliJ compiles (it's only via Gradle)
|
// 2) It is not possible to (at last I don't know) how to run this via IntelliJ compiles (it's only via Gradle)
|
||||||
id("dev.zacsweers.moshix") version "0.19.0" apply(false)
|
id("dev.zacsweers.moshix") version "0.20.0"
|
||||||
|
|
||||||
kotlin("jvm") version "1.7.21"
|
kotlin("jvm") version "1.7.21"
|
||||||
}
|
}
|
||||||
@ -115,8 +115,8 @@ dependencies {
|
|||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||||
|
|
||||||
val moshiVer = "1.12.0"
|
val moshiVer = "1.14.0"
|
||||||
val okHttpVer = "4.9.1"
|
val okHttpVer = "4.10.0"
|
||||||
val retroVer = "2.9.0"
|
val retroVer = "2.9.0"
|
||||||
|
|
||||||
api("com.squareup.okhttp3:okhttp:$okHttpVer")
|
api("com.squareup.okhttp3:okhttp:$okHttpVer")
|
||||||
|
@ -16,15 +16,10 @@
|
|||||||
package dorkbox.kloudflareApi.api.core
|
package dorkbox.kloudflareApi.api.core
|
||||||
|
|
||||||
import com.squareup.moshi.FromJson
|
import com.squareup.moshi.FromJson
|
||||||
import com.squareup.moshi.JsonQualifier
|
|
||||||
import com.squareup.moshi.ToJson
|
import com.squareup.moshi.ToJson
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
|
||||||
@JsonQualifier
|
|
||||||
annotation class ISO8601
|
|
||||||
|
|
||||||
/** Converts byte arrays to base64 (so it looks better as a string...) */
|
/** Converts byte arrays to base64 (so it looks better as a string...) */
|
||||||
internal class ISO8601Adapter {
|
internal class ISO8601Adapter {
|
||||||
companion object {
|
companion object {
|
||||||
@ -34,18 +29,17 @@ internal class ISO8601Adapter {
|
|||||||
|
|
||||||
|
|
||||||
@ToJson
|
@ToJson
|
||||||
fun toJson(@ISO8601 date: LocalDateTime): String {
|
fun toJson(date: LocalDateTime): String {
|
||||||
return format.format(date)
|
return format.format(date)
|
||||||
}
|
}
|
||||||
|
|
||||||
@FromJson
|
@FromJson
|
||||||
@ISO8601
|
|
||||||
fun fromJson(dateString: String): LocalDateTime {
|
fun fromJson(dateString: String): LocalDateTime {
|
||||||
return try {
|
return try {
|
||||||
return LocalDateTime.parse(dateString, format)
|
return LocalDateTime.parse(dateString, format)
|
||||||
}
|
}
|
||||||
catch (ignored: Exception) {
|
catch (ignored: Exception) {
|
||||||
// if there is an error, return epoc
|
// if there is an error, return the epoc
|
||||||
LocalDateTime.now()
|
LocalDateTime.now()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.dns
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import dorkbox.kloudflareApi.api.zone.Zone
|
import dorkbox.kloudflareApi.api.zone.Zone
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@ -108,13 +107,13 @@ open class DnsRecord {
|
|||||||
/**
|
/**
|
||||||
* When the record was last modified
|
* When the record was last modified
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "modified_on") ISO8601]
|
@field:[Json(name = "modified_on")]
|
||||||
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the record was created
|
* When the record was created
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "created_on") ISO8601]
|
@field:[Json(name = "created_on")]
|
||||||
var createdOn: LocalDateTime = LocalDateTime.now()
|
var createdOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.firewall
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,13 +65,13 @@ class AccessRule {
|
|||||||
/**
|
/**
|
||||||
* When the record was last modified
|
* When the record was last modified
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "modified_on") ISO8601]
|
@field:[Json(name = "modified_on")]
|
||||||
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the record was created
|
* When the record was created
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "created_on") ISO8601]
|
@field:[Json(name = "created_on")]
|
||||||
var createdOn: LocalDateTime = LocalDateTime.now()
|
var createdOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.user
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import dorkbox.kloudflareApi.api.zone.Zone
|
import dorkbox.kloudflareApi.api.zone.Zone
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@ -54,7 +53,7 @@ class BillingHistory {
|
|||||||
/**
|
/**
|
||||||
* When the billing item was created
|
* When the billing item was created
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "occurred_at") ISO8601]
|
@field:[Json(name = "occurred_at")]
|
||||||
var occurredAt: LocalDateTime = LocalDateTime.now()
|
var occurredAt: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.user
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,13 +143,13 @@ class BillingProfile {
|
|||||||
/**
|
/**
|
||||||
* When the profile was last modified
|
* When the profile was last modified
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "edited_on") ISO8601]
|
@field:[Json(name = "edited_on")]
|
||||||
var editedOn: LocalDateTime = LocalDateTime.now()
|
var editedOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the profile was created
|
* When the profile was created
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "created_on") ISO8601]
|
@field:[Json(name = "created_on")]
|
||||||
var createdOn: LocalDateTime = LocalDateTime.now()
|
var createdOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.user
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +58,7 @@ class User {
|
|||||||
/**
|
/**
|
||||||
* Last time the user was modified
|
* Last time the user was modified
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "modified_on") ISO8601]
|
@field:[Json(name = "modified_on")]
|
||||||
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +70,7 @@ class User {
|
|||||||
/**
|
/**
|
||||||
* When the user signed up.
|
* When the user signed up.
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "created_on") ISO8601]
|
@field:[Json(name = "created_on")]
|
||||||
var createdOn: LocalDateTime = LocalDateTime.now()
|
var createdOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.user.invite
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +28,7 @@ class Invite {
|
|||||||
/**
|
/**
|
||||||
* When the invite was sent
|
* When the invite was sent
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "invited_on") ISO8601]
|
@field:[Json(name = "invited_on")]
|
||||||
var invitedOn: LocalDateTime = LocalDateTime.now()
|
var invitedOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.user.subscription
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import dorkbox.kloudflareApi.api.zone.Zone
|
import dorkbox.kloudflareApi.api.zone.Zone
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ class Subscription {
|
|||||||
/**
|
/**
|
||||||
* The end of the current period, and also when the next billing is due
|
* The end of the current period, and also when the next billing is due
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "current_period_end") ISO8601]
|
@field:[Json(name = "current_period_end")]
|
||||||
var currentPeriodEnd: LocalDateTime = LocalDateTime.now()
|
var currentPeriodEnd: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,7 +59,7 @@ class Subscription {
|
|||||||
/**
|
/**
|
||||||
* When the current billing period started, may be the same as InitialPeriodStart if this is the first period
|
* When the current billing period started, may be the same as InitialPeriodStart if this is the first period
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "current_period_start") ISO8601]
|
@field:[Json(name = "current_period_start")]
|
||||||
var currentPeriodStart: LocalDateTime = LocalDateTime.now()
|
var currentPeriodStart: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,13 +25,13 @@ import com.squareup.moshi.JsonClass
|
|||||||
class Owner {
|
class Owner {
|
||||||
|
|
||||||
@field:[Json(name = "id")]
|
@field:[Json(name = "id")]
|
||||||
var id = ""
|
var id: String? = ""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The type of owner of the zone
|
* The type of owner of the zone
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "email")]
|
@field:[Json(name = "email")]
|
||||||
var email = ""
|
var email: String? = ""
|
||||||
|
|
||||||
@field:[Json(name = "owner_type")]
|
@field:[Json(name = "owner_type")]
|
||||||
var ownerType = "user"
|
var ownerType = "user"
|
||||||
|
@ -18,7 +18,6 @@ package dorkbox.kloudflareApi.api.zone
|
|||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.Kloudflare
|
import dorkbox.kloudflareApi.Kloudflare
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import dorkbox.kloudflareApi.api.dns.DnsRecord
|
import dorkbox.kloudflareApi.api.dns.DnsRecord
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
@ -80,13 +79,13 @@ class Zone {
|
|||||||
/**
|
/**
|
||||||
* When the zone was created
|
* When the zone was created
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "created_on") ISO8601]
|
@field:[Json(name = "created_on")]
|
||||||
var createdOn: LocalDateTime = LocalDateTime.now()
|
var createdOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When the zone was last modified
|
* When the zone was last modified
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "modified_on") ISO8601]
|
@field:[Json(name = "modified_on")]
|
||||||
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
var modifiedOn: LocalDateTime = LocalDateTime.now()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -135,7 +134,7 @@ class Zone {
|
|||||||
/**
|
/**
|
||||||
* The last time proof of ownership was detected and the zone was made active
|
* The last time proof of ownership was detected and the zone was made active
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "activated_on") ISO8601]
|
@field:[Json(name = "activated_on")]
|
||||||
var activatedOn: LocalDateTime? = null
|
var activatedOn: LocalDateTime? = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,6 @@ package dorkbox.kloudflareApi.api.zone.settings
|
|||||||
|
|
||||||
import com.squareup.moshi.Json
|
import com.squareup.moshi.Json
|
||||||
import com.squareup.moshi.JsonClass
|
import com.squareup.moshi.JsonClass
|
||||||
import dorkbox.kloudflareApi.api.core.ISO8601
|
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -862,7 +861,7 @@ open class ZoneSetting {
|
|||||||
/**
|
/**
|
||||||
* last time this setting was modified
|
* last time this setting was modified
|
||||||
*/
|
*/
|
||||||
@field:[Json(name = "modified_on") ISO8601]
|
@field:[Json(name = "modified_on")]
|
||||||
var modifiedOn: LocalDateTime? = null
|
var modifiedOn: LocalDateTime? = null
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
|
Loading…
Reference in New Issue
Block a user