Skip to content

About

Official Bagdock API client for Java

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

  ----++                                ----++                    ---+++     
  ---+++                                ---++                     ---++      
 ----+---     -----     ---------  --------++ ------     -----   ----++----- 
 ---------+ --------++----------++--------+++--------+ --------++---++---++++
 ---+++---++ ++++---++---+++---++---+++---++---+++---++---++---++------++++  
----++ ---++--------++---++----++---++ ---++---++ ---+---++     -------++    
----+----+---+++---++---++----++---++----++---++---+++--++ --------+---++   
---------++--------+++--------+++--------++ -------+++ -------++---++----++  
 +++++++++   +++++++++- +++---++   ++++++++    ++++++    ++++++  ++++  ++++  
                     --------+++                                             
                       +++++++                                               

bagdock-java

The official Java SDK for the Bagdock API — manage facilities, contacts, tenancies, invoices, marketplace listings, and loyalty programs using the JDK 17+ HttpClient.

Maven Central License: MIT

Install

Maven:

<dependency>
    <groupId>com.bagdock</groupId>
    <artifactId>bagdock-java</artifactId>
    <version>0.1.0</version>
</dependency>

Gradle:

implementation 'com.bagdock:bagdock-java:0.1.0'

Quick start

import com.bagdock.sdk.Bagdock;
import java.util.Map;

var client = new Bagdock(System.getenv("BAGDOCK_API_KEY"));

// List operator facilities
var facilities = client.operator().listFacilities();

// Create a contact
var contact = client.operator().createContact(Map.of(
    "email", "jane@example.com",
    "first_name", "Jane",
    "last_name", "Doe"
));

// Search marketplace
var results = client.marketplace().search();

API reference

client.operator()

Method Description
listFacilities() List facilities
getFacility(id) Get a facility
listContacts() List contacts
createContact(data) Create a contact
listListings() List listings
listTenancies() List tenancies
listUnits() List units
listInvoices() List invoices

client.marketplace()

Method Description
search() Search marketplace locations
getListing(id) Get a listing
createRental(data) Create a rental
getRental(id) Get a rental

client.loyalty()

Method Description
listMembers() List loyalty members
getMember(id) Get a member
awardPoints(data) Award points
listRewards() List rewards

Error handling

import com.bagdock.sdk.BagdockApiException;

try {
    client.operator().getFacility("fac_nonexistent");
} catch (BagdockApiException e) {
    System.err.printf("API error %d: %s%n", e.getStatusCode(), e.getErrorCode());
}

Authentication

The SDK supports three authentication modes: API keys, OAuth access tokens, and OAuth2 client credentials.

API key

Bagdock bagdock = new Bagdock(System.getenv("BAGDOCK_API_KEY"));

OAuth access token

Bagdock bagdock = Bagdock.withAccessToken("eyJhbGciOiJSUzI1NiIs...");

Client credentials

Bagdock bagdock = Bagdock.withClientCredentials(
    "oac_your_client_id",
    "bdok_secret_your_secret",
    new String[]{"facilities:read", "contacts:read"}
);

OAuth2 helpers

Use OAuthHelper for authorization code (PKCE), token exchange, and device flow. These primitives pair well with Bagdock connect webviews for external integrations such as access control, security, and insurance.

import com.bagdock.sdk.oauth.OAuthHelper;
import java.util.Map;

OAuthHelper.PKCEPair pkce = OAuthHelper.generatePKCE();
String url = OAuthHelper.buildAuthorizeUrl("oac_...", "https://your-app.com/callback", pkce.codeChallenge, "openid contacts:read", null, null);

Map<String, Object> tokens = OAuthHelper.exchangeCode("oac_...", code, redirectUri, pkce.codeVerifier, null, null);

Map<String, Object> device = OAuthHelper.deviceAuthorize("bagdock-cli", "developer:read", null);
System.out.printf("Open %s and enter: %s%n", device.get("verification_uri"), device.get("user_code"));
Map<String, Object> deviceTokens = OAuthHelper.pollDeviceToken("bagdock-cli", (String) device.get("device_code"), 5, 600, null);

Configuration

Option Type Default Description
apiKey String — API key via new Bagdock(apiKey) (overload with baseUrl)
accessToken String — OAuth bearer token via Bagdock.withAccessToken(accessToken)
clientId / clientSecret / scopes String / String / String[] — Client-credentials flow via Bagdock.withClientCredentials(...); optional issuer and baseUrl overload
baseUrl String https://api.bagdock.com/api/v1 API base URL

Documentation

License

MIT — see LICENSE

About

Official Bagdock API client for Java

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages