Overview


Nurego-Ruby is simple Ruby bindings library allows easy access to Nurego system, without any hassle of dealing with REST APIs and object mapping. Each object in the system has its own Ruby representation. There are relationships between some of them and they can be traversed using Nurego-Ruby API. The following objects can be used by the customers of Nurego-Ruby:
  • Bill
  • Connector
  • Customer
  • Entitlement
  • Feature
  • Instance
  • Offering
  • Organization
  • Password Reset
  • Payment Method
  • Plan
  • Registration
Some of the objects allow simple CRUD (or subset of it), when the others hide more complex operations like password reset.

Initialization

<span style="color:#400000; ">require</span> “nurego”
Nurego<span style="color:#308080; ">.</span>api_key <span style="color:#308080; ">=</span> “l230bc7b<span style="color:#308080; ">-</span>9b85<span style="color:#308080; ">-</span>4c5f<span style="color:#308080; ">-</span>ad9f<span style="color:#308080; ">-</span>4eeeef4d4f44”

Your API key can be obtained from Settings/Organization

Authorization


Some of the operations require customer login (TBD)

Error handling


Several errors can be thrown by the library. The base class for all Nurego errors is Nurego::NuregoError

Additional error that can be thrown by the library are:

Nurego::APIConnectionError - failed to connect to the Nurego API endpoing
Nurego::APIErrror - bad response from API endpoint
Nurego::CardError - invalid token was provided
Nurego::UserNotFoundError - user not found
Nurego::InvalidRequestError - the request to the API endpoint was bad or had wrong arguments
Nurego::AuthenticationError - bad API key or username/password was provided


Entitlement


To use an entitlement object you need to obtain customer external ID. In case of Stripe it will be Stripe customer ID (guid starting with cus_

Get entitlement for customer
<span style="color: rgb(16, 96, 182);">

Get entitlements for customer and feature

Submit usage for customer

Check allowed usage for customer

Feature


Response will look like this

Offering

Retrieve the current offering for the 'All' segment through the 'website' distribution channel.

To retrieve offerings available for a particular segment and/or distribution channel, add the optional :segment_guid and/or :distribution_channel parameters. To learn more about segments and distribution channels, take a look at the documentation
Response will look like this
<span style="color: rgb(16, 96, 182);">

Plan

The :distribution_channel and :segment_guid params are optional. Use them to call plans for a specific distribution channel and/or segment. To learn more about creating segments and distribution channels, check out the documentation