-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from zevektor/master
Add types declaration in JS SDK
- Loading branch information
Showing
5 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES6", | ||
"lib": ["ES2015", "ES6", "dom"], | ||
"module": "commonjs", | ||
"sourceMap": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Type definitions for {{ language.params.npmPackage }} {{ sdk.version }} | ||
// Project: {{ spec.title }} | ||
|
||
|
||
/*~ This declaration specifies that the class constructor function | ||
*~ is the exported object from the file | ||
*/ | ||
export = {{ spec.title | caseUcfirst }}; | ||
|
||
/*~ Write your module's methods and properties in this class */ | ||
declare class {{ spec.title | caseUcfirst }} { | ||
constructor(); | ||
|
||
/** | ||
* @param {string} endpoint | ||
* @returns {this} | ||
*/ | ||
setEndpoint(endpoint: string): this; | ||
|
||
{% for header in spec.global.headers %} | ||
/** | ||
* Set {{header.key | caseUcfirst}} | ||
* | ||
{% if header.description %} | ||
{{header.description|comment2}} | ||
* | ||
{% endif %} | ||
* @param value string | ||
* | ||
* @return this | ||
*/ | ||
set{{header.key | caseUcfirst}}({{ header.key | caseCamel }}: string): this; | ||
{% endfor %} | ||
|
||
{% for service in spec.services %} | ||
{{ service.name }}:{{ spec.title | caseUcfirst }}.{{ service.name | caseUcfirst }}; | ||
{% endfor %} | ||
|
||
} | ||
|
||
declare namespace {{ spec.title | caseUcfirst }} { | ||
|
||
{% for service in spec.services %} | ||
export interface {{ service.name | caseUcfirst }} { | ||
|
||
{% for method in service.methods %} | ||
/** | ||
* {{ method.title }} | ||
* | ||
{% if method.description %} | ||
{{ method.description|comment2 }} | ||
{% endif %} | ||
* | ||
{% for parameter in method.parameters.all %} | ||
* @param {{ '{' }}{{ parameter.type | typeName }}{{ '}' }} {{ parameter.name | caseCamel }} | ||
{% endfor %} | ||
* @throws {Error} | ||
* @return {% if method.location %}{string}{% elseif method.cookies %}{null}{% else %}{Promise}{% endif %} | ||
|
||
*/ | ||
{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}{{ parameter.name | caseCamel }}: {{ parameter.type | typeName }}{% if not loop.last %}, {% endif %}{% endfor %}): Promise<string>; | ||
|
||
{% endfor %} | ||
} | ||
|
||
{% endfor %} | ||
|
||
} |