@cemiar/cemiarlink-sdk 1.0.25 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,2 +1,2 @@
1
- # @cemiar/cemiarlink-sdk
2
-
1
+ # @cemiar/cemiarlink-sdk
2
+
@@ -4,7 +4,7 @@ export interface Contact {
4
4
  AccountType: string;
5
5
  Address: Address;
6
6
  BillingContactMethod: string;
7
- ServiceContactMethod: string;
7
+ ServicingContactMethod: string;
8
8
  BusinessName: string;
9
9
  Id: string;
10
10
  ContactMethod: string;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Google Ads conversion data for upload
3
+ */
4
+ export interface GoogleAdsConversion {
5
+ gclid: string;
6
+ conversion_action: string;
7
+ conversion_date_time: string;
8
+ conversion_value: number;
9
+ currency_code: string;
10
+ }
11
+ /**
12
+ * Base response interface for Google Ads API calls
13
+ */
14
+ export interface GoogleAdsBaseResponse {
15
+ success: boolean;
16
+ message?: string;
17
+ route?: string;
18
+ }
19
+ /**
20
+ * Response for campaign lookup
21
+ */
22
+ export interface GoogleAdsCampaignResponse extends GoogleAdsBaseResponse {
23
+ data?: {
24
+ campaign?: any;
25
+ ad_groups?: any[];
26
+ ads?: any[];
27
+ status?: string;
28
+ budget?: any;
29
+ metrics?: any;
30
+ };
31
+ }
32
+ /**
33
+ * Response for ad lookup
34
+ */
35
+ export interface GoogleAdsAdResponse extends GoogleAdsBaseResponse {
36
+ data?: {
37
+ resource_name?: string;
38
+ id?: string;
39
+ final_urls?: string[];
40
+ click_views?: any[];
41
+ };
42
+ }
43
+ /**
44
+ * Response for click view lookup
45
+ */
46
+ export interface GoogleAdsClickViewResponse extends GoogleAdsBaseResponse {
47
+ data?: {
48
+ campaign?: any;
49
+ ad_group?: any;
50
+ ad?: any;
51
+ location?: any;
52
+ device?: any;
53
+ gclid?: string;
54
+ click_info?: any;
55
+ };
56
+ }
57
+ /**
58
+ * Response for conversion actions list
59
+ */
60
+ export interface GoogleAdsConversionActionsResponse extends GoogleAdsBaseResponse {
61
+ data?: {
62
+ conversion_actions?: any[];
63
+ };
64
+ }
65
+ /**
66
+ * Response for single conversion action lookup
67
+ */
68
+ export interface GoogleAdsConversionActionResponse extends GoogleAdsBaseResponse {
69
+ data?: {
70
+ conversion_action?: any;
71
+ settings?: any;
72
+ configuration?: any;
73
+ };
74
+ }
75
+ /**
76
+ * Response for conversion upload
77
+ */
78
+ export interface GoogleAdsConversionUploadResponse {
79
+ success: boolean;
80
+ partial_failure_error?: string;
81
+ results?: any[];
82
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from './GoogleAds';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./GoogleAds"), exports);
@@ -0,0 +1,53 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { GoogleAdsConversion, GoogleAdsCampaignResponse, GoogleAdsAdResponse, GoogleAdsClickViewResponse, GoogleAdsConversionActionsResponse, GoogleAdsConversionActionResponse, GoogleAdsConversionUploadResponse } from '../models/googleads';
3
+ /**
4
+ * GoogleAdsService provides methods to interact with Google Ads API.
5
+ * It offers methods for campaigns, ads, click views, conversion actions, and conversion uploads.
6
+ */
7
+ export declare class GoogleAdsService {
8
+ axiosInstance: AxiosInstance;
9
+ constructor(baseUrl: string | undefined, headers: object);
10
+ /**
11
+ * Get campaign details by name from Google Ads
12
+ * @param enterprise - The enterprise identifier
13
+ * @param campaignName - The campaign name to look up
14
+ * @returns Campaign information including ad groups, ads, status, budget, and metrics
15
+ */
16
+ getCampaignByName(enterprise: string, campaignName: string): Promise<GoogleAdsCampaignResponse>;
17
+ /**
18
+ * Get ad details by ID from Google Ads
19
+ * @param enterprise - The enterprise identifier
20
+ * @param adId - The Ad ID to look up
21
+ * @param date - Optional filter date for click views (YYYY-MM-DD), defaults to today
22
+ * @returns Ad information including resource_name, id, final_urls, and click views with gclid
23
+ */
24
+ getAdById(enterprise: string, adId: string, date?: string): Promise<GoogleAdsAdResponse>;
25
+ /**
26
+ * Get click view details by gclid from Google Ads
27
+ * @param enterprise - The enterprise identifier
28
+ * @param gclid - The Google Click ID to look up
29
+ * @param date - Optional filter date (YYYY-MM-DD), defaults to today
30
+ * @returns Click view information including campaign, ad group, ad, location, device, and other click information
31
+ */
32
+ getClickViewByGclid(enterprise: string, gclid: string, date?: string): Promise<GoogleAdsClickViewResponse>;
33
+ /**
34
+ * Get all conversion actions from Google Ads
35
+ * @param enterprise - The enterprise identifier
36
+ * @returns List of conversion actions with their settings and configuration
37
+ */
38
+ getConversionActions(enterprise: string): Promise<GoogleAdsConversionActionsResponse>;
39
+ /**
40
+ * Get conversion action by ID from Google Ads
41
+ * @param enterprise - The enterprise identifier
42
+ * @param conversionId - The conversion ID to look up
43
+ * @returns Conversion details including settings and configuration
44
+ */
45
+ getConversionActionById(enterprise: string, conversionId: string): Promise<GoogleAdsConversionActionResponse>;
46
+ /**
47
+ * Upload offline conversions to Google Ads
48
+ * @param enterprise - The enterprise identifier
49
+ * @param conversions - Array of conversions to upload (each requires gclid, conversion_action, conversion_date_time, conversion_value, currency_code)
50
+ * @returns Upload result including success status and partial failure errors if any
51
+ */
52
+ uploadConversions(enterprise: string, conversions: GoogleAdsConversion[]): Promise<GoogleAdsConversionUploadResponse>;
53
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleAdsService = void 0;
4
+ const AxiosClient_1 = require("../utils/AxiosClient");
5
+ const BASE_PATH = 'google-ads';
6
+ /**
7
+ * GoogleAdsService provides methods to interact with Google Ads API.
8
+ * It offers methods for campaigns, ads, click views, conversion actions, and conversion uploads.
9
+ */
10
+ class GoogleAdsService {
11
+ constructor(baseUrl, headers) {
12
+ this.axiosInstance = new AxiosClient_1.AxiosClient(baseUrl, headers).getInstance();
13
+ }
14
+ /**
15
+ * Get campaign details by name from Google Ads
16
+ * @param enterprise - The enterprise identifier
17
+ * @param campaignName - The campaign name to look up
18
+ * @returns Campaign information including ad groups, ads, status, budget, and metrics
19
+ */
20
+ async getCampaignByName(enterprise, campaignName) {
21
+ const { data } = await this.axiosInstance.get(`${BASE_PATH}/${encodeURIComponent(enterprise)}/campaign/${encodeURIComponent(campaignName)}`);
22
+ return data;
23
+ }
24
+ /**
25
+ * Get ad details by ID from Google Ads
26
+ * @param enterprise - The enterprise identifier
27
+ * @param adId - The Ad ID to look up
28
+ * @param date - Optional filter date for click views (YYYY-MM-DD), defaults to today
29
+ * @returns Ad information including resource_name, id, final_urls, and click views with gclid
30
+ */
31
+ async getAdById(enterprise, adId, date) {
32
+ let url = `${BASE_PATH}/${encodeURIComponent(enterprise)}/ad/${encodeURIComponent(adId)}`;
33
+ if (date) {
34
+ url += `?date=${encodeURIComponent(date)}`;
35
+ }
36
+ const { data } = await this.axiosInstance.get(url);
37
+ return data;
38
+ }
39
+ /**
40
+ * Get click view details by gclid from Google Ads
41
+ * @param enterprise - The enterprise identifier
42
+ * @param gclid - The Google Click ID to look up
43
+ * @param date - Optional filter date (YYYY-MM-DD), defaults to today
44
+ * @returns Click view information including campaign, ad group, ad, location, device, and other click information
45
+ */
46
+ async getClickViewByGclid(enterprise, gclid, date) {
47
+ let url = `${BASE_PATH}/${encodeURIComponent(enterprise)}/click-view/${encodeURIComponent(gclid)}`;
48
+ if (date) {
49
+ url += `?date=${encodeURIComponent(date)}`;
50
+ }
51
+ const { data } = await this.axiosInstance.get(url);
52
+ return data;
53
+ }
54
+ /**
55
+ * Get all conversion actions from Google Ads
56
+ * @param enterprise - The enterprise identifier
57
+ * @returns List of conversion actions with their settings and configuration
58
+ */
59
+ async getConversionActions(enterprise) {
60
+ const { data } = await this.axiosInstance.get(`${BASE_PATH}/${encodeURIComponent(enterprise)}/conversion-actions`);
61
+ return data;
62
+ }
63
+ /**
64
+ * Get conversion action by ID from Google Ads
65
+ * @param enterprise - The enterprise identifier
66
+ * @param conversionId - The conversion ID to look up
67
+ * @returns Conversion details including settings and configuration
68
+ */
69
+ async getConversionActionById(enterprise, conversionId) {
70
+ const { data } = await this.axiosInstance.get(`${BASE_PATH}/${encodeURIComponent(enterprise)}/conversion-action/${encodeURIComponent(conversionId)}`);
71
+ return data;
72
+ }
73
+ /**
74
+ * Upload offline conversions to Google Ads
75
+ * @param enterprise - The enterprise identifier
76
+ * @param conversions - Array of conversions to upload (each requires gclid, conversion_action, conversion_date_time, conversion_value, currency_code)
77
+ * @returns Upload result including success status and partial failure errors if any
78
+ */
79
+ async uploadConversions(enterprise, conversions) {
80
+ const { data } = await this.axiosInstance.post(`${BASE_PATH}/${encodeURIComponent(enterprise)}/conversions`, conversions);
81
+ return data;
82
+ }
83
+ }
84
+ exports.GoogleAdsService = GoogleAdsService;
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
- {
2
- "name": "@cemiar/cemiarlink-sdk",
3
- "version": "1.0.25",
4
- "description": "CemiarLink SDK to access CemiarLink API services",
5
- "engines": {
6
- "npm": ">=9.5.1",
7
- "node": ">=18.16.0"
8
- },
9
- "author": "Cemiar",
10
- "license": "ISC",
11
- "main": "dist/services/Admin.js",
12
- "module": "./dist/services/Admin.mjs",
13
- "types": "./dist/services/Admin.d.ts",
14
- "files": [
15
- "dist"
16
- ],
17
- "dependencies": {
18
- "@types/nodemailer": "^8.0.0",
19
- "axios": "^1.15.0",
20
- "fs": "^0.0.1-security",
21
- "nodemailer": "^8.0.5",
22
- "path": "^0.12.7",
23
- "xlsx": "^0.18.5"
24
- },
25
- "devDependencies": {
26
- "@types/node": "^18.19.0",
27
- "ts-node": "^10.9.2"
28
- },
29
- "scripts": {
30
- "build": "rm -rf dist/ && tsc -p tsconfig.json",
31
- "buildWindows": "rmdir /s /q dist & tsc -p tsconfig.json"
32
- },
33
- "overrides": {
34
- "xlsx": {
35
- "sheetjs": "^2.0.0"
36
- }
37
- }
38
- }
1
+ {
2
+ "name": "@cemiar/cemiarlink-sdk",
3
+ "version": "1.0.27",
4
+ "description": "CemiarLink SDK to access CemiarLink API services",
5
+ "engines": {
6
+ "npm": ">=9.5.1",
7
+ "node": ">=18.16.0"
8
+ },
9
+ "author": "Cemiar",
10
+ "license": "ISC",
11
+ "main": "dist/services/Admin.js",
12
+ "module": "./dist/services/Admin.mjs",
13
+ "types": "./dist/services/Admin.d.ts",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "@types/nodemailer": "^8.0.0",
19
+ "axios": "^1.15.0",
20
+ "fs": "^0.0.1-security",
21
+ "nodemailer": "^8.0.5",
22
+ "path": "^0.12.7",
23
+ "xlsx": "^0.18.5"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^18.19.0",
27
+ "ts-node": "^10.9.2"
28
+ },
29
+ "scripts": {
30
+ "build": "rm -rf dist/ && tsc -p tsconfig.json",
31
+ "buildWindows": "rmdir /s /q dist & tsc -p tsconfig.json"
32
+ },
33
+ "overrides": {
34
+ "xlsx": {
35
+ "sheetjs": "^2.0.0"
36
+ }
37
+ }
38
+ }