GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - dubinc/dub-ruby: Official Dub Ruby SDK

BranchesTags
Open more actions menu

Latest commit

 

History

407 Commits
407 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.speakeasy
.speakeasy
 
 
docs
docs
 
 
lib
lib
 
 
sorbet
sorbet
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.rubocop-strict.yml
.rubocop-strict.yml
 
 
.rubocop.yml
.rubocop.yml
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
Gemfile
Gemfile
 
 
Gemfile.lock
Gemfile.lock
 
 
README.md
README.md
 
 
RELEASES.md
RELEASES.md
 
 
Rakefile
Rakefile
 
 
USAGE.md
USAGE.md
 
 
codeSamples.yaml
codeSamples.yaml
 
 
dub.gemspec
dub.gemspec
 
 

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 API: Dub is the modern link attribution platform for short links, conversion tracking, and affiliate programs.

Table of Contents

  • SDK Installation
  • SDK Example Usage
  • Authentication
  • Available Resources and Operations
  • Error Handling
  • Server Selection
  • Development
    • Contributions

SDK Installation

The SDK can be installed using RubyGems:

gem install dub

SDK Example Usage

Example 1

require 'dub'

Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Dub.new(
  security: Models::Shared::Security.new(
    token: 'DUB_API_KEY'
  )
)

req = Models::Operations::CreateLinkRequestBody.new(
  url: 'https://google.com',
  external_id: '123456',
  tag_ids: [
    'clux0rgak00011...',
  ],
  test_variants: [
    Models::Operations::TestVariants.new(
      url: 'https://example.com/variant-1',
      percentage: 50.0
    ),
    Models::Operations::TestVariants.new(
      url: 'https://example.com/variant-2',
      percentage: 50.0
    ),
  ]
)
res = s.links.create(request: req)

unless res.nil?
  # handle response
end

Example 2

require 'dub'

Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Dub.new(
  security: Models::Shared::Security.new(
    token: 'DUB_API_KEY'
  )
)

req = Models::Operations::UpsertLinkRequestBody.new(
  url: 'https://google.com',
  external_id: '123456',
  tag_ids: [
    'clux0rgak00011...',
  ],
  test_variants: [
    Models::Operations::UpsertLinkTestVariants.new(
      url: 'https://example.com/variant-1',
      percentage: 50.0
    ),
    Models::Operations::UpsertLinkTestVariants.new(
      url: 'https://example.com/variant-2',
      percentage: 50.0
    ),
  ]
)
res = s.links.upsert(request: req)

unless res.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'

Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Dub.new(
  security: Models::Shared::Security.new(
    token: 'DUB_API_KEY'
  )
)

req = Models::Operations::GetLinksRequest.new(
  ending_before: 'link_1KAP4CDPBSVMMBMH9XX3YZZ0Z...',
  starting_after: 'link_1KAP4CDPBSVMMBMH9XX3YZZ0Z...',
  page: 1,
  page_size: 50
)
res = s.links.list(request: req)

unless res.nil?
  # handle response
end

Available Resources and Operations

Available methods

Analytics

  • retrieve - Retrieve analytics for a link, a domain, or the authenticated workspace.

Bounties

  • list_submissions - List bounty submissions
  • approve_submission - Approve a bounty submission
  • reject_submission - Reject a bounty submission

Commissions

  • list - List all commissions
  • create - Create commission
  • update - Update a commission
  • update_many - Bulk update commissions

Customers

  • list - List all customers
  • get - Retrieve a customer
  • delete - Delete a customer
  • update - Update a customer

DiscountCodes

  • list - List discount codes
  • create - Create a discount code
  • delete - Delete a discount code

Domains

  • list - List all domains
  • create - Create a domain
  • delete - Delete a domain
  • update - Update a domain
  • register - Register a domain
  • check_status - Check the availability of one or more domains

EmbedTokens

  • referrals - Create a referrals embed token

Events

  • list - List all events

Folders

  • list - List all folders
  • create - Create a folder
  • delete - Delete a folder
  • update - Update a folder

Links

  • list - List all links
  • create - Create a link
  • count - Retrieve links count
  • get - Retrieve a link
  • delete - Delete a link
  • update - Update a link
  • create_many - Bulk create links
  • delete_many - Bulk delete links
  • update_many - Bulk update links
  • upsert - Upsert a link

Partners

  • list - List all partners
  • create - Create or update a partner
  • retrieve_links - Retrieve a partner's links.
  • create_link - Create a link for a partner
  • upsert_link - Upsert a link for a partner
  • analytics - Retrieve analytics for a partner
  • ban - Ban a partner
  • deactivate - Deactivate a partner

Payouts

  • list - List all payouts

ProgramApplications

  • list - List all program applications
  • approve - Approve a partner application
  • reject - Reject a partner application

QRCodes

  • get - Retrieve a QR code

Tags

  • list - List all tags
  • create - Create a tag
  • delete - Delete a tag
  • update - Update a tag

Track

  • lead - Track a lead
  • sale - Track a sale

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error.

By default an API error will raise a Errors::APIError, which has the following properties:

Property Type Description
message string The error message
status_code int The HTTP status code
raw_response Faraday::Response The raw HTTP response
body string The response content

When custom error responses are specified for an operation, the SDK may also throw their associated exception. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the list method throws the following exceptions:

Error Type Status Code Content Type
Models::Errors::BadRequest 400 application/json
Models::Errors::Unauthorized 401 application/json
Models::Errors::Forbidden 403 application/json
Models::Errors::NotFound 404 application/json
Models::Errors::Conflict 409 application/json
Models::Errors::InviteExpired 410 application/json
Models::Errors::UnprocessableEntity 422 application/json
Models::Errors::RateLimitExceeded 429 application/json
Models::Errors::InternalServerError 500 application/json
Errors::APIError 4XX, 5XX */*

Example

require 'dub'

Models = ::OpenApiSDK::Models
s = ::OpenApiSDK::Dub.new(
  security: Models::Shared::Security.new(
    token: 'DUB_API_KEY'
  )
)

begin
    req = Models::Operations::GetLinksRequest.new(
      ending_before: 'link_1KAP4CDPBSVMMBMH9XX3YZZ0Z...',
      starting_after: 'link_1KAP4CDPBSVMMBMH9XX3YZZ0Z...',
      page: 1,
      page_size: 50
    )
    res = s.links.list(request: req)

    unless res.nil?
      # handle response
    end
rescue Models::Errors::BadRequest => e
  # handle e.container data
  raise e
rescue Models::Errors::Unauthorized => e
  # handle e.container data
  raise e
rescue Models::Errors::Forbidden => e
  # handle e.container data
  raise e
rescue Models::Errors::NotFound => e
  # handle e.container data
  raise e
rescue Models::Errors::Conflict => e
  # handle e.container data
  raise e
rescue Models::Errors::InviteExpired => e
  # handle e.container data
  raise e
rescue Models::Errors::UnprocessableEntity => e
  # handle e.container data
  raise e
rescue Models::Errors::RateLimitExceeded => e
  # handle e.container data
  raise e
rescue Models::Errors::InternalServerError => e
  # handle e.container data
  raise e
rescue Errors::APIError => e
  # handle default exception
  raise e
end

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'

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

req = Models::Operations::GetLinksRequest.new(
  ending_before: 'link_1KAP4CDPBSVMMBMH9XX3YZZ0Z...',
  starting_after: 'link_1KAP4CDPBSVMMBMH9XX3YZZ0Z...',
  page: 1,
  page_size: 50
)
res = s.links.list(request: req)

unless res.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

About

Official Dub Ruby SDK

dub.co/solutions/ruby

Resources

Readme

Contributing

Contributing
Activity
Custom properties

Stars

2 stars

Watchers

1 watching

Forks

5 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.