Skip to content

anhtho-lago/lago-ruby-client

 
 

Repository files navigation

Lago Ruby Client

This is a ruby wrapper for Lago API

Gem Version

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add lago-ruby-client

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install lago-ruby-client

Usage

require 'lago-ruby-client'

client = Lago::Api::Client.new({api_key: 'key'})

Events

Api reference

event = {
    transaction_id: "__UNIQUE_ID__",
    customer_id:  "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
    code:  "code",
    timestamp:  1650893379,
    properties: {
        custom_field: "custom"
    }
}
client.events.create(event)

Customers

Api reference

customer = {
    customer_id: "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
    address_line1: nil,
    address_line2: nil,
    city: nil,
    country: nil,
    email: "test@example.com",
    legal_name: nil,
    legal_number: nil,
    logo_url: nil,
    name: "test name",
    phone: nil,
    state: nil,
    url: nil,
    vat_rate: nil,
    zipcode: nil
}
client.customers.create(customer)

Subscriptions

Api reference

subscription = {
    customer_id: "5eb02857-a71e-4ea2-bcf9-57d8885990ba",
    plan_code: "code"
}
client.subscriptions.create(subscription)

params_delete = {
    customer_id: "5eb02857-a71e-4ea2-bcf9-57d8885990ba"
}
client.subscriptions.delete(params_delete)

Applied coupons

Api reference

applied_coupon = {
  customer_id: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
  coupon_code: "code",
  amount_cents: 123,
  amount_currency: "EUR"
}

client.applied_coupons.create(applied_coupon)

Applied add-ons

Api reference

applied_add_on = {
  customer_id: "5eb02857-a71e-4ea2-bcf9-57d3a41bc6ba",
  add_on_code: "code",
  amount_cents: 123,
  amount_currency: "EUR"
}

client.applied_add_ons.create(applied_add_on)

Development

Install the dependencies

bundle install

Run tests

bundle exec rspec

Documentation

The Lago documentation is available at doc.getlago.com.

Contributing

The contribution documentation is available here

License

Lago Ruby client is distributed under AGPL-3.0.

About

Ruby wrapper for the Lago Rest API

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.4%
  • Shell 0.6%