Skip to content

dubinc/dub-ruby

Folders and files

NameName
Last commit message
Last commit date
Jul 9, 2024
Mar 17, 2025
Mar 17, 2025
Mar 17, 2025
Mar 14, 2025
May 30, 2024
May 30, 2024
Mar 14, 2025
Jan 14, 2025
May 30, 2024
Mar 17, 2025
Mar 7, 2025
Mar 17, 2025
Feb 26, 2025
Mar 7, 2025
Mar 14, 2025
Mar 17, 2025

Repository files navigation

Dub.co Ruby SDK to interact with APIs.

Dub.co Ruby SDK


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

Summary

Dub.co API: Dub is link management infrastructure for companies to create marketing campaigns, link sharing features, and referral programs.

Table of Contents

SDK Installation

The SDK can be installed using RubyGems:

gem install dub

SDK Example Usage

Example 1

require 'dub'

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

req = ::OpenApiSDK::Operations::CreateLinkRequestBody.new(
  url: "https://google.com",
  external_id: "123456",
  tag_ids: [
    "clux0rgak00011...",
  ],
)

res = s.links.create(req)

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

Example 2

require 'dub'

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

req = ::OpenApiSDK::Operations::UpsertLinkRequestBody.new(
  url: "https://google.com",
  external_id: "123456",
  tag_ids: [
    "clux0rgak00011...",
  ],
)

res = s.links.upsert(req)

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

Authentication

Per-Client Security Schemes

This SDK supports the following security scheme globally:

Name Type Scheme
token http HTTP Bearer

You can set the security parameters through the security optional parameter when initializing the SDK client instance. For example:

require 'dub'

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

req = ::OpenApiSDK::Operations::CreateLinkRequestBody.new(
  url: "https://google.com",
  external_id: "123456",
  tag_ids: [
    "clux0rgak00011...",
  ],
)

res = s.links.create(req)

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

Available Resources and Operations

Available methods
  • retrieve - Retrieve analytics for a link, a domain, or the authenticated workspace.
  • list - Retrieve a list of customers
  • create - Create a customer ⚠️ Deprecated
  • get - Retrieve a customer
  • update - Update a customer
  • delete - Delete a customer
  • create - Create a domain
  • list - Retrieve a list of domains
  • update - Update a domain
  • delete - Delete a domain
  • referrals - Create a new referrals embed token
  • list - Retrieve a list of events
  • create - Create a new folder
  • list - Retrieve a list of folders
  • update - Update a folder
  • delete - Delete a folder
  • get - Retrieve the metatags for a URL
  • get - Retrieve a QR code
  • lead - Track a lead
  • sale - Track a sale
  • get - Retrieve a workspace
  • update - Update a workspace

Server Selection

Override Server URL Per-Client

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

require 'dub'

s = ::OpenApiSDK::Dub.new(
      server_url: "https://api.dub.co",
      security: ::OpenApiSDK::Shared::Security.new(
        token: "DUB_API_KEY",
      ),
    )

req = ::OpenApiSDK::Operations::CreateLinkRequestBody.new(
  url: "https://google.com",
  external_id: "123456",
  tag_ids: [
    "clux0rgak00011...",
  ],
)

res = s.links.create(req)

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

Development

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