Class PromotionsServiceClient
PromotionsService client wrapper, for convenient use.
Namespace: Google.Shopping.Merchant.Promotions.V1Beta
Assembly: Google.Shopping.Merchant.Promotions.V1Beta.dll
Syntax
public abstract class PromotionsServiceClient
Remarks
Service to manage promotions for products.
Properties
DefaultEndpoint
The default endpoint for the PromotionsService service, which is a host of "merchantapi.googleapis.com" and a port of 443.
Declaration
public static string DefaultEndpoint { get; }
Property Value
Type | Description |
---|---|
string |
DefaultScopes
The default PromotionsService scopes.
Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<string> |
Remarks
The default PromotionsService scopes are:
- https://www.googleapis.com/auth/content
GrpcClient
The underlying gRPC PromotionsService client
Declaration
public virtual PromotionsService.PromotionsServiceClient GrpcClient { get; }
Property Value
Type | Description |
---|---|
PromotionsService.PromotionsServiceClient |
ServiceMetadata
The service metadata associated with this client type.
Declaration
public static ServiceMetadata ServiceMetadata { get; }
Property Value
Type | Description |
---|---|
ServiceMetadata |
Methods
Create()
Synchronously creates a PromotionsServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PromotionsServiceClientBuilder.
Declaration
public static PromotionsServiceClient Create()
Returns
Type | Description |
---|---|
PromotionsServiceClient | The created PromotionsServiceClient. |
CreateAsync(CancellationToken)
Asynchronously creates a PromotionsServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use PromotionsServiceClientBuilder.
Declaration
public static Task<PromotionsServiceClient> CreateAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The CancellationToken to use while creating the client. |
Returns
Type | Description |
---|---|
Task<PromotionsServiceClient> | The task representing the created PromotionsServiceClient. |
GetPromotion(GetPromotionRequest, CallSettings)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Promotion GetPromotion(GetPromotionRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
GetPromotionRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Promotion | The RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = PromotionsServiceClient.Create();
// Initialize request argument(s)
GetPromotionRequest request = new GetPromotionRequest
{
PromotionName = PromotionName.FromAccountPromotion("[ACCOUNT]", "[PROMOTION]"),
};
// Make the request
Promotion response = promotionsServiceClient.GetPromotion(request);
GetPromotion(PromotionName, CallSettings)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Promotion GetPromotion(PromotionName name, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
PromotionName | name | Required. The name of the promotion to retrieve.
Format: |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Promotion | The RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = PromotionsServiceClient.Create();
// Initialize request argument(s)
PromotionName name = PromotionName.FromAccountPromotion("[ACCOUNT]", "[PROMOTION]");
// Make the request
Promotion response = promotionsServiceClient.GetPromotion(name);
GetPromotion(string, CallSettings)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Promotion GetPromotion(string name, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | Required. The name of the promotion to retrieve.
Format: |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Promotion | The RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = PromotionsServiceClient.Create();
// Initialize request argument(s)
string name = "accounts/[ACCOUNT]/promotions/[PROMOTION]";
// Make the request
Promotion response = promotionsServiceClient.GetPromotion(name);
GetPromotionAsync(GetPromotionRequest, CallSettings)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Task<Promotion> GetPromotionAsync(GetPromotionRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
GetPromotionRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
GetPromotionRequest request = new GetPromotionRequest
{
PromotionName = PromotionName.FromAccountPromotion("[ACCOUNT]", "[PROMOTION]"),
};
// Make the request
Promotion response = await promotionsServiceClient.GetPromotionAsync(request);
GetPromotionAsync(GetPromotionRequest, CancellationToken)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Task<Promotion> GetPromotionAsync(GetPromotionRequest request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
GetPromotionRequest | request | The request object containing all of the parameters for the API call. |
CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
GetPromotionRequest request = new GetPromotionRequest
{
PromotionName = PromotionName.FromAccountPromotion("[ACCOUNT]", "[PROMOTION]"),
};
// Make the request
Promotion response = await promotionsServiceClient.GetPromotionAsync(request);
GetPromotionAsync(PromotionName, CallSettings)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Task<Promotion> GetPromotionAsync(PromotionName name, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
PromotionName | name | Required. The name of the promotion to retrieve.
Format: |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
PromotionName name = PromotionName.FromAccountPromotion("[ACCOUNT]", "[PROMOTION]");
// Make the request
Promotion response = await promotionsServiceClient.GetPromotionAsync(name);
GetPromotionAsync(PromotionName, CancellationToken)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Task<Promotion> GetPromotionAsync(PromotionName name, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
PromotionName | name | Required. The name of the promotion to retrieve.
Format: |
CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
PromotionName name = PromotionName.FromAccountPromotion("[ACCOUNT]", "[PROMOTION]");
// Make the request
Promotion response = await promotionsServiceClient.GetPromotionAsync(name);
GetPromotionAsync(string, CallSettings)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Task<Promotion> GetPromotionAsync(string name, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
string | name | Required. The name of the promotion to retrieve.
Format: |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "accounts/[ACCOUNT]/promotions/[PROMOTION]";
// Make the request
Promotion response = await promotionsServiceClient.GetPromotionAsync(name);
GetPromotionAsync(string, CancellationToken)
Retrieves the promotion from your Merchant Center account.
After inserting or updating a promotion input, it may take several minutes before the updated promotion can be retrieved.
Declaration
public virtual Task<Promotion> GetPromotionAsync(string name, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
string | name | Required. The name of the promotion to retrieve.
Format: |
CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
string name = "accounts/[ACCOUNT]/promotions/[PROMOTION]";
// Make the request
Promotion response = await promotionsServiceClient.GetPromotionAsync(name);
InsertPromotion(InsertPromotionRequest, CallSettings)
Inserts a promotion for your Merchant Center account. If the promotion already exists, then it updates the promotion instead.
Declaration
public virtual Promotion InsertPromotion(InsertPromotionRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
InsertPromotionRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Promotion | The RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = PromotionsServiceClient.Create();
// Initialize request argument(s)
InsertPromotionRequest request = new InsertPromotionRequest
{
Parent = "",
Promotion = new Promotion(),
DataSource = "",
};
// Make the request
Promotion response = promotionsServiceClient.InsertPromotion(request);
InsertPromotionAsync(InsertPromotionRequest, CallSettings)
Inserts a promotion for your Merchant Center account. If the promotion already exists, then it updates the promotion instead.
Declaration
public virtual Task<Promotion> InsertPromotionAsync(InsertPromotionRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
InsertPromotionRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
InsertPromotionRequest request = new InsertPromotionRequest
{
Parent = "",
Promotion = new Promotion(),
DataSource = "",
};
// Make the request
Promotion response = await promotionsServiceClient.InsertPromotionAsync(request);
InsertPromotionAsync(InsertPromotionRequest, CancellationToken)
Inserts a promotion for your Merchant Center account. If the promotion already exists, then it updates the promotion instead.
Declaration
public virtual Task<Promotion> InsertPromotionAsync(InsertPromotionRequest request, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
InsertPromotionRequest | request | The request object containing all of the parameters for the API call. |
CancellationToken | cancellationToken | A CancellationToken to use for this RPC. |
Returns
Type | Description |
---|---|
Task<Promotion> | A Task containing the RPC response. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
InsertPromotionRequest request = new InsertPromotionRequest
{
Parent = "",
Promotion = new Promotion(),
DataSource = "",
};
// Make the request
Promotion response = await promotionsServiceClient.InsertPromotionAsync(request);
ListPromotions(ListPromotionsRequest, CallSettings)
Lists the promotions in your Merchant Center account. The
response might contain fewer items than specified by pageSize
. Rely on
pageToken
to determine if there are more items to be requested.
After inserting or updating a promotion, it may take several minutes before the updated processed promotion can be retrieved.
Declaration
public virtual PagedEnumerable<ListPromotionsResponse, Promotion> ListPromotions(ListPromotionsRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
ListPromotionsRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
PagedEnumerable<ListPromotionsResponse, Promotion> | A pageable sequence of Promotion resources. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = PromotionsServiceClient.Create();
// Initialize request argument(s)
ListPromotionsRequest request = new ListPromotionsRequest { Parent = "", };
// Make the request
PagedEnumerable<ListPromotionsResponse, Promotion> response = promotionsServiceClient.ListPromotions(request);
// Iterate over all response items, lazily performing RPCs as required
foreach (Promotion item in response)
{
// Do something with each item
Console.WriteLine(item);
}
// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListPromotionsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Promotion item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}
// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Promotion> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Promotion item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
ListPromotions(string, string, int?, CallSettings)
Lists the promotions in your Merchant Center account. The
response might contain fewer items than specified by pageSize
. Rely on
pageToken
to determine if there are more items to be requested.
After inserting or updating a promotion, it may take several minutes before the updated processed promotion can be retrieved.
Declaration
public virtual PagedEnumerable<ListPromotionsResponse, Promotion> ListPromotions(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
string | parent | Required. The account to list processed promotions for.
Format: |
string | pageToken | The token returned from the previous request. A value of |
int? | pageSize | The size of page to request. The response will not be larger than this, but may be smaller. A value of
|
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
PagedEnumerable<ListPromotionsResponse, Promotion> | A pageable sequence of Promotion resources. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = PromotionsServiceClient.Create();
// Initialize request argument(s)
string parent = "";
// Make the request
PagedEnumerable<ListPromotionsResponse, Promotion> response = promotionsServiceClient.ListPromotions(parent);
// Iterate over all response items, lazily performing RPCs as required
foreach (Promotion item in response)
{
// Do something with each item
Console.WriteLine(item);
}
// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (ListPromotionsResponse page in response.AsRawResponses())
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Promotion item in page)
{
// Do something with each item
Console.WriteLine(item);
}
}
// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Promotion> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Promotion item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
ListPromotionsAsync(ListPromotionsRequest, CallSettings)
Lists the promotions in your Merchant Center account. The
response might contain fewer items than specified by pageSize
. Rely on
pageToken
to determine if there are more items to be requested.
After inserting or updating a promotion, it may take several minutes before the updated processed promotion can be retrieved.
Declaration
public virtual PagedAsyncEnumerable<ListPromotionsResponse, Promotion> ListPromotionsAsync(ListPromotionsRequest request, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
ListPromotionsRequest | request | The request object containing all of the parameters for the API call. |
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
PagedAsyncEnumerable<ListPromotionsResponse, Promotion> | A pageable asynchronous sequence of Promotion resources. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
ListPromotionsRequest request = new ListPromotionsRequest { Parent = "", };
// Make the request
PagedAsyncEnumerable<ListPromotionsResponse, Promotion> response = promotionsServiceClient.ListPromotionsAsync(request);
// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Promotion item) =>
{
// Do something with each item
Console.WriteLine(item);
});
// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListPromotionsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Promotion item in page)
{
// Do something with each item
Console.WriteLine(item);
}
});
// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Promotion> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Promotion item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
ListPromotionsAsync(string, string, int?, CallSettings)
Lists the promotions in your Merchant Center account. The
response might contain fewer items than specified by pageSize
. Rely on
pageToken
to determine if there are more items to be requested.
After inserting or updating a promotion, it may take several minutes before the updated processed promotion can be retrieved.
Declaration
public virtual PagedAsyncEnumerable<ListPromotionsResponse, Promotion> ListPromotionsAsync(string parent, string pageToken = null, int? pageSize = null, CallSettings callSettings = null)
Parameters
Type | Name | Description |
---|---|---|
string | parent | Required. The account to list processed promotions for.
Format: |
string | pageToken | The token returned from the previous request. A value of |
int? | pageSize | The size of page to request. The response will not be larger than this, but may be smaller. A value of
|
CallSettings | callSettings | If not null, applies overrides to this RPC call. |
Returns
Type | Description |
---|---|
PagedAsyncEnumerable<ListPromotionsResponse, Promotion> | A pageable asynchronous sequence of Promotion resources. |
Sample code
// Create client
PromotionsServiceClient promotionsServiceClient = await PromotionsServiceClient.CreateAsync();
// Initialize request argument(s)
string parent = "";
// Make the request
PagedAsyncEnumerable<ListPromotionsResponse, Promotion> response = promotionsServiceClient.ListPromotionsAsync(parent);
// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((Promotion item) =>
{
// Do something with each item
Console.WriteLine(item);
});
// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((ListPromotionsResponse page) =>
{
// Do something with each page of items
Console.WriteLine("A page of results:");
foreach (Promotion item in page)
{
// Do something with each item
Console.WriteLine(item);
}
});
// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<Promotion> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (Promotion item in singlePage)
{
// Do something with each item
Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;
ShutdownDefaultChannelsAsync()
Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.
Declaration
public static Task ShutdownDefaultChannelsAsync()
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous shutdown operation. |
Remarks
After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.