Ruby SDK setup and configuration
Adding the SDK to your project
The Ruby SDK is provided as a gem named docusign_esign. By default, you will always get the latest stable version of the SDK. Prerelease versions (either release candidate (rc) or beta) can also be downloaded, as shown below.
There are three ways to add the package to your project: via your project’s Gemfile, your preferred console, or by downloading the SDK from GitHub.
Adding the Ruby SDK to your project using your project’s Gemfile
- In your application’s Gemfile, add:
gem 'docusign_esign' - Open your console, navigate to your project directory, and run:
bundle install
If desired, you can specify a version. For example, adding the following to your project’s Gemfile installs version 3.5.0 of the Docusign Ruby eSignature gem:
Adding the Ruby SDK to your project using your console
- In your console, run:
gem install docusign_esign
To specify a version using your console, you can use the -v switch as in the following example:
Downloading the SDK from the GitHub repository
This open-source SDK is available for download in cases where you would like to make changes to the SDK. You can download the SDK from GitHub using the instructions below:
-
Download or clone the SDK from the docusign-esign-ruby-client repository.
-
In the console, navigate to local_path_to_repo/docusign-esign-ruby-client and run the following command:
- Install the gem from the newly generated gem file. For example:
You can also select a different version to download from the docusign-esign-ruby-client repository’s release history.
Including the SDK library
Once you have installed the docusign_esign gem, you need to find the public classes that are required to complete various eSignature tasks. When developing with Ruby on Rails and Bundler, the following line in config/application.rb takes care of requiring all the gems specified in your Gemfile:
When using RubyGems by itself, you must add the following
require statement in your Ruby code:
To access Docusign eSignature public classes and methods in your code, use the namespace
Docusign_eSign.
Docusign eSignature API classes
These Ruby SDK classes contain endpoint categories. Each of these classes corresponds to one of the categories listed in the left menu of the eSignature REST API reference. You will need these classes to make calls to the SDK methods that initiate REST API calls to the Docusign eSignature REST API.
Note: Hereafter in the SDK documentation, the term “API object” will refer to eSignature REST API reference objects.
An
API category contains all of the methods for each API resource in that category. For example, the Ruby SDK
EnvelopesApi class includes the
create_envelope method. This method corresponds to the API Envelopes resource
create method.
The SDK’s method names roughly correspond to the API Resource:method names.
The API Reference page for each endpoint lists the corresponding SDK method associated with that endpoint. To find the Ruby SDK method that corresponds to an API Resource:method page, use the API Reference page’s
SDK Method box. The Ruby method name will be the “snake_case” version of the API SDK method name. For example, the API SDK Method
Envelopes::createEnvelope is the Ruby SDK method
create_envelope .
Docusign eSignature Model classes
These classes contain the objects used for sending and receiving data from the eSignature API endpoints. By using these classes instead of generic JSON objects, Ruby developers can develop with the Docusign eSignature API more easily and quickly than by using JSON directly.
There’s a one-to-one correspondence between the objects described in the API Reference and the classes in the Ruby Docusign eSignature Model classes. The API object names use camelCase (the first letter is lowercase) while the corresponding SDK models use PascalCase (the first letter is uppercase). For example, the API object paymentgatewayaccount corresponds to the Ruby object PaymentGatewayAccount.
Note: The API object name is often not the same as the corresponding model in the Ruby SDK.
Object attribute names in the API also use camelCase. The corresponding properties of the Ruby SDK are in “snake_case.”
Some API endpoints also use HTTP query parameters. Within the API, such query parameters use “snake_case.” For example, the
Envelopes:create API method includes an optional query parameter,
change_routing_order. Within the SDK, the API’s query parameters are added as an elective
options parameter after the request object.
Example: The
Docusign_eSign::EnvelopesApi.create_envelope method signature is:
The
CreateEnvelopeOptions class is used to set the API method’s query parameters. The class is defined as:
The class attributes in “snake_case” correspond to the API endpoint’s query parameters.
Docusign eSignature Client, OAuth, and ApiError classes
These classes are needed to manage the overall API experience. The
Client,
OAuth, and
ApiError classes, respectively, handle instantiating a client element to make API calls, authenticating, and exception handling. You will need these classes to be able to use the Docusign eSignature API correctly.
Using the SDK
To make eSignature REST API calls with the SDK, you need:
- A current access token
- The base path for the API call
- For most API calls, you’ll also need the relevant
account_id. Note that it is common for a user to be a member of multiple accounts.