Skip to content

Commit

Permalink
Release 0.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Oct 28, 2022
1 parent 849187a commit 01971e6
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 73 deletions.
5 changes: 2 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ repositories {
}

dependencies {
api 'io.github.fern-api:jackson-utils:0.0.82'
api 'io.github.fern-api:jersey-utils:0.0.82'
api 'com.fasterxml.jackson.core:jackson-databind:2.12.3'
api 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3'
api 'io.github.openfeign:feign-jackson:11.8'
api 'io.github.openfeign:feign-core:11.8'
Expand All @@ -30,7 +29,7 @@ publishing {
maven(MavenPublication) {
groupId = 'io.github.fern-api'
artifactId = 'raven'
version = '0.0.10'
version = '0.0.11'
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion sample-app/src/main/java/sample/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

public final class App {
public static void main(String[] args) {
// import com.raven.api.client.RavenApiClient
// import com.raven.api.RavenApiClient
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.raven.api.client;
package com.raven.api;

import com.raven.api.client.Authorization;
import com.raven.api.client.device.DeviceServiceClient;
import com.raven.api.client.event.EventServiceClient;
import com.raven.api.client.user.UserServiceClient;
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/raven/api/client/device/DeviceService.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.raven.api.client.device;

import com.fern.java.jackson.ClientObjectMappers;
import com.fern.java.jersey.contracts.OptionalAwareContract;
import com.raven.api.client.Authorization;
import com.raven.api.client.device.exceptions.AddException;
import com.raven.api.client.device.exceptions.DeleteDeviceException;
import com.raven.api.client.device.exceptions.DeleteException;
import com.raven.api.client.device.exceptions.GetDeviceException;
import com.raven.api.client.device.exceptions.UpdateException;
import com.raven.api.client.device.types.Device;
import com.raven.api.client.ids.types.AppId;
import com.raven.api.client.ids.types.DeviceId;
import com.raven.api.client.ids.types.UserId;
import com.raven.api.core.ObjectMappers;
import feign.Feign;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
Expand Down Expand Up @@ -44,9 +44,9 @@ Device update(@HeaderParam("Authorization") Authorization auth, @PathParam("app_

@DELETE
@Path("/{app_id}/users/{user_id}/devices/{device_id}")
void deleteDevice(@HeaderParam("Authorization") Authorization auth,
@PathParam("app_id") AppId appId, @PathParam("user_id") UserId userId,
@PathParam("device_id") DeviceId deviceId) throws DeleteDeviceException;
void delete(@HeaderParam("Authorization") Authorization auth, @PathParam("app_id") AppId appId,
@PathParam("user_id") UserId userId, @PathParam("device_id") DeviceId deviceId) throws
DeleteException;

@GET
@Path("/{app_id}/users/{user_id}/devices/{device_id}")
Expand All @@ -57,8 +57,8 @@ Device getDevice(@HeaderParam("Authorization") Authorization auth,
static DeviceService getClient(String url) {
return Feign.builder()
.contract(new OptionalAwareContract(new JAXRSContract()))
.decoder(new JacksonDecoder(ClientObjectMappers.JSON_MAPPER))
.encoder(new JacksonEncoder(ClientObjectMappers.JSON_MAPPER))
.decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER))
.encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER))
.errorDecoder(new DeviceServiceErrorDecoder()).target(DeviceService.class, url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import com.raven.api.client.Authorization;
import com.raven.api.client.device.endpoints.Add;
import com.raven.api.client.device.endpoints.DeleteDevice;
import com.raven.api.client.device.endpoints.Delete;
import com.raven.api.client.device.endpoints.GetDevice;
import com.raven.api.client.device.endpoints.Update;
import com.raven.api.client.device.exceptions.AddException;
import com.raven.api.client.device.exceptions.DeleteDeviceException;
import com.raven.api.client.device.exceptions.DeleteException;
import com.raven.api.client.device.exceptions.GetDeviceException;
import com.raven.api.client.device.exceptions.UpdateException;
import com.raven.api.client.device.types.Device;
Expand Down Expand Up @@ -39,9 +39,9 @@ public Device update(Update.Request request) throws UpdateException {
return this.service.update(authValue, request.getAppId(), request.getUserId(), request.getDeviceId(), request.getBody());
}

public void deleteDevice(DeleteDevice.Request request) throws DeleteDeviceException {
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required for deleteDevice")));
this.service.deleteDevice(authValue, request.getAppId(), request.getUserId(), request.getDeviceId());
public void delete(Delete.Request request) throws DeleteException {
Authorization authValue = request.getAuthOverride().orElseGet(() -> this.auth.orElseThrow(() -> new RuntimeException("Auth is required for delete")));
this.service.delete(authValue, request.getAppId(), request.getUserId(), request.getDeviceId());
}

public Device getDevice(GetDevice.Request request) throws GetDeviceException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.raven.api.client.device;

import com.fern.java.jackson.ClientObjectMappers;
import com.raven.api.client.device.exceptions.AddException;
import com.raven.api.client.device.exceptions.DeleteDeviceException;
import com.raven.api.client.device.exceptions.DeleteException;
import com.raven.api.client.device.exceptions.GetDeviceException;
import com.raven.api.client.device.exceptions.UpdateException;
import com.raven.api.core.ObjectMappers;
import feign.Response;
import feign.codec.ErrorDecoder;
import java.io.IOException;
Expand All @@ -24,8 +24,8 @@ public Exception decode(String methodKey, Response response) {
if (methodKey.contains("update")) {
return decodeException(response, UpdateException.class);
}
if (methodKey.contains("deleteDevice")) {
return decodeException(response, DeleteDeviceException.class);
if (methodKey.contains("delete")) {
return decodeException(response, DeleteException.class);
}
if (methodKey.contains("getDevice")) {
return decodeException(response, GetDeviceException.class);
Expand All @@ -38,6 +38,6 @@ public Exception decode(String methodKey, Response response) {

private static <T extends Exception> Exception decodeException(Response response, Class<T> clazz)
throws IOException {
return ClientObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz);
return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import java.util.Objects;
import java.util.Optional;

public final class DeleteDevice {
private DeleteDevice() {
public final class Delete {
private Delete() {
}

public static final class Request {
Expand Down Expand Up @@ -68,7 +68,7 @@ public int hashCode() {

@Override
public String toString() {
return "DeleteDevice.Request{" + "authOverride: " + authOverride + ", appId: " + appId + ", userId: " + userId + ", deviceId: " + deviceId + "}";
return "Delete.Request{" + "authOverride: " + authOverride + ", appId: " + appId + ", userId: " + userId + ", deviceId: " + deviceId + "}";
}

public static AppIdStage builder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
import java.util.Optional;

@JsonDeserialize(
using = DeleteDeviceException.Deserializer.class
using = DeleteException.Deserializer.class
)
public final class DeleteDeviceException extends Exception {
public final class DeleteException extends Exception {
private final Value value;

private int statusCode;

private DeleteDeviceException(Value value, int statusCode) {
private DeleteException(Value value, int statusCode) {
this.value = value;
this.statusCode = statusCode;
}
Expand All @@ -37,8 +37,8 @@ public int getStatusCode() {
return this.statusCode;
}

public static DeleteDeviceException other(Object unknownValue, int statusCode) {
return new DeleteDeviceException(new UnknownErrorValue(unknownValue), statusCode);
public static DeleteException other(Object unknownValue, int statusCode) {
return new DeleteException(new UnknownErrorValue(unknownValue), statusCode);
}

public boolean isOther() {
Expand Down Expand Up @@ -101,17 +101,17 @@ public int hashCode() {

@Override
public String toString() {
return "DeleteDeviceException{" + "unknownValue: " + unknownValue + "}";
return "DeleteException{" + "unknownValue: " + unknownValue + "}";
}
}

static final class Deserializer extends JsonDeserializer<DeleteDeviceException> {
static final class Deserializer extends JsonDeserializer<DeleteException> {
@Override
public DeleteDeviceException deserialize(JsonParser p, DeserializationContext ctx) throws
public DeleteException deserialize(JsonParser p, DeserializationContext ctx) throws
IOException {
Value value = ctx.readValue(p, Value.class);
int statusCode = (int) ctx.getAttribute("statusCode");
return new DeleteDeviceException(value, statusCode);
return new DeleteException(value, statusCode);
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/raven/api/client/event/EventService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.raven.api.client.event;

import com.fern.java.jackson.ClientObjectMappers;
import com.fern.java.jersey.contracts.OptionalAwareContract;
import com.raven.api.client.Authorization;
import com.raven.api.client.event.exceptions.SendBulkException;
Expand All @@ -9,6 +8,7 @@
import com.raven.api.client.event.types.SendEventRequest;
import com.raven.api.client.event.types.SendEventResponse;
import com.raven.api.client.ids.types.AppId;
import com.raven.api.core.ObjectMappers;
import feign.Feign;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
Expand Down Expand Up @@ -42,8 +42,8 @@ SendEventResponse sendBulk(@HeaderParam("Authorization") Authorization auth,
static EventService getClient(String url) {
return Feign.builder()
.contract(new OptionalAwareContract(new JAXRSContract()))
.decoder(new JacksonDecoder(ClientObjectMappers.JSON_MAPPER))
.encoder(new JacksonEncoder(ClientObjectMappers.JSON_MAPPER))
.decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER))
.encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER))
.errorDecoder(new EventServiceErrorDecoder()).target(EventService.class, url);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.raven.api.client.event;

import com.fern.java.jackson.ClientObjectMappers;
import com.raven.api.client.event.exceptions.SendBulkException;
import com.raven.api.client.event.exceptions.SendException;
import com.raven.api.core.ObjectMappers;
import feign.Response;
import feign.codec.ErrorDecoder;
import java.io.IOException;
Expand Down Expand Up @@ -30,6 +30,6 @@ public Exception decode(String methodKey, Response response) {

private static <T extends Exception> Exception decodeException(Response response, Class<T> clazz)
throws IOException {
return ClientObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz);
return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz);
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/raven/api/client/user/UserService.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.raven.api.client.user;

import com.fern.java.jackson.ClientObjectMappers;
import com.fern.java.jersey.contracts.OptionalAwareContract;
import com.raven.api.client.Authorization;
import com.raven.api.client.ids.types.AppId;
Expand All @@ -9,6 +8,7 @@
import com.raven.api.client.user.exceptions.GetException;
import com.raven.api.client.user.types.CreateUserRequest;
import com.raven.api.client.user.types.RavenUser;
import com.raven.api.core.ObjectMappers;
import feign.Feign;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
Expand Down Expand Up @@ -40,8 +40,8 @@ RavenUser get(@HeaderParam("Authorization") Authorization auth, @PathParam("app_
static UserService getClient(String url) {
return Feign.builder()
.contract(new OptionalAwareContract(new JAXRSContract()))
.decoder(new JacksonDecoder(ClientObjectMappers.JSON_MAPPER))
.encoder(new JacksonEncoder(ClientObjectMappers.JSON_MAPPER))
.decoder(new JacksonDecoder(ObjectMappers.JSON_MAPPER))
.encoder(new JacksonEncoder(ObjectMappers.JSON_MAPPER))
.errorDecoder(new UserServiceErrorDecoder()).target(UserService.class, url);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.raven.api.client.user;

import com.fern.java.jackson.ClientObjectMappers;
import com.raven.api.client.user.exceptions.CreateOrUpdateException;
import com.raven.api.client.user.exceptions.GetException;
import com.raven.api.core.ObjectMappers;
import feign.Response;
import feign.codec.ErrorDecoder;
import java.io.IOException;
Expand Down Expand Up @@ -30,6 +30,6 @@ public Exception decode(String methodKey, Response response) {

private static <T extends Exception> Exception decodeException(Response response, Class<T> clazz)
throws IOException {
return ClientObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz);
return ObjectMappers.JSON_MAPPER.reader().withAttribute("statusCode", response.status()).readValue(response.body().asInputStream(), clazz);
}
}
58 changes: 29 additions & 29 deletions src/main/java/com/raven/api/client/user/types/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
import java.util.Locale;

public final class Channel {
public static final Channel SMS = new Channel(Value.SMS, "SMS");

public static final Channel IN_APP = new Channel(Value.IN_APP, "IN_APP");

public static final Channel VOICE = new Channel(Value.VOICE, "VOICE");
public static final Channel EMAIL = new Channel(Value.EMAIL, "EMAIL");

public static final Channel WHATSAPP = new Channel(Value.WHATSAPP, "WHATSAPP");

public static final Channel PUSH = new Channel(Value.PUSH, "PUSH");
public static final Channel SLACK = new Channel(Value.SLACK, "SLACK");

public static final Channel EMAIL = new Channel(Value.EMAIL, "EMAIL");
public static final Channel SMS = new Channel(Value.SMS, "SMS");

public static final Channel WEBHOOK = new Channel(Value.WEBHOOK, "WEBHOOK");

public static final Channel TELEGRAM = new Channel(Value.TELEGRAM, "TELEGRAM");

public static final Channel SLACK = new Channel(Value.SLACK, "SLACK");
public static final Channel IN_APP = new Channel(Value.IN_APP, "IN_APP");

public static final Channel WEBHOOK = new Channel(Value.WEBHOOK, "WEBHOOK");
public static final Channel VOICE = new Channel(Value.VOICE, "VOICE");

public static final Channel PUSH = new Channel(Value.PUSH, "PUSH");

private final Value value;

Expand Down Expand Up @@ -58,24 +58,24 @@ public int hashCode() {

public <T> T visit(Visitor<T> visitor) {
switch (value) {
case EMAIL:
return visitor.visitEmail();
case WHATSAPP:
return visitor.visitWhatsapp();
case SLACK:
return visitor.visitSlack();
case SMS:
return visitor.visitSms();
case WEBHOOK:
return visitor.visitWebhook();
case TELEGRAM:
return visitor.visitTelegram();
case IN_APP:
return visitor.visitInApp();
case VOICE:
return visitor.visitVoice();
case WHATSAPP:
return visitor.visitWhatsapp();
case PUSH:
return visitor.visitPush();
case EMAIL:
return visitor.visitEmail();
case TELEGRAM:
return visitor.visitTelegram();
case SLACK:
return visitor.visitSlack();
case WEBHOOK:
return visitor.visitWebhook();
case UNKNOWN:
default:
return visitor.visitUnknown(string);
Expand All @@ -88,24 +88,24 @@ public <T> T visit(Visitor<T> visitor) {
public static Channel valueOf(String value) {
String upperCasedValue = value.toUpperCase(Locale.ROOT);
switch (upperCasedValue) {
case "EMAIL":
return EMAIL;
case "WHATSAPP":
return WHATSAPP;
case "SLACK":
return SLACK;
case "SMS":
return SMS;
case "WEBHOOK":
return WEBHOOK;
case "TELEGRAM":
return TELEGRAM;
case "IN_APP":
return IN_APP;
case "VOICE":
return VOICE;
case "WHATSAPP":
return WHATSAPP;
case "PUSH":
return PUSH;
case "EMAIL":
return EMAIL;
case "TELEGRAM":
return TELEGRAM;
case "SLACK":
return SLACK;
case "WEBHOOK":
return WEBHOOK;
default:
return new Channel(Value.UNKNOWN, upperCasedValue);
}
Expand Down
Loading

0 comments on commit 01971e6

Please sign in to comment.