Runa Ruby Client
A simple client for Runa.io B2B Synchronous API (Document Version 1.7).
Installation
Add this line to your application's Gemfile:
gem 'runa-ruby-client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install runa-ruby-client
Usage
Simple example for ordering a Digital Card
client = Runa::Client.new(
:api_host => 'https://playground.runa.io',
:api_path => '/api/b2b-sync/v1',
:api_key => ENV['AUTH_NAME'],
:api_secret => ENV['AUTH_PASS'],
:proxy => ENV['PROXY']
)
get_products = client.products
if get_products.is_successful?
vouchers = products.all
else
end
product = client.products('PROD-ID')
product.description
product.redeem_instructions_html
product.e_code_usage_type
order = client.order(
:product_code => product.code,
:currency_code => 'USD',
:amount => '42.00',
:delivery_method => 'direct',
:delivery_format => 'raw',
:external_ref => '123'
)
if order.is_successful?
order.code
order.order_id
order.pin
order.barcode_format
order.barcode_string
order.expiry_date
order.delivery_url
end
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Testing
Run it!
rspec
It will load all tapes found in spec/tapes
, we are using VCR.
To remaster all recordings, you will need a playground account.
Add an .env
file to your root:
AUTH_NAME='playground_username'
AUTH_PASS='playground_password'
PROXY='proxy_uri'
Start the VCR with rspec
- this should add all Tapes to spec/tapes
.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mo-work/runa-ruby-client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.