Ruby
Use Dwolla’s SDK for Ruby to build applications that interact with the Dwolla API to perform account-to-account payment functions.
Ruby
dwolla_v2
is available on RubyGems with source code available on our GitHub page.
Getting Started
Installation
To begin using this SDK, you will first need to download it to your machine. We use RubyGems to distribute this package.
Add this line to your application’s Gemfile:
And then execute:
$ bundle
Or install it yourself as:
$ gem install dwolla_v2
Initialization
Before any API requests can be made, you must first determine which environment you will be using, as well as fetch the application key and secret. To fetch your application key and secret, please visit one of the following links:
- Production: https://dashboard.dwolla.com/applications
- Sandbox: https://dashboard-sandbox.dwolla.com/applications
Finally, you can create an instance of Client
with key
and secret
replaced with the application key and secret that you fetched from one of the aforementioned links, respectively.
Configure Faraday (Optional)
Dwolla for Ruby uses Faraday to make HTTP requests. You can configure your own Faraday middleware and adapter when configuring your client. Remember to always include an adapter last, even if you want to use the default adapter.
Making Requests
Once you’ve created a Client
, currently, you can make low-level HTTP requests.
Low-level Requests
To make low-level HTTP requests, you can use the get()
, post()
, and delete()
methods.
GET
POST
DELETE
Setting Headers
To set additional headers on a request, you can pass a Hash
of headers as the 3rd argument.
For example:
Responses
The following snippets demonstrate successful and errored responses from the Dwolla API.
An errored response is returned when Dwolla’s servers respond with a status code that is greater than or equal to 400, whereas a successful response is when Dwolla’s servers respond with a 200-level status code.
Success
Successful requests return a DwollaV2::Response
.
Error
If the server returns an error, a DwollaV2::Error
(or one of its subclasses) will be raised.
DwollaV2::Error
s are similar to DwollaV2::Response
s.
DwollaV2::Error
subclasses:
See https://developers.dwolla.com/api-reference#errors for more info.
DwollaV2::AccessDeniedError
DwollaV2::InvalidCredentialsError
DwollaV2::NotFoundError
DwollaV2::BadRequestError
DwollaV2::InvalidGrantError
DwollaV2::RequestTimeoutError
DwollaV2::ExpiredAccessTokenError
DwollaV2::InvalidRequestError
DwollaV2::ServerError
DwollaV2::ForbiddenError
DwollaV2::InvalidResourceStateError
DwollaV2::TemporarilyUnavailableError
DwollaV2::InvalidAccessTokenError
DwollaV2::InvalidScopeError
DwollaV2::UnauthorizedClientError
DwollaV2::InvalidAccountStatusError
DwollaV2::InvalidScopesError
DwollaV2::UnsupportedGrantTypeError
DwollaV2::InvalidApplicationStatusError
DwollaV2::InvalidVersionError
DwollaV2::UnsupportedResponseTypeError
DwollaV2::InvalidClientError
DwollaV2::MethodNotAllowedError
DwollaV2::ValidationError
DwollaV2::TooManyRequestsError
DwollaV2::ConflictError
Community
- If you have any feedback, please reach out to us on our forums or by creating a GitHub issue.
- If you would like to contribute to this library, bug reports and pull requests are always appreciated!
- After checking out the repo, run
bin/setup
to install dependencies. Then, runrake spec
to run the tests. You can also runbin/console
for an interactive prompt that will allow you to experiment. - To install this gem onto your local machine, run
bundle exec rake install
. To release a new version, update the version number inversion.rb
, and then runbundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the.gem
file to rubygems.org.
- After checking out the repo, run
Docker
If you prefer to use Docker to run dwolla-v2-python locally, a Dockerfile is included at the root directory. Follow these instructions from Docker’s website to create a Docker image from the Dockerfile, and run it.