Service to manage promotions for products. v1beta
Package
@google-shopping/promotionsConstructors
(constructor)(opts, gaxInstance)
constructor(opts?: ClientOptions, gaxInstance?: typeof gax | typeof gax.fallback);
Construct an instance of PromotionsServiceClient.
Parameters | |
---|---|
Name | Description |
opts |
ClientOptions
|
gaxInstance |
typeof gax | typeof fallback
: loaded instance of |
Properties
apiEndpoint
get apiEndpoint(): string;
The DNS address for this API service.
apiEndpoint
static get apiEndpoint(): string;
The DNS address for this API service - same as servicePath.
auth
auth: gax.GoogleAuth;
descriptors
descriptors: Descriptors;
innerApiCalls
innerApiCalls: {
[name: string]: Function;
};
pathTemplates
pathTemplates: {
[name: string]: gax.PathTemplate;
};
port
static get port(): number;
The port for this API service.
promotionsServiceStub
promotionsServiceStub?: Promise<{
[name: string]: Function;
}>;
scopes
static get scopes(): string[];
The scopes needed to make gRPC calls for every method defined in this service.
servicePath
static get servicePath(): string;
The DNS address for this API service.
universeDomain
get universeDomain(): string;
warn
warn: (code: string, message: string, warnType?: string) => void;
Methods
close()
close(): Promise<void>;
Terminate the gRPC channel and close the client.
The client will no longer be usable and all future behavior is undefined.
Returns | |
---|---|
Type | Description |
Promise<void> |
{Promise} A promise that resolves when the client is closed. |
getProjectId()
getProjectId(): Promise<string>;
Returns | |
---|---|
Type | Description |
Promise<string> |
getProjectId(callback)
getProjectId(callback: Callback<string, undefined, undefined>): void;
Parameter | |
---|---|
Name | Description |
callback |
Callback<string, undefined, undefined>
|
Returns | |
---|---|
Type | Description |
void |
getPromotion(request, options)
getPromotion(request?: protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest, options?: CallOptions): Promise<[
protos.google.shopping.merchant.promotions.v1beta.IPromotion,
(protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest | undefined),
{} | undefined
]>;
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.
Parameters | |
---|---|
Name | Description |
request |
IGetPromotionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.shopping.merchant.promotions.v1beta.IPromotion,
(protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest | undefined),
{} | undefined
]> |
{Promise} - The promise which resolves to an array. The first element of the array is an object representing Promotion. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The name of the promotion to retrieve.
* Format: `accounts/{account}/promotions/{promotions}`
*/
// const name = 'abc123'
// Imports the Promotions library
const {PromotionsServiceClient} = require('@google-shopping/promotions').v1beta;
// Instantiates a client
const promotionsClient = new PromotionsServiceClient();
async function callGetPromotion() {
// Construct request
const request = {
name,
};
// Run request
const response = await promotionsClient.getPromotion(request);
console.log(response);
}
callGetPromotion();
getPromotion(request, options, callback)
getPromotion(request: protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetPromotionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
getPromotion(request, callback)
getPromotion(request: protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest, callback: Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IGetPromotionRequest
|
callback |
Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IGetPromotionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
initialize()
initialize(): Promise<{
[name: string]: Function;
}>;
Initialize the client. Performs asynchronous operations (such as authentication) and prepares the client. This function will be called automatically when any class method is called for the first time, but if you need to initialize it before calling an actual method, feel free to call initialize() directly.
You can await on this method if you want to make sure the client is initialized.
Returns | |
---|---|
Type | Description |
Promise<{
[name: string]: Function;
}> |
{Promise} A promise that resolves to an authenticated service stub. |
insertPromotion(request, options)
insertPromotion(request?: protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest, options?: CallOptions): Promise<[
protos.google.shopping.merchant.promotions.v1beta.IPromotion,
(protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest | undefined),
{} | undefined
]>;
Inserts a promotion for your Merchant Center account. If the promotion already exists, then it updates the promotion instead.
Parameters | |
---|---|
Name | Description |
request |
IInsertPromotionRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.shopping.merchant.promotions.v1beta.IPromotion,
(protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest | undefined),
{} | undefined
]> |
{Promise} - The promise which resolves to an array. The first element of the array is an object representing Promotion. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The account where the promotion will be inserted.
* Format: accounts/{account}
*/
// const parent = 'abc123'
/**
* Required. The promotion to insert.
*/
// const promotion = {}
/**
* Required. The data source of the
* promotion (https://support.google.com/merchants/answer/6396268?sjid=5155774230887277618-NC)
* Format:
* `accounts/{account}/dataSources/{datasource}`.
*/
// const dataSource = 'abc123'
// Imports the Promotions library
const {PromotionsServiceClient} = require('@google-shopping/promotions').v1beta;
// Instantiates a client
const promotionsClient = new PromotionsServiceClient();
async function callInsertPromotion() {
// Construct request
const request = {
parent,
promotion,
dataSource,
};
// Run request
const response = await promotionsClient.insertPromotion(request);
console.log(response);
}
callInsertPromotion();
insertPromotion(request, options, callback)
insertPromotion(request: protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest, options: CallOptions, callback: Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IInsertPromotionRequest
|
options |
CallOptions
|
callback |
Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
insertPromotion(request, callback)
insertPromotion(request: protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest, callback: Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest | null | undefined, {} | null | undefined>): void;
Parameters | |
---|---|
Name | Description |
request |
IInsertPromotionRequest
|
callback |
Callback<protos.google.shopping.merchant.promotions.v1beta.IPromotion, protos.google.shopping.merchant.promotions.v1beta.IInsertPromotionRequest | null | undefined, {} | null | undefined>
|
Returns | |
---|---|
Type | Description |
void |
listPromotions(request, options)
listPromotions(request?: protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, options?: CallOptions): Promise<[
protos.google.shopping.merchant.promotions.v1beta.IPromotion[],
protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest | null,
protos.google.shopping.merchant.promotions.v1beta.IListPromotionsResponse
]>;
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.
Parameters | |
---|---|
Name | Description |
request |
IListPromotionsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Promise<[
protos.google.shopping.merchant.promotions.v1beta.IPromotion[],
protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest | null,
protos.google.shopping.merchant.promotions.v1beta.IListPromotionsResponse
]> |
{Promise} - The promise which resolves to an array. The first element of the array is Array of Promotion. The client library will perform auto-pagination by default: it will call the API as many times as needed and will merge results from all the pages into this array. Note that it can affect your quota. We recommend using |
listPromotions(request, options, callback)
listPromotions(request: protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, options: CallOptions, callback: PaginationCallback<protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, protos.google.shopping.merchant.promotions.v1beta.IListPromotionsResponse | null | undefined, protos.google.shopping.merchant.promotions.v1beta.IPromotion>): void;
Parameters | |
---|---|
Name | Description |
request |
IListPromotionsRequest
|
options |
CallOptions
|
callback |
PaginationCallback<protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, protos.google.shopping.merchant.promotions.v1beta.IListPromotionsResponse | null | undefined, protos.google.shopping.merchant.promotions.v1beta.IPromotion>
|
Returns | |
---|---|
Type | Description |
void |
listPromotions(request, callback)
listPromotions(request: protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, callback: PaginationCallback<protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, protos.google.shopping.merchant.promotions.v1beta.IListPromotionsResponse | null | undefined, protos.google.shopping.merchant.promotions.v1beta.IPromotion>): void;
Parameters | |
---|---|
Name | Description |
request |
IListPromotionsRequest
|
callback |
PaginationCallback<protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, protos.google.shopping.merchant.promotions.v1beta.IListPromotionsResponse | null | undefined, protos.google.shopping.merchant.promotions.v1beta.IPromotion>
|
Returns | |
---|---|
Type | Description |
void |
listPromotionsAsync(request, options)
listPromotionsAsync(request?: protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, options?: CallOptions): AsyncIterable<protos.google.shopping.merchant.promotions.v1beta.IPromotion>;
Equivalent to listPromotions
, but returns an iterable object.
for
-await
-of
syntax is used with the iterable to get response elements on-demand.
Parameters | |
---|---|
Name | Description |
request |
IListPromotionsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
AsyncIterable<protos.google.shopping.merchant.promotions.v1beta.IPromotion> |
{Object} An iterable Object that allows async iteration. When you iterate the returned iterable, each element will be an object representing Promotion. The API will be called under the hood as needed, once per the page, so you can stop the iteration when you don't need more results. Please see the documentation for more details and examples. |
/**
* This snippet has been automatically generated and should be regarded as a code template only.
* It will require modifications to work.
* It may require correct/in-range values for request initialization.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The account to list processed promotions for.
* Format: `accounts/{account}`
*/
// const parent = 'abc123'
/**
* Output only. The maximum number of promotions to return. The service may
* return fewer than this value. The maximum value is 1000; values above 1000
* will be coerced to 1000. If unspecified, the maximum number of promotions
* will be returned.
*/
// const pageSize = 1234
/**
* Output only. A page token, received from a previous `ListPromotions` call.
* Provide this to retrieve the subsequent page.
* When paginating, all other parameters provided to `ListPromotions` must
* match the call that provided the page token.
*/
// const pageToken = 'abc123'
// Imports the Promotions library
const {PromotionsServiceClient} = require('@google-shopping/promotions').v1beta;
// Instantiates a client
const promotionsClient = new PromotionsServiceClient();
async function callListPromotions() {
// Construct request
const request = {
parent,
pageSize,
pageToken,
};
// Run request
const iterable = promotionsClient.listPromotionsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}
callListPromotions();
listPromotionsStream(request, options)
listPromotionsStream(request?: protos.google.shopping.merchant.promotions.v1beta.IListPromotionsRequest, options?: CallOptions): Transform;
Equivalent to method.name.toCamelCase()
, but returns a NodeJS Stream object.
Parameters | |
---|---|
Name | Description |
request |
IListPromotionsRequest
The request object that will be sent. |
options |
CallOptions
Call options. See CallOptions for more details. |
Returns | |
---|---|
Type | Description |
Transform |
{Stream} An object stream which emits an object representing Promotion on 'data' event. The client library will perform auto-pagination by default: it will call the API as many times as needed. Note that it can affect your quota. We recommend using |
matchAccountFromPromotionName(promotionName)
matchAccountFromPromotionName(promotionName: string): string | number;
Parse the account from Promotion resource.
Parameter | |
---|---|
Name | Description |
promotionName |
string
A fully-qualified path representing Promotion resource. |
Returns | |
---|---|
Type | Description |
string | number |
{string} A string representing the account. |
matchPromotionFromPromotionName(promotionName)
matchPromotionFromPromotionName(promotionName: string): string | number;
Parse the promotion from Promotion resource.
Parameter | |
---|---|
Name | Description |
promotionName |
string
A fully-qualified path representing Promotion resource. |
Returns | |
---|---|
Type | Description |
string | number |
{string} A string representing the promotion. |
promotionPath(account, promotion)
promotionPath(account: string, promotion: string): string;
Return a fully-qualified promotion resource name string.
Parameters | |
---|---|
Name | Description |
account |
string
|
promotion |
string
|
Returns | |
---|---|
Type | Description |
string |
{string} Resource name string. |