Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

google-adwords

Package Overview
Dependencies
Maintainers
4
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

google-adwords - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

test/mocha.opts

2

index.js

@@ -14,2 +14,2 @@ // Copyright (c) 2015, Trent Oswald <trentoswald@therebelrobot.com

module.exports = require('./lib/googleadwords');
module.exports = require('./lib/googleadwords')

@@ -7,3 +7,3 @@ // Copyright (c) 2015, Trent Oswald <trentoswald@therebelrobot.com

//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// THE SOFTWARE IS PROVIDED 'AS IS' AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND

@@ -15,9 +15,7 @@ // FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,

var Promise = require('bluebird');
var request = require('unirest');
var auth = require('adwords-auth');
var _ = require('lodash');
var parseString = require("xml2js").parseString;
var parseStringAsync = Promise.promisify(require("xml2js").parseString);
var moment = require('moment');
var BBPromise = require('bluebird')
var request = require('unirest')
var auth = require('adwords-auth')
var _ = require('lodash')
var moment = require('moment')

@@ -31,15 +29,15 @@ /**

*/
var GoogleAdwords = function(spec, my) {
my = my || {};
spec = spec || {};
var GoogleAdwords = function (spec, my) {
my = my || {}
spec = spec || {}
var self = this;
var self = this
my.limit = null;
my.remaining = null;
my.awqlOptions = {};
my.auth = {};
my.agent = spec.agent;
my.host = spec.host || 'https://adwords.google.com/api/adwords/reportdownload/v201409';
my.port = spec.port || 443;
my.limit = null
my.remaining = null
my.awqlOptions = {}
my.auth = {}
my.agent = spec.agent
my.host = spec.host || 'https://adwords.google.com/api/adwords/reportdownload/v201409'
my.port = spec.port || 443

@@ -50,13 +48,13 @@ /*******************************/

var _selectStatement = function(rows) {
var _selectStatement = function (rows) {
if (_.isArray(rows)) {
rows = rows.join(',');
rows = rows.join(',')
}
my.awqlOptions.select = rows;
my.awqlOptions.select = rows
return {
from: _fromStatement
};
}
}
var _fromStatement = function(report) {
my.awqlOptions.from = report;
var _fromStatement = function (report) {
my.awqlOptions.from = report
return {

@@ -68,4 +66,4 @@ where: _whereStatement,

}
var _whereStatement = function(statement) {
my.awqlOptions.where = statement;
var _whereStatement = function (statement) {
my.awqlOptions.where = statement
return {

@@ -76,10 +74,10 @@ and: _andStatement,

}
var _andStatement = function(statement) {
var _andStatement = function (statement) {
if (!my.awqlOptions.and) {
my.awqlOptions.and = [];
my.awqlOptions.and = []
}
if (_.isArray(statement)) {
my.awqlOptions.and = _.union(my.awqlOptions.and, statement);
my.awqlOptions.and = _.union(my.awqlOptions.and, statement)
} else {
my.awqlOptions.and.push(statement);
my.awqlOptions.and.push(statement)
}

@@ -91,7 +89,7 @@ return {

}
var _duringStatement = function(timeframe) {
var _duringStatement = function (timeframe) {
if (_.isArray(timeframe)) {
timeframe = timeframe.join(',');
timeframe = timeframe.join(',')
}
my.awqlOptions.during = timeframe;
my.awqlOptions.during = timeframe
return {

@@ -101,22 +99,22 @@ send: _refreshAuth

}
var _refreshAuth = function() {
return new Promise(function(resolve, reject) {
if (!my.auth.accessToken || my.auth.tokenExpires < parseInt(moment().format('X'))) {
auth.refresh(my.auth.clientID, my.auth.clientSecret, my.auth.refreshToken, function(err, token) {;
if (token.error) {
reject(token.error + token.error_description);
var _refreshAuth = function () {
return new BBPromise(function (resolve, reject) {
if (!my.auth.accessToken || my.auth.tokenExpires < parseInt(moment().format('X'), 10)) {
auth.refresh(my.auth.clientID, my.auth.clientSecret, my.auth.refreshToken, function (err, token) {
if (err || token.error) {
reject(err + token.error + token.error_description)
return
};
my.auth.accessToken = token.access_token;
my.auth.tokenExpires = token.expires;
return resolve(_sendAWQL());
});
}
my.auth.accessToken = token.access_token
my.auth.tokenExpires = token.expires
return resolve(_sendAWQL())
})
} else {
return resolve(_sendAWQL());
return resolve(_sendAWQL())
}
});
})
}
var _sendAWQL = function() {
return new Promise(function(resolve, reject) {
var finalAWQL = _.cloneDeep(my.awqlOptions);
var _sendAWQL = function () {
return new BBPromise(function (resolve, reject) {
var finalAWQL = _.cloneDeep(my.awqlOptions)
if (_.isObject(finalAWQL)) {

@@ -127,24 +125,24 @@ finalAWQL =

'+FROM+' +
my.awqlOptions.from;
my.awqlOptions.from
if (my.awqlOptions.where) {
finalAWQL += '+WHERE+' + my.awqlOptions.where;
finalAWQL += '+WHERE+' + my.awqlOptions.where
}
if (my.awqlOptions.and) {
finalAWQL += '+AND+' + my.awqlOptions.and.join('+AND+');
finalAWQL += '+AND+' + my.awqlOptions.and.join('+AND+')
}
if (my.awqlOptions.during) {
finalAWQL += '+DURING+' + my.awqlOptions.during;
finalAWQL += '+DURING+' + my.awqlOptions.during
}
} else if (_.isString(finalAWQL)) {
finalAWQL = finalAWQL.split(', ').join(',').split(' ').join('+');
finalAWQL = finalAWQL.split(', ').join(',').split(' ').join('+')
}
my.awqlOptions = {};
var builtAWQL = '__rdquery=' + finalAWQL + '&__fmt=TSV';
var header = _buildHeader(builtAWQL.length);
my.awqlOptions = {}
var builtAWQL = '__rdquery=' + finalAWQL + '&__fmt=TSV'
var header = _buildHeader(builtAWQL.length)
request.post(my.host)
.header(header)
.send(builtAWQL)
.end(function(results) {
.end(function (results) {
if (results.error) {
var msg;
var msg
if (results.body.indexOf('ReportDefinitionError.INVALID_FIELD_NAME_FOR_REPORT') > -1) {

@@ -154,19 +152,19 @@ msg = 'Error: Invalid field selected. Please review your query and try again.'

if (results.body.indexOf('ReportDefinitionError.CUSTOMER_SERVING_TYPE_REPORT_MISMATCH') > -1) {
msg = "Error: Please use your Google Adwords credentials other than MCC Account.";
msg = 'Error: Please use your Google Adwords credentials other than MCC Account.'
}
if (results.body.indexOf('AuthorizationError.USER_PERMISSION_DENIED') > -1) {
msg = 'AuthorizationError.USER_PERMISSION_DENIED';
msg = 'AuthorizationError.USER_PERMISSION_DENIED'
}
if (results.body.indexOf('AuthenticationError.OAUTH_TOKEN_INVALID') > -1) {
msg = "Authentication Error. OAUTH_TOKEN_INVALID";
msg = 'Authentication Error. OAUTH_TOKEN_INVALID'
}
msg = msg || results.error;
msg = msg || results.error
return reject(msg)
}
var body = results.body;
resolve(_parseResults(body));
});
});
};
var _buildHeader = function(bodyLength) {
var body = results.body
resolve(_parseResults(body))
})
})
}
var _buildHeader = function (bodyLength) {
return {

@@ -179,26 +177,26 @@ Authorization: 'Bearer ' + my.auth.accessToken,

'Content-Length': bodyLength
};
};
var _parseResults = function(body) {
var _finalObj = {};
var bodyArray = body.split('\n');
bodyArray.pop();
var title = bodyArray[0].split('"').join('');
var date = title.split('(')[1].split(')')[0];
_finalObj.report = title.split(' ')[0];
_finalObj.timeframe = date;
bodyArray.shift();
_finalObj.total = bodyArray[bodyArray.length - 1].split('\t')[1];
bodyArray.pop();
var columnNames = bodyArray[0].split('\t');
_finalObj.fieldLength = columnNames.length;
bodyArray.shift();
_finalObj.data = _.map(bodyArray, function(row) {
row = row.split('\t');
var rowObj = {};
_.forEach(columnNames, function(columnName, index) {
rowObj[columnName.toLowerCase()] = row[index];
}
}
var _parseResults = function (body) {
var _finalObj = {}
var bodyArray = body.split('\n')
bodyArray.pop()
var title = bodyArray[0].split('"').join('')
var date = title.split('(')[1].split(')')[0]
_finalObj.report = title.split(' ')[0]
_finalObj.timeframe = date
bodyArray.shift()
_finalObj.total = bodyArray[bodyArray.length - 1].split('\t')[1]
bodyArray.pop()
var columnNames = bodyArray[0].split('\t')
_finalObj.fieldLength = columnNames.length
bodyArray.shift()
_finalObj.data = _.map(bodyArray, function (row) {
row = row.split('\t')
var rowObj = {}
_.forEach(columnNames, function (columnName, index) {
rowObj[columnName.toLowerCase()] = row[index]
})
return rowObj;
});
return rowObj
})
_finalObj.auth = {

@@ -208,4 +206,4 @@ accessToken: my.auth.accessToken,

}
return _finalObj;
};
return _finalObj
}

@@ -224,47 +222,47 @@ /*****************************/

*/
this.use = function(options) {
if (typeof options === 'object') {
if (options.refreshToken && options.clientCustomerID) {
my.limit = null;
my.remaining = null;
my.auth.accessToken = options.accessToken || null;
my.auth.tokenExpires = options.tokenExpires || null;
my.auth.refreshToken = options.refreshToken;
my.auth.clientCustomerID = options.clientCustomerID;
} else if (options.clientID && options.clientSecret && options.developerToken) {
my.limit = null;
my.remaining = null;
my.auth.accessToken = null;
my.auth.tokenExpires = null;
my.auth.clientID = options.clientID;
my.auth.clientSecret = options.clientSecret;
my.auth.developerToken = options.developerToken;
self.use = function (options) {
if (typeof options === 'object') {
if (options.refreshToken && options.clientCustomerID) {
my.limit = null
my.remaining = null
my.auth.accessToken = options.accessToken || null
my.auth.tokenExpires = options.tokenExpires || null
my.auth.refreshToken = options.refreshToken
my.auth.clientCustomerID = options.clientCustomerID
} else if (options.clientID && options.clientSecret && options.developerToken) {
my.limit = null
my.remaining = null
my.auth.accessToken = null
my.auth.tokenExpires = null
my.auth.clientID = options.clientID
my.auth.clientSecret = options.clientSecret
my.auth.developerToken = options.developerToken
} else {
throw new Error('Wrong param "options"')
}
} else {
throw new Error('Wrong param "options"');
throw new Error('Wrong param "options"')
}
} else {
throw new Error('Wrong param "options"');
}
};
// https://developers.google.com/adwords/api/docs/guides/awql
this.awql = function(options) {
// https://developers.google.com/adwords/api/docs/guides/awql
self.awql = function (options) {
if (options) {
my.awqlOptions = _.cloneDeep(options);
my.awqlOptions = _.cloneDeep(options)
if (_.isArray(my.awqlOptions.select)) {
my.awqlOptions.select = my.awqlOptions.select.join(',');
my.awqlOptions.select = my.awqlOptions.select.join(',')
}
if (_.isArray(my.awqlOptions.during)) {
my.awqlOptions.during = my.awqlOptions.during.join(',');
my.awqlOptions.during = my.awqlOptions.during.join(',')
}
return {
send: _refreshAuth
};
}
}
return {
select: _selectStatement
};
}
}
return this;
};
return self
}
module.exports = new GoogleAdwords();
module.exports = new GoogleAdwords()
{
"name": "google-adwords",
"version": "1.0.0",
"version": "1.1.0",
"description": "A Node.js driver for Google Adwords Reporting API (v201409)",
"main": "lib/googleadwords.js",
"scripts": {
"test": "mocha"
"test": "./node_modules/standard/bin/cmd.js && ./node_modules/istanbul/lib/cli.js cover _mocha --",
"testCoverage": "./node_modules/istanbul/lib/cli.js cover _mocha --"
},

@@ -34,5 +35,7 @@ "repository": {

"devDependencies": {
"chai": "^2.0.0",
"mocha": "^2.1.0"
"chai": "^2.1.1",
"istanbul": "^0.3.7",
"mocha": "^2.2.1",
"standard": "^2.11.0"
}
}
# google-adwords
[![npm](https://img.shields.io/npm/dm/google-adwords.svg)](https://www.npmjs.com/package/google-adwords)
[![Code Climate](https://img.shields.io/codeclimate/coverage/github/Growmies/google-adwords.svg)](https://codeclimate.com/github/Growmies/google-adwords)
[![NPM](https://nodei.co/npm/google-adwords.png?downloads=true)](https://nodei.co/npm/google-adwords/)
[![NPM](https://nodei.co/npm-dl/google-adwords.png?months=3&height=2)](https://nodei.co/npm/google-adwords/)
[![Dependency Status](https://david-dm.org/Growmies/google-adwords.svg)](https://david-dm.org/Growmies/google-adwords)
[![Code Climate](https://codeclimate.com/github/Growmies/google-adwords/badges/gpa.svg)](https://codeclimate.com/github/Growmies/google-adwords)
[![Test Coverage](https://codeclimate.com/github/Growmies/google-adwords/badges/coverage.svg)](https://codeclimate.com/github/Growmies/google-adwords)
A Node.js driver for Google Adwords Reporting API (v201409)

@@ -225,22 +230,27 @@

To contribute, fork the repo, and make sure to install dev dependencies using
```bash
npm install --dev
```
To contribute code to this module, please follow this workflow:
Make sure all changes have been updated/added in the `test/` folder, and, making sure you have [`mocha` installed globally](http://mochajs.org/#installation), run:
1. fork the repo
2. make sure to install dev dependencies using
```bash
mocha
```
```bash
npm install --dev
```
which should return without any errors. Additionally, make sure you have checked the test coverage for your change, by [installing `istanbul` globally](https://github.com/gotwarlost/istanbul#getting-started), then running:
3. Make the changes you desire
4. Ensure all changes have a new test in the `test/` folder, and run:
```bash
istanbul cover _mocha --
```
You can then find the coverage report in `coverage/lcov-report/index.html`.
```bash
npm test
```
After making changes in your fork, open a pull request.
This will check do the following:
* Check your code against [feross/standard style](https://github.com/feross/standard) and notify of any issues.
* Run all mocha tests listed in `test/`
* Run all code through [istanbul's code coverage runner](https://github.com/gotwarlost/istanbul). You can check the coverage afterwards the coverage report page: `coverage/lcov-report/index.html`
5. After making changes in your fork, open a pull request.
Please note that if your code updates do not pass JS Standard style, mocha tests and code coverage, your PR may be rejected and you'll need to fix any issues listed in it.
## Changelog

@@ -253,2 +263,9 @@

### v1.1.0 - 2015-03-13
#### Added
- Converted to [feross/standard style](https://github.com/feross/standard)
- Updated tests and scripts in package.json
- Updated contributing docs
### v1.0.0 - 2015-02-23

@@ -267,2 +284,2 @@ #### Added

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

@@ -1,17 +0,18 @@

var _ = require('lodash');
var Promise = require('bluebird');
var fs = require('fs');
var expect = require('chai').expect;
var authFileName = __dirname + '/test-auth.json';
var ga = require('../lib/googleadwords');
var auth = null;
var auth2 = null;
var _ = require('lodash')
var fs = require('fs')
var expect = require('chai').expect
var authFileName = __dirname + '/test-auth.json'
var ga = require('../lib/googleadwords')
var auth = null
var auth2 = null
describe('google-adwords', function() {
/* JS Standard definitions */
/* globals describe, beforeEach, it */
this.timeout(5000);
beforeEach(function(done) {
fs.readFile(authFileName, 'utf8', function(err, results) {
auth = JSON.parse(results);
describe('google-adwords', function () {
this.timeout(5000)
beforeEach(function (done) {
fs.readFile(authFileName, 'utf8', function (err, results) {
if (err) throw new Error(err)
auth = JSON.parse(results)
ga.use({

@@ -21,16 +22,12 @@ clientID: auth.clientID,

developerToken: auth.developerToken
});
})
ga.use({
refreshToken: auth.user.refreshToken,
clientCustomerID: auth.user.clientCustomerId
});
done();
});
});
// it('should validate auth', function(done) {
// });
describe('ga-awql', function() {
it('should get data from AWQL using promises (w/arrays)', function(done) {
})
done()
})
})
describe('ga-awql', function () {
it('should get data from AWQL using promises (w/arrays)', function (done) {
ga.awql()

@@ -40,15 +37,15 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
.send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using promises (w/strings)', function(done) {
})
it('should get data from AWQL using promises (w/strings)', function (done) {
ga.awql()

@@ -58,15 +55,15 @@ .select('Date,Clicks')

.during('20120101,20150125')
.send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
.send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using options (w/arrays)', function(done) {
})
it('should get data from AWQL using options (w/arrays)', function (done) {
var options = {

@@ -77,15 +74,15 @@ select: ['Date', 'Clicks'],

}
ga.awql(options).send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
ga.awql(options).send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using options (w/strings)', function(done) {
})
it('should get data from AWQL using options (w/strings)', function (done) {
var options = {

@@ -96,29 +93,29 @@ select: 'Date,Clicks',

}
ga.awql(options).send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
ga.awql(options).send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
})
it('should get data from AWQL using string', function(done) {
ga.awql('SELECT Date, Clicks FROM ACCOUNT_PERFORMANCE_REPORT DURING 20120101, 20150125').send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
it('should get data from AWQL using string', function (done) {
ga.awql('SELECT Date, Clicks FROM ACCOUNT_PERFORMANCE_REPORT DURING 20120101, 20150125').send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using promises (w/WHERE clause)', function(done) {
})
it('should get data from AWQL using promises (w/WHERE clause)', function (done) {
ga.awql()

@@ -129,15 +126,15 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
.send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using promises (w/WHERE and AND(string) clauses)', function(done) {
})
it('should get data from AWQL using promises (w/WHERE and AND(string) clauses)', function (done) {
ga.awql()

@@ -149,15 +146,15 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
.send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using promises (w/WHERE and AND(array) clauses)', function(done) {
})
it('should get data from AWQL using promises (w/WHERE and AND(array) clauses)', function (done) {
ga.awql()

@@ -169,15 +166,15 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
.send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using options (w/WHERE and AND(promises) clauses)', function(done) {
})
it('should get data from AWQL using options (w/WHERE and AND(promises) clauses)', function (done) {
ga.awql({

@@ -189,16 +186,16 @@ select: ['Date', 'Clicks'],

during: ['20120101', '20150125']
}).send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
}).send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
console.log(error);
expect(false).to.equal(true);
done(error);
.catch(function (error) {
console.log(error)
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using promises (w/WHERE and AND(promises) clauses)', function(done) {
})
it('should get data from AWQL using promises (w/WHERE and AND(promises) clauses)', function (done) {
ga.awql()

@@ -211,18 +208,18 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
auth.user.accessToken = results.auth.accessToken;
auth.user.tokenExpires = results.auth.tokenExpires;
auth2 = _.cloneDeep(auth);
done();
.send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
auth.user.accessToken = results.auth.accessToken
auth.user.tokenExpires = results.auth.tokenExpires
auth2 = _.cloneDeep(auth)
done()
})
.catch(function(error) {
expect(false).to.equal(true);
done(error);
.catch(function (error) {
expect(false).to.equal(true)
done(error)
})
});
it('should get data from AWQL using previous auth token', function(done) {
})
it('should get data from AWQL using previous auth token', function (done) {
ga.use({

@@ -241,17 +238,17 @@ accessToken: auth2.user.accessToken,

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(results).to.be.an('object');
expect(results.report).to.be.a('string');
expect(results.total).to.be.a('string');
expect(results.data).to.be.an('array');
done();
.send().then(function (results) {
expect(results).to.be.an('object')
expect(results.report).to.be.a('string')
expect(results.total).to.be.a('string')
expect(results.data).to.be.an('array')
done()
})
.catch(function(error) {
console.log(error);
expect(false).to.equal(true);
done(error);
.catch(function (error) {
console.log(error)
expect(false).to.equal(true)
done(error)
})
});
})
it('should error out on bad clientID', function(done) {
it('should error out on bad clientID', function (done) {
ga.use({

@@ -261,7 +258,7 @@ clientID: auth.clientID + 'TRASH',

developerToken: auth.developerToken
});
})
ga.use({
refreshToken: auth.user.refreshToken,
clientCustomerID: auth.user.clientCustomerId
});
})
ga.awql()

@@ -274,11 +271,11 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
});
it('should error out on bad clientSecret', function(done) {
})
it('should error out on bad clientSecret', function (done) {
ga.use({

@@ -288,7 +285,7 @@ clientID: auth.clientID,

developerToken: auth.developerToken
});
})
ga.use({
refreshToken: auth.user.refreshToken,
clientCustomerID: auth.user.clientCustomerId
});
})
ga.awql()

@@ -301,11 +298,11 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
});
it('should error out on bad developerToken', function(done) {
})
it('should error out on bad developerToken', function (done) {
ga.use({

@@ -315,7 +312,7 @@ clientID: auth.clientID,

developerToken: auth.developerToken + 'GARBAGE'
});
})
ga.use({
refreshToken: auth.user.refreshToken,
clientCustomerID: auth.user.clientCustomerId
});
})
ga.awql()

@@ -328,11 +325,11 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
});
it('should error out on bad refreshToken', function(done) {
})
it('should error out on bad refreshToken', function (done) {
ga.use({

@@ -342,7 +339,7 @@ clientID: auth.clientID,

developerToken: auth.developerToken
});
})
ga.use({
refreshToken: auth.user.refreshToken + 'GARBAGE',
clientCustomerID: auth.user.clientCustomerId
});
})
ga.awql()

@@ -355,11 +352,11 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
});
it('should error out on bad clientCustomerId', function(done) {
})
it('should error out on bad clientCustomerId', function (done) {
ga.use({

@@ -369,7 +366,7 @@ clientID: auth.clientID,

developerToken: auth.developerToken
});
})
ga.use({
refreshToken: auth.user.refreshToken,
clientCustomerID: auth.user.clientCustomerId + 'GARBAGE'
});
})
ga.awql()

@@ -382,11 +379,11 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
});
it('should error out on invalid access token', function(done) {
})
it('should error out on invalid access token', function (done) {
ga.use({

@@ -405,11 +402,11 @@ accessToken: auth2.user.accessToken + 'TRASH',

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
});
it('should error out on invalid field selected', function(done) {
})
it('should error out on invalid field selected', function (done) {
ga.use({

@@ -428,11 +425,11 @@ accessToken: auth2.user.accessToken,

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
});
it('should error out on malformed client use options (wrong fields)', function(done) {
})
it('should error out on malformed client use options (wrong fields)', function (done) {
try {

@@ -443,7 +440,7 @@ ga.use({

developerT: auth.developerToken
});
})
ga.use({
refreshToken: auth.user.refreshToken,
clientCustomerID: auth.user.clientCustomerId
});
})
ga.awql()

@@ -456,14 +453,14 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
} catch (e) {
done();
if (e) done()
}
});
it('should error out on malformed user use options', function(done) {
})
it('should error out on malformed user use options', function (done) {
try {

@@ -474,7 +471,7 @@ ga.use({

developerToken: auth.developerToken
});
})
ga.use({
refreshT: auth.user.refreshToken,
clientC: auth.user.clientCustomerId
});
})
ga.awql()

@@ -487,16 +484,16 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
} catch (e) {
done();
if (e) done()
}
});
it('should error out on malformed use options (no options)', function(done) {
})
it('should error out on malformed use options (no options)', function (done) {
try {
ga.use();
ga.use()
ga.awql()

@@ -509,16 +506,16 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
} catch (e) {
done();
if (e) done()
}
});
it('should error out on malformed use options (string input)', function(done) {
})
it('should error out on malformed use options (string input)', function (done) {
try {
ga.use('THIS WILL BREAK');
ga.use('THIS WILL BREAK')
ga.awql()

@@ -531,28 +528,14 @@ .select(['Date', 'Clicks'])

.during(['20120101', '20150125'])
.send().then(function(results) {
expect(false).to.equal(true);
done(error);
.send().then(function (results) {
expect(false).to.equal(true)
done()
})
.catch(function(error) {
done();
.catch(function (error) {
if (error) done()
})
} catch (e) {
done();
if (e) done()
}
});
});
// it('should catch an error', function(done) {
// });
// it('should catch an an OAuthError', function(done) {
// });
// it('should throw an error because of <insert issue>', function(done) {
// });
});
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc