|
| 1 | +## Overview |
| 2 | + |
| 3 | +This is the Adyen Ruby API Library, providing Ruby developers with an easy way to interact with the Adyen API. The library is a wrapper around the Adyen API, with services generated from OpenAPI specifications. |
| 4 | + |
| 5 | +## Code Generation |
| 6 | + |
| 7 | +A significant portion of this library, particularly the API services, is automatically generated. |
| 8 | + |
| 9 | +- **Engine**: We use [OpenAPI Generator](https://openapi-generator.tech/) with custom [Mustache](https://mustache.github.io/) templates to convert Adyen's OpenAPI specifications into Ruby code. |
| 10 | +- **Templates**: The custom templates are located in the `/templates` directory. These templates are tailored to fit our custom HTTP client and service structure. |
| 11 | +- **Automation**: |
| 12 | + - **Centralized**: The primary generation process is managed in a separate repository, [`adyen-sdk-automation`](https://github.com/Adyen/adyen-sdk-automation). Changes to the OpenAPI specs trigger a GitHub workflow in that repository, which generates the code and opens Pull Requests in this library. |
| 13 | + - **Local**: For development and testing, you must use the [`adyen-sdk-automation`](https://github.com/Adyen/adyen-sdk-automation) repository. |
| 14 | + |
| 15 | +### Local Code Generation |
| 16 | + |
| 17 | +To test new features or changes to the templates, you must run the generation process from a local clone of the `adyen-sdk-automation` repository. |
| 18 | + |
| 19 | +1. **Clone the automation repository**: |
| 20 | + ```bash |
| 21 | + git clone https://github.com/Adyen/adyen-sdk-automation.git |
| 22 | + ``` |
| 23 | + |
| 24 | +2. **Link this library**: The automation project needs to target your local clone of `adyen-ruby-api-library`. From inside the `adyen-sdk-automation` directory, run the following commands. This will replace the `ruby/repo` directory with a symlink to your local project. |
| 25 | + ```bash |
| 26 | + rm -rf ruby/repo |
| 27 | + ln -s /path/to/your/adyen-ruby-api-library ruby/repo |
| 28 | + ``` |
| 29 | + |
| 30 | +3. **Run the generator**: You can now run the Gradle commands to generate code. |
| 31 | + - **To generate all services for the Ruby library**: |
| 32 | + ```bash |
| 33 | + ./gradlew :ruby:services |
| 34 | + ``` |
| 35 | + - **To generate a single service (e.g., Checkout)**: |
| 36 | + ```bash |
| 37 | + ./gradlew :ruby:checkout |
| 38 | + ``` |
| 39 | + - **To clean the repository before generating**: |
| 40 | + ```bash |
| 41 | + ./gradlew :ruby:cleanRepo :ruby:checkout |
| 42 | + ``` |
| 43 | + |
| 44 | +## Core Components |
| 45 | + |
| 46 | +- **`Adyen::Client`**: The main class in `lib/adyen/client.rb` that provides easy access to all API services and handles configuration (API key, environment, etc.). |
| 47 | +- **`Adyen::Service`**: The base class located in `lib/adyen/services/service.rb` from which all generated services inherit. It contains the logic for making API calls. |
| 48 | +- **`lib/adyen/services/`**: This directory contains the generated service classes (e.g., `Checkout`, `Management`) that expose methods for specific API endpoints. This library does not use generated models for requests and responses; standard Ruby Hashes are used instead. |
| 49 | + |
| 50 | +## Development Workflow |
| 51 | + |
| 52 | +### Setup |
| 53 | + |
| 54 | +To install the library and its development dependencies, run: |
| 55 | +```bash |
| 56 | +bundle config set with development |
| 57 | +bundle install |
| 58 | +``` |
| 59 | + |
| 60 | +### Running Tests |
| 61 | + |
| 62 | +To run the RSpec test suite, use the following command: |
| 63 | +```bash |
| 64 | +bundle exec rspec |
| 65 | +``` |
| 66 | +This is the command used in our GitHub Actions workflow to ensure code quality and correctness. |
| 67 | + |
| 68 | +## Release Process |
| 69 | + |
| 70 | +The release process is automated via GitHub Actions and involves two main workflows: |
| 71 | + |
| 72 | +1. **Release PR Creation**: After a pull request is merged to `main`, the `release.yml` workflow automatically creates a new pull request that bumps the version number in `lib/adyen/version.rb`. |
| 73 | +2. **Publishing to RubyGems**: Once the version bump PR is merged, a maintainer can create a GitHub Release. This can be done by manually running the `Release` workflow with the `github-release` option. The creation of a published release on GitHub triggers the `rubygems_release.yml` workflow, which publishes the new version of the gem to RubyGems. |
0 commit comments