Skip to content

Latest commit

 

History

History
316 lines (218 loc) · 9.09 KB

vendors.md

File metadata and controls

316 lines (218 loc) · 9.09 KB

Vendors

$vendorsApi = $client->getVendorsApi();

Class Name

VendorsApi

Methods

Bulk Create Vendors

Creates one or more Vendor objects to represent suppliers to a seller.

function bulkCreateVendors(BulkCreateVendorsRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body BulkCreateVendorsRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type BulkCreateVendorsResponse.

Example Usage

$body = BulkCreateVendorsRequestBuilder::init(
    [
        'key0' => VendorBuilder::init()->build(),
        'key1' => VendorBuilder::init()->build()
    ]
)->build();

$apiResponse = $vendorsApi->bulkCreateVendors($body);

if ($apiResponse->isSuccess()) {
    $bulkCreateVendorsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Bulk Retrieve Vendors

Retrieves one or more vendors of specified Vendor IDs.

function bulkRetrieveVendors(BulkRetrieveVendorsRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body BulkRetrieveVendorsRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type BulkRetrieveVendorsResponse.

Example Usage

$body = BulkRetrieveVendorsRequestBuilder::init()
    ->vendorIds(
        [
            'INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4'
        ]
    )
    ->build();

$apiResponse = $vendorsApi->bulkRetrieveVendors($body);

if ($apiResponse->isSuccess()) {
    $bulkRetrieveVendorsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Bulk Update Vendors

Updates one or more of existing Vendor objects as suppliers to a seller.

function bulkUpdateVendors(BulkUpdateVendorsRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body BulkUpdateVendorsRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type BulkUpdateVendorsResponse.

Example Usage

$body = BulkUpdateVendorsRequestBuilder::init(
    [
        'key0' => UpdateVendorRequestBuilder::init(
            VendorBuilder::init()->build()
        )->build(),
        'key1' => UpdateVendorRequestBuilder::init(
            VendorBuilder::init()->build()
        )->build()
    ]
)->build();

$apiResponse = $vendorsApi->bulkUpdateVendors($body);

if ($apiResponse->isSuccess()) {
    $bulkUpdateVendorsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Create Vendor

Creates a single Vendor object to represent a supplier to a seller.

function createVendor(CreateVendorRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body CreateVendorRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type CreateVendorResponse.

Example Usage

$body = CreateVendorRequestBuilder::init(
    'idempotency_key2'
)->build();

$apiResponse = $vendorsApi->createVendor($body);

if ($apiResponse->isSuccess()) {
    $createVendorResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Search Vendors

Searches for vendors using a filter against supported Vendor properties and a supported sorter.

function searchVendors(SearchVendorsRequest $body): ApiResponse

Parameters

Parameter Type Tags Description
body SearchVendorsRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type SearchVendorsResponse.

Example Usage

$body = SearchVendorsRequestBuilder::init()->build();

$apiResponse = $vendorsApi->searchVendors($body);

if ($apiResponse->isSuccess()) {
    $searchVendorsResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Retrieve Vendor

Retrieves the vendor of a specified Vendor ID.

function retrieveVendor(string $vendorId): ApiResponse

Parameters

Parameter Type Tags Description
vendorId string Template, Required ID of the Vendor to retrieve.

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type RetrieveVendorResponse.

Example Usage

$vendorId = 'vendor_id8';

$apiResponse = $vendorsApi->retrieveVendor($vendorId);

if ($apiResponse->isSuccess()) {
    $retrieveVendorResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());

Update Vendor

Updates an existing Vendor object as a supplier to a seller.

function updateVendor(UpdateVendorRequest $body, string $vendorId): ApiResponse

Parameters

Parameter Type Tags Description
body UpdateVendorRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.
vendorId string Template, Required -

Response Type

This method returns a Square\Utils\ApiResponse instance. The getResult() method on this instance returns the response data which is of type UpdateVendorResponse.

Example Usage

$body = UpdateVendorRequestBuilder::init(
    VendorBuilder::init()
        ->id('INV_V_JDKYHBWT1D4F8MFH63DBMEN8Y4')
        ->name('Jack\'s Chicken Shack')
        ->version(1)
        ->status(VendorStatus::ACTIVE)
        ->build()
)
    ->idempotencyKey('8fc6a5b0-9fe8-4b46-b46b-2ef95793abbe')
    ->build();

$vendorId = 'vendor_id8';

$apiResponse = $vendorsApi->updateVendor(
    $body,
    $vendorId
);

if ($apiResponse->isSuccess()) {
    $updateVendorResponse = $apiResponse->getResult();
} else {
    $errors = $apiResponse->getErrors();
}

// Getting more response information
var_dump($apiResponse->getStatusCode());
var_dump($apiResponse->getHeaders());