Skip to content

Latest commit

 

History

History
623 lines (454 loc) · 30.6 KB

README.md

File metadata and controls

623 lines (454 loc) · 30.6 KB

Links

(links)

Overview

Available Operations

createMany

Bulk create up to 100 links for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

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

$request = [
    new Operations\RequestBody(
        url: 'https://google.com',
        tagIds: [
            'clux0rgak00011...',
        ],
        externalId: '123456',
    ),
];

$response = $sdk->links->createMany(
    request: $request
);

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

Parameters

Parameter Type Required Description
$request array<Operations\RequestBody> ✔️ The request object to use for the request.

Response

?Operations\BulkCreateLinksResponse

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 */*

deleteMany

Bulk delete up to 100 links for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;

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



$response = $sdk->links->deleteMany(
    linkIds: [
        'clux0rgak00011...',
        'clux0rgak00022...',
    ]
);

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

Parameters

Parameter Type Required Description Example
linkIds array<string> ✔️ Comma-separated list of link IDs to delete. Maximum of 100 IDs. Non-existing IDs will be ignored. [
"clux0rgak00011...",
"clux0rgak00022..."
]

Response

?Operations\BulkDeleteLinksResponse

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 */*

updateMany

Bulk update up to 100 links with the same data for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

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

$request = new Operations\BulkUpdateLinksRequestBody(
    data: new Operations\Data(
        url: 'https://google.com',
        tagIds: [
            'clux0rgak00011...',
        ],
    ),
);

$response = $sdk->links->updateMany(
    request: $request
);

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

Parameters

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

Response

?Operations\BulkUpdateLinksResponse

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 */*

create

Create a new link for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

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

$request = new Operations\CreateLinkRequestBody(
    url: 'https://google.com',
    tagIds: [
        'clux0rgak00011...',
    ],
    externalId: '123456',
);

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

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

Parameters

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

Response

?Operations\CreateLinkResponse

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 link for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;

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



$response = $sdk->links->delete(
    linkId: '<id>'
);

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

Parameters

Parameter Type Required Description
linkId string ✔️ The id of the link to delete. You may use either linkId (obtained via /links/info endpoint) or externalId prefixed with ext_.

Response

?Operations\DeleteLinkResponse

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 */*

get

Retrieve the info for a link.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;

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



$response = $sdk->links->get(
    domain: 'rural-mathematics.name',
    key: '<key>',
    linkId: 'clux0rgak00011...',
    externalId: '123456'

);

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

Parameters

Parameter Type Required Description Example
domain ?string N/A
key ?string The key of the link to retrieve. E.g. for d.to/github, the key is github.
linkId ?string The unique ID of the short link. clux0rgak00011...
externalId ?string This is the ID of the link in the your database. 123456

Response

?Operations\GetLinkInfoResponse

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 paginated list of links for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

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

$request = new Operations\GetLinksRequest();

$responses = $sdk->links->list(
    request: $request
);


foreach ($responses as $response) {
    if ($response->statusCode === 200) {
        // handle response
    }
}

Parameters

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

Response

?Operations\GetLinksResponse

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 */*

count

Retrieve the number of links for the authenticated workspace.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

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

$request = new Operations\GetLinksCountRequest();

$response = $sdk->links->count(
    request: $request
);

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

Parameters

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

Response

?Operations\GetLinksCountResponse

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 link for the authenticated workspace. If there's no change, returns it as it is.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

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

$requestBody = new Operations\UpdateLinkRequestBody(
    url: 'https://google.com',
    tagIds: [
        'clux0rgak00011...',
    ],
    externalId: '123456',
);

$response = $sdk->links->update(
    linkId: '<id>',
    requestBody: $requestBody

);

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

Parameters

Parameter Type Required Description
linkId string ✔️ The id of the link to update. You may use either linkId (obtained via /links/info endpoint) or externalId prefixed with ext_.
requestBody ?Operations\UpdateLinkRequestBody N/A

Response

?Operations\UpdateLinkResponse

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 */*

upsert

Upsert a link for the authenticated workspace by its URL. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Dub;
use Dub\Models\Operations;

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

$request = new Operations\UpsertLinkRequestBody(
    url: 'https://google.com',
    tagIds: [
        'clux0rgak00011...',
    ],
    externalId: '123456',
);

$response = $sdk->links->upsert(
    request: $request
);

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

Parameters

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

Response

?Operations\UpsertLinkResponse

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 */*