Skip to content

Latest commit

 

History

History
247 lines (172 loc) · 13 KB

README.md

File metadata and controls

247 lines (172 loc) · 13 KB

Domains

(domains)

Overview

Available Operations

  • create - Create a domain
  • list - Retrieve a list of domains
  • update - Update a domain
  • delete - Delete a domain

create

Create a domain for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

$security = 'DUB_API_KEY';

$sdk = Dub\Dub::builder()->setSecurity($security)->build();

$request = new Operations\CreateDomainRequestBody(
    slug: 'acme.com',
    archived: false,
    expiredUrl: 'https://acme.com/expired',
    notFoundUrl: 'https://acme.com/not-found',
    placeholder: 'https://dub.co/help/article/what-is-dub',
);

$response = $sdk->domains->create(
    request: $request
);

if ($response->domainSchema !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\CreateDomainRequestBody ✔️ The request object to use for the request.

Response

?Operations\CreateDomainResponse

Errors

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

list

Retrieve a list of domains associated with the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;

$security = 'DUB_API_KEY';

$sdk = Dub\Dub::builder()->setSecurity($security)->build();



$response = $sdk->domains->list(
    archived: true,
    search: '<value>',
    page: 1,
    pageSize: 50

);

if ($response->domainSchemas !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
archived ?bool Whether to include archived domains in the response. Defaults to false if not provided.
search ?string The search term to filter the domains by.
page ?float The page number for pagination. 1
pageSize ?float The number of items per page. 50

Response

?Operations\ListDomainsResponse

Errors

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

update

Update a domain for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

$security = 'DUB_API_KEY';

$sdk = Dub\Dub::builder()->setSecurity($security)->build();

$requestBody = new Operations\UpdateDomainRequestBody(
    slug: 'acme.com',
    archived: false,
    expiredUrl: 'https://acme.com/expired',
    notFoundUrl: 'https://acme.com/not-found',
    placeholder: 'https://dub.co/help/article/what-is-dub',
);

$response = $sdk->domains->update(
    slug: 'acme.com',
    requestBody: $requestBody

);

if ($response->domainSchema !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
slug string ✔️ The domain name. acme.com
requestBody ?Operations\UpdateDomainRequestBody N/A

Response

?Operations\UpdateDomainResponse

Errors

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

delete

Delete a domain from a workspace. It cannot be undone. This will also delete all the links associated with the domain.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;

$security = 'DUB_API_KEY';

$sdk = Dub\Dub::builder()->setSecurity($security)->build();



$response = $sdk->domains->delete(
    slug: 'acme.com'
);

if ($response->object !== null) {
    // handle response
}

Parameters

Parameter Type Required Description Example
slug string ✔️ The domain name. acme.com

Response

?Operations\DeleteDomainResponse

Errors

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