This commit is contained in:
GotPPay
2017-10-16 20:21:19 +02:00
parent 8a7f8794cf
commit a75ea978f9
2554 changed files with 804218 additions and 109 deletions

View File

@@ -0,0 +1,91 @@
/**
* 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.
*/
/* jshint maxlen: false */
import createAPIRequest from '../../lib/apirequest';
{% set Name = name|capitalize %}
{% set Version = version|replace('\.', '_')|capitalize %}
{% set Namespace = [Name, Version]|join('') %}
/**
* {{ title }}
*
* {{ description }}
*
* @example
* const google = require('googleapis');
* const {{ name }} = google.{{ name }}('{{ version }}');
*
* @namespace {{ name }}
* @type {Function}
* @version {{ version }}
* @variation {{ version }}
* @param {object=} options Options for {{ Name }}
*/
function {{ Name }} (options) { // eslint-disable-line
const self = this;
self._options = options || {};
{% if methods %}
{% set globalmethods = true %}
{% for mname in methods|sort %}
{% set m = methods[mname] %}
{% include "./method-partial.ts" with m %}
{% endfor -%}
{%- endif -%}
{% if resources %}
{% set globalmethods = false %}
{% for rname in resources|sort %}
{% set r = resources[rname] %}
{% set ResourceNamespace = [Name, rname]|join('.') %}
self.{{ rname }} = {
{% include "./resource-partial.ts" with r %}
};
{%- endfor -%}
{%- endif -%}
}
{% set lb = "{" %}
{% set rb = "}" %}
{% for schemaName in schemas|sort %}
{% set schema = schemas[schemaName] %}
/**
* @typedef {{ schema.id }}
* @memberOf! {{ name }}({{ version }})
* @type {{ schema.type }}
{% if schema.properties -%}
{%- for pname in schema.properties|sort -%}
{%- set p = schema.properties[pname] -%}
{%- if p.$ref -%}
* @property {{ lb }}{{ name }}({{ version }}).{{ p.$ref }}{{ rb }} {{ pname }} {{ p.description | cleanPaths }}
{%- elif p.items and p.items.type -%}
* @property {{ lb }}{{ p.items.type }}[]{{ rb }} {{ pname }} {{ p.description | cleanPaths }}
{%- elif p.items and p.items.$ref -%}
* @property {{ lb }}{{ name }}({{ version }}).{{ p.items.$ref }}[]{{ rb }} {{ pname }} {{ p.description | cleanPaths }}
{%- else -%}
* @property {{ lb }}{{ p.type }}{{ rb }} {{ pname }} {{ p.description | cleanPaths }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
*/
{%- endfor -%}
export = {{ Name }};

View File

@@ -0,0 +1,63 @@
{% set lb = "{" %}
{% set rb = "}" %}
{%- set pathParams = m.parameters|getPathParams|sort -%}
/**
* {{ m.id }}
*
* {% if m.description %}@desc {{ m.description|oneLine|cleanComments|safe }}{% endif %}
*
{% if m.fragment -%}
* @example
{{ m.fragment|safe }}
*
{% endif -%}
* @alias {{ m.id }}
* @memberOf! {{ name }}({{ version }})
*
* @param {object{% if !m.parameterOrder && !m.request %}={% endif %}} params Parameters for request
{% for pname in m.parameters|sort -%}
{% set p = m.parameters[pname] -%}
* @param {{ lb }}{{ p.type }}{% if ! p.required %}={% endif %}{{ rb }} params.{{ pname|getSafeParamName }} {{ p.description|oneLine|cleanComments|safe }}
{% endfor -%}
{% if m.supportsMediaUpload -%}
{% if m.request -%}
* @param {object} params.resource Media resource metadata
{% endif -%}
* @param {object} params.media Media object
* @param {string} params.media.mimeType Media mime-type
* @param {string|object} params.media.body Media body contents
{% elif m.request -%}
{% if m.request.$ref -%}
* @param {{ lb }}{{ name }}({{ version }}).{{ m.request.$ref }}{{ rb }} params.resource Request body data
{% else -%}
* @param {object} params.resource Request body data
{% endif -%}
{% endif -%}
* @param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`.
* @param {callback} callback The callback that handles the response.
* @return {object} Request object
*/
{% if globalmethods %}this.{{ mname }} ={% else %}{{ mname }}:{% endif %} function (params, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
options || (options = {});
const rootUrl = options.rootUrl || {{ rootUrl|buildurl }};
const parameters = {
options: Object.assign({
url: (rootUrl + {{ ('/' + servicePath + m.path)|buildurl }}).replace(/([^:]\/)\/+/g, '$1'),
method: '{{ m.httpMethod }}'
}, options),
params: params,
{%- if m.mediaUpload.protocols.simple.path -%}mediaUrl: (rootUrl + {{ ('/' + m.mediaUpload.protocols.simple.path)|buildurl }}).replace(/([^:]\/)\/+/g, '$1'),{%- endif -%}
requiredParams: [{%- if m.parameterOrder.length -%}'{{ m.parameterOrder|join("', '")|safe }}'{%- endif -%}],
pathParams: [{%- if pathParams.length -%}'{{ pathParams|join("', '")|safe }}'{%- endif -%}],
context: self
};
return createAPIRequest(parameters, callback);
}{%- if globalmethods -%};{%- elif not loop.last -%},
{%- endif -%}

View File

@@ -0,0 +1,16 @@
{% if r.methods %}
{% for mname in methods|sort -%}
{% set m = methods[mname] %}
{% include "./method-partial.ts" with m %}
{%- endfor -%}
{%- endif -%}{%- if r.methods && r.resources -%},{%- endif -%}
{% if r.resources %}
{%- for rname in resources|sort -%}
{%- set r = resources[rname] -%}
{{ rname }}: {
{%- include "./resource-partial.ts" with r -%}
}{%- if not loop.last -%},{%- endif -%}
{%- endfor -%}
{%- endif -%}