// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/common/ServiceError.java
// public final class ServiceError implements Serializable {
// 
//     private final String code;
// 
//     private final String message;
// 
//     public ServiceError(String code, String message) {
//         this.code = code;
//         this.message = message;
//     }
// 
//     /**
//      * Returns the error code identifying the error.
//      * @return the error code.
//      */
//     public String getCode() {
//         return code;
//     }
// 
//     /**
//      * A human readable description of the error, sometimes with additional details of its cause.
//      * @return a human readable message.
//      */
//     public String getMessage() {
//         return message;
//     }
// 
//     @Override
//     public String toString() {
//         return "ServiceError{" +
//                 "code='" + code + '\'' +
//                 ", message='" + message + '\'' +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         ServiceError that = (ServiceError) o;
//         if (code != null ? !code.equals(that.code) : that.code != null) return false;
//         if (message != null ? !message.equals(that.message) : that.message != null) return false;
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = code != null ? code.hashCode() : 0;
//         result = 31 * result + (message != null ? message.hashCode() : 0);
//         return result;
//     }
// 
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/exception/BrightpearlServiceException.java
// public class BrightpearlServiceException extends BrightpearlClientException {
// 
//     private final int status;
// 
//     private final List<ServiceError> serviceErrors;
// 
//     public BrightpearlServiceException(int status, List<ServiceError> serviceErrors) {
//         super(buildMessage(status, serviceErrors));
//         this.status = status;
//         this.serviceErrors = serviceErrors == null ? null : Collections.unmodifiableList(serviceErrors);
//     }
// 
//     /**
//      * Returns the HTTP status of the response received.
//      * @return HTTP response status.
//      */
//     public int getStatus() {
//         return status;
//     }
// 
//     /**
//      * Returns service errors from the response.
//      * @return service errors.
//      */
//     public List<ServiceError> getServiceErrors() {
//         return serviceErrors;
//     }
// 
//     private static String buildMessage(int status, List<ServiceError> serviceErrors) {
//         if (serviceErrors != null) {
//             StringBuilder builder = new StringBuilder();
//             for (ServiceError serviceError : serviceErrors) {
//                 if (builder.length() > 0) {
//                     builder.append(", ");
//                 }
//                 builder.append(serviceError.getCode());
//             }
//             return "Status code " + status + " and " + serviceErrors.size() + " errors returned from Brightpearl API (" + builder.toString() + ")";
//         }
//         return "Status code " + status + " and 0 errors returned from Brightpearl API";
//     }
// 
// }


import uk.co.visalia.brightpearl.apiclient.common.ServiceError;
import uk.co.visalia.brightpearl.apiclient.exception.BrightpearlServiceException;
import java.util.List;
/*
 * Copyright 2014 David Morrissey
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.co.visalia.brightpearl.apiclient.multimessage;



/**
 * Contains the response for an individual request executed in a multimessage batch.
 * @param <T> placeholder for the response type.
 */
public final class ServiceResponse<T> {

    /**
     * The unique ID of the request sent.
     */
    private final String ruid;

    /**
     * HTTP status code received.
     */
    private final int status;

    /**
     * The parsed response entity of the type expected for the request.
     */
    private final T response;

    /**
     * Errors returned by the Brightpearl API.
     */
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/common/ServiceError.java
// public final class ServiceError implements Serializable {
// 
//     private final String code;
// 
//     private final String message;
// 
//     public ServiceError(String code, String message) {
//         this.code = code;
//         this.message = message;
//     }
// 
//     /**
//      * Returns the error code identifying the error.
//      * @return the error code.
//      */
//     public String getCode() {
//         return code;
//     }
// 
//     /**
//      * A human readable description of the error, sometimes with additional details of its cause.
//      * @return a human readable message.
//      */
//     public String getMessage() {
//         return message;
//     }
// 
//     @Override
//     public String toString() {
//         return "ServiceError{" +
//                 "code='" + code + '\'' +
//                 ", message='" + message + '\'' +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         ServiceError that = (ServiceError) o;
//         if (code != null ? !code.equals(that.code) : that.code != null) return false;
//         if (message != null ? !message.equals(that.message) : that.message != null) return false;
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = code != null ? code.hashCode() : 0;
//         result = 31 * result + (message != null ? message.hashCode() : 0);
//         return result;
//     }
// 
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/exception/BrightpearlServiceException.java
// public class BrightpearlServiceException extends BrightpearlClientException {
// 
//     private final int status;
// 
//     private final List<ServiceError> serviceErrors;
// 
//     public BrightpearlServiceException(int status, List<ServiceError> serviceErrors) {
//         super(buildMessage(status, serviceErrors));
//         this.status = status;
//         this.serviceErrors = serviceErrors == null ? null : Collections.unmodifiableList(serviceErrors);
//     }
// 
//     /**
//      * Returns the HTTP status of the response received.
//      * @return HTTP response status.
//      */
//     public int getStatus() {
//         return status;
//     }
// 
//     /**
//      * Returns service errors from the response.
//      * @return service errors.
//      */
//     public List<ServiceError> getServiceErrors() {
//         return serviceErrors;
//     }
// 
//     private static String buildMessage(int status, List<ServiceError> serviceErrors) {
//         if (serviceErrors != null) {
//             StringBuilder builder = new StringBuilder();
//             for (ServiceError serviceError : serviceErrors) {
//                 if (builder.length() > 0) {
//                     builder.append(", ");
//                 }
//                 builder.append(serviceError.getCode());
//             }
//             return "Status code " + status + " and " + serviceErrors.size() + " errors returned from Brightpearl API (" + builder.toString() + ")";
//         }
//         return "Status code " + status + " and 0 errors returned from Brightpearl API";
//     }
// 
// }


// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/multimessage/ServiceResponse.java
import uk.co.visalia.brightpearl.apiclient.common.ServiceError;
import uk.co.visalia.brightpearl.apiclient.exception.BrightpearlServiceException;
import java.util.List;

/*
 * Copyright 2014 David Morrissey
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.co.visalia.brightpearl.apiclient.multimessage;



/**
 * Contains the response for an individual request executed in a multimessage batch.
 * @param <T> placeholder for the response type.
 */
public final class ServiceResponse<T> {

    /**
     * The unique ID of the request sent.
     */
    private final String ruid;

    /**
     * HTTP status code received.
     */
    private final int status;

    /**
     * The parsed response entity of the type expected for the request.
     */
    private final T response;

    /**
     * Errors returned by the Brightpearl API.
     */
    private final List<ServiceError> errors;