create method

Future<YoutubeAssetAssociation> create(
  1. YoutubeAssetAssociation request,
  2. String advertiserId,
  3. String lineItemId,
  4. String youtubeAssetType, {
  5. String? linkedEntity_adGroupId,
  6. String? $fields,
})

Creates a new association between the identified resource and a YouTube asset.

Returns the newly-created association. Warning: This method is only available to an informed subset of users.

request - The metadata request object.

Request parameters:

advertiserId - Required. The ID of the advertiser that the linked entity belongs to. Value must have pattern ^\[^/\]+$.

lineItemId - The ID of a line item. Value must have pattern ^\[^/\]+$.

youtubeAssetType - Required. The type of YouTube asset associated with the resource. Value must have pattern ^\[^/\]+$. Possible string values are:

  • "YOUTUBE_ASSET_TYPE_UNSPECIFIED" : YouTube asset type is not specified or is unknown in this version.
  • "YOUTUBE_ASSET_TYPE_LOCATION" : Location asset.
  • "YOUTUBE_ASSET_TYPE_AFFILIATE_LOCATION" : Affiliate location asset.
  • "YOUTUBE_ASSET_TYPE_SITELINK" : Sitelink asset.

linkedEntity_adGroupId - The ID of an ad group.

$fields - Selector specifying which fields to include in a partial response.

Completes with a YoutubeAssetAssociation.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<YoutubeAssetAssociation> create(
  YoutubeAssetAssociation request,
  core.String advertiserId,
  core.String lineItemId,
  core.String youtubeAssetType, {
  core.String? linkedEntity_adGroupId,
  core.String? $fields,
}) async {
  final body_ = convert.json.encode(request);
  final queryParams_ = <core.String, core.List<core.String>>{
    'linkedEntity.adGroupId': ?linkedEntity_adGroupId == null
        ? null
        : [linkedEntity_adGroupId],
    'fields': ?$fields == null ? null : [$fields],
  };

  final url_ =
      'v4/advertisers/' +
      core.Uri.encodeFull('$advertiserId') +
      '/lineItems/' +
      core.Uri.encodeFull('$lineItemId') +
      '/youtubeAssetTypes/' +
      core.Uri.encodeFull('$youtubeAssetType') +
      '/youtubeAssetAssociations';

  final response_ = await _requester.request(
    url_,
    'POST',
    body: body_,
    queryParams: queryParams_,
  );
  return YoutubeAssetAssociation.fromJson(
    response_ as core.Map<core.String, core.dynamic>,
  );
}