Initial commit for push service
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package de.pushservice.client;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
public enum ResponseReason {
|
||||
OK(HttpStatus.OK),
|
||||
UNKNOWN_ERROR(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
private final HttpStatus httpStatus;
|
||||
|
||||
ResponseReason(HttpStatus httpStatus) {
|
||||
this.httpStatus = httpStatus;
|
||||
}
|
||||
|
||||
public ResponseEntity toResponseEntity() {
|
||||
return new ResponseEntity<>(this.name(), this.httpStatus);
|
||||
}
|
||||
|
||||
public HttpStatus getHttpStatus() {
|
||||
return this.httpStatus;
|
||||
}
|
||||
|
||||
public static ResponseReason fromResponseEntity(ResponseEntity<String> entity) {
|
||||
for (ResponseReason reason : values()) {
|
||||
if (reason.name().equals(entity.getBody())) {
|
||||
return reason;
|
||||
}
|
||||
}
|
||||
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package de.pushservice.client.dto;
|
||||
|
||||
import de.pushservice.client.model.Urgency;
|
||||
|
||||
public class MessageDto {
|
||||
private String payload;
|
||||
private String topic;
|
||||
private Urgency urgency;
|
||||
|
||||
public String getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(String payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
|
||||
public Urgency getUrgency() {
|
||||
return urgency;
|
||||
}
|
||||
|
||||
public void setUrgency(Urgency urgency) {
|
||||
this.urgency = urgency;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.pushservice.client.dto;
|
||||
|
||||
public class NotificationRequestDto {
|
||||
private SubscriptionDto subscriptionDto;
|
||||
private MessageDto messageDto;
|
||||
|
||||
public SubscriptionDto getSubscriptionDto() {
|
||||
return subscriptionDto;
|
||||
}
|
||||
|
||||
public void setSubscriptionDto(SubscriptionDto subscriptionDto) {
|
||||
this.subscriptionDto = subscriptionDto;
|
||||
}
|
||||
|
||||
public MessageDto getMessageDto() {
|
||||
return messageDto;
|
||||
}
|
||||
|
||||
public void setMessageDto(MessageDto messageDto) {
|
||||
this.messageDto = messageDto;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.pushservice.client.dto;
|
||||
|
||||
public class SubscriptionDto {
|
||||
private String auth;
|
||||
private String endpoint;
|
||||
private String key;
|
||||
|
||||
public void setAuth(String auth) {
|
||||
this.auth = auth;
|
||||
}
|
||||
|
||||
public String getAuth() {
|
||||
return auth;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setEndpoint(String endpoint) {
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
public String getEndpoint() {
|
||||
return endpoint;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package de.pushservice.client.model;
|
||||
|
||||
public enum Urgency {
|
||||
VERY_LOW,
|
||||
LOW,
|
||||
NORMAL,
|
||||
HIGH
|
||||
}
|
||||
Reference in New Issue
Block a user