Skip to content

Commit

Permalink
Merge pull request #15 from htdangkhoa/develop
Browse files Browse the repository at this point in the history
feat: support Google Ads v16
  • Loading branch information
htdangkhoa authored Mar 4, 2024
2 parents 6512243 + 269557e commit fad5f41
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h1 align="center">Google Ads API Nodejs Client Library</h1>

<p align="center">
<a href="https://developers.google.com/google-ads/api/docs/release-notes#v15">
<img src="https://img.shields.io/badge/google%20ads-v15-009688.svg?style=flat-square">
<a href="https://developers.google.com/google-ads/api/docs/release-notes#v16">
<img src="https://img.shields.io/badge/google%20ads-v16-009688.svg?style=flat-square">
</a>
<a href="https://www.npmjs.com/package/@htdangkhoa/google-ads">
<img src="https://img.shields.io/npm/v/@htdangkhoa/google-ads.svg?style=flat-square">
Expand Down Expand Up @@ -314,7 +314,7 @@ See more at [Node.js gRPC Library](https://grpc.github.io/grpc/node/module-src_c
yarn generate <GOOGLE_ADS_API_VERSION>
# example
yarn generate v15
yarn generate v16
```
3. Make sure the version number in the `src` folder is correct (it should match the version number you passed to the `generate` command)

Expand Down
4 changes: 2 additions & 2 deletions example/ad-group-ad.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { google } from 'googleapis';

import { GoogleAds } from '../src/lib';
import { AdTextAsset } from '../src/generated/google/ads/googleads/v15/common/ad_asset';
import { AdGroupAdStatusEnum_AdGroupAdStatus } from '../src/generated/google/ads/googleads/v15/enums/ad_group_ad_status';
import { AdTextAsset } from '../src/generated/google/ads/googleads/v16/common/ad_asset';
import { AdGroupAdStatusEnum_AdGroupAdStatus } from '../src/generated/google/ads/googleads/v16/enums/ad_group_ad_status';

const authClient = new google.auth.JWT({
keyFile: process.env.GOOGLE_APPLICATION_CREDENTIALS,
Expand Down
4 changes: 2 additions & 2 deletions example/ad-group.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { google } from 'googleapis';

import { GoogleAds } from '../src/lib';
import { AdGroupStatusEnum_AdGroupStatus } from '../src/generated/google/ads/googleads/v15/enums/ad_group_status';
import { AdGroupTypeEnum_AdGroupType } from '../src/generated/google/ads/googleads/v15/enums/ad_group_type';
import { AdGroupStatusEnum_AdGroupStatus } from '../src/generated/google/ads/googleads/v16/enums/ad_group_status';
import { AdGroupTypeEnum_AdGroupType } from '../src/generated/google/ads/googleads/v16/enums/ad_group_type';

const authClient = new google.auth.JWT({
keyFile: process.env.GOOGLE_APPLICATION_CREDENTIALS,
Expand Down
4 changes: 2 additions & 2 deletions example/asset.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { google } from 'googleapis';

import { GoogleAds } from '../src/lib';
import { Asset } from '../src/generated/google/ads/googleads/v15/resources/asset';
import { MutateOperation } from '../src/generated/google/ads/googleads/v15/services/google_ads_service';
import { Asset } from '../src/generated/google/ads/googleads/v16/resources/asset';
import { MutateOperation } from '../src/generated/google/ads/googleads/v16/services/google_ads_service';

const authClient = new google.auth.JWT({
keyFile: process.env.GOOGLE_APPLICATION_CREDENTIALS,
Expand Down
5 changes: 5 additions & 0 deletions scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ rm -rf $outdir
if [ ! -d "$path/.git" ]; then
echo 'Cloning Git repository'
git clone https://github.com/googleapis/googleapis.git "$path"
else
echo 'Pulling latest changes'
cd $path
git pull
cd -
fi

mkdir -p $outdir
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CustomerServiceClient } from '../generated/google';
import {
ListAccessibleCustomersRequest,
ListAccessibleCustomersResponse,
} from '../generated/google/ads/googleads/v15/services/customer_service';
} from '../generated/google/ads/googleads/v16/services/customer_service';

export class Customer extends Service {
protected get callMetadata(): Metadata {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/GoogleAds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SearchGoogleAdsStreamResponse,
MutateGoogleAdsRequest,
MutateGoogleAdsResponse,
} from '../generated/google/ads/googleads/v15/services/google_ads_service';
} from '../generated/google/ads/googleads/v16/services/google_ads_service';

export class GoogleAds extends Service {
private customerOptions: CustomerOptions;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const HOST = 'googleads.googleapis.com' as const;

export const VERSION = 'v15' as const;
export const VERSION = 'v16' as const;

export const FAILURE_KEY = `google.ads.googleads.${VERSION}.errors.googleadsfailure-bin`;
2 changes: 1 addition & 1 deletion src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { credentials, OAuth2Client, ServiceError } from '@grpc/grpc-js';
import { GoogleAdsFailure } from '../generated/google/ads/googleads/v15/errors/errors';
import { GoogleAdsFailure } from '../generated/google/ads/googleads/v16/errors/errors';
import { FAILURE_KEY } from './constants';

export const getCredentials = (authClient: OAuth2Client) => {
Expand Down
8 changes: 4 additions & 4 deletions src/tests/google-ads.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { status, Metadata, ServiceError } from '@grpc/grpc-js';
import { AuthenticationErrorEnum_AuthenticationError } from '../generated/google/ads/googleads/v15/errors/authentication_error';
import { AuthenticationErrorEnum_AuthenticationError } from '../generated/google/ads/googleads/v16/errors/authentication_error';
import {
ErrorCode,
GoogleAdsFailure,
} from '../generated/google/ads/googleads/v15/errors/errors';
import { RequestErrorEnum_RequestError } from '../generated/google/ads/googleads/v15/errors/request_error';
import { GoogleAdsRow } from '../generated/google/ads/googleads/v15/services/google_ads_service';
} from '../generated/google/ads/googleads/v16/errors/errors';
import { RequestErrorEnum_RequestError } from '../generated/google/ads/googleads/v16/errors/request_error';
import { GoogleAdsRow } from '../generated/google/ads/googleads/v16/services/google_ads_service';
import { Status } from '../generated/google/rpc/status';
import { FAILURE_KEY, QueryBuilder, VERSION } from '../lib';
import { GoogleAds } from '../lib/GoogleAds';
Expand Down
8 changes: 4 additions & 4 deletions src/tests/protos.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CustomerServiceClient } from '../generated/google/ads/googleads/v15/services/customer_service';
import { GoogleAdsServiceClient } from '../generated/google/ads/googleads/v15/services/google_ads_service';
import { Campaign } from '../generated/google/ads/googleads/v15/resources/campaign';
import { AdvertisingChannelTypeEnum_AdvertisingChannelType } from '../generated/google/ads/googleads/v15/enums/advertising_channel_type';
import { CustomerServiceClient } from '../generated/google/ads/googleads/v16/services/customer_service';
import { GoogleAdsServiceClient } from '../generated/google/ads/googleads/v16/services/google_ads_service';
import { Campaign } from '../generated/google/ads/googleads/v16/resources/campaign';
import { AdvertisingChannelTypeEnum_AdvertisingChannelType } from '../generated/google/ads/googleads/v16/enums/advertising_channel_type';
import { MOCK_ADDRESS, MOCK_CREDENTIALS } from './test-utils';

describe('CustomerServiceClient', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/tests/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { credentials, Metadata, ServiceError } from '@grpc/grpc-js';
import { google } from 'googleapis';
import { AdGroupStatusEnum_AdGroupStatus } from '../generated/google/ads/googleads/v15/enums/ad_group_status';
import { AdGroupTypeEnum_AdGroupType } from '../generated/google/ads/googleads/v15/enums/ad_group_type';
import { ListAccessibleCustomersResponse } from '../generated/google/ads/googleads/v15/services/customer_service';
import { AdGroupStatusEnum_AdGroupStatus } from '../generated/google/ads/googleads/v16/enums/ad_group_status';
import { AdGroupTypeEnum_AdGroupType } from '../generated/google/ads/googleads/v16/enums/ad_group_type';
import { ListAccessibleCustomersResponse } from '../generated/google/ads/googleads/v16/services/customer_service';
import {
GoogleAdsRow,
MutateGoogleAdsRequest,
Expand All @@ -13,7 +13,7 @@ import {
SearchGoogleAdsResponse,
SearchGoogleAdsStreamRequest,
SearchGoogleAdsStreamResponse,
} from '../generated/google/ads/googleads/v15/services/google_ads_service';
} from '../generated/google/ads/googleads/v16/services/google_ads_service';
import { AllServices, Customer, GoogleAds, Service, ServiceName } from '../lib';

export const MOCK_ADDRESS = 'googleads.googleapis.com';
Expand Down

0 comments on commit fad5f41

Please sign in to comment.