start method

Future<AssociationSession> start(
  1. List<String> productCode,
  2. String websiteUrl, {
  3. String? callbackUrl,
  4. String? userLocale,
  5. String? websiteLocale,
  6. String? $fields,
})

Create an association session for initiating an association with an AdSense user.

Request parameters:

productCode - Products to associate with the user.

websiteUrl - The URL of the user's hosted website.

callbackUrl - The URL to redirect the user to once association is completed. It receives a token parameter that can then be used to retrieve the associated account.

userLocale - The preferred locale of the user.

websiteLocale - The locale of the user's hosted website.

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

Completes with a AssociationSession.

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<AssociationSession> start(
  core.List<core.String> productCode,
  core.String websiteUrl, {
  core.String? callbackUrl,
  core.String? userLocale,
  core.String? websiteLocale,
  core.String? $fields,
}) async {
  if (productCode.isEmpty) {
    throw core.ArgumentError('Parameter productCode cannot be empty.');
  }
  final queryParams_ = <core.String, core.List<core.String>>{
    'productCode': productCode,
    'websiteUrl': [websiteUrl],
    if (callbackUrl != null) 'callbackUrl': [callbackUrl],
    if (userLocale != null) 'userLocale': [userLocale],
    if (websiteLocale != null) 'websiteLocale': [websiteLocale],
    if ($fields != null) 'fields': [$fields],
  };

  const url_ = 'associationsessions/start';

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