Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5a94369
chore(internal): protect SSE parsing pipeline from broken UTF-8 chara…
stainless-app[bot] Apr 15, 2025
eecc22b
feat(client): enable setting base URL from environment variable
stainless-app[bot] Apr 16, 2025
5bec964
fix(client): send correct HTTP path
stainless-app[bot] Apr 17, 2025
e4764d3
fix: restore ability to configure server environment as string during…
stainless-app[bot] Apr 17, 2025
314324d
chore(internal): contribute.md and contributor QoL improvements
stainless-app[bot] Apr 17, 2025
fda1fee
fix: always send idempotency header when specified as a request option
stainless-app[bot] Apr 17, 2025
f19c447
chore: refine `#inspect` and `#to_s` for model classes
stainless-app[bot] Apr 17, 2025
b0dcacf
feat(api): api update
stainless-app[bot] Apr 17, 2025
084fafd
feat(api): api update
stainless-app[bot] Apr 18, 2025
e819d32
chore: make sorbet enums easier to read
stainless-app[bot] Apr 18, 2025
214dd6b
chore: use `@!method` instead of `@!parse` for virtual method type de…
stainless-app[bot] Apr 18, 2025
f02e474
chore: simplify yard annotations by removing most `@!parse` directives
stainless-app[bot] Apr 18, 2025
e6dfa3b
chore: documentation improvements
stainless-app[bot] Apr 18, 2025
68c733d
feat: implement `#hash` for data containers
stainless-app[bot] Apr 18, 2025
7983dd2
feat(api): api update
stainless-app[bot] Apr 18, 2025
3c7848c
chore: update README with recommended editor plugins
stainless-app[bot] Apr 18, 2025
ae80e4b
feat(api): api update
stainless-app[bot] Apr 18, 2025
9f0a5dd
chore: explicitly mark apis public under `Internal` module
stainless-app[bot] Apr 19, 2025
d9594f8
chore(internal): minor type annotation improvements
stainless-app[bot] Apr 21, 2025
1429a1b
release: 0.1.0-alpha.11
stainless-app[bot] Apr 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
*.gem
.idea/
.ignore
.prism.log
.ruby-lsp/
.yardoc/
Brewfile.lock.json
bin/tapioca
Brewfile.lock.json
doc/
sorbet/*
!/sorbet/config
sorbet/tapioca/*
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.10"
".": "0.1.0-alpha.11"
}
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.1.0
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 199
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-1044f3fb430b9b4019ec3adeaa8b37e6615264fddb273a48b1d9ddd7c2b7b854.yml
openapi_spec_hash: c2526b64321711688cada903e7b4397d
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-77c909117116f16f4bd7d5596257445e57c54d288d6534fe5b11ee37126c4c34.yml
openapi_spec_hash: 29e929217173626e3edec897a5b6c5e7
config_hash: 20a463ecd33bd32b7b9bc6f4990907ac
2 changes: 2 additions & 0 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
--type-name-tag generic:Generic
--default-return void
--markup markdown
--markup-provider redcarpet
--exclude /rbi
Expand Down
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# Changelog

## 0.1.0-alpha.11 (2025-04-21)

Full Changelog: [v0.1.0-alpha.10...v0.1.0-alpha.11](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.10...v0.1.0-alpha.11)

### Features

* **api:** api update ([ae80e4b](https://github.com/Increase/increase-ruby/commit/ae80e4b0f18695b8056770456cb1e95cc3eae719))
* **api:** api update ([7983dd2](https://github.com/Increase/increase-ruby/commit/7983dd2191954ebccf1e547cc78a4bd2f47e279d))
* **api:** api update ([084fafd](https://github.com/Increase/increase-ruby/commit/084fafd7be0db3b6a1b04b54163a2d38aebacfd5))
* **api:** api update ([b0dcacf](https://github.com/Increase/increase-ruby/commit/b0dcacfc8219d7ae549a79a40f57c1af5a94b208))
* **client:** enable setting base URL from environment variable ([eecc22b](https://github.com/Increase/increase-ruby/commit/eecc22b9c93398f185f15bfe9f435df94c3c6f6f))
* implement `#hash` for data containers ([68c733d](https://github.com/Increase/increase-ruby/commit/68c733d16baadd5f069a1fc13760bb6d1f22dfa7))


### Bug Fixes

* always send idempotency header when specified as a request option ([fda1fee](https://github.com/Increase/increase-ruby/commit/fda1fee2190a625869e4fd512c0174c904bdf90d))
* **client:** send correct HTTP path ([5bec964](https://github.com/Increase/increase-ruby/commit/5bec9649252fed72bbca45f1c692552419b1813f))
* restore ability to configure server environment as string during client construction ([e4764d3](https://github.com/Increase/increase-ruby/commit/e4764d326a2ffee3c344cd63d805a47bfbb0829f))


### Chores

* documentation improvements ([e6dfa3b](https://github.com/Increase/increase-ruby/commit/e6dfa3b4b14575590012703b80fe03e4f1f5d15e))
* explicitly mark apis public under `Internal` module ([9f0a5dd](https://github.com/Increase/increase-ruby/commit/9f0a5dd4027d4d9a88f6b390e30fbda0820a262b))
* **internal:** contribute.md and contributor QoL improvements ([314324d](https://github.com/Increase/increase-ruby/commit/314324d41279d0d25657d0fc8d962c2d66341537))
* **internal:** minor type annotation improvements ([d9594f8](https://github.com/Increase/increase-ruby/commit/d9594f81d8e9e287f9a31427306b9706fde19216))
* **internal:** protect SSE parsing pipeline from broken UTF-8 characters ([5a94369](https://github.com/Increase/increase-ruby/commit/5a943694f406e0fcb99497eb587dd4d3cd0452cf))
* make sorbet enums easier to read ([e819d32](https://github.com/Increase/increase-ruby/commit/e819d322bc12b2e83396965dbd600d2ed2cf9a76))
* refine `#inspect` and `#to_s` for model classes ([f19c447](https://github.com/Increase/increase-ruby/commit/f19c4478427850bbe790c8735ffeb1ee7bc5b562))
* simplify yard annotations by removing most `@!parse` directives ([f02e474](https://github.com/Increase/increase-ruby/commit/f02e474bb85778b66357450e5b0c2c0d6d34ca8c))
* update README with recommended editor plugins ([3c7848c](https://github.com/Increase/increase-ruby/commit/3c7848ce9d097c79e47204029b1c916f0cb864e2))
* use `@!method` instead of `@!parse` for virtual method type definitions ([214dd6b](https://github.com/Increase/increase-ruby/commit/214dd6bc8aaef7e3a5aab216d6a22be1001beb54))

## 0.1.0-alpha.10 (2025-04-15)

Full Changelog: [v0.1.0-alpha.9...v0.1.0-alpha.10](https://github.com/Increase/increase-ruby/compare/v0.1.0-alpha.9...v0.1.0-alpha.10)
Expand Down
125 changes: 125 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
## Setting up the environment

This repository contains a `.ruby-version` file, which should work with either [rbenv](https://github.com/rbenv/rbenv) or [asdf](https://github.com/asdf-vm/asdf) with the [ruby plugin](https://github.com/asdf-vm/asdf-ruby).

Please follow the instructions for your preferred version manager to install the Ruby version specified in the `.ruby-version` file.

To set up the repository, run:

```bash
$ ./scripts/bootstrap
```

This will install all the required dependencies.

## Modifying/Adding code

Most of the SDK is generated code. Modifications to code will be persisted between generations, but may result in merge conflicts between manual patches and changes from the generator. The generator will never modify the contents `examples/` directory.

## Adding and running examples

All files in the `examples/` directory are not modified by the generator and can be freely edited or added to.

```ruby
#!/usr/bin/env ruby
# frozen_string_literal: true

require_relative "../lib/increase"

# ...
```

```bash
$ chmod +x './examples/<your-example>.rb'

# run the example against your api
$ ruby './examples/<your-example>.rb'
```

## Using the repository from source

If you’d like to use the repository from source, you can either install from git or reference a cloned repository:

To install via git in your `Gemfile`:

```ruby
gem "increase", git: "https://www.github.com/Increase/increase-ruby"
```

Alternatively, reference local copy of the repo:

```bash
$ git clone -- 'https://www.github.com/Increase/increase-ruby' '<path-to-repo>'
```

```ruby
gem "increase", path: "<path-to-repo>"
```

## Running commands

Running `rake` by itself will show all runnable commands.

```bash
$ bundle exec rake
```

## Running tests

Most tests require you to [set up a mock server](https://github.com/stoplightio/prism) against the OpenAPI spec to run the tests.

```bash
$ npx prism mock path/to/your/openapi.yml
```

```bash
$ bundle exec rake test
```

## Linting and formatting

This repository uses [rubocop](https://github.com/rubocop/rubocop) for linting and formatting of `*.rb` and `*.rbi` files. [syntax_tree](https://github.com/ruby-syntax-tree/syntax_tree) is used for formatting `*.rbs` files.

There are two separate type checkers supported by this library: [sorbet](https://github.com/sorbet/sorbet) and [steep](https://github.com/soutaro/steep) are used for verifying `*.rbi` and `*.rbs` files respectively.

To lint and typecheck:

```bash
$ bundle exec rake lint
```

To format and fix all lint issues automatically:

```bash
$ bundle exec rake format
```

## Editor Support

### Ruby LSP

[Ruby LSP](https://github.com/Shopify/ruby-lsp) has quite good support for go to definition, but not auto-completion.

This can be installed along side Solargraph.

### Solargraph

[Solargraph](https://solargraph.org) has quite good support for auto-completion, but not go to definition.

This can be installed along side Ruby LSP.

### Sorbet

[Sorbet](https://sorbet.org) should mostly work out of the box when editing this library directly. However, there are a some caveats due to the colocation of `*.rb` and `*.rbi` files in the same project. These issues should not otherwise manifest when this library is used as a dependency.

1. For go to definition usages, sorbet might get confused and may not always navigate to the correct location.

2. For each generic type in `*.rbi` files, a spurious "Duplicate type member" error is present.

## Documentation Preview

To preview the documentation, run:

```bash
$ bundle exec rake docs:preview [PORT=8808]
```
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
increase (0.1.0.pre.alpha.10)
increase (0.1.0.pre.alpha.11)
connection_pool

GEM
Expand Down
108 changes: 57 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "increase", "~> 0.1.0.pre.alpha.10"
gem "increase", "~> 0.1.0.pre.alpha.11"
```

<!-- x-release-please-end -->
Expand All @@ -40,6 +40,20 @@ account = increase.accounts.create(
puts(account.id)
```

## Sorbet

This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.

When using sorbet, it is recommended to use model classes as below. This provides stronger type checking and tooling integration.

```ruby
increase.accounts.create(
name: "New Account!",
entity_id: "entity_n8y8tnk2p9339ti393yi",
program_id: "program_i2v2os4mwza1oetokh9i"
)
```

### Pagination

List methods in the Increase API are paginated.
Expand Down Expand Up @@ -67,11 +81,11 @@ Request parameters that correspond to file uploads can be passed as `StringIO`,
require "pathname"

# using `Pathname`, the file will be lazily read, without reading everything in to memory
file = increase.files.create(file: Pathname("my/file.txt"), purpose: "check_image_front")
file = increase.files.create(file: Pathname("my/file.txt"), purpose: :check_image_front)

file = File.read("my/file.txt")
# using `StringIO`, useful if you already have the data in memory
file = increase.files.create(file: StringIO.new(file), purpose: "check_image_front")
file = increase.files.create(file: StringIO.new(file), purpose: :check_image_front)

puts(file.id)
```
Expand Down Expand Up @@ -149,65 +163,38 @@ increase.accounts.create(
)
```

## LSP Support

### Solargraph

This library includes [Solargraph](https://solargraph.org) support for both auto completion and go to definition.

```ruby
gem "solargraph", group: :development
```

After Solargraph is installed, **you must populate its index** either via the provided editor command, or by running the following in your terminal:

```sh
bundle exec solargraph gems
```
## Model DSL

Note: if you had installed the gem either using a `git:` or `github:` URL, or had vendored the gem using bundler, you will need to set up your [`.solargraph.yml`](https://solargraph.org/guides/configuration) to include the path to the gem's `lib` directory.
This library uses a simple DSL to represent request parameters and response shapes in `lib/increase/models`.

```yaml
include:
- 'vendor/bundle/ruby/*/gems/increase-*/lib/**/*.rb'
```

Otherwise Solargraph will not be able to provide type information or auto-completion for any non-indexed libraries.

### Sorbet

This library is written with [Sorbet type definitions](https://sorbet.org/docs/rbi). However, there is no runtime dependency on the `sorbet-runtime`.
With the right [editor plugins](https://shopify.github.io/ruby-lsp), you can ctrl-click on elements of the DSL to navigate around and explore the library.

What this means is that while you can use Sorbet to type check your code statically, and benefit from the [Sorbet Language Server](https://sorbet.org/docs/lsp) in your editor, there is no runtime type checking and execution overhead from Sorbet itself.

Due to limitations with the Sorbet type system, where a method otherwise can take an instance of `Increase::BaseModel` class, you will need to use the `**` splat operator to pass the arguments:

Please follow Sorbet's [setup guides](https://sorbet.org/docs/adopting) for best experience.
In all places where a `BaseModel` type is specified, vanilla Ruby `Hash` can also be used. For example, the following are interchangeable as arguments:

```ruby
# This has tooling readability, for auto-completion, static analysis, and goto definition with supported language services
params = Increase::Models::AccountCreateParams.new(
name: "New Account!",
entity_id: "entity_n8y8tnk2p9339ti393yi",
program_id: "program_i2v2os4mwza1oetokh9i"
)

increase.accounts.create(**params)
# This also works
params = {
name: "New Account!",
entity_id: "entity_n8y8tnk2p9339ti393yi",
program_id: "program_i2v2os4mwza1oetokh9i"
}
```

Note: **This library emits an intentional warning under the [`tapioca` toolchain](https://github.com/Shopify/tapioca)**. This is normal, and does not impact functionality.

### Ruby LSP
## Editor support

The Ruby LSP has [best effort support](https://shopify.github.io/ruby-lsp/#guessed-types) for inferring type information from Ruby code, and as such it may not always be able to provide accurate type information.
A combination of [Shopify LSP](https://shopify.github.io/ruby-lsp) and [Solargraph](https://solargraph.org/) is recommended for non-[Sorbet](https://sorbet.org) users. The former is especially good at go to definition, while the latter has much better auto-completion support.

## Advanced
## Advanced concepts

### Making custom/undocumented requests

This library is typed for convenient access to the documented API.

If you need to access undocumented endpoints, params, or response properties, the library can still be used.

#### Undocumented request params

If you want to explicitly send an extra param, you can do so with the `extra_query`, `extra_body`, and `extra_headers` under the `request_options:` parameter when making a requests as seen in examples above.
Expand All @@ -218,15 +205,15 @@ To make requests to undocumented endpoints, you can make requests using `client.

```ruby
response = client.request(
method: :post,
path: '/undocumented/endpoint',
query: {"dog": "woof"},
headers: {"useful-header": "interesting-value"},
body: {"he": "llo"},
)
method: :post,
path: '/undocumented/endpoint',
query: {"dog": "woof"},
headers: {"useful-header": "interesting-value"},
body: {"he": "llo"},
)
```

### Concurrency & Connection Pooling
### Concurrency & connection pooling

The `Increase::Client` instances are thread-safe, and should be re-used across multiple threads. By default, each `Client` have their own HTTP connection pool, with a maximum number of connections equal to thread count.

Expand All @@ -236,6 +223,21 @@ Unless otherwise specified, other classes in the SDK do not have locks protectin

Currently, `Increase::Client` instances are only fork-safe if there are no in-flight HTTP requests.

### Sorbet

#### Argument passing trick

It is possible to pass a compatible model / parameter class to a method that expects keyword arguments by using the `**` splat operator.

```ruby
params = Increase::Models::AccountCreateParams.new(
name: "New Account!",
entity_id: "entity_n8y8tnk2p9339ti393yi",
program_id: "program_i2v2os4mwza1oetokh9i"
)
increase.accounts.create(**params)
```

## Versioning

This package follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions. As the library is in initial development and has a major version of `0`, APIs may change at any time.
Expand All @@ -245,3 +247,7 @@ This package considers improvements to the (non-runtime) `*.rbi` and `*.rbs` typ
## Requirements

Ruby 3.1.0 or higher.

## Contributing

See [the contributing documentation](https://github.com/Increase/increase-ruby/tree/main/CONTRIBUTING.md).
Loading
Loading