diff --git a/templates/flow-class.mustache b/templates/flow-class.mustache index 9b8e62c9..6bd260df 100644 --- a/templates/flow-class.mustache +++ b/templates/flow-class.mustache @@ -8,6 +8,7 @@ export default class {{&className}} { method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH', query: {[string]: mixed}, body?: {[string]: any} | string | Array, + headers?: {[string]: any} | string | Array, ) { throw new Error("Must be implemented"); } diff --git a/templates/flow-method.mustache b/templates/flow-method.mustache index 35df9d40..f31ee9ea 100644 --- a/templates/flow-method.mustache +++ b/templates/flow-method.mustache @@ -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) { @@ -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}}']; @@ -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); }