Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pause/play adword compaign #90

Open
fawad-khalil opened this issue Nov 27, 2018 · 1 comment
Open

How to pause/play adword compaign #90

fawad-khalil opened this issue Nov 27, 2018 · 1 comment

Comments

@fawad-khalil
Copy link

Refering to php's client library (here) below is the pattern of pausing an ad:

  1. Create a new object.
  2. Set its ID to be the ID of the entity you want to modify.
  3. Set the new value of the property on that new object.
  4. Create an operation object with SET as the operator and this new entity object as the operand.
  5. Pass the operation object into the mutate() method of the appropriate service.

How will I do the same using node-adwords? an example snippet will be much appreciated.

@mbejda
Copy link

mbejda commented Jan 21, 2019

Here is an example from my code :
adwords user object

        const obj = {
            userAgent:'test',
            developerToken: developerToken,
            client_id: googleClientId,
            client_secret: googleClientSecret,
            access_token: authObject.access_token,
            refresh_token: authObject.refresh_token,
            debug: false
    };
        if(authObject.clientCustomerId){
            obj.clientCustomerId = authObject.clientCustomerId;
        }
        this.adwordsUser = new AdwordsUser(obj);
    }

Operation

        return new Promise((resolve, reject) => {
            const campaignService = this.adwordsUser.getService('CampaignService', 'v201802');
            const campaignOperation = {
                operations: {
                    operator: 'SET',
                    operand: {
                        id: campaignId,
                        status: obj.status
                    }
                }
            };
            campaignService.mutate(campaignOperation, function (error, result) {
                if (error) {
                    return reject(error);
                }
                return resolve(result);
            });
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants