Xooa Ruby SDK

This repository contains Xooa Ruby SDK to connect with the Xooa Blockchain PaaS.

This SDK refers to APIs available for Xooa platform. For more details, refer: https://api.xooa.com/explorer

The platform documentation is available at https://docs.xooa.com

Installation

There are two ways to install the xooa-sdk gem in your project.

You can install the latest code for the xooa-sdk gem in a project by including this line in your Gemfile:

    gem "xooa-sdk", :git => "git://https://github.com/Xooa/xooa-ruby-sdk.git"

Installing a gem directly from a git repository is a feature of Bundler, not a feature of RubyGems. Gems installed this way will not show up when you run gem list.

The other way to install xooa-sdk is to add this line to your application's Gemfile:

    gem 'xooa-sdk', '~> 1.0'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install xooa-sdk

Usage


XooaClient

    require 'xooa'

    Xooa::XooaClient

This is the base class of Xooa Ruby SDK. This class contains all the methods made available by the SDK.

Summary


Properties

API Token

The API Token for the app provided on Xooa Platform when you deploy an app there. You can also regenerate a new API Token for an Identity by going to Identities tab in the app and clicking on Actions -> Regenerate API Token.

    attr_accessor :apiToken
App URL

The App URL where the app is deployed. It is default to Xooa. You can change it if you want to test your app in a local environment.

    attr_accessor :appUrl
Debugging

instance variable to set logging level to debugging.

    attr_accessor :debugging

Constructors

initialize
    def initialize

Default Constructor of XooaClient.

initialize(apiToken, appUrl)
      def initialize(apiToken, appUrl = "https://api.xooa.com/api/v1")

Constructor to create a XooaClient object with the given API Token and App Url. It sets the default value for app url to Xooa.

Methods

validate
     def validate

Method to Validate if the given API Token is valid or not.

Return - IdentityResponse Instance of IdentityResponse giving details about the identity.

Throws - XooaApiException XooaRequestTimeoutException giving the error code and error message.

subscribe(callback)
    def subscribe(callback)

Method to subscribe to events generated in the smart contract. This method requires a callback method which decides what to do when an event is received.

unsubscribe
    def unsubscribe

Method to unsubscribe the events from the smart contract.

invoke(functionName, args, timeout = "4000")
   def invoke(functionName, args, timeout = "4000")

Method to Invoke blockchain to submit transactions. For more details refer Xooa Invoke API.

Return - InvokeResponse Instance of Invoke Response giving Transaction Id and Payload returned by the smart contract.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

invokeAsync(functionName, args)
    def invokeAsync(functionName, args)

Method to Invoke blockchain in async mode to submit transactions. For more details refer Xooa Invoke API.

Return - PendingTransactionResponse Instance of PendingTransactionResponse giving result id and result url for pending transaction.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message.

query(functionName, args, timeout = "4000")
    def query(functionName, args, timeout = "4000")

Method to Query blockchain to fetch state for arguments. For more details refer Xooa Query API.

Return - QueryResponse Instance of QueryResponse giving payload returned by the smart contract.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

queryAsync(functionName, args)
    def queryAsync(functionName, args)

Method to Query blockchain in async mode to fetch state for arguments. For more details refer Xooa Query API.

Return - PendingTransactionResponse Instance of PendingTransactionResponse giving result id and result url for pending transaction.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message.

currentIdentity(timeout = "4000")
    def currentIdentity(timeout = "4000")

Method to get the authenticating identity details. For more details refer Authenticated Identity.

Return - IdentityResponse Instance of IdentityResponse giving details about the identity.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getIdentities(timeout = "4000")
    def getIdentities(timeout = "4000")

Method to get a list of all the identities associated with the app. For more details refer Get All Identitites.

Return - List List containing all the instances of IdentityResponse.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

enrollIdentity(identityRequest, timeout = "4000")
    def enrollIdentity(identityRequest, timeout = "4000")

Method to enroll a new identity for the app. For more details refer Enroll Identity.

Return - IdentityResponse Instance of IdentityResponse giving details about the new identity.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

enrollIdentityAsync(identityRequest)
    def enrollIdentityAsync(identityRequest)

Method to enroll a new identity for the app in async mode. For more details refer Enroll Identity.

Return - PendingTransactionResponse Instance of PendingTransactionResponse giving result id and result url for pending transaction.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message.

