Learn more about the Dub.co Ruby SDK in the official documentation.
gem install dubrequire '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
endrequire '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- list - Retrieve a list of links
- create - Create a new link
- count - Retrieve links count
- get - Retrieve a link
- delete - Delete a link
- update - Update a link
- create_many - Bulk create links
- update_many - Bulk update links
- upsert - Upsert a link
- get - Retrieve a QR code
- retrieve - Retrieve analytics for a link, a domain, or the authenticated workspace.
- 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
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.
The following global parameters are available.
| Name | Type | Required | Description |
|---|---|---|---|
| workspace_id | ::String | The workspace_id parameter. | |
| project_slug | ::String | The project_slug parameter. |
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
endYou 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 |
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:
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.
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!
