{"id":19030630,"url":"https://github.com/hackclub/increase-ruby","last_synced_at":"2025-04-23T16:06:47.570Z","repository":{"id":142628967,"uuid":"613813944","full_name":"hackclub/increase-ruby","owner":"hackclub","description":"Ruby API client for Increase, a platform for Bare-Metal Banking APIs","archived":false,"fork":false,"pushed_at":"2024-02-12T19:11:32.000Z","size":267,"stargazers_count":8,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-23T16:06:40.967Z","etag":null,"topics":["api","banking","fintech","increase","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/increase","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackclub.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-14T10:23:00.000Z","updated_at":"2024-07-30T01:47:52.000Z","dependencies_parsed_at":"2024-11-08T21:19:10.763Z","dependency_job_id":"86fd7dc5-2b7b-41c5-a057-d8fb8b0e0940","html_url":"https://github.com/hackclub/increase-ruby","commit_stats":null,"previous_names":["garyhtou/increase-ruby"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fincrease-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fincrease-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fincrease-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackclub%2Fincrease-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackclub","download_url":"https://codeload.github.com/hackclub/increase-ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250468272,"owners_count":21435452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","banking","fintech","increase","ruby"],"created_at":"2024-11-08T21:18:57.632Z","updated_at":"2025-04-23T16:06:47.537Z","avatar_url":"https://github.com/hackclub.png","language":"Ruby","readme":"# Increase\n\n_A Ruby API client for [Increase](https://increase.com/), a platform for\nBare-Metal Banking APIs!_\n\nInteract with Increase's API in a simple and Ruby-like manner.\n\n🏦 Battle-tested at [HCB](https://hackclub.com/hcb/)\n\n- [Installation](#installation)\n- [Usage](#usage)\n    - [Per-request Configuration](#per-request-configuration)\n    - [Pagination](#pagination)\n    - [Error Handling](#error-handling)\n    - [Configuration](#configuration)\n    - [File Uploads](#file-uploads)\n    - [Webhooks](#webhooks)\n    - [Idempotency](#idempotency)\n- [Development](#development)\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```sh\n$ bundle add increase -v 0.3.2\n```\n\nIf bundler is not being used to manage dependencies, install the gem by\nexecuting:\n\n```sh\n$ gem install increase -v 0.3.2\n```\n\n## Usage\n\n```ruby\nrequire 'increase'\n\n# Grab your API key from https://dashboard.increase.com/developers/api_keys\nIncrease.api_key = 'my_api_key'\nIncrease.base_url = 'https://api.increase.com'\n\n# List transactions\nIncrease::Transactions.list\n\n# Retrieve a transaction\nIncrease::Transactions.retrieve('transaction_1234abcd')\n\n# Create an ACH Transfer\nIncrease::AchTransfers.create(\n  account_id: 'account_1234abcd',\n  amount: 100_00, # 10,000 cents ($100 dollars)\n  routing_number: '123456789',\n  account_number: '9876543210',\n  statement_descriptor: 'broke the bank for some retail therapy'\n)\n```\n\n### Per-request Configuration\n\nBy default, the client will use the global API key and configurations. However,\nyou can define a custom client to be used for per-request configuration.\n\nFor example, you may want access to production and sandbox data at the same\ntime.\n\n```ruby\nsandbox = Increase::Client.new(\n  api_key: 'playing_it_safe',\n  base_url: 'https://sandbox.increase.com'\n)\n\n# This request will use the `sandbox` client and its configurations\nIncrease::Transactions.with_config(sandbox).list\n# =\u003e [{some sandbox transactions here}, {transaction}, {transaction}, ...]\n\n# This request will still use the global configurations (using production key)\nIncrease::Transactions.list\n# =\u003e [{some production transactions here}, {transaction}, {transaction}, ...]\n```\n\nAlternatively, directly passing as hash to `with_config` works too!\n\n```ruby\nIncrease::Transactions.with_config(api_key: 'time_is_money', base_url: :sandbox).list\n# =\u003e [{some sandbox transactions here}, {transaction}, {transaction}, ...]\n```\n\nSee the [Configuration](#configuration) section for more information on the\navailable configurations.\n\n### Pagination\n\nWhen listing resources (e.g. transactions), **Increase** limits the number of\nresults per page to 100. Luckily, the client will automatically paginate through\nall the results for you!\n\n```ruby\nIncrease::Transactions.list(limit: :all) do |transactions|\n  # This block will be called once for each page of results\n  puts \"I got #{transactions.count} transactions!\"\nend\n\n# Or, if you'd like a gargantuan array of all the transactions\nIncrease::Transactions.list(limit: :all)\n\n# You can also use the `next_cursor` to manually paginate through the results\ntxns = Increase::Transactions.list(\n  limit: 2_000,\n  'created_at.after': '2022-01-15T06:34:23Z'\n)\n# =\u003e [{transaction}, {transaction}, {transaction}, ...]\ntxns.next_cursor\n# =\u003e \"eyJwb2NpdGlvbiI6eyJvZmlzZXQiOjEwMH0sIm3pbHRlclI6e319\"\n```\n\nWatch out for the rate limit!\n\n### Error Handling\n\nWhenever you make an oopsie, the client will raise an error! Errors originating\nfrom the API will be a subclass of `Increase::ApiError`.\n\n```ruby\n\nbegin\n  Increase::Transactions.retrieve('i_dont_exist')\nrescue Increase::ApiError =\u003e e\n  puts e.message # \"[404: object_not_found_error] Could not find the ...\"\n  puts e.title # \"Could not find the specified object.\"\n  puts e.detail # \"No resource of type transaction was found with ID ...\"\n  puts e.status # 404\n\n  puts e.response # This contains the full response, including headers!\n  # =\u003e #\u003cFaraday::Response:0x000000010b1fe2b0 ...\u003e\n\n  puts e.class # Increase::ObjectNotFoundError (subclass of Increase::ApiError)\nend\n```\n\nTo disable this behavior, set `Increase.raise_api_errors = false`. Errors will\nthen be returned as a normal response.\n\n```ruby\nIncrease.raise_api_errors = false # Default: true\n\nIncrease::Transactions.retrieve('i_dont_exist')\n# =\u003e {\"status\"=\u003e404, \"type\"=\u003e\"object_not_found_error\", ... }\n```\n\n### Configuration\n\n| Name                 | Description                                                                                                                                                                                                                                                     | Default                      |\n|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------|\n| **api_key**          | Your Increase API Key. Grab it from https://dashboard.increase.com/developers/api_keys                                                                                                                                                                          | `nil`                        |\n| **base_url**         | The base URL for Increase's API. You can use `:production` (https://api.increase.com), `:sandbox` (https://sandbox.increase.com), or set an actual URL                                                                                                          | `\"https://api.increase.com\"` |\n| **raise_api_errors** | Whether to raise an error when the API returns a non-2XX status. Learn more about Increase's errors [here](https://increase.com/documentation/api#errors). See error classes [here](https://github.com/garyhtou/increase-ruby/blob/main/lib/increase/errors.rb) | `true`                       |\n\nThere are multiple syntaxes for configuring the client. Choose your favorite!\n\n```ruby\n# Set the configurations directly\nIncrease.api_key = 'terabytes_of_cash' # Default: nil (you'll need one tho!)\nIncrease.base_url = :production # Default: :production\nIncrease.raise_api_errors = true # Default: true\n\n# Or, you can pass in a hash\nIncrease.configure(api_key: 'just_my_two_cents')\n\n# Or, you can use a block!\nIncrease.configure do |config|\n  config.api_key = 'digital_dough'\n  config.base_url = :sandbox # Default: :production\n  config.raise_api_errors = false # Default: true\nend\n```\n\nIf you are using Rails, the recommended way is to set your configurations as a\nblock in an initializer.\n\n```ruby\n# config/initializers/increase.rb\n\nIncrease.configure do |config|\n  # Your Increase API Key!\n  # Grab it from https://dashboard.increase.com/developers/api_keys\n  config.api_key = Rails.application.credentials.dig(:increase, :api_key)\n\n  # The base URL for Increase's API.\n  # You can use\n  # - :production (https://api.increase.com)\n  # - :sandbox (https://sandbox.increase.com)\n  # - or set an actual URL\n  config.base_url = Rails.env.production? ? :production : :sandbox\n\n  # Whether to raise an error when the API returns a non-2XX status.\n  # If disabled (false), the client will return the error response as a normal,\n  # instead of raising an error.\n  # \n  # Learn more about...\n  # - Increase's errors: https://increase.com/documentation/api#errors\n  # - Error classes: https://github.com/garyhtou/increase-ruby/blob/main/lib/increase/errors.rb\n  config.raise_api_errors = true # Default: true\nend\n```\n\n### File Uploads\n\nIt's as simple as passing in a file path!\n\n```ruby\nIncrease::Files.create(\n  purpose: 'identity_document',\n  file: '/path/to/file.jpg'\n) \n```\n\nAlternatively, you can pass in a `File` object.\n\n```ruby\nfile = File.open('/path/to/file.jpg')\n\nIncrease::Files.create(\n  purpose: 'identity_document',\n  file: file\n) \n```\n\nOr, get even fancier and use `Increase::FileUpload` to specify the content type\nand filename.\n\n```ruby\nfile = Increase::FileUpload.new(\n  '/path/to/file.jpg',\n  content_type: 'image/jpeg',\n  filename: 'my_file.jpg'\n)\n\nIncrease::Files.create(\n  purpose: 'identity_document',\n  file: file\n) \n```\n\nIf no content type or filename is provided, the client will try to guess it.\n\n### Webhooks\n\n**Increase**'s webhooks include a `Increase-Webhook-Signature` header for\nsecuring your webhook endpoint. Although not required, it's strongly recommended\nthat you verify the signature to ensure the request is coming from **Increase**.\n\nHere is an example for Rails.\n\n```ruby\n\nclass IncreaseController \u003c ApplicationController\n  protect_from_forgery except: :webhook # Ignore CSRF checks\n\n  def webhook\n    payload = request.body.read\n    sig_header = request.headers['Increase-Webhook-Signature']\n    secret = Rails.application.credentials.dig(:increase, :webhook_secret)\n\n    Increase::Webhook::Signature.verify(\n      payload: payload,\n      signature_header: sig_header,\n      secret: secret\n    )\n\n    # It's a valid webhook! Do something with it...\n\n    render json: {success: true}\n\n  rescue Increase::WebhookSignatureVerificationError =\u003e e\n    render json: {error: 'Webhook signature verification failed'}, status: :bad_request\n  end\nend\n```\n\n### Idempotency\n\n**Increase**\nsupports [idempotent requests](https://increase.com/documentation/api#idempotency)\nto allow for safely retrying requests without accidentally performing the same\noperation twice.\n\n```ruby\ncard = Increase::Cards.create(\n  {\n    # Card parameters\n    account_id: 'account_1234abcd',\n    description: 'My Chipotle card'\n  },\n  {\n    # Request headers\n    'Idempotency-Key': 'use a V4 UUID here'\n  }\n)\n# =\u003e {\"id\"=\u003e\"card_1234abcd\", \"type\"=\u003e\"card\", ... }\n\ncard.idempotent_replayed\n# =\u003e nil\n\n# Repeat the exact same request\ncard = Increase::Cards.create(...)\n# =\u003e {\"id\"=\u003e\"card_1234abcd\", \"type\"=\u003e\"card\", ... }\n\ncard.idempotent_replayed\n# =\u003e \"true\"\n```\n\nReusing the key in subsequent requests will return the same response code and\nbody as the original request along with an additional HTTP\nheader (`Idempotent-Replayed: true`). This applies to both success and error\nresponses. In situations where your request results in a validation error,\nyou'll need to update your request and retry with a new idempotency key.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then,\nrun `rake spec` to run the tests. You can also run `bin/console` for an\ninteractive prompt that will allow you to experiment.\n\nYou can also\nrun `INCREASE_API_KEY=my_key_here INCREASE_BASE_URL=https://sandbox.increase.com bin/console`\nto run the console with your Increase sandbox API key pre-filled.\n\nTo install this gem onto your local machine, run `bundle exec rake install`.\n\nTo release a new version:\n\n- `gem bump --version patch|minor|major`\n    - Make sure you\n      have [`gem-release`](https://github.com/svenfuchs/gem-release)\n      installed\n- Update the CHANGELOG and README if necessary\n- `bundle exec rake release`\n- Create release on GitHub from newly created tag\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub\nat https://github.com/garyhtou/increase.\n\n## License\n\nThe gem is available as open source under the terms of\nthe [MIT License](https://github.com/hackclub/increase-ruby/blob/main/LICENSE.txt).\n\n---\n\nPlease note that this is not an official library by **Increase**. This gem was\ncreated and maintained by [Gary Tou](https://garytou.com/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackclub%2Fincrease-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackclub%2Fincrease-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackclub%2Fincrease-ruby/lists"}