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_coupons
For 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 -d
This will boot a Lago instance (to run integration tests) and a container with the Lago Ruby Client code.
Install the dependencies
bundle install
This 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_ENABLED
environment variable totrue
and provide theTEST_LAGO_API_URL
andTEST_LAGO_API_KEY
environment 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 rspec
or with Docker Compose:
docker compose exec client bundle exec rspec
Linting
bundle exec rubocop
or with Docker Compose:
docker compose exec client bundle exec rubocop
To format the code, run:
bundle exec rubocop -a # or -A
or with Docker Compose:
docker compose exec client bundle exec rubocop -a # or -A
Documentation
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.