Thanks to visit codestin.com
Credit goes to github.com

Skip to content

UniBee-Billing/unibee-ruby-client

Repository files navigation

UniBee Ruby SDK

The official Ruby library for the UniBee Billing API. It provides a simple way to integrate subscriptions, invoices, payments, users, plans, and more into your Ruby application.

Documentation

Installation

Add the gem to your application:

# Gemfile
gem 'unibee'

Then run:

bundle install

Or install the gem directly:

gem install unibee

Requirements

  • Ruby 2.7+

Usage

Configure the client with your merchant credentials (from the UniBee Dashboard):

require 'unibee'

# Default host is https://api.unibee.top
Unibee.configure do |config|
  config.api_key['Authorization'] = 'your_merchant_api_key'
end

Examples

List subscriptions:

api = Unibee::SubscriptionApi.new
response = api.subscription_list_get
# => subscription list response

Get a single invoice:

api = Unibee::InvoiceApi.new
invoice = api.invoice_detail_get(invoice_id)

List plans:

api = Unibee::PlanApi.new
plans = api.plan_list_get

Create a checkout session:

api = Unibee::CheckoutSetupApi.new
req = Unibee::UnibeeApiMerchantCheckoutSetupReq.new(
  plan_id: plan_id,
  user_id: user_id,
  success_url: 'https://yoursite.com/success',
  cancel_url: 'https://yoursite.com/cancel'
)
result = api.checkout_setup_post(req)

Per-request configuration

You can pass options to a single request instead of using the global config:

api = Unibee::MerchantApi.new
api.merchant_detail_get(Unibee::ApiClient.new(Unibee.configure))

Or build a dedicated client:

config = Unibee::Configuration.new
config.api_key['Authorization'] = 'another_key'
config.host = 'https://api.unibee.top'
client = Unibee::ApiClient.new(config)
api = Unibee::SubscriptionApi.new(client)
api.subscription_list_get

Error handling

begin
  api.invoice_detail_get(invoice_id)
rescue Unibee::ApiError => e
  puts "HTTP status: #{e.code}"
  puts "Response: #{e.response_body}"
end

Configuration

Option Description Default
host API base URL https://api.unibee.top
api_key Auth header key/value
scheme http or https https
timeout Request timeout (sec)
Unibee.configure do |config|
  config.host = 'https://api.unibee.top'
  config.api_key['Authorization'] = 'Bearer your_key'
  config.debugging = false
end

License

MIT. See LICENSE for details.

About

Unibee ruby client. Repo which will help client with integration of API for their source code

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors