Module: Boldsign

Defined in:
lib/boldsign.rb,
lib/boldsign/error.rb,
lib/boldsign/client.rb,
lib/boldsign/version.rb,
lib/boldsign/resource.rb,
lib/boldsign/access_token.rb,
lib/boldsign/case_convert.rb,
lib/boldsign/resources/plan.rb,
lib/boldsign/resources/team.rb,
lib/boldsign/resources/user.rb,
lib/boldsign/resources/brand.rb,
lib/boldsign/resources/contact.rb,
lib/boldsign/resources/document.rb,
lib/boldsign/resources/template.rb,
lib/boldsign/resources/custom_field.rb,
lib/boldsign/resources/contact_group.rb,
lib/boldsign/resources/sender_identity.rb,
lib/boldsign/resources/identity_verification.rb

Overview

Top-level namespace for the BoldSign Ruby client.

Configure once at boot and access a shared Client via Boldsign.client, or instantiate Client directly when you need multiple credentials/regions.

Examples:

Configure with OAuth and use the shared client

Boldsign.configure do |c|
  c.client_id     = ENV["BOLDSIGN_CLIENT_ID"]
  c.client_secret = ENV["BOLDSIGN_CLIENT_SECRET"]
  c.region        = :us
end
Boldsign.client.documents.list

Defined Under Namespace

Modules: CaseConvert, Resources Classes: AccessToken, AuthenticationError, BadRequestError, Client, ConfigurationError, Error, ForbiddenError, NotFoundError, RateLimitError, Resource, ServerError, UnprocessableEntityError

Constant Summary collapse

REGIONS =

Region → base URL map for BoldSign’s regional API hosts.

{
  us: "https://api.boldsign.com",
  eu: "https://api-eu.boldsign.com",
  ca: "https://api-ca.boldsign.com",
  au: "https://api-au.boldsign.com"
}.freeze
TOKEN_REGIONS =

Region → account host map for the OAuth token endpoint. Non-US hosts follow BoldSign’s regional naming; override with ‘token_url:` if a region differs.

{
  us: "https://account.boldsign.com",
  eu: "https://account-eu.boldsign.com",
  ca: "https://account-ca.boldsign.com",
  au: "https://account-au.boldsign.com"
}.freeze
DEFAULT_TOKEN_BASE_URL =

Default account host (US) for the OAuth token endpoint.

"https://account.boldsign.com".freeze
ERROR_MAP =

Maps HTTP status codes to Error subclasses.

{
  400 => BadRequestError,
  401 => AuthenticationError,
  403 => ForbiddenError,
  404 => NotFoundError,
  422 => UnprocessableEntityError,
  429 => RateLimitError
}.freeze
VERSION =
"0.5.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.access_tokenString?

Returns Pre-obtained OAuth bearer token (used as-is, not refreshed).

Returns:

  • (String, nil)

    Pre-obtained OAuth bearer token (used as-is, not refreshed).



68
69
70
# File 'lib/boldsign.rb', line 68

def access_token
  @access_token
end

.api_keyString?

Returns API key used by the shared client.

Returns:

  • (String, nil)

    API key used by the shared client.



59
60
61
# File 'lib/boldsign.rb', line 59

def api_key
  @api_key
end

.base_urlString?

Returns Optional explicit base URL override (takes precedence over region).

Returns:

  • (String, nil)

    Optional explicit base URL override (takes precedence over region).



80
81
82
# File 'lib/boldsign.rb', line 80

def base_url
  @base_url
end

.client_idString?

Returns OAuth app client ID used by the shared client.

Returns:

  • (String, nil)

    OAuth app client ID used by the shared client.



62
63
64
# File 'lib/boldsign.rb', line 62

def client_id
  @client_id
end

.client_secretString?

Returns OAuth app client secret used by the shared client.

Returns:

  • (String, nil)

    OAuth app client secret used by the shared client.



65
66
67
# File 'lib/boldsign.rb', line 65

def client_secret
  @client_secret
end

.regionSymbol?

Returns Region key (‘:us`, `:eu`, `:ca`, `:au`).

Returns:

  • (Symbol, nil)

    Region key (‘:us`, `:eu`, `:ca`, `:au`).



77
78
79
# File 'lib/boldsign.rb', line 77

def region
  @region
end

.scopeString?

Returns OAuth scope to request (defaults to Boldsign::AccessToken::DEFAULT_SCOPE).

Returns:



71
72
73
# File 'lib/boldsign.rb', line 71

def scope
  @scope
end

.token_urlString?

Returns Override for the full OAuth token endpoint URL.

Returns:

  • (String, nil)

    Override for the full OAuth token endpoint URL.



74
75
76
# File 'lib/boldsign.rb', line 74

def token_url
  @token_url
end

Class Method Details

.clientClient

Returns memoized shared client built from module-level config.

Returns:

  • (Client)

    memoized shared client built from module-level config.



90
91
92
93
94
95
96
# File 'lib/boldsign.rb', line 90

def client
  @client ||= Client.new(
    api_key: api_key, client_id: client_id, client_secret: client_secret,
    access_token: access_token, scope: scope, token_url: token_url,
    region: region, base_url: base_url
  )
end

.configure {|config| ... } ⇒ void

This method returns an undefined value.

Yields self for block-style configuration.

Yield Parameters:

  • config (Boldsign)

    the module itself



85
86
87
# File 'lib/boldsign.rb', line 85

def configure
  yield self
end

.reset!void

This method returns an undefined value.

Clears the memoized shared client so the next call to client rebuilds it.



100
101
102
# File 'lib/boldsign.rb', line 100

def reset!
  @client = nil
end