// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/ServiceName.java
// public final class ServiceName {
// 
//     private static final Pattern PATH_PATTERN = Pattern.compile("[a-zA-Z0-9_\\-]+");
// 
//     public static final ServiceName ACCOUNTING = new ServiceName("accounting-service");
//     public static final ServiceName CONTACT = new ServiceName("contact-service");
//     public static final ServiceName INTEGRATION = new ServiceName("integration-service");
//     public static final ServiceName ORDER = new ServiceName("order-service");
//     public static final ServiceName PRODUCT = new ServiceName("product-service");
//     public static final ServiceName WAREHOUSE = new ServiceName("warehouse-service");
// 
//     private final String path;
// 
//     /**
//      * Constructs a custom service name instance, using the path, for example &quot;product-service&quot;.
//      * @param path path component for the service.
//      */
//     public ServiceName(String path) {
//         validatePath(path);
//         this.path = path;
//     }
// 
//     /**
//      * Returns the URI component for the service, for example &quot;product-service&quot;.
//      * @return path component for the service.
//      */
//     public String getPath() {
//         return path;
//     }
// 
//     private void validatePath(String path) {
//         if (path == null || path.trim().length() == 0) {
//             throw new IllegalArgumentException("Service path must be provided");
//         } else if (!PATH_PATTERN.matcher(path).matches()) {
//             throw new IllegalArgumentException("Service must contain alphanumeric characters, hyphen and underscore only");
//         }
//     }
// 
//     @Override
//     public String toString() {
//         return "ServiceName{" +
//                 "path='" + path + '\'' +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         ServiceName that = (ServiceName) o;
//         if (path != null ? !path.equals(that.path) : that.path != null) return false;
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return path != null ? path.hashCode() : 0;
//     }
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/http/Method.java
// public enum Method {
// 
//     GET,
//     POST,
//     PUT,
//     DELETE,
//     OPTIONS
// 
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/util/StringUtils.java
// public final class StringUtils {
// 
//     private StringUtils() { }
// 
//     public static boolean isEmpty(String string) {
//         return string == null || string.length() == 0;
//     }
// 
//     public static boolean isNotEmpty(String string) {
//         return !isEmpty(string);
//     }
// 
//     public static boolean isBlank(String string) {
//         return string == null || string.trim().length() == 0;
//     }
// 
//     public static boolean isNotBlank(String string) {
//         return !isBlank(string);
//     }
// 
//     public static boolean equals(String lhs, String rhs) {
//         if ((lhs == null) != (rhs == null)) {
//             return false;
//         } else if (lhs == null && rhs == null) {
//             return true;
//         } else {
//             return lhs.equals(rhs);
//         }
//     }
// 
//     public static String join(Collection<String> strings, String separator) {
//         StringBuilder builder = new StringBuilder();
//         for (String string : strings) {
//             if (builder.length() > 0) {
//                 builder.append(separator);
//             }
//             builder.append(string);
//         }
//         return builder.toString();
//     }
// 
// }


