googleapis
Version:
Google APIs Client Library for Node.js
235 lines • 7.97 kB
JavaScript
;
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var apirequest_1 = require("../../lib/apirequest");
// TODO: We will eventually get the `any` in here cleared out, but in the
// interim we want to turn on no-implicit-any.
// tslint:disable: no-any
// tslint:disable: class-name
// tslint:disable: variable-name
// tslint:disable: jsdoc-format
/**
* Google Civic Information API
*
* Provides polling places, early vote locations, contest data, election
* officials, and government representatives for U.S. residential addresses.
*
* @example
* const google = require('googleapis');
* const civicinfo = google.civicinfo('v2');
*
* @namespace civicinfo
* @type {Function}
* @version v2
* @variation v2
* @param {object=} options Options for Civicinfo
*/
var Civicinfo = /** @class */ (function () {
function Civicinfo(options, google) {
this.root = this;
this._options = options || {};
this.google = google;
this.getRoot.bind(this);
this.divisions = new Resource$Divisions(this);
this.elections = new Resource$Elections(this);
this.representatives = new Resource$Representatives(this);
}
Civicinfo.prototype.getRoot = function () {
return this.root;
};
return Civicinfo;
}());
exports.Civicinfo = Civicinfo;
var Resource$Divisions = /** @class */ (function () {
function Resource$Divisions(root) {
this.root = root;
this.getRoot.bind(this);
}
Resource$Divisions.prototype.getRoot = function () {
return this.root;
};
Resource$Divisions.prototype.search = function (params, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (typeof params === 'function') {
callback = params;
params = {};
}
options = options || {};
var rootUrl = options.rootUrl || 'https://www.googleapis.com/';
var parameters = {
options: Object.assign({
url: (rootUrl + '/civicinfo/v2/divisions')
.replace(/([^:]\/)\/+/g, '$1'),
method: 'GET'
}, options),
params: params,
requiredParams: [],
pathParams: [],
context: this.getRoot()
};
if (callback) {
apirequest_1.createAPIRequest(parameters, callback);
}
else {
return apirequest_1.createAPIRequest(parameters);
}
};
return Resource$Divisions;
}());
exports.Resource$Divisions = Resource$Divisions;
var Resource$Elections = /** @class */ (function () {
function Resource$Elections(root) {
this.root = root;
this.getRoot.bind(this);
}
Resource$Elections.prototype.getRoot = function () {
return this.root;
};
Resource$Elections.prototype.electionQuery = function (params, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (typeof params === 'function') {
callback = params;
params = {};
}
options = options || {};
var rootUrl = options.rootUrl || 'https://www.googleapis.com/';
var parameters = {
options: Object.assign({
url: (rootUrl + '/civicinfo/v2/elections')
.replace(/([^:]\/)\/+/g, '$1'),
method: 'GET'
}, options),
params: params,
requiredParams: [],
pathParams: [],
context: this.getRoot()
};
if (callback) {
apirequest_1.createAPIRequest(parameters, callback);
}
else {
return apirequest_1.createAPIRequest(parameters);
}
};
Resource$Elections.prototype.voterInfoQuery = function (params, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (typeof params === 'function') {
callback = params;
params = {};
}
options = options || {};
var rootUrl = options.rootUrl || 'https://www.googleapis.com/';
var parameters = {
options: Object.assign({
url: (rootUrl + '/civicinfo/v2/voterinfo')
.replace(/([^:]\/)\/+/g, '$1'),
method: 'GET'
}, options),
params: params,
requiredParams: ['address'],
pathParams: [],
context: this.getRoot()
};
if (callback) {
apirequest_1.createAPIRequest(parameters, callback);
}
else {
return apirequest_1.createAPIRequest(parameters);
}
};
return Resource$Elections;
}());
exports.Resource$Elections = Resource$Elections;
var Resource$Representatives = /** @class */ (function () {
function Resource$Representatives(root) {
this.root = root;
this.getRoot.bind(this);
}
Resource$Representatives.prototype.getRoot = function () {
return this.root;
};
Resource$Representatives.prototype.representativeInfoByAddress = function (params, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (typeof params === 'function') {
callback = params;
params = {};
}
options = options || {};
var rootUrl = options.rootUrl || 'https://www.googleapis.com/';
var parameters = {
options: Object.assign({
url: (rootUrl + '/civicinfo/v2/representatives')
.replace(/([^:]\/)\/+/g, '$1'),
method: 'GET'
}, options),
params: params,
requiredParams: [],
pathParams: [],
context: this.getRoot()
};
if (callback) {
apirequest_1.createAPIRequest(parameters, callback);
}
else {
return apirequest_1.createAPIRequest(parameters);
}
};
Resource$Representatives.prototype.representativeInfoByDivision = function (params, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (typeof params === 'function') {
callback = params;
params = {};
}
options = options || {};
var rootUrl = options.rootUrl || 'https://www.googleapis.com/';
var parameters = {
options: Object.assign({
url: (rootUrl + '/civicinfo/v2/representatives/{ocdId}')
.replace(/([^:]\/)\/+/g, '$1'),
method: 'GET'
}, options),
params: params,
requiredParams: ['ocdId'],
pathParams: ['ocdId'],
context: this.getRoot()
};
if (callback) {
apirequest_1.createAPIRequest(parameters, callback);
}
else {
return apirequest_1.createAPIRequest(parameters);
}
};
return Resource$Representatives;
}());
exports.Resource$Representatives = Resource$Representatives;
//# sourceMappingURL=v2.js.map