This is a ruby wrapper for Lago API
| Project | Release Badge |
|---|---|
| Lago | |
| Lago Ruby Client |
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
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.
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.
bundle installThis is not necessary if you use the Docker Compose file, as it will install the dependencies for you.
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.
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 rspecbundle 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 -AThe Lago documentation is available at doc.getlago.com.
The contribution documentation is available here
Lago Ruby client is distributed under MIT license.