diff --git a/adWordsObject.js b/adWordsObject.js index 45338c6..47f1e7e 100644 --- a/adWordsObject.js +++ b/adWordsObject.js @@ -23,7 +23,7 @@ function AdWordsObject(options) { // check if all credentials are supplied if ( !options.ADWORDS_CLIENT_ID || - !options.ADWORDS_CLIENT_CUSTOMER_ID || + // !options.ADWORDS_CLIENT_CUSTOMER_ID || // ClientCustomerID is not requeried for customerService.js !options.ADWORDS_DEVELOPER_TOKEN || !options.ADWORDS_REFRESH_TOKEN || !options.ADWORDS_SECRET || diff --git a/index.js b/index.js index 33f5a53..c3544eb 100644 --- a/index.js +++ b/index.js @@ -69,7 +69,7 @@ module.exports = { TrafficEstimatorService: require('./services/trafficEstimatorService'), // Account management - CustomerService: null, + CustomerService: require('./services/customerService'), CustomerSyncService: null, ManagedCustomerService: require('./services/managedCustomerService'), diff --git a/services/customerService.js b/services/customerService.js new file mode 100644 index 0000000..1563abd --- /dev/null +++ b/services/customerService.js @@ -0,0 +1,52 @@ +var + _ = require('lodash'), + async = require('async'), + soap = require('soap'); + +var AdWordsService = require('./adWordsService'); +var types = require('../types/customerService'); + +function Service(options) { + var self = this; + AdWordsService.call(self, options); + self.Collection = types.collection; + self.Model = types.model; + + self.parseGetResponse = function(response) { + if (self.validateOnly) { + return {}; + } else { + if (response.rval) { + return new self.Collection(response.rval); + } else { + return {}; + } + } + }; + + self.parseQueryResponse = function(response) { + return self.parseGetResponse(response); + }; + + self.selectable = [ + 'customerId', + 'currencyCode', + 'dateTimeZone', + 'descriptiveName', + 'companyName', + 'canManageClients', + 'testAccount', + 'autoTaggingEnabled', + 'conversionTrackingSettings', + 'remarketingSettings', + ]; + + self.xmlns = 'https://adwords.google.com/api/adwords/mcm/' + self.version; + self.wsdlUrl = self.xmlns + '/CustomerService?wsdl'; +} + +Service.prototype = _.create(AdWordsService.prototype, { + 'constructor': Service +}); + +module.exports = (Service); diff --git a/types/customerService.js b/types/customerService.js new file mode 100644 index 0000000..e6ee649 --- /dev/null +++ b/types/customerService.js @@ -0,0 +1,12 @@ +var Backbone = require('backbone'); + +var Customer = Backbone.Model.extend({}); + +var CustomerCollection = Backbone.Collection.extend({ + model: Customer, +}); + +module.exports = { + collection: CustomerCollection, + model: Customer +};