Skip to content

zold-io/zold-ruby-sdk

Repository files navigation

EO principles respected here DevOps By Rultor.com We recommend RubyMine

rake PDD status Gem Version Test Coverage Yard Docs License Hits-of-Code

Here is the White Paper.

Join our Telegram group to discuss it all live.

This is a simple Ruby SDK for making payments, checking balances, and finding transactions in Zold wallets via WTS system.

There are other languages too: Java SDK.

First, you install it:

gem install zold-ruby-sdk

Then, you get your API key here.

The, you make an instance of class Zold::WTS:

require 'zold/wts'
wts = Zold::WTS.new(key)

Now you can pull your wallet and then check its balance:

job = wts.pull # Initiate PULL and returns the unique ID of the job
wts.wait(job) # Wait for the job to finish
b = wts.balance # Retrieve the balance as an instance of Zold::Amount
puts b

To make a payment you will need to know your keygap:

job = wts.pay(keygap, 'yegor256', '19.95', 'For pizza') # Initiate a payment request
wts.wait(job) # Wait for the job to finish

To find a payment in your wallet, you do this (don't forget to pull first):

# Finds all payments that match this query and returns
# an array of Zold::Txn objects.
txns = wts.find(id: '123', details: /pizza/)

That's it.

How to contribute

Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 2.3+ and Bundler installed. Then:

$ bundle update
$ bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.