# Faire\ProductVariantsApi



All URIs are relative to https://www.faire.com/external-api/v2, except if the operation defines another base path.

| Method | HTTP request | Description |
| ------------- | ------------- | ------------- |
| [**productsProductIdVariantOptionSetsPatch()**](ProductVariantsApi.md#productsProductIdVariantOptionSetsPatch) | **PATCH** /products/{product_id}/variant-option-sets | PATCH /products/{product_id}/variant-option-sets |
| [**productsProductIdVariantsPost()**](ProductVariantsApi.md#productsProductIdVariantsPost) | **POST** /products/{product_id}/variants | POST /products/{product_id}/variants |
| [**productsProductIdVariantsVariantIdDelete()**](ProductVariantsApi.md#productsProductIdVariantsVariantIdDelete) | **DELETE** /products/{product_id}/variants/{variant_id} | DELETE /products/{product_id}/variants/{variant_id} |
| [**productsProductIdVariantsVariantIdImagesImageIdDelete()**](ProductVariantsApi.md#productsProductIdVariantsVariantIdImagesImageIdDelete) | **DELETE** /products/{product_id}/variants/{variant_id}/images/{image_id} | DELETE /products/{product_id}/variants/{variant_id}/images/{image_id} |
| [**productsProductIdVariantsVariantIdPatch()**](ProductVariantsApi.md#productsProductIdVariantsVariantIdPatch) | **PATCH** /products/{product_id}/variants/{variant_id} | PATCH /products/{product_id}/variants/{variant_id} |


## `productsProductIdVariantOptionSetsPatch()`

```php
productsProductIdVariantOptionSetsPatch($product_id, $patch_variant_option_sets_request_v2): \Faire\Model\PatchVariantOptionSetsResponseV2
```

PATCH /products/{product_id}/variant-option-sets

This endpoint replaces the current variant option sets of a product by the given new variant option sets. Options currently in use by variants cannot be removed. If the product is sold in prepacks, size options cannot be reorganized and new values cannot be inserted into the middle of the size options.

### Example

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: AppCredentials
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-APP-CREDENTIALS', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-APP-CREDENTIALS', 'Bearer');

// Configure API key authorization: OAuth
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-OAUTH-ACCESS-TOKEN', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-OAUTH-ACCESS-TOKEN', 'Bearer');


$apiInstance = new Faire\Api\ProductVariantsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$product_id = 'product_id_example'; // string
$patch_variant_option_sets_request_v2 = new \Faire\Model\PatchVariantOptionSetsRequestV2(); // \Faire\Model\PatchVariantOptionSetsRequestV2

try {
    $result = $apiInstance->productsProductIdVariantOptionSetsPatch($product_id, $patch_variant_option_sets_request_v2);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ProductVariantsApi->productsProductIdVariantOptionSetsPatch: ', $e->getMessage(), PHP_EOL;
}
```

### Parameters

| Name | Type | Description  | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **product_id** | **string**|  | |
| **patch_variant_option_sets_request_v2** | [**\Faire\Model\PatchVariantOptionSetsRequestV2**](../Model/PatchVariantOptionSetsRequestV2.md)|  | |

### Return type

[**\Faire\Model\PatchVariantOptionSetsResponseV2**](../Model/PatchVariantOptionSetsResponseV2.md)

### Authorization

[AppCredentials](../../README.md#AppCredentials), [OAuth](../../README.md#OAuth)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`

[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)

## `productsProductIdVariantsPost()`

```php
productsProductIdVariantsPost($product_id, $external_product_variant_v2): \Faire\Model\ExternalProductVariantV2
```

POST /products/{product_id}/variants

Creates a new variant for a product.

### Example

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: AppCredentials
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-APP-CREDENTIALS', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-APP-CREDENTIALS', 'Bearer');

// Configure API key authorization: OAuth
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-OAUTH-ACCESS-TOKEN', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-OAUTH-ACCESS-TOKEN', 'Bearer');


$apiInstance = new Faire\Api\ProductVariantsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$product_id = 'product_id_example'; // string
$external_product_variant_v2 = new \Faire\Model\ExternalProductVariantV2(); // \Faire\Model\ExternalProductVariantV2

try {
    $result = $apiInstance->productsProductIdVariantsPost($product_id, $external_product_variant_v2);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ProductVariantsApi->productsProductIdVariantsPost: ', $e->getMessage(), PHP_EOL;
}
```

### Parameters

| Name | Type | Description  | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **product_id** | **string**|  | |
| **external_product_variant_v2** | [**\Faire\Model\ExternalProductVariantV2**](../Model/ExternalProductVariantV2.md)|  | |

### Return type

[**\Faire\Model\ExternalProductVariantV2**](../Model/ExternalProductVariantV2.md)

### Authorization

[AppCredentials](../../README.md#AppCredentials), [OAuth](../../README.md#OAuth)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`

[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)

## `productsProductIdVariantsVariantIdDelete()`

```php
productsProductIdVariantsVariantIdDelete($product_id, $variant_id)
```

DELETE /products/{product_id}/variants/{variant_id}

This endpoint deletes a single variant given a product ID and a variant ID. This means that the product variant will have its lifecycle_state set to DELETED and will no longer be visible on Faire. A product must have at least one non-deleted variant. To delete the last variant of product, need to delete the product instead.

### Example

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: AppCredentials
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-APP-CREDENTIALS', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-APP-CREDENTIALS', 'Bearer');

