diff --git a/pom.xml b/pom.xml index a57bd34..2d16708 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,26 @@ + + org.openapitools + jackson-databind-nullable + 0.2.1 + + + javax.annotation + javax.annotation-api + 1.3.2 + + + org.threeten + threetenbp + 1.4.3 + + + io.swagger + swagger-annotations + 1.5.24 + javax.servlet javax.servlet-api diff --git a/src/main/java/io/castle/client/api/CastleApi.java b/src/main/java/io/castle/client/api/CastleApi.java index 86565d3..0e257da 100644 --- a/src/main/java/io/castle/client/api/CastleApi.java +++ b/src/main/java/io/castle/client/api/CastleApi.java @@ -3,6 +3,7 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.JsonElement; import io.castle.client.model.*; +import io.castle.client.model.generated.*; import javax.annotation.Nullable; @@ -289,15 +290,15 @@ public interface CastleApi { CastleResponse get(String path); - CastleResponse post(String path, ImmutableMap payload); + CastleResponse post(String path, Object payload); CastleResponse put(String path); - CastleResponse put(String path, ImmutableMap payload); + CastleResponse put(String path, Object payload); CastleResponse delete(String path); - CastleResponse delete(String path, ImmutableMap payload); + CastleResponse delete(String path, Object payload); /** * Makes a sync POST request to the risk endpoint. @@ -307,6 +308,14 @@ public interface CastleApi { */ CastleResponse risk(ImmutableMap payload); + /** + * Makes a sync POST request to the risk endpoint. + * + * @param payload Event parameters + * @return + */ + RiskResponse risk(Risk payload); + /** * Makes a sync POST request to the filter endpoint. * @@ -315,6 +324,14 @@ public interface CastleApi { */ CastleResponse filter(ImmutableMap payload); + /** + * Makes a sync POST request to the filter endpoint. + * + * @param payload Event parameters + * @return + */ + FilterResponse filter(Filter payload); + /** * Makes a sync POST request to the log endpoint. * @@ -323,6 +340,14 @@ public interface CastleApi { */ CastleResponse log(ImmutableMap payload); + /** + * Makes a sync POST request to the log endpoint. + * + * @param payload Event parameters + * @return + */ + CastleResponse log(Log payload); + /** * Makes a sync PUT request to the recover endpoint. * diff --git a/src/main/java/io/castle/client/internal/CastleApiImpl.java b/src/main/java/io/castle/client/internal/CastleApiImpl.java index d193a4d..21ccb6a 100644 --- a/src/main/java/io/castle/client/internal/CastleApiImpl.java +++ b/src/main/java/io/castle/client/internal/CastleApiImpl.java @@ -13,6 +13,7 @@ import io.castle.client.internal.utils.Timestamp; import io.castle.client.internal.utils.VerdictBuilder; import io.castle.client.model.*; +import io.castle.client.model.generated.*; import javax.annotation.Nullable; import javax.servlet.http.HttpServletRequest; @@ -285,7 +286,7 @@ public CastleResponse get(String path) { } @Override - public CastleResponse post(String path, ImmutableMap payload) { + public CastleResponse post(String path, Object payload) { RestApi restApi = configuration.getRestApiFactory().buildBackend(); return restApi.post(path, payload); } @@ -297,7 +298,7 @@ public CastleResponse put(String path) { } @Override - public CastleResponse put(String path, ImmutableMap payload) { + public CastleResponse put(String path, Object payload) { RestApi restApi = configuration.getRestApiFactory().buildBackend(); return restApi.put(path, payload); } @@ -309,7 +310,7 @@ public CastleResponse delete(String path) { } @Override - public CastleResponse delete(String path, ImmutableMap payload) { + public CastleResponse delete(String path, Object payload) { RestApi restApi = configuration.getRestApiFactory().buildBackend(); return restApi.delete(path, payload); } @@ -320,6 +321,14 @@ public CastleResponse risk(ImmutableMap payload) { return restApi.post(Castle.URL_RISK, payload); } + @Override + public RiskResponse risk(Risk payload) { + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(Castle.URL_RISK, payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), RiskResponse.class); + } + @Override public CastleResponse filter(ImmutableMap payload) { Preconditions.checkNotNull(payload); @@ -327,6 +336,14 @@ public CastleResponse filter(ImmutableMap payload) { return restApi.post(Castle.URL_FILTER, payload); } + @Override + public FilterResponse filter(Filter payload) { + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + CastleResponse castleResponse = restApi.post(Castle.URL_FILTER, payload); + return configuration.getModel().getGson().fromJson(castleResponse.json(), FilterResponse.class); + } + @Override public CastleResponse log(ImmutableMap payload) { Preconditions.checkNotNull(payload); @@ -334,6 +351,13 @@ public CastleResponse log(ImmutableMap payload) { return restApi.post(Castle.URL_LOG, payload); } + @Override + public CastleResponse log(Log payload) { + Preconditions.checkNotNull(payload); + RestApi restApi = configuration.getRestApiFactory().buildBackend(); + return restApi.post(Castle.URL_LOG, payload); + } + @Override public CastleResponse recover(String userId) { Preconditions.checkNotNull(userId, "UserId can not be null"); diff --git a/src/main/java/io/castle/client/internal/backend/OkRestApiBackend.java b/src/main/java/io/castle/client/internal/backend/OkRestApiBackend.java index a3a1889..8c3c11e 100644 --- a/src/main/java/io/castle/client/internal/backend/OkRestApiBackend.java +++ b/src/main/java/io/castle/client/internal/backend/OkRestApiBackend.java @@ -254,7 +254,7 @@ public CastleResponse put(String path) { } @Override - public CastleResponse put(String path, ImmutableMap payload) { + public CastleResponse put(String path, Object payload) { return makeRequest(path, model.getGson().toJsonTree(payload), METHOD_PUT); } @@ -264,12 +264,12 @@ public CastleResponse delete(String path) { } @Override - public CastleResponse delete(String path, ImmutableMap payload) { + public CastleResponse delete(String path, Object payload) { return makeRequest(path, model.getGson().toJsonTree(payload), METHOD_DELETE); } @Override - public CastleResponse post(String path, ImmutableMap payload) { + public CastleResponse post(String path, Object payload) { return makeRequest(path, model.getGson().toJsonTree(payload), METHOD_POST); } diff --git a/src/main/java/io/castle/client/internal/backend/RestApi.java b/src/main/java/io/castle/client/internal/backend/RestApi.java index 29dc97a..c5a9d14 100644 --- a/src/main/java/io/castle/client/internal/backend/RestApi.java +++ b/src/main/java/io/castle/client/internal/backend/RestApi.java @@ -103,7 +103,7 @@ public interface RestApi { * @param payload request payload * @return a decoded json response */ - CastleResponse post(String path, ImmutableMap payload); + CastleResponse post(String path, Object payload); /** * Make a PUT request to a Castle API endpoint such as /v1/devices/{deviceToken}/report @@ -120,7 +120,7 @@ public interface RestApi { * @param payload request payload * @return a decoded json response */ - CastleResponse put(String path, ImmutableMap payload); + CastleResponse put(String path, Object payload); /** * Make a DELETE request to a Castle API endpoint such as /v1/impersonate @@ -137,5 +137,5 @@ public interface RestApi { * @param payload request payload * @return a decoded json response */ - CastleResponse delete(String path, ImmutableMap payload); + CastleResponse delete(String path, Object payload); } diff --git a/src/main/java/io/castle/client/internal/json/CastleGsonModel.java b/src/main/java/io/castle/client/internal/json/CastleGsonModel.java index a3ede4e..67a0a7c 100644 --- a/src/main/java/io/castle/client/internal/json/CastleGsonModel.java +++ b/src/main/java/io/castle/client/internal/json/CastleGsonModel.java @@ -1,14 +1,24 @@ package io.castle.client.internal.json; -import com.google.gson.FieldNamingPolicy; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonParser; +import com.google.gson.*; +import com.google.gson.internal.bind.DateTypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; import io.castle.client.model.AuthenticateAction; import io.castle.client.model.RiskPolicyType; import io.castle.client.model.CastleHeaders; import io.castle.client.model.CastleMessage; +import okio.ByteString; +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.format.DateTimeFormatter; + +import java.io.IOException; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.util.Date; public class CastleGsonModel { @@ -22,6 +32,13 @@ public CastleGsonModel() { builder.registerTypeAdapter(CastleHeaders.class, new CastleHeadersDeserializer()); builder.registerTypeAdapter(AuthenticateAction.class, new AuthenticateActionDeserializer()); builder.registerTypeAdapter(RiskPolicyType.class, new RiskPolicyTypeDeserializer()); + + builder.registerTypeAdapter(Date.class, new DateTypeAdapter()); + builder.registerTypeAdapter(java.sql.Date.class, new SqlDateTypeAdapter()); + builder.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeTypeAdapter()); + builder.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter()); + builder.registerTypeAdapter(byte[].class, new ByteArrayAdapter()); + this.gson = builder.create(); } @@ -32,4 +49,228 @@ public Gson getGson() { public static GsonBuilder createGsonBuilder() { return new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES); } + + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } } diff --git a/src/main/java/io/castle/client/model/generated/Address.java b/src/main/java/io/castle/client/model/generated/Address.java new file mode 100644 index 0000000..06404b6 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Address.java @@ -0,0 +1,257 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.openapitools.jackson.nullable.JsonNullable; + +/** + * Address + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Address { + public static final String SERIALIZED_NAME_LINE1 = "line1"; + @SerializedName(SERIALIZED_NAME_LINE1) + private String line1; + + public static final String SERIALIZED_NAME_LINE2 = "line2"; + @SerializedName(SERIALIZED_NAME_LINE2) + private String line2; + + public static final String SERIALIZED_NAME_CITY = "city"; + @SerializedName(SERIALIZED_NAME_CITY) + private String city; + + public static final String SERIALIZED_NAME_COUNTRY_CODE = "country_code"; + @SerializedName(SERIALIZED_NAME_COUNTRY_CODE) + private String countryCode; + + public static final String SERIALIZED_NAME_REGION_CODE = "region_code"; + @SerializedName(SERIALIZED_NAME_REGION_CODE) + private String regionCode; + + public static final String SERIALIZED_NAME_POSTAL_CODE = "postal_code"; + @SerializedName(SERIALIZED_NAME_POSTAL_CODE) + private String postalCode; + + + public Address line1(String line1) { + + this.line1 = line1; + return this; + } + + /** + * Get line1 + * @return line1 + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "60 Rausch Street", value = "") + + public String getLine1() { + return line1; + } + + + public void setLine1(String line1) { + this.line1 = line1; + } + + + public Address line2(String line2) { + + this.line2 = line2; + return this; + } + + /** + * Get line2 + * @return line2 + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getLine2() { + return line2; + } + + + public void setLine2(String line2) { + this.line2 = line2; + } + + + public Address city(String city) { + + this.city = city; + return this; + } + + /** + * Name of the city associated to this address. + * @return city + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "San Francisco", value = "Name of the city associated to this address.") + + public String getCity() { + return city; + } + + + public void setCity(String city) { + this.city = city; + } + + + public Address countryCode(String countryCode) { + + this.countryCode = countryCode; + return this; + } + + /** + * ISO-3166 country code + * @return countryCode + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "US", required = true, value = "ISO-3166 country code") + + public String getCountryCode() { + return countryCode; + } + + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + + public Address regionCode(String regionCode) { + + this.regionCode = regionCode; + return this; + } + + /** + * ISO region code + * @return regionCode + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "CA", value = "ISO region code") + + public String getRegionCode() { + return regionCode; + } + + + public void setRegionCode(String regionCode) { + this.regionCode = regionCode; + } + + + public Address postalCode(String postalCode) { + + this.postalCode = postalCode; + return this; + } + + /** + * Get postalCode + * @return postalCode + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "94103", value = "") + + public String getPostalCode() { + return postalCode; + } + + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Address address = (Address) o; + return Objects.equals(this.line1, address.line1) && + Objects.equals(this.line2, address.line2) && + Objects.equals(this.city, address.city) && + Objects.equals(this.countryCode, address.countryCode) && + Objects.equals(this.regionCode, address.regionCode) && + Objects.equals(this.postalCode, address.postalCode); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(line1, line2, city, countryCode, regionCode, postalCode); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() + ? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get())) + : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Address {\n"); + sb.append(" line1: ").append(toIndentedString(line1)).append("\n"); + sb.append(" line2: ").append(toIndentedString(line2)).append("\n"); + sb.append(" city: ").append(toIndentedString(city)).append("\n"); + sb.append(" countryCode: ").append(toIndentedString(countryCode)).append("\n"); + sb.append(" regionCode: ").append(toIndentedString(regionCode)).append("\n"); + sb.append(" postalCode: ").append(toIndentedString(postalCode)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Amount.java b/src/main/java/io/castle/client/model/generated/Amount.java new file mode 100644 index 0000000..f534364 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Amount.java @@ -0,0 +1,201 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * CryptoAmount + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Amount { + /** + * Gets or Sets type + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + CRYPTO("$crypto"), + FIAT("$fiat"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_VALUE = "value"; + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + public static final String SERIALIZED_NAME_CURRENCY = "currency"; + @SerializedName(SERIALIZED_NAME_CURRENCY) + private String currency; + + + public Amount type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public Amount value(String value) { + + this.value = value; + return this; + } + + /** + * Monetary amount of transaction with decimals + * @return value + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "1.512342352", required = true, value = "Monetary amount of transaction with decimals") + + public String getValue() { + return value; + } + + + public void setValue(String value) { + this.value = value; + } + + + public Amount currency(String currency) { + + this.currency = currency; + return this; + } + + /** + * Digital currency code + * @return currency + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "BTC", required = true, value = "Digital currency code") + + public String getCurrency() { + return currency; + } + + + public void setCurrency(String currency) { + this.currency = currency; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Amount amount = (Amount) o; + return Objects.equals(this.type, amount.type) && + Objects.equals(this.value, amount.value) && + Objects.equals(this.currency, amount.currency); + } + + @Override + public int hashCode() { + return Objects.hash(type, value, currency); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CryptoAmount {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append(" currency: ").append(toIndentedString(currency)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/AuthenticationMethod.java b/src/main/java/io/castle/client/model/generated/AuthenticationMethod.java new file mode 100644 index 0000000..ff847b1 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/AuthenticationMethod.java @@ -0,0 +1,186 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import io.castle.client.model.generated.AuthenticationMethodType; + +/** + * AuthenticationMethod + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class AuthenticationMethod { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private AuthenticationMethodType type; + + public static final String SERIALIZED_NAME_VARIANT = "variant"; + @SerializedName(SERIALIZED_NAME_VARIANT) + private String variant; + + public static final String SERIALIZED_NAME_EMAIL = "email"; + @SerializedName(SERIALIZED_NAME_EMAIL) + private String email; + + public static final String SERIALIZED_NAME_PHONE = "phone"; + @SerializedName(SERIALIZED_NAME_PHONE) + private String phone; + + + public AuthenticationMethod type(AuthenticationMethodType type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public AuthenticationMethodType getType() { + return type; + } + + + public void setType(AuthenticationMethodType type) { + this.type = type; + } + + + public AuthenticationMethod variant(String variant) { + + this.variant = variant; + return this; + } + + /** + * Get variant + * @return variant + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getVariant() { + return variant; + } + + + public void setVariant(String variant) { + this.variant = variant; + } + + + public AuthenticationMethod email(String email) { + + this.email = email; + return this; + } + + /** + * Used when `type` is `$email` + * @return email + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Used when `type` is `$email`") + + public String getEmail() { + return email; + } + + + public void setEmail(String email) { + this.email = email; + } + + + public AuthenticationMethod phone(String phone) { + + this.phone = phone; + return this; + } + + /** + * Used when `type` is `$phone` + * @return phone + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Used when `type` is `$phone`") + + public String getPhone() { + return phone; + } + + + public void setPhone(String phone) { + this.phone = phone; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AuthenticationMethod authenticationMethod = (AuthenticationMethod) o; + return Objects.equals(this.type, authenticationMethod.type) && + Objects.equals(this.variant, authenticationMethod.variant) && + Objects.equals(this.email, authenticationMethod.email) && + Objects.equals(this.phone, authenticationMethod.phone); + } + + @Override + public int hashCode() { + return Objects.hash(type, variant, email, phone); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AuthenticationMethod {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" variant: ").append(toIndentedString(variant)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/AuthenticationMethodType.java b/src/main/java/io/castle/client/model/generated/AuthenticationMethodType.java new file mode 100644 index 0000000..f6f83d5 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/AuthenticationMethodType.java @@ -0,0 +1,89 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets AuthenticationMethodType + */ +@JsonAdapter(AuthenticationMethodType.Adapter.class) +public enum AuthenticationMethodType { + + AUTHENTICATOR("$authenticator"), + + BIOMETRICS("$biometrics"), + + EMAIL("$email"), + + PASSWORD("$password"), + + PHONE("$phone"), + + PUSH("$push"), + + SECURITY_KEY("$security_key"), + + SOCIAL("$social"), + + SSO("$sso"), + + KBA("$kba"); + + private String value; + + AuthenticationMethodType(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AuthenticationMethodType fromValue(String value) { + for (AuthenticationMethodType b : AuthenticationMethodType.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final AuthenticationMethodType enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AuthenticationMethodType read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return AuthenticationMethodType.fromValue(value); + } + } +} + diff --git a/src/main/java/io/castle/client/model/generated/BaseChangesetEntry.java b/src/main/java/io/castle/client/model/generated/BaseChangesetEntry.java new file mode 100644 index 0000000..9f9fb2c --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/BaseChangesetEntry.java @@ -0,0 +1,4 @@ +package io.castle.client.model.generated; + +public abstract class BaseChangesetEntry { +} diff --git a/src/main/java/io/castle/client/model/generated/ChangedChangesetEntry.java b/src/main/java/io/castle/client/model/generated/ChangedChangesetEntry.java new file mode 100644 index 0000000..283ab9c --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ChangedChangesetEntry.java @@ -0,0 +1,75 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.Objects; + +/** + * Information that the attribute changed along with the changed values. Examples: `{ \"password\": { \"changed\": true } }` + */ +@ApiModel(description = "Information that the attribute changed along with the changed values. Examples: `{ \"password\": { \"changed\": true } }`") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class ChangedChangesetEntry extends BaseChangesetEntry { + public static final String SERIALIZED_NAME_CHANGED = "changed"; + @SerializedName(SERIALIZED_NAME_CHANGED) + private boolean changed = true; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangedChangesetEntry changedChangesetEntry = (ChangedChangesetEntry) o; + return Objects.equals(this.changed, changedChangesetEntry.changed); + } + + @Override + public int hashCode() { + return Objects.hash(changed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChangedChangesetEntry {\n"); + sb.append(" changed: ").append(toIndentedString(changed)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Changeset.java b/src/main/java/io/castle/client/model/generated/Changeset.java new file mode 100644 index 0000000..db893e4 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Changeset.java @@ -0,0 +1,213 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.HashMap; +import java.util.Objects; + +/** + * An object containing information about attributes that changed due to the event. You can send either anonymous attributes (eg. to track password changes) or full attributes (eg. email changes). To simplify your implementation, Castle *automatically* tracks changes to name, email, and phone, however, if you have the `from` and `to` values at hand, you can also send the changeset yourself, which also allows you to specify changes a user’s password as well as any other custom attributes. Changes to custom attributes won’t be searchable in the dashboard, but they will appear in the event stream. + */ +@ApiModel(description = "An object containing information about attributes that changed due to the event. You can send either anonymous attributes (eg. to track password changes) or full attributes (eg. email changes). To simplify your implementation, Castle *automatically* tracks changes to name, email, and phone, however, if you have the `from` and `to` values at hand, you can also send the changeset yourself, which also allows you to specify changes a user’s password as well as any other custom attributes. Changes to custom attributes won’t be searchable in the dashboard, but they will appear in the event stream.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Changeset { + public static final String SERIALIZED_NAME_PASSWORD = "password"; + @SerializedName(SERIALIZED_NAME_PASSWORD) + private BaseChangesetEntry password; + + public static final String SERIALIZED_NAME_EMAIL = "email"; + @SerializedName(SERIALIZED_NAME_EMAIL) + private BaseChangesetEntry email; + + public static final String SERIALIZED_NAME_PHONE = "phone"; + @SerializedName(SERIALIZED_NAME_PHONE) + private BaseChangesetEntry phone; + + public static final String SERIALIZED_NAME_AUTHENTICATION_METHOD_TYPE = "authentication_method.type"; + @SerializedName(SERIALIZED_NAME_AUTHENTICATION_METHOD_TYPE) + private BaseChangesetEntry authenticationMethodType; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private BaseChangesetEntry name; + + + public Changeset password(BaseChangesetEntry password) { + + this.password = password; + return this; + } + + /** + * Get password + * @return password + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public BaseChangesetEntry getPassword() { + return password; + } + + + public void setPassword(BaseChangesetEntry password) { + this.password = password; + } + + + public Changeset email(BaseChangesetEntry email) { + + this.email = email; + return this; + } + + /** + * Email address change. Both from and to must be valid emails if provided. You can also inform Castle that the email changed without sending the values explicitly: `{ \"email\": { \"changed\": true } }` + * @return email + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Email address change. Both from and to must be valid emails if provided. You can also inform Castle that the email changed without sending the values explicitly: `{ \"email\": { \"changed\": true } }`") + + public BaseChangesetEntry getEmail() { + return email; + } + + + public void setEmail(BaseChangesetEntry email) { + this.email = email; + } + + + public Changeset phone(BaseChangesetEntry phone) { + + this.phone = phone; + return this; + } + + /** + * Phone number change. Both from and to must be valid phone numbers if provided. You can also inform Castle that the phone changed without sending the values explicitly: `{ \"phone\": { \"changed\": true } }` + * @return phone + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Phone number change. Both from and to must be valid phone numbers if provided. You can also inform Castle that the phone changed without sending the values explicitly: `{ \"phone\": { \"changed\": true } }`") + + public BaseChangesetEntry getPhone() { + return phone; + } + + + public void setPhone(BaseChangesetEntry phone) { + this.phone = phone; + } + + + public Changeset authenticationMethodType(BaseChangesetEntry authenticationMethodType) { + + this.authenticationMethodType = authenticationMethodType; + return this; + } + + /** + * Get authenticationMethodType + * @return authenticationMethodType + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public BaseChangesetEntry getAuthenticationMethodType() { + return authenticationMethodType; + } + + + public void setAuthenticationMethodType(BaseChangesetEntry authenticationMethodType) { + this.authenticationMethodType = authenticationMethodType; + } + + + public Changeset name(BaseChangesetEntry name) { + + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public BaseChangesetEntry getName() { + return name; + } + + + public void setName(BaseChangesetEntry name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Changeset changeset = (Changeset) o; + return Objects.equals(this.password, changeset.password) && + Objects.equals(this.email, changeset.email) && + Objects.equals(this.phone, changeset.phone) && + Objects.equals(this.authenticationMethodType, changeset.authenticationMethodType) && + Objects.equals(this.name, changeset.name) && + super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(password, email, phone, authenticationMethodType, name, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Changeset {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" authenticationMethodType: ").append(toIndentedString(authenticationMethodType)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/ChangesetEntry.java b/src/main/java/io/castle/client/model/generated/ChangesetEntry.java new file mode 100644 index 0000000..d02cedf --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/ChangesetEntry.java @@ -0,0 +1,128 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Information that the attribute changed along with the changed values. Examples: `{ \"email\": { \"from\": \"a@example.com\", \"to\": \"b@example.com\" }`, `{ \"authentication_method.type\": { \"from\": null, \"to\": \"$push\" }` + */ +@ApiModel(description = "Information that the attribute changed along with the changed values. Examples: `{ \"email\": { \"from\": \"a@example.com\", \"to\": \"b@example.com\" }`, `{ \"authentication_method.type\": { \"from\": null, \"to\": \"$push\" }`") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class ChangesetEntry extends BaseChangesetEntry { + public static final String SERIALIZED_NAME_FROM = "from"; + @SerializedName(SERIALIZED_NAME_FROM) + private String from; + + public static final String SERIALIZED_NAME_TO = "to"; + @SerializedName(SERIALIZED_NAME_TO) + private String to; + + + public ChangesetEntry from(String from) { + + this.from = from; + return this; + } + + /** + * Attribute value before the event + * @return from + **/ + @javax.annotation.Nullable + @ApiModelProperty(required = true, value = "Attribute value before the event") + + public String getFrom() { + return from; + } + + + public void setFrom(String from) { + this.from = from; + } + + + public ChangesetEntry to(String to) { + + this.to = to; + return this; + } + + /** + * Attribute value after the event + * @return to + **/ + @javax.annotation.Nullable + @ApiModelProperty(required = true, value = "Attribute value after the event") + + public String getTo() { + return to; + } + + + public void setTo(String to) { + this.to = to; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ChangesetEntry changesetEntry = (ChangesetEntry) o; + return Objects.equals(this.from, changesetEntry.from) && + Objects.equals(this.to, changesetEntry.to); + } + + @Override + public int hashCode() { + return Objects.hash(from, to); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ChangesetEntry {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Context.java b/src/main/java/io/castle/client/model/generated/Context.java new file mode 100644 index 0000000..7b714de --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Context.java @@ -0,0 +1,129 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +/** + * Context + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Context { + public static final String SERIALIZED_NAME_HEADERS = "headers"; + @SerializedName(SERIALIZED_NAME_HEADERS) + private List> headers = new ArrayList>(); + + public static final String SERIALIZED_NAME_IP = "ip"; + @SerializedName(SERIALIZED_NAME_IP) + private String ip; + + + public Context headers(List> headers) { + + this.headers = headers; + return this; + } + + public Context addHeadersItem(String key, String value) { + this.headers.add(Arrays.asList(key, value)); + return this; + } + + /** + * The Headers object of the originating request. For best results, it's recommended to forward all headers from the originating request. At minimum, the following headers should be forwarded: `Host`, `User-Agent`, `Accept`, `Accept-Encoding`, `Accept-Language`. + * @return headers + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "[[\"User-Agent\",\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15\"],[\"Accept-Encoding\",\"gzip, deflate, br\"],[\"Accept-Language\",\"en-us\"],[\"Accept\",\"text/html,application/xhtml+xml,application/xml;q=0.9,*_/_*;q=0.8\"],[\"Connection\",\"close\"],[\"Host\",\"castle.io\"]]", required = true, value = "The Headers object of the originating request. For best results, it's recommended to forward all headers from the originating request. At minimum, the following headers should be forwarded: `Host`, `User-Agent`, `Accept`, `Accept-Encoding`, `Accept-Language`. ") + + public List> getHeaders() { + return headers; + } + + + public void setHeaders(List> headers) { + this.headers = headers; + } + + + public Context ip(String ip) { + + this.ip = ip; + return this; + } + + /** + * The IPv4 or IPv6 address of the originating request. Must be a valid, public IP. Supports ipv4 and ipv6 + * @return ip + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "211.96.77.55", required = true, value = "The IPv4 or IPv6 address of the originating request. Must be a valid, public IP. Supports ipv4 and ipv6 ") + + public String getIp() { + return ip; + } + + + public void setIp(String ip) { + this.ip = ip; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Context context = (Context) o; + return Objects.equals(this.headers, context.headers) && + Objects.equals(this.ip, context.ip); + } + + @Override + public int hashCode() { + return Objects.hash(headers, ip); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Context {\n"); + sb.append(" headers: ").append(toIndentedString(headers)).append("\n"); + sb.append(" ip: ").append(toIndentedString(ip)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Device.java b/src/main/java/io/castle/client/model/generated/Device.java new file mode 100644 index 0000000..6c1e58f --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Device.java @@ -0,0 +1,253 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import org.threeten.bp.OffsetDateTime; + +import java.util.Objects; + +/** + * Device + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Device { + public static final String SERIALIZED_NAME_TOKEN = "token"; + @SerializedName(SERIALIZED_NAME_TOKEN) + private String token; + + public static final String SERIALIZED_NAME_USER_ID = "user_id"; + @SerializedName(SERIALIZED_NAME_USER_ID) + private String userId; + + public static final String SERIALIZED_NAME_CREATED_AT = "created_at"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_LAST_SEEN_AT = "last_seen_at"; + @SerializedName(SERIALIZED_NAME_LAST_SEEN_AT) + private OffsetDateTime lastSeenAt; + + public static final String SERIALIZED_NAME_APPROVED_AT = "approved_at"; + @SerializedName(SERIALIZED_NAME_APPROVED_AT) + private OffsetDateTime approvedAt; + + public static final String SERIALIZED_NAME_ESCALATED_AT = "escalated_at"; + @SerializedName(SERIALIZED_NAME_ESCALATED_AT) + private OffsetDateTime escalatedAt; + + public static final String SERIALIZED_NAME_MITIGATED_AT = "mitigated_at"; + @SerializedName(SERIALIZED_NAME_MITIGATED_AT) + private OffsetDateTime mitigatedAt; + + public static final String SERIALIZED_NAME_IS_CURRENT_DEVICE = "is_current_device"; + @SerializedName(SERIALIZED_NAME_IS_CURRENT_DEVICE) + private Boolean isCurrentDevice; + + public static final String SERIALIZED_NAME_CONTEXT = "context"; + @SerializedName(SERIALIZED_NAME_CONTEXT) + private DeviceContext context; + + + /** + * Unique identifier for a user's device. This value may change over time and **should not** be used as a stable reference to the device + * @return token + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "eyJhbGciOiJIUzI1NiJ9.eyJhIjoxfQ.CLqLzOmK8uYmIXNlhPXhrWCTQOT-XO2Vx8pB2Xqol4g", required = true, value = "Unique identifier for a user's device. This value may change over time and **should not** be used as a stable reference to the device") + + public String getToken() { + return token; + } + + + + + /** + * Get userId + * @return userId + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "262ad900-b126-44df-9564-689f30391c57", required = true, value = "") + + public String getUserId() { + return userId; + } + + + + + /** + * The time and date on which the device was created + * @return createdAt + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "2012-12-02T00:30:08.276Z", required = true, value = "The time and date on which the device was created") + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + + + /** + * The time and date on which the device was last used + * @return lastSeenAt + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "2012-12-02T00:30:08.276Z", required = true, value = "The time and date on which the device was last used") + + public OffsetDateTime getLastSeenAt() { + return lastSeenAt; + } + + + + + /** + * The time and date on which the device was approved + * @return approvedAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "2012-12-02T00:30:08.276Z", required = true, value = "The time and date on which the device was approved") + + public OffsetDateTime getApprovedAt() { + return approvedAt; + } + + + + + /** + * The time and date on which the device was escalated + * @return escalatedAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "2012-12-02T00:30:08.276Z", required = true, value = "The time and date on which the device was escalated") + + public OffsetDateTime getEscalatedAt() { + return escalatedAt; + } + + + + + /** + * Get mitigatedAt + * @return mitigatedAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(required = true, value = "") + + public OffsetDateTime getMitigatedAt() { + return mitigatedAt; + } + + + + + /** + * Get isCurrentDevice + * @return isCurrentDevice + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Boolean getIsCurrentDevice() { + return isCurrentDevice; + } + + + + + public Device context(DeviceContext context) { + + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public DeviceContext getContext() { + return context; + } + + + public void setContext(DeviceContext context) { + this.context = context; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Device device = (Device) o; + return Objects.equals(this.token, device.token) && + Objects.equals(this.userId, device.userId) && + Objects.equals(this.createdAt, device.createdAt) && + Objects.equals(this.lastSeenAt, device.lastSeenAt) && + Objects.equals(this.approvedAt, device.approvedAt) && + Objects.equals(this.escalatedAt, device.escalatedAt) && + Objects.equals(this.mitigatedAt, device.mitigatedAt) && + Objects.equals(this.isCurrentDevice, device.isCurrentDevice) && + Objects.equals(this.context, device.context); + } + + @Override + public int hashCode() { + return Objects.hash(token, userId, createdAt, lastSeenAt, approvedAt, escalatedAt, mitigatedAt, isCurrentDevice, context); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Device {\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" lastSeenAt: ").append(toIndentedString(lastSeenAt)).append("\n"); + sb.append(" approvedAt: ").append(toIndentedString(approvedAt)).append("\n"); + sb.append(" escalatedAt: ").append(toIndentedString(escalatedAt)).append("\n"); + sb.append(" mitigatedAt: ").append(toIndentedString(mitigatedAt)).append("\n"); + sb.append(" isCurrentDevice: ").append(toIndentedString(isCurrentDevice)).append("\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/DeviceContext.java b/src/main/java/io/castle/client/model/generated/DeviceContext.java new file mode 100644 index 0000000..9c815a2 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/DeviceContext.java @@ -0,0 +1,255 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Context for the most recent activity + */ +@ApiModel(description = "Context for the most recent activity") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class DeviceContext { + public static final String SERIALIZED_NAME_IP = "ip"; + @SerializedName(SERIALIZED_NAME_IP) + private String ip; + + public static final String SERIALIZED_NAME_LOCATION = "location"; + @SerializedName(SERIALIZED_NAME_LOCATION) + private DeviceContextLocation location; + + public static final String SERIALIZED_NAME_USER_AGENT = "user_agent"; + @SerializedName(SERIALIZED_NAME_USER_AGENT) + private DeviceContextUserAgent userAgent; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private Map properties = new HashMap(); + + /** + * Gets or Sets type + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + DESKTOP("desktop"), + + MOBILE("mobile"), + + TABLET("tablet"), + + OTHER("other"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + + /** + * The IPv4 or IPv6 address of the originating request. Must be a valid, public IP. Supports ipv4 and ipv6 + * @return ip + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "211.96.77.55", required = true, value = "The IPv4 or IPv6 address of the originating request. Must be a valid, public IP. Supports ipv4 and ipv6 ") + + public String getIp() { + return ip; + } + + + + + public DeviceContext location(DeviceContextLocation location) { + + this.location = location; + return this; + } + + /** + * Get location + * @return location + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public DeviceContextLocation getLocation() { + return location; + } + + + public void setLocation(DeviceContextLocation location) { + this.location = location; + } + + + public DeviceContext userAgent(DeviceContextUserAgent userAgent) { + + this.userAgent = userAgent; + return this; + } + + /** + * Get userAgent + * @return userAgent + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public DeviceContextUserAgent getUserAgent() { + return userAgent; + } + + + public void setUserAgent(DeviceContextUserAgent userAgent) { + this.userAgent = userAgent; + } + + + public DeviceContext properties(Map properties) { + + this.properties = properties; + return this; + } + + public DeviceContext putPropertiesItem(String key, Object propertiesItem) { + this.properties.put(key, propertiesItem); + return this; + } + + /** + * User defined properties + * @return properties + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "User defined properties") + + public Map getProperties() { + return properties; + } + + + public void setProperties(Map properties) { + this.properties = properties; + } + + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "desktop", required = true, value = "") + + public TypeEnum getType() { + return type; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeviceContext deviceContext = (DeviceContext) o; + return Objects.equals(this.ip, deviceContext.ip) && + Objects.equals(this.location, deviceContext.location) && + Objects.equals(this.userAgent, deviceContext.userAgent) && + Objects.equals(this.properties, deviceContext.properties) && + Objects.equals(this.type, deviceContext.type); + } + + @Override + public int hashCode() { + return Objects.hash(ip, location, userAgent, properties, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeviceContext {\n"); + sb.append(" ip: ").append(toIndentedString(ip)).append("\n"); + sb.append(" location: ").append(toIndentedString(location)).append("\n"); + sb.append(" userAgent: ").append(toIndentedString(userAgent)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/DeviceContextLocation.java b/src/main/java/io/castle/client/model/generated/DeviceContextLocation.java new file mode 100644 index 0000000..a79158c --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/DeviceContextLocation.java @@ -0,0 +1,211 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Location of matched device. + */ +@ApiModel(description = "Location of matched device.") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class DeviceContextLocation { + public static final String SERIALIZED_NAME_COUNTRY_CODE = "country_code"; + @SerializedName(SERIALIZED_NAME_COUNTRY_CODE) + private String countryCode; + + public static final String SERIALIZED_NAME_COUNTRY = "country"; + @SerializedName(SERIALIZED_NAME_COUNTRY) + private String country; + + public static final String SERIALIZED_NAME_REGION = "region"; + @SerializedName(SERIALIZED_NAME_REGION) + private String region; + + public static final String SERIALIZED_NAME_REGION_CODE = "region_code"; + @SerializedName(SERIALIZED_NAME_REGION_CODE) + private String regionCode; + + public static final String SERIALIZED_NAME_CITY = "city"; + @SerializedName(SERIALIZED_NAME_CITY) + private String city; + + public static final String SERIALIZED_NAME_LAT = "lat"; + @SerializedName(SERIALIZED_NAME_LAT) + private BigDecimal lat; + + public static final String SERIALIZED_NAME_LON = "lon"; + @SerializedName(SERIALIZED_NAME_LON) + private BigDecimal lon; + + + /** + * Get countryCode + * @return countryCode + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "US", required = true, value = "") + + public String getCountryCode() { + return countryCode; + } + + + + + /** + * Get country + * @return country + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "United States", required = true, value = "") + + public String getCountry() { + return country; + } + + + + + /** + * Get region + * @return region + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "California", required = true, value = "") + + public String getRegion() { + return region; + } + + + + + /** + * Get regionCode + * @return regionCode + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "CA", required = true, value = "") + + public String getRegionCode() { + return regionCode; + } + + + + + /** + * Get city + * @return city + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "San Francisco", required = true, value = "") + + public String getCity() { + return city; + } + + + + + /** + * Get lat + * @return lat + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "37.7749", required = true, value = "") + + public BigDecimal getLat() { + return lat; + } + + + + + /** + * Get lon + * @return lon + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "122.4194", required = true, value = "") + + public BigDecimal getLon() { + return lon; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeviceContextLocation deviceContextLocation = (DeviceContextLocation) o; + return Objects.equals(this.countryCode, deviceContextLocation.countryCode) && + Objects.equals(this.country, deviceContextLocation.country) && + Objects.equals(this.region, deviceContextLocation.region) && + Objects.equals(this.regionCode, deviceContextLocation.regionCode) && + Objects.equals(this.city, deviceContextLocation.city) && + Objects.equals(this.lat, deviceContextLocation.lat) && + Objects.equals(this.lon, deviceContextLocation.lon); + } + + @Override + public int hashCode() { + return Objects.hash(countryCode, country, region, regionCode, city, lat, lon); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeviceContextLocation {\n"); + sb.append(" countryCode: ").append(toIndentedString(countryCode)).append("\n"); + sb.append(" country: ").append(toIndentedString(country)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" regionCode: ").append(toIndentedString(regionCode)).append("\n"); + sb.append(" city: ").append(toIndentedString(city)).append("\n"); + sb.append(" lat: ").append(toIndentedString(lat)).append("\n"); + sb.append(" lon: ").append(toIndentedString(lon)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/DeviceContextUserAgent.java b/src/main/java/io/castle/client/model/generated/DeviceContextUserAgent.java new file mode 100644 index 0000000..bdbb802 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/DeviceContextUserAgent.java @@ -0,0 +1,229 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * DeviceContextUserAgent + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class DeviceContextUserAgent { + public static final String SERIALIZED_NAME_RAW = "raw"; + @SerializedName(SERIALIZED_NAME_RAW) + private String raw; + + public static final String SERIALIZED_NAME_BROWSER = "browser"; + @SerializedName(SERIALIZED_NAME_BROWSER) + private String browser; + + public static final String SERIALIZED_NAME_VERSION = "version"; + @SerializedName(SERIALIZED_NAME_VERSION) + private String version; + + public static final String SERIALIZED_NAME_OS = "os"; + @SerializedName(SERIALIZED_NAME_OS) + private String os; + + public static final String SERIALIZED_NAME_MOBILE = "mobile"; + @SerializedName(SERIALIZED_NAME_MOBILE) + private Boolean mobile; + + public static final String SERIALIZED_NAME_PLATFORM = "platform"; + @SerializedName(SERIALIZED_NAME_PLATFORM) + private String platform; + + public static final String SERIALIZED_NAME_DEVICE = "device"; + @SerializedName(SERIALIZED_NAME_DEVICE) + private String device; + + public static final String SERIALIZED_NAME_FAMILY = "family"; + @SerializedName(SERIALIZED_NAME_FAMILY) + private String family; + + + /** + * Get raw + * @return raw + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36", required = true, value = "") + + public String getRaw() { + return raw; + } + + + + + /** + * Get browser + * @return browser + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "Chrome", required = true, value = "") + + public String getBrowser() { + return browser; + } + + + + + /** + * Get version + * @return version + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "92.0.4515", required = true, value = "") + + public String getVersion() { + return version; + } + + + + + /** + * Get os + * @return os + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "Mac OS X 10.15.7", required = true, value = "") + + public String getOs() { + return os; + } + + + + + /** + * Get mobile + * @return mobile + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "false", required = true, value = "") + + public Boolean getMobile() { + return mobile; + } + + + + + /** + * Get platform + * @return platform + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "Mac OS X", required = true, value = "") + + public String getPlatform() { + return platform; + } + + + + + /** + * Get device + * @return device + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "Mac", required = true, value = "") + + public String getDevice() { + return device; + } + + + + + /** + * Get family + * @return family + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "Chrome", required = true, value = "") + + public String getFamily() { + return family; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeviceContextUserAgent deviceContextUserAgent = (DeviceContextUserAgent) o; + return Objects.equals(this.raw, deviceContextUserAgent.raw) && + Objects.equals(this.browser, deviceContextUserAgent.browser) && + Objects.equals(this.version, deviceContextUserAgent.version) && + Objects.equals(this.os, deviceContextUserAgent.os) && + Objects.equals(this.mobile, deviceContextUserAgent.mobile) && + Objects.equals(this.platform, deviceContextUserAgent.platform) && + Objects.equals(this.device, deviceContextUserAgent.device) && + Objects.equals(this.family, deviceContextUserAgent.family); + } + + @Override + public int hashCode() { + return Objects.hash(raw, browser, version, os, mobile, platform, device, family); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeviceContextUserAgent {\n"); + sb.append(" raw: ").append(toIndentedString(raw)).append("\n"); + sb.append(" browser: ").append(toIndentedString(browser)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" os: ").append(toIndentedString(os)).append("\n"); + sb.append(" mobile: ").append(toIndentedString(mobile)).append("\n"); + sb.append(" platform: ").append(toIndentedString(platform)).append("\n"); + sb.append(" device: ").append(toIndentedString(device)).append("\n"); + sb.append(" family: ").append(toIndentedString(family)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Devices.java b/src/main/java/io/castle/client/model/generated/Devices.java new file mode 100644 index 0000000..6880269 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Devices.java @@ -0,0 +1,113 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import io.castle.client.model.generated.Device; + +/** + * Devices + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Devices { + public static final String SERIALIZED_NAME_TOTAL_COUNT = "total_count"; + @SerializedName(SERIALIZED_NAME_TOTAL_COUNT) + private Integer totalCount; + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + private List data = new ArrayList(); + + + /** + * The total number of devices + * minimum: 0 + * @return totalCount + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "The total number of devices") + + public Integer getTotalCount() { + return totalCount; + } + + + + + /** + * Get data + * @return data + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public List getData() { + return data; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Devices devices = (Devices) o; + return Objects.equals(this.totalCount, devices.totalCount) && + Objects.equals(this.data, devices.data); + } + + @Override + public int hashCode() { + return Objects.hash(totalCount, data); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Devices {\n"); + sb.append(" totalCount: ").append(toIndentedString(totalCount)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Filter.java b/src/main/java/io/castle/client/model/generated/Filter.java new file mode 100644 index 0000000..3b9bfeb --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Filter.java @@ -0,0 +1,469 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.threeten.bp.OffsetDateTime; + +/** + * Filter + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Filter { + public static final String SERIALIZED_NAME_CONTEXT = "context"; + @SerializedName(SERIALIZED_NAME_CONTEXT) + private Context context; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private Map> properties = null; + + public static final String SERIALIZED_NAME_PRODUCT = "product"; + @SerializedName(SERIALIZED_NAME_PRODUCT) + private Product product; + + public static final String SERIALIZED_NAME_CREATED_AT = "created_at"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_REQUEST_TOKEN = "request_token"; + @SerializedName(SERIALIZED_NAME_REQUEST_TOKEN) + private String requestToken; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private User user; + + /** + * Gets or Sets type + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + + REGISTRATION("$registration"), + LOGIN("$login"), + PASSWORD_RESET_REQUEST("$password_reset_request"), + CUSTOM("$custom"), + CHALLENGE("$challenge"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type = TypeEnum.CHALLENGE; + + /** + * Gets or Sets status + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + REQUESTED("$requested"), + + SUCCEEDED("$succeeded"), + + FAILED("$failed"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public static final String SERIALIZED_NAME_AUTHENTICATION_METHOD = "authentication_method"; + @SerializedName(SERIALIZED_NAME_AUTHENTICATION_METHOD) + private AuthenticationMethod authenticationMethod; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + + public Filter context(Context context) { + + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Context getContext() { + return context; + } + + + public void setContext(Context context) { + this.context = context; + } + + + public Filter properties(Map> properties) { + + this.properties = properties; + return this; + } + + public Filter putPropertiesItem(String key, Map propertiesItem) { + if (this.properties == null) { + this.properties = new HashMap>(); + } + this.properties.put(key, propertiesItem); + return this; + } + + /** + * User defined properties associated with this device + * @return properties + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "User defined properties associated with this device") + + public Map> getProperties() { + return properties; + } + + + public void setProperties(Map> properties) { + this.properties = properties; + } + + + public Filter product(Product product) { + + this.product = product; + return this; + } + + /** + * Get product + * @return product + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Product getProduct() { + return product; + } + + + public void setProduct(Product product) { + this.product = product; + } + + + public Filter createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * The default value is the time of which the event was received by Castle. If you’re passing events in a delayed fashion, such as via an event queue, you should make sure to set this field to the time of which the event was tracked and put into the queue. + * @return createdAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "2021-09-27T16:46:38.313Z", value = "The default value is the time of which the event was received by Castle. If you’re passing events in a delayed fashion, such as via an event queue, you should make sure to set this field to the time of which the event was tracked and put into the queue.") + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + public Filter requestToken(String requestToken) { + + this.requestToken = requestToken; + return this; + } + + /** + * Token generated from a client. Check out our [quick start guide](/v1/getting-started) to generate a `request_token` + * @return requestToken + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "test_lZWva9rsNe3u0_EIc6R8V3t5beV38piPAQbhgREGygYCAo2FRSv1tAQ4-cb6ArKHOWK_zG18hO1uZ8K0LDbNqU9njuhscoLyaj3NyGxyiO0iS4ziIkm-oVom3LEsN9i6InSbuzo-w7ErJqrkYW2CrjA23LEyN92wIkCE82dggvktPtWvMmrl42Bj2uM7Zdn2AQGXC6qGTIECRlwaAgZcgcAGeX4", required = true, value = "Token generated from a client. Check out our [quick start guide](/v1/getting-started) to generate a `request_token` ") + + public String getRequestToken() { + return requestToken; + } + + + public void setRequestToken(String requestToken) { + this.requestToken = requestToken; + } + + + public Filter user(User user) { + + this.user = user; + return this; + } + + /** + * Get user + * @return user + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public User getUser() { + return user; + } + + + public void setUser(User user) { + this.user = user; + } + + + public Filter type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public Filter status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public StatusEnum getStatus() { + return status; + } + + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + public Filter authenticationMethod(AuthenticationMethod authenticationMethod) { + + this.authenticationMethod = authenticationMethod; + return this; + } + + /** + * Get authenticationMethod + * @return authenticationMethod + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public AuthenticationMethod getAuthenticationMethod() { + return authenticationMethod; + } + + + public void setAuthenticationMethod(AuthenticationMethod authenticationMethod) { + this.authenticationMethod = authenticationMethod; + } + + + public Filter name(String name) { + + this.name = name; + return this; + } + + /** + * Your custom name of the event. + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Your custom name of the event.") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Filter filter = (Filter) o; + return Objects.equals(this.context, filter.context) && + Objects.equals(this.properties, filter.properties) && + Objects.equals(this.product, filter.product) && + Objects.equals(this.createdAt, filter.createdAt) && + Objects.equals(this.requestToken, filter.requestToken) && + Objects.equals(this.user, filter.user) && + Objects.equals(this.type, filter.type) && + Objects.equals(this.status, filter.status) && + Objects.equals(this.authenticationMethod, filter.authenticationMethod) && + Objects.equals(this.name, filter.name); + } + + @Override + public int hashCode() { + return Objects.hash(context, properties, product, createdAt, requestToken, user, type, status, authenticationMethod, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Filter {\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" product: ").append(toIndentedString(product)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" requestToken: ").append(toIndentedString(requestToken)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" authenticationMethod: ").append(toIndentedString(authenticationMethod)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/FilterResponse.java b/src/main/java/io/castle/client/model/generated/FilterResponse.java new file mode 100644 index 0000000..efac34e --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/FilterResponse.java @@ -0,0 +1,145 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import io.castle.client.model.generated.Policy; + +/** + * FilterResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class FilterResponse { + public static final String SERIALIZED_NAME_RISK = "risk"; + @SerializedName(SERIALIZED_NAME_RISK) + private double risk; + + public static final String SERIALIZED_NAME_POLICY = "policy"; + @SerializedName(SERIALIZED_NAME_POLICY) + private Policy policy; + + public static final String SERIALIZED_NAME_SIGNALS = "signals"; + @SerializedName(SERIALIZED_NAME_SIGNALS) + private Map signals = new HashMap(); + + + /** + * Calculated Risk. + * minimum: 0 + * maximum: 1 + * @return risk + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "0.65", required = true, value = "Calculated Risk.") + + public double getRisk() { + return risk; + } + + + + + public FilterResponse policy(Policy policy) { + + this.policy = policy; + return this; + } + + /** + * Get policy + * @return policy + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Policy getPolicy() { + return policy; + } + + + public void setPolicy(Policy policy) { + this.policy = policy; + } + + + /** + * Signals triggered for this event/context + * @return signals + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "{\"bot_behavior\":{},\"proxy_ip\":{},\"disposable_email\":{},\"spoofed_device\":{},\"multiple_accounts_per_device\":{}}", required = true, value = "Signals triggered for this event/context") + + public Map getSignals() { + return signals; + } + + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FilterResponse filterResponse = (FilterResponse) o; + return Objects.equals(this.risk, filterResponse.risk) && + Objects.equals(this.policy, filterResponse.policy) && + Objects.equals(this.signals, filterResponse.signals); + } + + @Override + public int hashCode() { + return Objects.hash(risk, policy, signals); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FilterResponse {\n"); + sb.append(" risk: ").append(toIndentedString(risk)).append("\n"); + sb.append(" policy: ").append(toIndentedString(policy)).append("\n"); + sb.append(" signals: ").append(toIndentedString(signals)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Log.java b/src/main/java/io/castle/client/model/generated/Log.java new file mode 100644 index 0000000..9e675bb --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Log.java @@ -0,0 +1,488 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.*; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.openapitools.jackson.nullable.JsonNullable; +import org.threeten.bp.OffsetDateTime; + +/** + * Log + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Log { + public static final String SERIALIZED_NAME_CONTEXT = "context"; + @SerializedName(SERIALIZED_NAME_CONTEXT) + private Context context; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private Map> properties = null; + + public static final String SERIALIZED_NAME_PRODUCT = "product"; + @SerializedName(SERIALIZED_NAME_PRODUCT) + private Product product; + + public static final String SERIALIZED_NAME_CREATED_AT = "created_at"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private User user; + + /** + * Castle supported events available for this endpoint + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + CHALLENGE("$challenge"), + CUSTOM("$custom"), + LOGIN("$login"), + PASSWORD_RESET_REQUEST("$password_reset_request"), + PROFILE_RESET("$profile_reset"), + PROFILE_UPDATE("$profile_update"), + REGISTRATION("$registration"), + LOGOUT("$logout"), + TRANSACTION("$transaction"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + /** + * Gets or Sets status + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + ATTEMPTED("$attempted"), + + SUCCEEDED("$succeeded"), + + FAILED("$failed"), + + REQUESTED("$requested"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status; + + public static final String SERIALIZED_NAME_AUTHENTICATION_METHOD = "authentication_method"; + @SerializedName(SERIALIZED_NAME_AUTHENTICATION_METHOD) + private AuthenticationMethod authenticationMethod; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_TRANSACTION = "transaction"; + @SerializedName(SERIALIZED_NAME_TRANSACTION) + private Transaction transaction; + + + public Log context(Context context) { + + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Context getContext() { + return context; + } + + + public void setContext(Context context) { + this.context = context; + } + + + public Log properties(Map> properties) { + + this.properties = properties; + return this; + } + + public Log putPropertiesItem(String key, Map propertiesItem) { + if (this.properties == null) { + this.properties = new HashMap>(); + } + this.properties.put(key, propertiesItem); + return this; + } + + /** + * User defined properties associated with this device + * @return properties + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "User defined properties associated with this device") + + public Map> getProperties() { + return properties; + } + + + public void setProperties(Map> properties) { + this.properties = properties; + } + + + public Log product(Product product) { + + this.product = product; + return this; + } + + /** + * Get product + * @return product + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Product getProduct() { + return product; + } + + + public void setProduct(Product product) { + this.product = product; + } + + + public Log createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * The ISO8601 timestamp for event creation + * @return createdAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The ISO8601 timestamp for event creation") + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + public Log user(User user) { + + this.user = user; + return this; + } + + /** + * Get user + * @return user + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "{\"id\":\"78184d37-a8a0-4f61-a05a-9a8ed85b1e43\"}", value = "") + + public User getUser() { + return user; + } + + + public void setUser(User user) { + this.user = user; + } + + + public Log type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Castle supported events available for this endpoint + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Castle supported events available for this endpoint") + + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public Log status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public StatusEnum getStatus() { + return status; + } + + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + public Log authenticationMethod(AuthenticationMethod authenticationMethod) { + + this.authenticationMethod = authenticationMethod; + return this; + } + + /** + * Get authenticationMethod + * @return authenticationMethod + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public AuthenticationMethod getAuthenticationMethod() { + return authenticationMethod; + } + + + public void setAuthenticationMethod(AuthenticationMethod authenticationMethod) { + this.authenticationMethod = authenticationMethod; + } + + + public Log name(String name) { + + this.name = name; + return this; + } + + /** + * Your custom name of the event. + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Your custom name of the event.") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public Log transaction(Transaction transaction) { + + this.transaction = transaction; + return this; + } + + /** + * Get transaction + * @return transaction + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Transaction getTransaction() { + return transaction; + } + + + public void setTransaction(Transaction transaction) { + this.transaction = transaction; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Log log = (Log) o; + return Objects.equals(this.context, log.context) && + Objects.equals(this.properties, log.properties) && + Objects.equals(this.product, log.product) && + Objects.equals(this.createdAt, log.createdAt) && + Objects.equals(this.user, log.user) && + Objects.equals(this.type, log.type) && + Objects.equals(this.status, log.status) && + Objects.equals(this.authenticationMethod, log.authenticationMethod) && + Objects.equals(this.name, log.name) && + Objects.equals(this.transaction, log.transaction); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(context, properties, product, createdAt, user, type, status, authenticationMethod, name, transaction); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() + ? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get())) + : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Log {\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" product: ").append(toIndentedString(product)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" authenticationMethod: ").append(toIndentedString(authenticationMethod)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" transaction: ").append(toIndentedString(transaction)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/PaymentMethod.java b/src/main/java/io/castle/client/model/generated/PaymentMethod.java new file mode 100644 index 0000000..7e9c7ca --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/PaymentMethod.java @@ -0,0 +1,353 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import io.castle.client.model.generated.Address; +import io.castle.client.model.generated.PaymentMethodCard; + +/** + * PaymentMethod + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class PaymentMethod { + /** + * Gets or Sets type + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + ABA("$aba"), + + ACH("$ach"), + + AMAZON_PAY("$amazon_pay"), + + ANDROID_PAY("$android_pay"), + + APPLE_PAY("$apple_pay"), + + BLINC("$blinc"), + + BOLETO("$boleto"), + + CARD("$card"), + + CRYPTO_WALLET("$crypto_wallet"), + + FPS("$fps"), + + GOOGLE_PAY("$google_pay"), + + OTHER("$other"), + + PAYPAL("$paypal"), + + SAMSUNG_PAY("$samsung_pay"), + + SEN("$sen"), + + SEPA("$sepa"), + + SIGNET("$signet"), + + WIRE("$wire"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_FINGERPRINT = "fingerprint"; + @SerializedName(SERIALIZED_NAME_FINGERPRINT) + private String fingerprint; + + public static final String SERIALIZED_NAME_HOLDER_NAME = "holder_name"; + @SerializedName(SERIALIZED_NAME_HOLDER_NAME) + private String holderName; + + public static final String SERIALIZED_NAME_BANK_NAME = "bank_name"; + @SerializedName(SERIALIZED_NAME_BANK_NAME) + private String bankName; + + public static final String SERIALIZED_NAME_COUNTRY_CODE = "country_code"; + @SerializedName(SERIALIZED_NAME_COUNTRY_CODE) + private String countryCode; + + public static final String SERIALIZED_NAME_BILLING_ADDRESS = "billing_address"; + @SerializedName(SERIALIZED_NAME_BILLING_ADDRESS) + private Address billingAddress; + + public static final String SERIALIZED_NAME_CARD = "card"; + @SerializedName(SERIALIZED_NAME_CARD) + private PaymentMethodCard card; + + + public PaymentMethod type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public PaymentMethod fingerprint(String fingerprint) { + + this.fingerprint = fingerprint; + return this; + } + + /** + * Get fingerprint + * @return fingerprint + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getFingerprint() { + return fingerprint; + } + + + public void setFingerprint(String fingerprint) { + this.fingerprint = fingerprint; + } + + + public PaymentMethod holderName(String holderName) { + + this.holderName = holderName; + return this; + } + + /** + * Get holderName + * @return holderName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getHolderName() { + return holderName; + } + + + public void setHolderName(String holderName) { + this.holderName = holderName; + } + + + public PaymentMethod bankName(String bankName) { + + this.bankName = bankName; + return this; + } + + /** + * Get bankName + * @return bankName + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getBankName() { + return bankName; + } + + + public void setBankName(String bankName) { + this.bankName = bankName; + } + + + public PaymentMethod countryCode(String countryCode) { + + this.countryCode = countryCode; + return this; + } + + /** + * Get countryCode + * @return countryCode + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getCountryCode() { + return countryCode; + } + + + public void setCountryCode(String countryCode) { + this.countryCode = countryCode; + } + + + public PaymentMethod billingAddress(Address billingAddress) { + + this.billingAddress = billingAddress; + return this; + } + + /** + * Get billingAddress + * @return billingAddress + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Address getBillingAddress() { + return billingAddress; + } + + + public void setBillingAddress(Address billingAddress) { + this.billingAddress = billingAddress; + } + + + public PaymentMethod card(PaymentMethodCard card) { + + this.card = card; + return this; + } + + /** + * Get card + * @return card + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public PaymentMethodCard getCard() { + return card; + } + + + public void setCard(PaymentMethodCard card) { + this.card = card; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PaymentMethod paymentMethod = (PaymentMethod) o; + return Objects.equals(this.type, paymentMethod.type) && + Objects.equals(this.fingerprint, paymentMethod.fingerprint) && + Objects.equals(this.holderName, paymentMethod.holderName) && + Objects.equals(this.bankName, paymentMethod.bankName) && + Objects.equals(this.countryCode, paymentMethod.countryCode) && + Objects.equals(this.billingAddress, paymentMethod.billingAddress) && + Objects.equals(this.card, paymentMethod.card); + } + + @Override + public int hashCode() { + return Objects.hash(type, fingerprint, holderName, bankName, countryCode, billingAddress, card); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PaymentMethod {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" fingerprint: ").append(toIndentedString(fingerprint)).append("\n"); + sb.append(" holderName: ").append(toIndentedString(holderName)).append("\n"); + sb.append(" bankName: ").append(toIndentedString(bankName)).append("\n"); + sb.append(" countryCode: ").append(toIndentedString(countryCode)).append("\n"); + sb.append(" billingAddress: ").append(toIndentedString(billingAddress)).append("\n"); + sb.append(" card: ").append(toIndentedString(card)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/PaymentMethodCard.java b/src/main/java/io/castle/client/model/generated/PaymentMethodCard.java new file mode 100644 index 0000000..d6c282a --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/PaymentMethodCard.java @@ -0,0 +1,361 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * PaymentMethodCard + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class PaymentMethodCard { + public static final String SERIALIZED_NAME_BIN = "bin"; + @SerializedName(SERIALIZED_NAME_BIN) + private String bin; + + public static final String SERIALIZED_NAME_LAST4 = "last4"; + @SerializedName(SERIALIZED_NAME_LAST4) + private String last4; + + public static final String SERIALIZED_NAME_EXP_MONTH = "exp_month"; + @SerializedName(SERIALIZED_NAME_EXP_MONTH) + private Integer expMonth; + + public static final String SERIALIZED_NAME_EXP_YEAR = "exp_year"; + @SerializedName(SERIALIZED_NAME_EXP_YEAR) + private Integer expYear; + + /** + * Gets or Sets network + */ + @JsonAdapter(NetworkEnum.Adapter.class) + public enum NetworkEnum { + AMEX("$amex"), + + CARTES_BANCAIRES("$cartes_bancaires"), + + DINERS("$diners"), + + DISCOVER("$discover"), + + INTERAC("$interac"), + + JCB("$jcb"), + + MASTERCARD("$mastercard"), + + OTHER("$other"), + + UNIONPAY("$unionpay"), + + VISA("$visa"); + + private String value; + + NetworkEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static NetworkEnum fromValue(String value) { + for (NetworkEnum b : NetworkEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final NetworkEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public NetworkEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return NetworkEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_NETWORK = "network"; + @SerializedName(SERIALIZED_NAME_NETWORK) + private NetworkEnum network; + + /** + * Gets or Sets funding + */ + @JsonAdapter(FundingEnum.Adapter.class) + public enum FundingEnum { + CREDIT("$credit"), + + DEBIT("$debit"), + + OTHER("$other"), + + PREPAID("$prepaid"); + + private String value; + + FundingEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static FundingEnum fromValue(String value) { + for (FundingEnum b : FundingEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final FundingEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public FundingEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return FundingEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_FUNDING = "funding"; + @SerializedName(SERIALIZED_NAME_FUNDING) + private FundingEnum funding; + + + public PaymentMethodCard bin(String bin) { + + this.bin = bin; + return this; + } + + /** + * Get bin + * @return bin + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getBin() { + return bin; + } + + + public void setBin(String bin) { + this.bin = bin; + } + + + public PaymentMethodCard last4(String last4) { + + this.last4 = last4; + return this; + } + + /** + * Get last4 + * @return last4 + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getLast4() { + return last4; + } + + + public void setLast4(String last4) { + this.last4 = last4; + } + + + public PaymentMethodCard expMonth(Integer expMonth) { + + this.expMonth = expMonth; + return this; + } + + /** + * Get expMonth + * minimum: 1 + * maximum: 12 + * @return expMonth + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Integer getExpMonth() { + return expMonth; + } + + + public void setExpMonth(Integer expMonth) { + this.expMonth = expMonth; + } + + + public PaymentMethodCard expYear(Integer expYear) { + + this.expYear = expYear; + return this; + } + + /** + * Get expYear + * minimum: 2000 + * maximum: 2100 + * @return expYear + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Integer getExpYear() { + return expYear; + } + + + public void setExpYear(Integer expYear) { + this.expYear = expYear; + } + + + public PaymentMethodCard network(NetworkEnum network) { + + this.network = network; + return this; + } + + /** + * Get network + * @return network + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public NetworkEnum getNetwork() { + return network; + } + + + public void setNetwork(NetworkEnum network) { + this.network = network; + } + + + public PaymentMethodCard funding(FundingEnum funding) { + + this.funding = funding; + return this; + } + + /** + * Get funding + * @return funding + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public FundingEnum getFunding() { + return funding; + } + + + public void setFunding(FundingEnum funding) { + this.funding = funding; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PaymentMethodCard paymentMethodCard = (PaymentMethodCard) o; + return Objects.equals(this.bin, paymentMethodCard.bin) && + Objects.equals(this.last4, paymentMethodCard.last4) && + Objects.equals(this.expMonth, paymentMethodCard.expMonth) && + Objects.equals(this.expYear, paymentMethodCard.expYear) && + Objects.equals(this.network, paymentMethodCard.network) && + Objects.equals(this.funding, paymentMethodCard.funding); + } + + @Override + public int hashCode() { + return Objects.hash(bin, last4, expMonth, expYear, network, funding); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PaymentMethodCard {\n"); + sb.append(" bin: ").append(toIndentedString(bin)).append("\n"); + sb.append(" last4: ").append(toIndentedString(last4)).append("\n"); + sb.append(" expMonth: ").append(toIndentedString(expMonth)).append("\n"); + sb.append(" expYear: ").append(toIndentedString(expYear)).append("\n"); + sb.append(" network: ").append(toIndentedString(network)).append("\n"); + sb.append(" funding: ").append(toIndentedString(funding)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Policy.java b/src/main/java/io/castle/client/model/generated/Policy.java new file mode 100644 index 0000000..ddcdd8b --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Policy.java @@ -0,0 +1,235 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * The matching policy + */ +@ApiModel(description = "The matching policy") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Policy { + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_REVISION_ID = "revision_id"; + @SerializedName(SERIALIZED_NAME_REVISION_ID) + private String revisionId; + + /** + * Gets or Sets action + */ + @JsonAdapter(ActionEnum.Adapter.class) + public enum ActionEnum { + ALLOW("allow"), + + CHALLENGE("challenge"), + + DENY("deny"); + + private String value; + + ActionEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ActionEnum fromValue(String value) { + for (ActionEnum b : ActionEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return null; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ActionEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ActionEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ActionEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ACTION = "action"; + @SerializedName(SERIALIZED_NAME_ACTION) + private ActionEnum action; + + + public Policy name(String name) { + + this.name = name; + return this; + } + + /** + * Name of the matching policy + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "Challenge risk >= 60", required = true, value = "Name of the matching policy") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public Policy id(String id) { + + this.id = id; + return this; + } + + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "2ee938c8-24c2-4c26-9d25-19511dd75029", required = true, value = "") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public Policy revisionId(String revisionId) { + + this.revisionId = revisionId; + return this; + } + + /** + * Get revisionId + * @return revisionId + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "900b183a-9f6d-4579-8c47-9ddcccf637b4", required = true, value = "") + + public String getRevisionId() { + return revisionId; + } + + + public void setRevisionId(String revisionId) { + this.revisionId = revisionId; + } + + + public Policy action(ActionEnum action) { + + this.action = action; + return this; + } + + /** + * Get action + * @return action + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "challenge", required = true, value = "") + + public ActionEnum getAction() { + return action; + } + + + public void setAction(ActionEnum action) { + this.action = action; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Policy policy = (Policy) o; + return Objects.equals(this.name, policy.name) && + Objects.equals(this.id, policy.id) && + Objects.equals(this.revisionId, policy.revisionId) && + Objects.equals(this.action, policy.action); + } + + @Override + public int hashCode() { + return Objects.hash(name, id, revisionId, action); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Policy {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" revisionId: ").append(toIndentedString(revisionId)).append("\n"); + sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Product.java b/src/main/java/io/castle/client/model/generated/Product.java new file mode 100644 index 0000000..e9428b1 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Product.java @@ -0,0 +1,98 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * Product + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Product { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + + public Product id(String id) { + + this.id = id; + return this; + } + + /** + * If you have multiple products that your users can log into using the same credentials, populate this field so that you can segment the data in the dashboard by product. + * @return id + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "If you have multiple products that your users can log into using the same credentials, populate this field so that you can segment the data in the dashboard by product.") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Product product = (Product) o; + return Objects.equals(this.id, product.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Product {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Risk.java b/src/main/java/io/castle/client/model/generated/Risk.java new file mode 100644 index 0000000..f2f1772 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Risk.java @@ -0,0 +1,530 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; +import org.threeten.bp.OffsetDateTime; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Risk + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Risk { + public static final String SERIALIZED_NAME_CONTEXT = "context"; + @SerializedName(SERIALIZED_NAME_CONTEXT) + private Context context; + + public static final String SERIALIZED_NAME_PROPERTIES = "properties"; + @SerializedName(SERIALIZED_NAME_PROPERTIES) + private Map> properties = null; + + public static final String SERIALIZED_NAME_PRODUCT = "product"; + @SerializedName(SERIALIZED_NAME_PRODUCT) + private Product product; + + public static final String SERIALIZED_NAME_CREATED_AT = "created_at"; + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_REQUEST_TOKEN = "request_token"; + @SerializedName(SERIALIZED_NAME_REQUEST_TOKEN) + private String requestToken; + + public static final String SERIALIZED_NAME_USER = "user"; + @SerializedName(SERIALIZED_NAME_USER) + private User user; + + /** + * Gets or Sets type + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + CHALLENGE("$challenge"), + REGISTRATION("$registration"), + LOGIN("$login"), + PROFILE_UPDATE("$profile_update"), + PROFILE_RESET("$profile_reset"), + TRANSACTION("$transaction"), + LOGOUT("$logout"), + CUSTOM("$custom"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type = TypeEnum.CUSTOM; + + /** + * Gets or Sets status + */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + ATTEMPTED("$attempted"), + + SUCCEEDED("$succeeded"), + + FAILED("$failed"), + + REQUESTED("$requested"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + private StatusEnum status = StatusEnum.SUCCEEDED; + + public static final String SERIALIZED_NAME_AUTHENTICATION_METHOD = "authentication_method"; + @SerializedName(SERIALIZED_NAME_AUTHENTICATION_METHOD) + private AuthenticationMethod authenticationMethod; + + public static final String SERIALIZED_NAME_CHANGESET = "changeset"; + @SerializedName(SERIALIZED_NAME_CHANGESET) + private Changeset changeset; + + public static final String SERIALIZED_NAME_TRANSACTION = "transaction"; + @SerializedName(SERIALIZED_NAME_TRANSACTION) + private Transaction transaction; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + + public Risk context(Context context) { + + this.context = context; + return this; + } + + /** + * Get context + * @return context + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Context getContext() { + return context; + } + + + public void setContext(Context context) { + this.context = context; + } + + + public Risk properties(Map> properties) { + + this.properties = properties; + return this; + } + + public Risk putPropertiesItem(String key, Map propertiesItem) { + if (this.properties == null) { + this.properties = new HashMap>(); + } + this.properties.put(key, propertiesItem); + return this; + } + + /** + * User defined properties associated with this device + * @return properties + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "User defined properties associated with this device") + + public Map> getProperties() { + return properties; + } + + + public void setProperties(Map> properties) { + this.properties = properties; + } + + + public Risk product(Product product) { + + this.product = product; + return this; + } + + /** + * Get product + * @return product + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Product getProduct() { + return product; + } + + + public void setProduct(Product product) { + this.product = product; + } + + + public Risk createdAt(OffsetDateTime createdAt) { + + this.createdAt = createdAt; + return this; + } + + /** + * The default value is the time of which the event was received by Castle. If you’re passing events in a delayed fashion, such as via an event queue, you should make sure to set this field to the time of which the event was tracked and put into the queue. + * @return createdAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(example = "2021-09-27T16:46:38.313Z", value = "The default value is the time of which the event was received by Castle. If you’re passing events in a delayed fashion, such as via an event queue, you should make sure to set this field to the time of which the event was tracked and put into the queue.") + + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + + public Risk requestToken(String requestToken) { + + this.requestToken = requestToken; + return this; + } + + /** + * Token generated from a client. Check out our [quick start guide](/v1/getting-started) to generate a `request_token` + * @return requestToken + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "test_lZWva9rsNe3u0_EIc6R8V3t5beV38piPAQbhgREGygYCAo2FRSv1tAQ4-cb6ArKHOWK_zG18hO1uZ8K0LDbNqU9njuhscoLyaj3NyGxyiO0iS4ziIkm-oVom3LEsN9i6InSbuzo-w7ErJqrkYW2CrjA23LEyN92wIkCE82dggvktPtWvMmrl42Bj2uM7Zdn2AQGXC6qGTIECRlwaAgZcgcAGeX4", required = true, value = "Token generated from a client. Check out our [quick start guide](/v1/getting-started) to generate a `request_token` ") + + public String getRequestToken() { + return requestToken; + } + + + public void setRequestToken(String requestToken) { + this.requestToken = requestToken; + } + + + public Risk user(User user) { + + this.user = user; + return this; + } + + /** + * Get user + * @return user + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public User getUser() { + return user; + } + + + public void setUser(User user) { + this.user = user; + } + + + public Risk type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public Risk status(StatusEnum status) { + + this.status = status; + return this; + } + + /** + * Get status + * @return status + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public StatusEnum getStatus() { + return status; + } + + + public void setStatus(StatusEnum status) { + this.status = status; + } + + + public Risk authenticationMethod(AuthenticationMethod authenticationMethod) { + + this.authenticationMethod = authenticationMethod; + return this; + } + + /** + * Get authenticationMethod + * @return authenticationMethod + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public AuthenticationMethod getAuthenticationMethod() { + return authenticationMethod; + } + + + public void setAuthenticationMethod(AuthenticationMethod authenticationMethod) { + this.authenticationMethod = authenticationMethod; + } + + + public Risk changeset(Changeset changeset) { + + this.changeset = changeset; + return this; + } + + /** + * Get changeset + * @return changeset + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Changeset getChangeset() { + return changeset; + } + + + public void setChangeset(Changeset changeset) { + this.changeset = changeset; + } + + + public Risk transaction(Transaction transaction) { + + this.transaction = transaction; + return this; + } + + /** + * Get transaction + * @return transaction + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Transaction getTransaction() { + return transaction; + } + + + public void setTransaction(Transaction transaction) { + this.transaction = transaction; + } + + + public Risk name(String name) { + + this.name = name; + return this; + } + + /** + * Your custom name of the event. + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Your custom name of the event.") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Risk risk = (Risk) o; + return Objects.equals(this.context, risk.context) && + Objects.equals(this.properties, risk.properties) && + Objects.equals(this.product, risk.product) && + Objects.equals(this.createdAt, risk.createdAt) && + Objects.equals(this.requestToken, risk.requestToken) && + Objects.equals(this.user, risk.user) && + Objects.equals(this.type, risk.type) && + Objects.equals(this.status, risk.status) && + Objects.equals(this.authenticationMethod, risk.authenticationMethod) && + Objects.equals(this.changeset, risk.changeset) && + Objects.equals(this.transaction, risk.transaction) && + Objects.equals(this.name, risk.name); + } + + @Override + public int hashCode() { + return Objects.hash(context, properties, product, createdAt, requestToken, user, type, status, authenticationMethod, changeset, transaction, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Risk {\n"); + sb.append(" context: ").append(toIndentedString(context)).append("\n"); + sb.append(" properties: ").append(toIndentedString(properties)).append("\n"); + sb.append(" product: ").append(toIndentedString(product)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" requestToken: ").append(toIndentedString(requestToken)).append("\n"); + sb.append(" user: ").append(toIndentedString(user)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" authenticationMethod: ").append(toIndentedString(authenticationMethod)).append("\n"); + sb.append(" changeset: ").append(toIndentedString(changeset)).append("\n"); + sb.append(" transaction: ").append(toIndentedString(transaction)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/RiskResponse.java b/src/main/java/io/castle/client/model/generated/RiskResponse.java new file mode 100644 index 0000000..dbf027f --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/RiskResponse.java @@ -0,0 +1,167 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +/** + * RiskResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class RiskResponse { + public static final String SERIALIZED_NAME_RISK = "risk"; + @SerializedName(SERIALIZED_NAME_RISK) + private double risk; + + public static final String SERIALIZED_NAME_POLICY = "policy"; + @SerializedName(SERIALIZED_NAME_POLICY) + private Policy policy; + + public static final String SERIALIZED_NAME_SIGNALS = "signals"; + @SerializedName(SERIALIZED_NAME_SIGNALS) + private Map signals = new HashMap(); + + public static final String SERIALIZED_NAME_DEVICE = "device"; + @SerializedName(SERIALIZED_NAME_DEVICE) + private Device device; + + + /** + * Calculated Risk. + * minimum: 0 + * maximum: 1 + * @return risk + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "0.65", required = true, value = "Calculated Risk.") + + public double getRisk() { + return risk; + } + + + + + public RiskResponse policy(Policy policy) { + + this.policy = policy; + return this; + } + + /** + * Get policy + * @return policy + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Policy getPolicy() { + return policy; + } + + + public void setPolicy(Policy policy) { + this.policy = policy; + } + + + /** + * Signals triggered for this event/context + * @return signals + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "{\"bot_behavior\":{},\"proxy_ip\":{},\"disposable_email\":{},\"spoofed_device\":{},\"multiple_accounts_per_device\":{}}", required = true, value = "Signals triggered for this event/context") + + public Map getSignals() { + return signals; + } + + + + + public RiskResponse device(Device device) { + + this.device = device; + return this; + } + + /** + * Get device + * @return device + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Device getDevice() { + return device; + } + + + public void setDevice(Device device) { + this.device = device; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RiskResponse riskResponse = (RiskResponse) o; + return Objects.equals(this.risk, riskResponse.risk) && + Objects.equals(this.policy, riskResponse.policy) && + Objects.equals(this.signals, riskResponse.signals) && + Objects.equals(this.device, riskResponse.device); + } + + @Override + public int hashCode() { + return Objects.hash(risk, policy, signals, device); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RiskResponse {\n"); + sb.append(" risk: ").append(toIndentedString(risk)).append("\n"); + sb.append(" policy: ").append(toIndentedString(policy)).append("\n"); + sb.append(" signals: ").append(toIndentedString(signals)).append("\n"); + sb.append(" device: ").append(toIndentedString(device)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/Transaction.java b/src/main/java/io/castle/client/model/generated/Transaction.java new file mode 100644 index 0000000..17cd6b6 --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/Transaction.java @@ -0,0 +1,239 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModelProperty; + +import java.io.IOException; +import java.util.Objects; + +/** + * Transaction + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class Transaction { + /** + * Gets or Sets type + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + PURCHASE("$purchase"), + + WITHDRAWAL("$withdrawal"), + + DEPOSIT("$deposit"), + + TRANSFER("$transfer"), + + REWARD("$reward"), + + SALE("$sale"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_AMOUNT = "amount"; + @SerializedName(SERIALIZED_NAME_AMOUNT) + private Amount amount; + + public static final String SERIALIZED_NAME_PAYMENT_METHOD = "payment_method"; + @SerializedName(SERIALIZED_NAME_PAYMENT_METHOD) + private PaymentMethod paymentMethod; + + + public Transaction type(TypeEnum type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public TypeEnum getType() { + return type; + } + + + public void setType(TypeEnum type) { + this.type = type; + } + + + public Transaction id(String id) { + + this.id = id; + return this; + } + + /** + * Unique identifier for this transaction. Use this to link the flow of your transactions with different events and types + * @return id + **/ + @javax.annotation.Nonnull + @ApiModelProperty(example = "900b183a-9f6d-4579-8c47-9ddcccf637b4", required = true, value = "Unique identifier for this transaction. Use this to link the flow of your transactions with different events and types ") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public Transaction amount(Amount amount) { + + this.amount = amount; + return this; + } + + /** + * Get amount + * @return amount + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Amount getAmount() { + return amount; + } + + + public void setAmount(Amount amount) { + this.amount = amount; + } + + + public Transaction paymentMethod(PaymentMethod paymentMethod) { + + this.paymentMethod = paymentMethod; + return this; + } + + /** + * Get paymentMethod + * @return paymentMethod + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public PaymentMethod getPaymentMethod() { + return paymentMethod; + } + + + public void setPaymentMethod(PaymentMethod paymentMethod) { + this.paymentMethod = paymentMethod; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Transaction transaction = (Transaction) o; + return Objects.equals(this.type, transaction.type) && + Objects.equals(this.id, transaction.id) && + Objects.equals(this.amount, transaction.amount) && + Objects.equals(this.paymentMethod, transaction.paymentMethod); + } + + @Override + public int hashCode() { + return Objects.hash(type, id, amount, paymentMethod); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Transaction {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" paymentMethod: ").append(toIndentedString(paymentMethod)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/main/java/io/castle/client/model/generated/User.java b/src/main/java/io/castle/client/model/generated/User.java new file mode 100644 index 0000000..329291a --- /dev/null +++ b/src/main/java/io/castle/client/model/generated/User.java @@ -0,0 +1,282 @@ +/* + * Castle API + * ## Introduction **Just getting started? Check out our [quick start guide](https://docs.castle.io/docs/quickstart)** Castle APIs uses standard HTTP response codes, authentication and verbs. JSON is used as data exchange format, both for parsing incoming request bodies, and in the returned response. This means that the `Content-Type` header should to be set to `application/json` in requests with a body, such as `POST` or `PUT`. All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Non-HTTPS calls will fail and the **TLS version needs to be 1.1 or higher**. ## Supported types For a list of supported types, see our [Types Reference](https://docs.castle.io/docs/events). ## Rate limits Our Risk, Log (and the legacy Authenticate) APIs have a per-user-id rate limit of 6 requests per second and 10 requests per 5 seconds. + * + * The version of the OpenAPI document: 1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.castle.client.model.generated; + +import java.util.Objects; +import java.util.Arrays; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import org.openapitools.jackson.nullable.JsonNullable; +import org.threeten.bp.OffsetDateTime; + +/** + * User + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2022-05-16T17:44:30.591898+02:00[Europe/Stockholm]") +public class User { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_EMAIL = "email"; + @SerializedName(SERIALIZED_NAME_EMAIL) + private String email; + + public static final String SERIALIZED_NAME_PHONE = "phone"; + @SerializedName(SERIALIZED_NAME_PHONE) + private String phone; + + public static final String SERIALIZED_NAME_REGISTERED_AT = "registered_at"; + @SerializedName(SERIALIZED_NAME_REGISTERED_AT) + private OffsetDateTime registeredAt; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_TRAITS = "traits"; + @SerializedName(SERIALIZED_NAME_TRAITS) + private Object traits; + + public static final String SERIALIZED_NAME_ADDRESS = "address"; + @SerializedName(SERIALIZED_NAME_ADDRESS) + private Address address; + + + public User id(String id) { + + this.id = id; + return this; + } + + /** + * A unique user identifier + * @return id + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "A unique user identifier") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public User email(String email) { + + this.email = email; + return this; + } + + /** + * The identified user's email address + * @return email + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The identified user's email address") + + public String getEmail() { + return email; + } + + + public void setEmail(String email) { + this.email = email; + } + + + public User phone(String phone) { + + this.phone = phone; + return this; + } + + /** + * The identified user's phone number E.164 formatted + * @return phone + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The identified user's phone number E.164 formatted") + + public String getPhone() { + return phone; + } + + + public void setPhone(String phone) { + this.phone = phone; + } + + + public User registeredAt(OffsetDateTime registeredAt) { + + this.registeredAt = registeredAt; + return this; + } + + /** + * The ISO8601 timestamp of the user's account creation + * @return registeredAt + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The ISO8601 timestamp of the user's account creation") + + public OffsetDateTime getRegisteredAt() { + return registeredAt; + } + + + public void setRegisteredAt(OffsetDateTime registeredAt) { + this.registeredAt = registeredAt; + } + + + public User name(String name) { + + this.name = name; + return this; + } + + /** + * The full name of the user + * @return name + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "The full name of the user") + + public String getName() { + return name; + } + + + public void setName(String name) { + this.name = name; + } + + + public User traits(Object traits) { + + this.traits = traits; + return this; + } + + /** + * Known traits of the identified user + * @return traits + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "Known traits of the identified user") + + public Object getTraits() { + return traits; + } + + + public void setTraits(Object traits) { + this.traits = traits; + } + + + public User address(Address address) { + + this.address = address; + return this; + } + + /** + * Get address + * @return address + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public Address getAddress() { + return address; + } + + + public void setAddress(Address address) { + this.address = address; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User User = (User) o; + return Objects.equals(this.id, User.id) && + Objects.equals(this.email, User.email) && + Objects.equals(this.phone, User.phone) && + Objects.equals(this.registeredAt, User.registeredAt) && + Objects.equals(this.name, User.name) && + Objects.equals(this.traits, User.traits) && + Objects.equals(this.address, User.address); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && a.get().getClass().isArray() ? Arrays.equals((T[])a.get(), (T[])b.get()) : Objects.equals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(id, email, phone, registeredAt, name, traits, address); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() + ? (a.get().getClass().isArray() ? Arrays.hashCode((T[])a.get()) : Objects.hashCode(a.get())) + : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" registeredAt: ").append(toIndentedString(registeredAt)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" traits: ").append(toIndentedString(traits)).append("\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/src/test/java/io/castle/client/CastleFilterHttpTest.java b/src/test/java/io/castle/client/CastleFilterHttpTest.java new file mode 100644 index 0000000..d9506e1 --- /dev/null +++ b/src/test/java/io/castle/client/CastleFilterHttpTest.java @@ -0,0 +1,96 @@ +package io.castle.client; + +import com.google.gson.JsonParser; +import io.castle.client.model.AuthenticateAction; +import io.castle.client.model.AuthenticateFailoverStrategy; +import io.castle.client.model.generated.*; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.RecordedRequest; +import org.assertj.core.api.Assertions; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.threeten.bp.OffsetDateTime; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; + +public class CastleFilterHttpTest extends AbstractCastleHttpLayerTest { + + public CastleFilterHttpTest() { + super(new AuthenticateFailoverStrategy(AuthenticateAction.CHALLENGE)); + } + + @Test public void risk() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + "\"risk\": 0.65,\n" + + "\"policy\": {\n" + + "\"name\": \"Challenge risk >= 60\",\n" + + "\"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + "\"revision_id\": \"900b183a-9f6d-4579-8c47-9ddcccf637b4\",\n" + + "\"action\": \"challenge\"\n" + + "},\n" + + "\"signals\": {\n" + + "\"bot_behavior\": { },\n" + + "\"proxy_ip\": { },\n" + + "\"disposable_email\": { },\n" + + "\"spoofed_device\": { },\n" + + "\"multiple_accounts_per_device\": { }\n" + + "}\n" + + "}"); + mockResponse.setResponseCode(201); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + Filter filter = new Filter() + .type(Filter.TypeEnum.CHALLENGE) + .status(Filter.StatusEnum.REQUESTED) + .requestToken("4-ugt5CFooaxt5KbpISi1Kurm5KTpqawlYmFs5PXsqKootPgRB3z12OpvPOWOQ9PkztagtqicAnk9Qowu7FlU9qabyi4k2QR6KUUL5p3gr-A2w8Ju8gWe0XyRi_OkmFj2oZiU9OTPAjijjIK4sA-a7f19GC_xzhYurdkWM-ZY1jR_l4R8JloVdGTfj7IhXY6_pd5SNGThjmM2DoSjWNup74xC3v-l3lI0ZMlDZPGJAyd3jsVnd5JXc6CZlmdxSQMk8UxHPyYbk7Sn24cjMQxHPqZZVvRkypP2Z1VW82eZVLYwD5jxc48Y4vCI4C1gDJWiIVMXssRDTmrPME9aeZPSc-ZelmSpX5T3p1iU9Gb1jnYmCdp7gnJ"); + + User user = new User() + .id("12345"); + filter.user(user); + + Context context = new Context() + .ip("211.96.77.55") + .addHeadersItem("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"); + filter.context(context); + + Product product = new Product() + .id("1234"); + filter.product(product); + + AuthenticationMethod authenticationMethod = new AuthenticationMethod() + .type(AuthenticationMethodType.SOCIAL) + .variant("facebook"); + filter.authenticationMethod(authenticationMethod); + + filter.putPropertiesItem("property1", new HashMap()); + filter.putPropertiesItem("property2", new HashMap()); + + filter.createdAt(OffsetDateTime.parse("2022-05-20T09:03:27.468+02:00")); + + FilterResponse response = sdk.onRequest(request).filter(filter); + + // Check response object + Assert.assertEquals(response.getRisk(), 0.65, 0); + Assert.assertEquals(response.getSignals().size(), 5); + Assert.assertEquals(response.getPolicy().getAction(), Policy.ActionEnum.CHALLENGE); + Assert.assertEquals(response.getPolicy().getId(), "2ee938c8-24c2-4c26-9d25-19511dd75029"); + Assert.assertEquals(response.getPolicy().getRevisionId(), "900b183a-9f6d-4579-8c47-9ddcccf637b4"); + Assert.assertEquals(response.getPolicy().getName(), "Challenge risk >= 60"); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve("v1/filter"), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + + String body = recordedRequest.getBody().readUtf8(); + + String expected = "{\"context\":{\"headers\":[[\"User-Agent\",\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15\"]],\"ip\":\"211.96.77.55\"},\"properties\":{\"property2\":{},\"property1\":{}},\"product\":{\"id\":\"1234\"},\"created_at\":\"2022-05-20T09:03:27.468+02:00\",\"request_token\":\"4-ugt5CFooaxt5KbpISi1Kurm5KTpqawlYmFs5PXsqKootPgRB3z12OpvPOWOQ9PkztagtqicAnk9Qowu7FlU9qabyi4k2QR6KUUL5p3gr-A2w8Ju8gWe0XyRi_OkmFj2oZiU9OTPAjijjIK4sA-a7f19GC_xzhYurdkWM-ZY1jR_l4R8JloVdGTfj7IhXY6_pd5SNGThjmM2DoSjWNup74xC3v-l3lI0ZMlDZPGJAyd3jsVnd5JXc6CZlmdxSQMk8UxHPyYbk7Sn24cjMQxHPqZZVvRkypP2Z1VW82eZVLYwD5jxc48Y4vCI4C1gDJWiIVMXssRDTmrPME9aeZPSc-ZelmSpX5T3p1iU9Gb1jnYmCdp7gnJ\",\"user\":{\"id\":\"12345\"},\"type\":\"$challenge\",\"status\":\"$requested\",\"authentication_method\":{\"type\":\"$social\",\"variant\":\"facebook\"}}"; + Assertions.assertThat(JsonParser.parseString(body)).isEqualTo(JsonParser.parseString(expected)); + } +} diff --git a/src/test/java/io/castle/client/CastleLogHttpTest.java b/src/test/java/io/castle/client/CastleLogHttpTest.java new file mode 100644 index 0000000..ef6b58e --- /dev/null +++ b/src/test/java/io/castle/client/CastleLogHttpTest.java @@ -0,0 +1,100 @@ +package io.castle.client; + +import com.google.gson.JsonParser; +import io.castle.client.model.AuthenticateAction; +import io.castle.client.model.AuthenticateFailoverStrategy; +import io.castle.client.model.CastleResponse; +import io.castle.client.model.generated.*; +import io.castle.client.utils.DeviceUtils; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.RecordedRequest; +import org.assertj.core.api.Assertions; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.threeten.bp.OffsetDateTime; + +import javax.servlet.http.HttpServletRequest; +import java.util.Arrays; +import java.util.HashMap; + +public class CastleLogHttpTest extends AbstractCastleHttpLayerTest { + + public CastleLogHttpTest() { + super(new AuthenticateFailoverStrategy(AuthenticateAction.CHALLENGE)); + } + + @Test public void log() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setResponseCode(204); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + Log log = new Log() + .type(Log.TypeEnum.TRANSACTION) + .status(Log.StatusEnum.ATTEMPTED); + + User user = new User() + .id("12345"); + log.user(user); + + Context context = new Context() + .ip("211.96.77.55") + .addHeadersItem("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"); + log.context(context); + + Product product = new Product() + .id("1234"); + log.product(product); + + log.putPropertiesItem("property1", new HashMap()); + log.putPropertiesItem("property2", new HashMap()); + + log.createdAt(OffsetDateTime.parse("2022-05-20T09:03:27.468+02:00")); + + Transaction transaction = new Transaction() + .type(Transaction.TypeEnum.PURCHASE) + .id("900b183a-9f6d-4579-8c47-9ddcccf637b4") + .amount(new Amount() + .type(Amount.TypeEnum.FIAT) + .value("100") + .currency("USD")) + .paymentMethod(new PaymentMethod() + .type(PaymentMethod.TypeEnum.ABA) + .fingerprint("string") + .holderName("string") + .bankName("string") + .countryCode("str") + .billingAddress(new Address() + .line1("60 Rausch Street") + .line2("string") + .city("San Francisco") + .countryCode("US") + .regionCode("CA") + .postalCode("94103")) + .card(new PaymentMethodCard() + .bin("123456") + .last4("1234") + .expMonth(1) + .expYear(2000) + .network(PaymentMethodCard.NetworkEnum.AMEX) + .funding(PaymentMethodCard.FundingEnum.CREDIT))); + log.transaction(transaction); + + CastleResponse response = sdk.onRequest(request).log(log); + + Assert.assertTrue(response.isSuccessful()); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve("v1/log"), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + + String body = recordedRequest.getBody().readUtf8(); + + String expected = "{\"context\":{\"headers\":[[\"User-Agent\",\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15\"]],\"ip\":\"211.96.77.55\"},\"properties\":{\"property2\":{},\"property1\":{}},\"product\":{\"id\":\"1234\"},\"created_at\":\"2022-05-20T09:03:27.468+02:00\",\"user\":{\"id\":\"12345\"},\"type\":\"$transaction\",\"status\":\"$attempted\",\"transaction\":{\"type\":\"$purchase\",\"id\":\"900b183a-9f6d-4579-8c47-9ddcccf637b4\",\"amount\":{\"type\":\"$fiat\",\"value\":\"100\",\"currency\":\"USD\"},\"payment_method\":{\"type\":\"$aba\",\"fingerprint\":\"string\",\"holder_name\":\"string\",\"bank_name\":\"string\",\"country_code\":\"str\",\"billing_address\":{\"line1\":\"60 Rausch Street\",\"line2\":\"string\",\"city\":\"San Francisco\",\"country_code\":\"US\",\"region_code\":\"CA\",\"postal_code\":\"94103\"},\"card\":{\"bin\":\"123456\",\"last4\":\"1234\",\"exp_month\":1,\"exp_year\":2000,\"network\":\"$amex\",\"funding\":\"$credit\"}}}}"; + Assertions.assertThat(JsonParser.parseString(body)).isEqualTo(JsonParser.parseString(expected)); + } +} diff --git a/src/test/java/io/castle/client/CastleRiskHttpTest.java b/src/test/java/io/castle/client/CastleRiskHttpTest.java new file mode 100644 index 0000000..63aad01 --- /dev/null +++ b/src/test/java/io/castle/client/CastleRiskHttpTest.java @@ -0,0 +1,108 @@ +package io.castle.client; + +import com.google.gson.JsonParser; +import io.castle.client.model.AuthenticateAction; +import io.castle.client.model.AuthenticateFailoverStrategy; +import io.castle.client.model.CastleResponse; +import io.castle.client.model.generated.*; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.RecordedRequest; +import org.assertj.core.api.Assertions; +import org.junit.Assert; +import org.junit.Test; +import org.springframework.mock.web.MockHttpServletRequest; +import org.threeten.bp.OffsetDateTime; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; + +public class CastleRiskHttpTest extends AbstractCastleHttpLayerTest { + + public CastleRiskHttpTest() { + super(new AuthenticateFailoverStrategy(AuthenticateAction.CHALLENGE)); + } + + @Test public void risk() throws InterruptedException { + MockResponse mockResponse = new MockResponse(); + mockResponse.setBody("{\n" + + " \"risk\": 0.65,\n" + + " \"policy\": {\n" + + " \"name\": \"Challenge risk >= 60\",\n" + + " \"id\": \"2ee938c8-24c2-4c26-9d25-19511dd75029\",\n" + + " \"revision_id\": \"900b183a-9f6d-4579-8c47-9ddcccf637b4\",\n" + + " \"action\": \"challenge\"\n" + + " },\n" + + " \"signals\": {\n" + + " \"bot_behavior\": {},\n" + + " \"proxy_ip\": {},\n" + + " \"disposable_email\": {},\n" + + " \"spoofed_device\": {},\n" + + " \"multiple_accounts_per_device\": {}\n" + + " },\n" + + " \"device\": {\n" + + " \"token\": \"eyJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6IjEzc2x6RzNHQ0RzeFJCejdJWF9SUDJkV1Y0RFgiLCJxdWFsaWZpZXIiOiJBUUlEQ2pFME5EZzFPREF3T1RZIiwiYW5vbnltb3VzIjpmYWxzZSwidmVyc2lvbiI6MC4zfQ.y3vOt-W1IpOi7Oyn1jll1uDw1YL-JPZtNMTU-PyaYhQ\"\n" + + " }\n" + + "}"); + mockResponse.setResponseCode(201); + server.enqueue(mockResponse); + + // And a mock Request + HttpServletRequest request = new MockHttpServletRequest(); + + Risk risk = new Risk().type(Risk.TypeEnum.PROFILE_UPDATE) + .status(Risk.StatusEnum.SUCCEEDED) + .requestToken("4-ugt5CFooaxt5KbpISi1Kurm5KTpqawlYmFs5PXsqKootPgRB3z12OpvPOWOQ9PkztagtqicAnk9Qowu7FlU9qabyi4k2QR6KUUL5p3gr-A2w8Ju8gWe0XyRi_OkmFj2oZiU9OTPAjijjIK4sA-a7f19GC_xzhYurdkWM-ZY1jR_l4R8JloVdGTfj7IhXY6_pd5SNGThjmM2DoSjWNup74xC3v-l3lI0ZMlDZPGJAyd3jsVnd5JXc6CZlmdxSQMk8UxHPyYbk7Sn24cjMQxHPqZZVvRkypP2Z1VW82eZVLYwD5jxc48Y4vCI4C1gDJWiIVMXssRDTmrPME9aeZPSc-ZelmSpX5T3p1iU9Gb1jnYmCdp7gnJ"); + + User user = new User() + .id("12345"); + risk.user(user); + + Context context = new Context() + .ip("211.96.77.55") + .addHeadersItem("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15"); + risk.context(context); + + Changeset changeSet = new Changeset() + .email(new ChangesetEntry() + .from("before@exmaple.com") + .to("after@example.com")) + .password(new ChangedChangesetEntry()) + .authenticationMethodType(new ChangesetEntry() + .from("$authenticator") + .to("$email")) + .name(new ChangesetEntry() + .from("Jon Snow") + .to("King of the North")); + risk.changeset(changeSet); + + Product product = new Product() + .id("1234"); + risk.product(product); + + risk.putPropertiesItem("property1", new HashMap()); + risk.putPropertiesItem("property2", new HashMap()); + + risk.createdAt(OffsetDateTime.parse("2022-05-20T09:03:27.468+02:00")); + + RiskResponse response = sdk.onRequest(request).risk(risk); + + // Check response object + Assert.assertEquals(response.getRisk(), 0.65, 0); + Assert.assertEquals(response.getSignals().size(), 5); + Assert.assertEquals(response.getDevice().getToken(), "eyJhbGciOiJIUzI1NiJ9.eyJ0b2tlbiI6IjEzc2x6RzNHQ0RzeFJCejdJWF9SUDJkV1Y0RFgiLCJxdWFsaWZpZXIiOiJBUUlEQ2pFME5EZzFPREF3T1RZIiwiYW5vbnltb3VzIjpmYWxzZSwidmVyc2lvbiI6MC4zfQ.y3vOt-W1IpOi7Oyn1jll1uDw1YL-JPZtNMTU-PyaYhQ"); + Assert.assertEquals(response.getPolicy().getAction(), Policy.ActionEnum.CHALLENGE); + Assert.assertEquals(response.getPolicy().getId(), "2ee938c8-24c2-4c26-9d25-19511dd75029"); + Assert.assertEquals(response.getPolicy().getRevisionId(), "900b183a-9f6d-4579-8c47-9ddcccf637b4"); + Assert.assertEquals(response.getPolicy().getName(), "Challenge risk >= 60"); + + // Then + RecordedRequest recordedRequest = server.takeRequest(); + Assert.assertEquals(testServerBaseUrl.resolve("v1/risk"), recordedRequest.getRequestUrl()); + Assert.assertEquals("POST", recordedRequest.getMethod()); + + String body = recordedRequest.getBody().readUtf8(); + + String expected = "{\"context\":{\"headers\":[[\"User-Agent\",\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15\"]],\"ip\":\"211.96.77.55\"},\"properties\":{\"property2\":{},\"property1\":{}},\"product\":{\"id\":\"1234\"},\"created_at\":\"2022-05-20T09:03:27.468+02:00\",\"request_token\":\"4-ugt5CFooaxt5KbpISi1Kurm5KTpqawlYmFs5PXsqKootPgRB3z12OpvPOWOQ9PkztagtqicAnk9Qowu7FlU9qabyi4k2QR6KUUL5p3gr-A2w8Ju8gWe0XyRi_OkmFj2oZiU9OTPAjijjIK4sA-a7f19GC_xzhYurdkWM-ZY1jR_l4R8JloVdGTfj7IhXY6_pd5SNGThjmM2DoSjWNup74xC3v-l3lI0ZMlDZPGJAyd3jsVnd5JXc6CZlmdxSQMk8UxHPyYbk7Sn24cjMQxHPqZZVvRkypP2Z1VW82eZVLYwD5jxc48Y4vCI4C1gDJWiIVMXssRDTmrPME9aeZPSc-ZelmSpX5T3p1iU9Gb1jnYmCdp7gnJ\",\"user\":{\"id\":\"12345\"},\"type\":\"$profile_update\",\"status\":\"$succeeded\",\"changeset\":{\"password\":{\"changed\":true},\"email\":{\"from\":\"before@exmaple.com\",\"to\":\"after@example.com\"},\"authentication_method.type\":{\"from\":\"$authenticator\",\"to\":\"$email\"},\"name\":{\"from\":\"Jon Snow\",\"to\":\"King of the North\"}}}"; + Assertions.assertThat(JsonParser.parseString(body)).isEqualTo(JsonParser.parseString(expected)); + } +}