diff --git a/src/main/java/ca/mgamble/postman/api/response/ErrorCode.java b/src/main/java/ca/mgamble/postman/api/response/ErrorCode.java new file mode 100644 index 0000000..8e475b3 --- /dev/null +++ b/src/main/java/ca/mgamble/postman/api/response/ErrorCode.java @@ -0,0 +1,91 @@ + +package ca.mgamble.postman.api.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +/** + * + * @author mgamble + */ +/* +The MIT License (MIT) + +Copyright (c) 2017 Matthew M. Gamble https://www.mgamble.ca + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + */ + +public enum ErrorCode implements Serializable { + @SerializedName("InvalidServerAPIKey") + InvalidServerAPIKey("InvalidServerAPIKey"), + + @SerializedName("NoRecipients") + NoRecipients("NoRecipients"), + + @SerializedName("NoContent") + NoContent("NoContent"), + + @SerializedName("NotEnoughCredits") + NotEnoughCredits("NotEnoughCredits"), + + @SerializedName("TooManyToAddresses") + TooManyToAddresses("TooManyToAddresses"), + + @SerializedName("TooManyCCAddresses") + TooManyCCAddresses("TooManyCCAddresses"), + + @SerializedName("TooManyBCCAddresses") + TooManyBCCAddresses("TooManyBCCAddresses"), + + @SerializedName("FromAddressMissing") + FromAddressMissing("FromAddressMissing"), + + @SerializedName("UnauthenticatedFromAddress") + UnauthenticatedFromAddress("UnauthenticatedFromAddress"), + + @SerializedName("AttachmentMissingName") + AttachmentMissingName("AttachmentMissingName"), + + @SerializedName("AttachmentMissingData") + AttachmentMissingData("AttachmentMissingData"), + + @SerializedName("ValidationError") + ValidationError("ValidationError"); + + private final String text; + + ErrorCode(String text) { + this.text = text; + } + + public String getText() { + return this.text; + } + + public static ErrorCode fromString(String text) { + if (text != null) { + for (ErrorCode b : ErrorCode.values()) { + if (text.equalsIgnoreCase(b.text)) { + return b; + } + } + } + return null; + } +} diff --git a/src/main/java/ca/mgamble/postman/api/response/OperationStatus.java b/src/main/java/ca/mgamble/postman/api/response/OperationStatus.java new file mode 100644 index 0000000..5d8d101 --- /dev/null +++ b/src/main/java/ca/mgamble/postman/api/response/OperationStatus.java @@ -0,0 +1,60 @@ + +package ca.mgamble.postman.api.response; + +import com.google.gson.annotations.SerializedName; +import java.io.Serializable; +/** + * + * @author mgamble + */ +/* +The MIT License (MIT) + +Copyright (c) 2017 Matthew M. Gamble https://www.mgamble.ca + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + */ + +public enum OperationStatus implements Serializable { + @SerializedName("success") + SUCCESS("success"), + @SerializedName("error") + ERROR("error"); + + private final String text; + + OperationStatus(String text) { + this.text = text; + } + + public String getText() { + return this.text; + } + + public static OperationStatus fromString(String text) { + if (text != null) { + for (OperationStatus b : OperationStatus.values()) { + if (text.equalsIgnoreCase(b.text)) { + return b; + } + } + } + return null; + } +} diff --git a/src/main/java/ca/mgamble/postman/api/response/PostmanApiResponse.java b/src/main/java/ca/mgamble/postman/api/response/PostmanApiResponse.java new file mode 100644 index 0000000..bfb3421 --- /dev/null +++ b/src/main/java/ca/mgamble/postman/api/response/PostmanApiResponse.java @@ -0,0 +1,44 @@ +/** + * + * @author mgamble + */ +/* +The MIT License (MIT) + +Copyright (c) 2017 Matthew M. Gamble https://www.mgamble.ca + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + */ + +package ca.mgamble.postman.api.response; + +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class PostmanApiResponse { + private OperationStatus status; + private String time; + private ResponseData data; + + public PostmanApiResponse(OperationStatus status) { + this.status = status; + } +} diff --git a/src/main/java/ca/mgamble/postman/api/response/ResponseData.java b/src/main/java/ca/mgamble/postman/api/response/ResponseData.java new file mode 100644 index 0000000..c6e8ae8 --- /dev/null +++ b/src/main/java/ca/mgamble/postman/api/response/ResponseData.java @@ -0,0 +1,45 @@ +/* + * The MIT License + * + * Copyright 2017 mgamble. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package ca.mgamble.postman.api.response; + +import lombok.Data; + +import java.util.Map; + +/** + * + * @author mgamble + */ +@Data +public class ResponseData { + private ErrorCode code; + private String message; + private String token; + private String message_id; + private Map messages; + + public String getResponseSumary() { + return code != null ? code.getText() + " " : "" + message + " for message_id = " + message_id; + } +} diff --git a/src/main/java/ca/mgamble/postman/api/response/SendResult.java b/src/main/java/ca/mgamble/postman/api/response/SendResult.java new file mode 100644 index 0000000..353f739 --- /dev/null +++ b/src/main/java/ca/mgamble/postman/api/response/SendResult.java @@ -0,0 +1,36 @@ +/* + * The MIT License + * + * Copyright 2017 mgamble. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package ca.mgamble.postman.api.response; + +import lombok.Data; + +/** + * + * @author mgamble + */ +@Data +public class SendResult { + private String id; + private String token; +}