stigg-sidecar-sdk
Stigg Ruby SDK makes it easier to interact with Stigg Sidecar
Documentation
See https://docs.stigg.io/docs/sidecar-sdk
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add stigg-sidecar-sdk
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install stigg-sidecar-sdk
Usage
Initialize the client:
require("stigg_sidecar_sdk")
api_key = ENV["STIGG_SERVER_API_KEY"]
client = Stigg::Sidecar.create_client(Stigg::Sidecar::ApiConfig.new(api_key),
remote_sidecar_host: "localhost",
remote_sidecar_port: 8443)
Get single entitlement of a customer
require("stigg_sidecar_sdk")
client = Stigg::Sidecar.create_client(Stigg::Sidecar::ApiConfig.new(api_key))
entitlement = client.get_metered_entitlement(
Stigg::Sidecar::V1::GetMeteredEntitlementRequest.new(customer_id: "customer-demo-01",
feature_id: "feature-01-templates",
options: Stigg::Sidecar::V1::MeteredEntitlementOptions.new(
requested_usage: 1
))
)
p "Has access: #{entitlement.has_access}"
Accessing the api
client:
client = Stigg::Sidecar.create_client(Stigg::Sidecar::ApiConfig.new(api_key))
customer_resp = client.api.request(
Stigg::Mutation::ProvisionCustomer, {
"input": {
"customerId": "customer-demo-104",
"name": "customer name"
}
}
)
p "Customer created: #{customer_resp.data.provision_customer.customer.ref_id}"