Lago Ruby Client
This is a ruby wrapper for Lago API
Current Releases
| Project | Release Badge |
|---|---|
| Lago | |
| Lago Ruby Client |
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
Once the gem is installed, you can use it in your Ruby application as follows:
require 'lago-ruby-client'
client = Lago::Api::Client.new(api_key: "xyz")
applied_coupons = client.applied_coupons.get_all(
page: 1,
per_page: 10,
"coupon_code[]": ["BLACK_FRIDAY", "CHRISTMAS"],
)
puts "Listing all applied coupons:"
puts applied_couponsFor detailed usage, refer to the lago API reference.
Development
Docker Compose
To simplify the development process, you can use the docker-compose.yml to run tests and lint the code.
docker compose up -dThis will boot a Lago instance (to run integration tests) and a container with the Lago Ruby Client code.
Install the dependencies
bundle installThis is not necessary if you use the Docker Compose file, as it will install the dependencies for you.
Testing
The repository includes two types of tests:
-
Unit tests which tests the Ruby code itself
-
Integration tests which tests the Ruby code against a running Lago instance.
To run these tests, you need to set the
INTEGRATION_TESTS_ENABLEDenvironment variable totrueand provide theTEST_LAGO_API_URLandTEST_LAGO_API_KEYenvironment variables. These variables are set by default when using the Docker Compose file.
Running the tests
bundle exec rspec
INTEGRATION_TESTS_ENABLED=true TEST_LAGO_API_URL=http://lago:3000 TEST_LAGO_API_KEY=123456 bundle exec rspecor with Docker Compose:
docker compose exec client bundle exec rspecLinting
bundle exec rubocopor with Docker Compose:
docker compose exec client bundle exec rubocopTo format the code, run:
bundle exec rubocop -a # or -Aor with Docker Compose:
docker compose exec client bundle exec rubocop -a # or -ADocumentation
The Lago documentation is available at doc.getlago.com.
Contributing
The contribution documentation is available here
License
Lago Ruby client is distributed under MIT license.