import uk.co.visalia.brightpearl.apiclient.ServiceName;
import uk.co.visalia.brightpearl.apiclient.http.Method;
import uk.co.visalia.brightpearl.apiclient.util.StringUtils;
import java.lang.reflect.Type;
import java.util.UUID;
    public static <T> ServiceReadRequestBuilder<T> newOptionsRequest(ServiceName service, String path, Class<T> responseType) {
        ServiceReadRequestBuilder<T> builder = new ServiceReadRequestBuilder<T>();
        return builder.withMethod(Method.GET)
                .withService(service)
                .withPath(path)
                .withResponseType(responseType);
    }

    /**
     * Creates a new OPTIONS request builder configured with the URL to call and expected response type. This method supports
     * extraction of generic types (e.g. typed lists or maps) from the response element.
     * @param service Brightpearl service that contains the resource.
     * @param path path to the search resource, for example '/product'.
     * @param responseType type of result expected in the 'response' element of the JSON response body. Use Void or null if no response is expected, or the response is not required.
     * @param <T> placeholder for the response type, used to avoid casting of responses.
     * @return A OPTIONS request builder instance.
     */
    public static <T> ServiceReadRequestBuilder<T> newOptionsRequest(ServiceName service, String path, Type responseType) {
        ServiceReadRequestBuilder<T> builder = new ServiceReadRequestBuilder<T>();
        return builder.withMethod(Method.OPTIONS)
                .withService(service)
                .withPath(path)
                .withResponseType(responseType);
    }

    /**
     * Builds an immutable request instance from values provided to this builder.
     * @return immutable request instance.
     */
    public ServiceReadRequest<T> build() {
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/ServiceName.java
// public final class ServiceName {
// 
//     private static final Pattern PATH_PATTERN = Pattern.compile("[a-zA-Z0-9_\\-]+");
// 
//     public static final ServiceName ACCOUNTING = new ServiceName("accounting-service");
//     public static final ServiceName CONTACT = new ServiceName("contact-service");
//     public static final ServiceName INTEGRATION = new ServiceName("integration-service");
//     public static final ServiceName ORDER = new ServiceName("order-service");
//     public static final ServiceName PRODUCT = new ServiceName("product-service");
//     public static final ServiceName WAREHOUSE = new ServiceName("warehouse-service");
// 
//     private final String path;
// 
//     /**
//      * Constructs a custom service name instance, using the path, for example &quot;product-service&quot;.
//      * @param path path component for the service.
//      */
//     public ServiceName(String path) {
//         validatePath(path);
//         this.path = path;
//     }
// 
//     /**
//      * Returns the URI component for the service, for example &quot;product-service&quot;.
//      * @return path component for the service.
//      */
//     public String getPath() {
//         return path;
//     }
// 
//     private void validatePath(String path) {
//         if (path == null || path.trim().length() == 0) {
//             throw new IllegalArgumentException("Service path must be provided");
//         } else if (!PATH_PATTERN.matcher(path).matches()) {
//             throw new IllegalArgumentException("Service must contain alphanumeric characters, hyphen and underscore only");
//         }
//     }
// 
//     @Override
//     public String toString() {
//         return "ServiceName{" +
//                 "path='" + path + '\'' +
//                 '}';
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
//         ServiceName that = (ServiceName) o;
//         if (path != null ? !path.equals(that.path) : that.path != null) return false;
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         return path != null ? path.hashCode() : 0;
//     }
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/http/Method.java
// public enum Method {
// 
//     GET,
//     POST,
//     PUT,
//     DELETE,
//     OPTIONS
// 
// }
// 
// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/util/StringUtils.java
// public final class StringUtils {
// 
//     private StringUtils() { }
// 
//     public static boolean isEmpty(String string) {
//         return string == null || string.length() == 0;
//     }
// 
//     public static boolean isNotEmpty(String string) {
//         return !isEmpty(string);
//     }
// 
//     public static boolean isBlank(String string) {
//         return string == null || string.trim().length() == 0;
//     }
// 
//     public static boolean isNotBlank(String string) {
//         return !isBlank(string);
//     }
// 
//     public static boolean equals(String lhs, String rhs) {
//         if ((lhs == null) != (rhs == null)) {
//             return false;
//         } else if (lhs == null && rhs == null) {
//             return true;
//         } else {
//             return lhs.equals(rhs);
//         }
//     }
// 
//     public static String join(Collection<String> strings, String separator) {
//         StringBuilder builder = new StringBuilder();
//         for (String string : strings) {
//             if (builder.length() > 0) {
//                 builder.append(separator);
//             }
//             builder.append(string);
//         }
//         return builder.toString();
//     }
// 
// }


// Path: src/main/java/uk/co/visalia/brightpearl/apiclient/request/ServiceReadRequestBuilder.java
import uk.co.visalia.brightpearl.apiclient.ServiceName;
import uk.co.visalia.brightpearl.apiclient.http.Method;
import uk.co.visalia.brightpearl.apiclient.util.StringUtils;
import java.lang.reflect.Type;
import java.util.UUID;

    public static <T> ServiceReadRequestBuilder<T> newOptionsRequest(ServiceName service, String path, Class<T> responseType) {
        ServiceReadRequestBuilder<T> builder = new ServiceReadRequestBuilder<T>();
        return builder.withMethod(Method.GET)
                .withService(service)
                .withPath(path)
                .withResponseType(responseType);
    }

    /**
     * Creates a new OPTIONS request builder configured with the URL to call and expected response type. This method supports
     * extraction of generic types (e.g. typed lists or maps) from the response element.
     * @param service Brightpearl service that contains the resource.
     * @param path path to the search resource, for example '/product'.
     * @param responseType type of result expected in the 'response' element of the JSON response body. Use Void or null if no response is expected, or the response is not required.
     * @param <T> placeholder for the response type, used to avoid casting of responses.
     * @return A OPTIONS request builder instance.
     */
    public static <T> ServiceReadRequestBuilder<T> newOptionsRequest(ServiceName service, String path, Type responseType) {
        ServiceReadRequestBuilder<T> builder = new ServiceReadRequestBuilder<T>();
        return builder.withMethod(Method.OPTIONS)
                .withService(service)
                .withPath(path)
                .withResponseType(responseType);
    }

    /**
     * Builds an immutable request instance from values provided to this builder.
     * @return immutable request instance.
     */
    public ServiceReadRequest<T> build() {
        String ruid = StringUtils.isNotEmpty(getRuid()) ? getRuid() : UUID.randomUUID().toString();