// Configure API key authorization: OAuth
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-OAUTH-ACCESS-TOKEN', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-OAUTH-ACCESS-TOKEN', 'Bearer');


$apiInstance = new Faire\Api\ProductVariantsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$product_id = 'product_id_example'; // string
$variant_id = 'variant_id_example'; // string

try {
    $apiInstance->productsProductIdVariantsVariantIdDelete($product_id, $variant_id);
} catch (Exception $e) {
    echo 'Exception when calling ProductVariantsApi->productsProductIdVariantsVariantIdDelete: ', $e->getMessage(), PHP_EOL;
}
```

### Parameters

| Name | Type | Description  | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **product_id** | **string**|  | |
| **variant_id** | **string**|  | |

### Return type

void (empty response body)

### Authorization

[AppCredentials](../../README.md#AppCredentials), [OAuth](../../README.md#OAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)

## `productsProductIdVariantsVariantIdImagesImageIdDelete()`

```php
productsProductIdVariantsVariantIdImagesImageIdDelete($product_id, $variant_id, $image_id)
```

DELETE /products/{product_id}/variants/{variant_id}/images/{image_id}

Removes an image from a variant.

### Example

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: AppCredentials
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-APP-CREDENTIALS', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-APP-CREDENTIALS', 'Bearer');

// Configure API key authorization: OAuth
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-OAUTH-ACCESS-TOKEN', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-OAUTH-ACCESS-TOKEN', 'Bearer');


$apiInstance = new Faire\Api\ProductVariantsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$product_id = 'product_id_example'; // string
$variant_id = 'variant_id_example'; // string
$image_id = 'image_id_example'; // string

try {
    $apiInstance->productsProductIdVariantsVariantIdImagesImageIdDelete($product_id, $variant_id, $image_id);
} catch (Exception $e) {
    echo 'Exception when calling ProductVariantsApi->productsProductIdVariantsVariantIdImagesImageIdDelete: ', $e->getMessage(), PHP_EOL;
}
```

### Parameters

| Name | Type | Description  | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **product_id** | **string**|  | |
| **variant_id** | **string**|  | |
| **image_id** | **string**|  | |

### Return type

void (empty response body)

### Authorization

[AppCredentials](../../README.md#AppCredentials), [OAuth](../../README.md#OAuth)

### HTTP request headers

- **Content-Type**: Not defined
- **Accept**: Not defined

[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)

## `productsProductIdVariantsVariantIdPatch()`

```php
productsProductIdVariantsVariantIdPatch($product_id, $variant_id, $external_product_variant_v2): \Faire\Model\ExternalProductVariantV2
```

PATCH /products/{product_id}/variants/{variant_id}

This endpoint accepts a variant with only the fields populated that you want to modify. A variant's options cannot be updated. If you want to change the options, delete the existing variant and create a new variant with new options.

### Example

```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');


// Configure API key authorization: AppCredentials
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-APP-CREDENTIALS', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-APP-CREDENTIALS', 'Bearer');

// Configure API key authorization: OAuth
$config = Faire\Configuration::getDefaultConfiguration()->setApiKey('X-FAIRE-OAUTH-ACCESS-TOKEN', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = Faire\Configuration::getDefaultConfiguration()->setApiKeyPrefix('X-FAIRE-OAUTH-ACCESS-TOKEN', 'Bearer');


$apiInstance = new Faire\Api\ProductVariantsApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$product_id = 'product_id_example'; // string
$variant_id = 'variant_id_example'; // string
$external_product_variant_v2 = new \Faire\Model\ExternalProductVariantV2(); // \Faire\Model\ExternalProductVariantV2

try {
    $result = $apiInstance->productsProductIdVariantsVariantIdPatch($product_id, $variant_id, $external_product_variant_v2);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling ProductVariantsApi->productsProductIdVariantsVariantIdPatch: ', $e->getMessage(), PHP_EOL;
}
```

### Parameters

| Name | Type | Description  | Notes |
| ------------- | ------------- | ------------- | ------------- |
| **product_id** | **string**|  | |
| **variant_id** | **string**|  | |
| **external_product_variant_v2** | [**\Faire\Model\ExternalProductVariantV2**](../Model/ExternalProductVariantV2.md)|  | |

### Return type

[**\Faire\Model\ExternalProductVariantV2**](../Model/ExternalProductVariantV2.md)

### Authorization

[AppCredentials](../../README.md#AppCredentials), [OAuth](../../README.md#OAuth)

### HTTP request headers

- **Content-Type**: `application/json`
- **Accept**: `application/json`

[[Back to top]](#) [[Back to API list]](../../README.md#endpoints)
[[Back to Model list]](../../README.md#models)
[[Back to README]](../../README.md)
