Add usage example to README

This commit is contained in:
Adriano Caloiaroooo 2025-11-20 11:53:00 -08:00
parent 000eb69c9e
commit 3459e3e0fc
No known key found for this signature in database
5 changed files with 44 additions and 6 deletions

View file

@ -2,4 +2,39 @@
This experimental repository generates a Ruby SDK from [Kombo's OpenAPI spec](https://api.kombo.dev/openapi.json).
This is not production-ready.
## Generate code
This repo uses a nix [devenv](devenv.sh) to generate code. With `direnv` installed, run `direnv allow` inside of this
repository directory to enable the devenv.
When kombo changes their OpenAPI spec, this SDK can be updated by running `generate-sdk` inside the devenv.
## Usage
To make calls to Kombo's unified API, first create a `Kombo::Configuration` and create a client from it:
**Create a client**
```
config ||= Kombo.configure do |c|
# As far as we can tell, this value is not currently used
c.api_key = ENV['KOMBO_API_KEYY']
# The access token is used in as the Bearer token when making requests to kombo's API; it's not clear why the
# OpenAPI SDK generator doesn't use `api_key`, so for now, we are setting both until the difference between api_key
# and access_token is sorted out in the SDK generator. This might be an oddity in Komobo's upstream OpenAPI spec.
c.access_token = ENV['KOMBO_API_KEY']
c.host = 'api.us.kombo.dev' # Use api.eu.kombo.dev for instances in the EU; the default value of api.kombo.dev does not work
c
end
client = Kombo::ApiClient.new(config)
```
**Example: Get a HRIS API instance**
`hris = Kombo::UnifiedHRISAPIApi.new(client)`
**Example: Get all employees using the unified HRIS API**
`hris.get_hris_employees('<INTEGRATION ID>')`

View file

@ -1 +1 @@
v0.0.1

View file

@ -49,6 +49,10 @@
''
bundle check || bundle install
run-show-help
''
+ lib.optionalString stdenv.isDarwin ''
# Fix for https://github.com/NixOS/nixpkgs/issues/358795
unset DEVELOPER_DIR
'';
env = {
@ -114,8 +118,7 @@
echo "Fetching latest OpenAPI spec..."
curl -sSL "$SPEC_URL" -o new_openapi.json
# Using svu current to determine the last known version from git tags
# Fallback to 0.0.0 if no version is found
# Using svu current to determine the last known version
if command -v svu &> /dev/null; then
CURRENT_VERSION=$(cat $VERSION_FILE)
else
@ -138,10 +141,10 @@
NEW_VERSION=$(svu patch)
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"
sleep 10
NEW_SPEC_FILE="$SPECS_DIR/kombo-openapi-spec-$NEW_VERSION.json"
mv new_openapi.json "$NEW_SPEC_FILE"
echo "$NEW_VERSION" > "$VERSION_FILE"
echo "$NEW_VERSION" > $VERSION_FILE
echo "Generating Ruby Client..."
openapi-generator-cli generate \

View file

@ -11,5 +11,5 @@ Generator version: 7.17.0
=end
module Kombo
VERSION = ''
VERSION = 'v0.0.1'
end