/dub-ruby

Official Dub Ruby SDK

Primary LanguageRuby

Dub.co Ruby SDK to interact with APIs.

Dub.co Ruby SDK


Learn more about the Dub.co Ruby SDK in the official documentation.

SDK Installation

gem install dub

SDK Example Usage

Example 1

require 'dub'


s = ::OpenApiSDK::Dub.new
s.config_security(
  ::OpenApiSDK::Shared::Security.new(
    token: "DUB_API_KEY",
  )
)


req = ::OpenApiSDK::Operations::CreateLinkRequest.new(
  request_body: ::OpenApiSDK::Operations::CreateLinkRequestBody.new(
    url: "https://google/com",
    external_id: "123456",
    tag_ids: [
    "<value>",
  ],
  ),
)
    
res = s.links.create(req)

if ! res.link_schema.nil?
  # handle response
end

Example 2

require 'dub'


s = ::OpenApiSDK::Dub.new
s.config_security(
  ::OpenApiSDK::Shared::Security.new(
    token: "DUB_API_KEY",
  )
)


req = ::OpenApiSDK::Operations::UpsertLinkRequest.new(
  request_body: ::OpenApiSDK::Operations::UpsertLinkRequestBody.new(
    url: "https://google/com",
    external_id: "123456",
    tag_ids: [
    "<value>",
  ],
  ),
)
    
res = s.links.upsert(req)

if ! res.link_schema.nil?
  # handle response
end

Available Resources and Operations

  • get - Retrieve a QR code
  • retrieve - Retrieve analytics for a link, a domain, or the authenticated workspace.
  • get - Retrieve a workspace
  • update - Update a workspace
  • list - Retrieve a list of tags
  • create - Create a new tag
  • update - Update a tag
  • list - Retrieve a list of domains
  • create - Create a domain
  • delete - Delete a domain
  • update - Update a domain
  • get - Retrieve the metatags for a URL

Global Parameters

Certain parameters are configured globally. These parameters may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, These global values will be used as defaults on the operations that use them. When such operations are called, there is a place in each to override the global value, if needed.

For example, you can set workspaceId to "<value>" at SDK initialization and then you do not have to pass the same value on calls to operations like list. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.

Available Globals

The following global parameters are available.

Name Type Required Description
workspace_id ::String The workspace_id parameter.
project_slug ::String The project_slug parameter.

Example

require 'dub'


s = ::OpenApiSDK::Dub.new
s.config_security(
  ::OpenApiSDK::Shared::Security.new(
    token: "DUB_API_KEY",
  )
)


req = ::OpenApiSDK::Operations::GetLinksRequest.new()
    
res = s.links.list(req)

if ! res.link_schemas.nil?
  # handle response
end

Server Selection

Server Selection

Select Server by Index

You can override the default server globally by passing a server index to the server_idx: int optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:

# Server Variables
0 https://api.dub.co None

Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:

Development

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy