Skip to content

AdamBurdik/Sonoran.java

Repository files navigation

Sonoran.java

Sonoran.java is a library that allows you to interact with the Sonoran CAD API.

Disclaimer

This library is a work in progress — many endpoints are not yet implemented.
I plan to support all major Sonoran CAD API endpoints in future updates.

How To Build

  1. Clone the repository
   git clone https://github.com/adamBurdik/Sonoran.java
  1. Navigate to the directory
   cd Sonoran.java
  1. Build the module
   gradlew build

How To Use

  1. Add Sonoran.java as a dependency to your project, using jitpack
maven { url = uri("https://www.jitpack.io") }

dependencies {
    implementation("com.github.adamBurdik:Sonoran.java:VERSION") // Get version from https://github.com/AdamBurdik/Sonoran.java/releases
}
  1. Create Sonoran instance with cad.
Sonoran sonoran = Sonoran.builder()
        .withCad("CAD_API_TOKEN_HERE", "CAD_COMMUNITY_ID_HERE")
        .build();

// Shuts down the internal HTTP client and task executor.
// Call this method during application shutdown to clean up resources.
sonoran.shutdown();
  1. Use provided methods
// Prints the current Sonoran CAD version
sonoran.cad().getVersion()
    .onSuccess(version -> System.out.println("Version: " + version))
    .onError(error -> System.out.println("API error: " + error.message())) // Use onError to handle unsuccessful API responses
    .onException(Throwable::printStackTrace); // Use onException to handle unexpected internal errors

// Retrieves the CAD Account for the provided username
sonoran.cad().getAccount("ACCOUNT_NAME_HERE")
    .onSuccess(account -> System.out.println("Found account: " + account))
    .onError(error -> System.out.println("API error: " + error.message()))
    .onException(Throwable::printStackTrace);

Contributing

Contributions are welcome!

If you have suggestions, ideas, or issues, feel free to open an issue or contact me on discord: @adamix.dev.

Credits

Sonoran CAD Docs - Documentation for Sonoran CAD API

sonoran.js - Initial idea to create a library for java

minestom - Codec design

About

Library for interacting with the Sonoran CAD API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages