Upload files to 'src/main/java/ca/mgamble/postman/api/response'

This commit is contained in:
nikkel 2020-03-20 03:20:19 +07:00
parent 1d62cc4284
commit 2500a571bd
5 changed files with 276 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<String, SendResult> messages;
public String getResponseSumary() {
return code != null ? code.getText() + " " : "" + message + " for message_id = " + message_id;
}
}

View File

@ -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;
}