Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions templates/flow-class.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class {{&className}} {
method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH',
query: {[string]: mixed},
body?: {[string]: any} | string | Array<any>,
headers?: {[string]: any} | string | Array<any>,
) {
throw new Error("Must be implemented");
}
Expand Down
16 changes: 14 additions & 2 deletions templates/flow-method.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ static async {{&methodName}}(
{{/parameters}}
}
{{/hasParameters}}
): Promise<{{#methodResponse}}"{{&methodResponse}}"{{/methodResponse}}{{#methodFlowType}}{{> type}}{{/methodFlowType}}> {
): Promise<{{#methodResponse}}"{{&methodResponse}}"{{/methodResponse}}{{#methodFlowType}}{{> type}}{{/methodFlowType}}{{^methodResponse}}{{^methodFlowType}}any{{/methodFlowType}}{{/methodResponse}}> {
let path = '{{&path}}';
let body;
let query = {};
let headers = {};
{{#parameters}}
{{#required}}
if(parameters['{{&camelCaseName}}'] === undefined) {
Expand All @@ -21,6 +22,17 @@ static async {{&methodName}}(
path = path.replace('{{=<% %>=}}{<%&name%>}<%={{ }}=%>', `${parameters['{{&camelCaseName}}']}`);
{{/isPathParameter}}

{{#isHeaderParameter}}
{{#isSingleton}}
headers['{{&name}}'] = '{{&singleton}}';
{{/isSingleton}}
{{^isSingleton}}
if(parameters['{{&camelCaseName}}'] !== undefined) {
headers['{{&name}}'] = parameters['{{&camelCaseName}}'];
}
{{/isSingleton}}
{{/isHeaderParameter}}

{{#isBodyParameter}}
if(parameters['{{&camelCaseName}}'] !== undefined) {
body = parameters['{{&camelCaseName}}'];
Expand All @@ -35,5 +47,5 @@ static async {{&methodName}}(

{{/parameters}}

return await this.request(path, '{{method}}', query, body);
return await this.request(path, '{{method}}', query, body, headers);
}