regenerateIdentityApiToken(identityId, timeout = "4000")
    def regenerateIdentityApiToken(identityId, timeout = "4000")

Method to regenerate a new API Token for the given identity id. For more details refer Regenerate Token.

Return - IdentityResponse Instance of IdentityResponse giving details about the new identity.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getIdentity(identityId, timeout = "4000")
    def getIdentity(identityId, timeout = "4000")

Method to get Identity details for the given identity id. For more details refer Identity Information.

Return - IdentityResponse Instance of IdentityResponse giving details about the new identity.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

deleteIdentity(identityId, timeout = "4000")
    def deleteIdentity(identityId, timeout = "4000")

Method to delete the identity from the app for the given identity id. For more details refer Delete Identity.

Return - Boolean True if identity was deleted false otherwise.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getCurrentBlock(timeout = "4000")
    def getCurrentBlock(timeout = "4000")

Method to get the block number and hashes of current (highest) block. For more details refer Get Current Block.

Return - CurrentBlockResponse Instance of CurrentBlockResponse giving the block number and hashes of current block.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getCurrentBlockAsync
    def getCurrentBlockAsync

Method to get the block number and hashes of current (highest) block in async mode. For more details refer Get Current Block.

Return - PendingTransactionResponse Instance of PendingTransactionResponse giving result id and result url for pending transaction.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message.

getBlockByNumber(blockNumber, timeout = "4000")
    def getBlockByNumber(blockNumber, timeout = "4000")

Method to get the block number and hashes of the block number. For more details refer Get Block.

Return - BlockResponse Instance of BlockResponse giving the block number and hashes of the block.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getBlockByNumberAsync(blockNumber)
    def getBlockByNumberAsync(blockNumber)

Method to get the block number and hashes of the block number in async mode. For more details refer Get Block.

Return - PendingTransactionResponse Instance of PendingTransactionResponse giving result id and result url for pending transaction.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message.

getTransactionByTransactionId(transactionId, timeout = "4000")
    def getTransactionByTransactionId(transactionId, timeout = "4000")

Method to get the transaction details for the transaction id. For more details refer Get Transaction By TransactionId.

Return - TransactionResponse Instance of TransactionResponse giving the details about the transaction.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getTransactionByTransactionIdAsync(transactionId)
    def getTransactionByTransactionIdAsync(transactionId)

Method to get the transaction details for the transaction id in async mode. For more details refer Get Transaction By TransactionId.

Return - PendingTransactionResponse Instance of PendingTransactionResponse giving result id and result url for pending transaction.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message.

getResultForInvoke(resultId, timeout = "4000")
    def getResultForInvoke(resultId, timeout = "4000")

Method to get Invoke Response for a request in pending state. For more detials refer Result API.

Return - InvokeResponse Instance of InvokeResponse giving the transaction id and payload.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getResultForQuery(resultId, timeout = "4000")
    def getResultForQuery(resultId, timeout = "4000")

Method to get Query Response for a request in pending state. For more detials refer Result API.

Return - QueryResponse Instance of QueryResponse giving the payload.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getResultForIdentities(resultId, timeout = "4000")
    def getResultForIdentities(resultId, timeout = "4000")

Method to get Identity Response for a request in pending state. For more detials refer Result API.

Return - IdentityResponse Instance of IdentityResponse giving the details related to the identity.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getResultForCurrentBlock(resultId, timeout = "4000")
    def getResultForCurrentBlock(resultId, timeout = "4000")

Method to get CurrentBlockResponse for a request in pending state. For more detials refer Result API.

Return - CurrentBlockResponse Instance of CurrentBlockResponse giving the block number and hashes for the current block.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getResultForBlockByNumber(resultId, timeout = "4000")
    def getResultForBlockByNumber(resultId, timeout = "4000")

Method to get BlockResponse for a request in pending state. For more detials refer Result API.

Return - BlockResponse Instance of BlockResponse giving the block number and hashes for the block.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.

getResultForTransaction(resultId, timeout = "4000")
    def getResultForTransaction(resultId, timeout = "4000")

Method to get TransactionResponse for a request in pending state. For more detials refer Result API.

Return - TransactionResponse Instance of TransactionResponse giving the transaction details for the transaction id.

Throws - XooaApiException - Instance of XooaApiException giving the error code and error message. XooaRequestTimeoutException - Instance of XooaRequestTimeoutException giving result id and result url for pending transaction.