|
9 | 9 | namespace {{this}} { |
10 | 10 | {{/cppNamespaceDeclarations}} |
11 | 11 |
|
12 | | -{{classname}}::{{classname}}() : basePath("{{{basePathWithoutHost}}}"), |
13 | | - host("{{#serverHost}}{{#scheme}}{{scheme}}://{{/scheme}}{{serverHost}}{{#serverPort}}:{{serverPort}}{{/serverPort}}{{/serverHost}}"), |
14 | | - timeout(0){ |
15 | | -
|
| 12 | +{{classname}}::{{classname}}(const QString &scheme, const QString &host, int port, const QString& basePath, const int timeOut) : |
| 13 | + _scheme(scheme), |
| 14 | + _host(host), |
| 15 | + _port(port), |
| 16 | + _basePath(basePath), |
| 17 | + _timeOut(timeOut) { |
16 | 18 | } |
17 | 19 |
|
18 | 20 | {{classname}}::~{{classname}}() { |
| 21 | +} |
19 | 22 |
|
| 23 | +void {{classname}}::setScheme(const QString& scheme){ |
| 24 | + _scheme = scheme; |
20 | 25 | } |
21 | 26 |
|
22 | | -{{classname}}::{{classname}}(const QString& host, const QString& basePath, const int tout) { |
23 | | - this->host = host; |
24 | | - this->basePath = basePath; |
25 | | - this->timeout = tout; |
| 27 | +void {{classname}}::setHost(const QString& host){ |
| 28 | + _host = host; |
26 | 29 | } |
27 | 30 |
|
28 | | -void {{classname}}::setBasePath(const QString& basePath){ |
29 | | - this->basePath = basePath; |
| 31 | +void {{classname}}::setPort(int port){ |
| 32 | + _port = port; |
30 | 33 | } |
31 | 34 |
|
32 | | -void {{classname}}::setHost(const QString& host){ |
33 | | - this->host = host; |
| 35 | +void {{classname}}::setBasePath(const QString& basePath){ |
| 36 | + _basePath = basePath; |
34 | 37 | } |
35 | 38 |
|
36 | | -void {{classname}}::setApiTimeOutMs(const int tout){ |
37 | | - timeout = tout; |
| 39 | +void {{classname}}::setTimeOut(const int timeOut){ |
| 40 | + _timeOut = timeOut; |
38 | 41 | } |
39 | 42 |
|
40 | 43 | void {{classname}}::setWorkingDirectory(const QString& path){ |
41 | | - workingDirectory = path; |
| 44 | + _workingDirectory = path; |
42 | 45 | } |
43 | 46 |
|
44 | 47 | void {{classname}}::addHeaders(const QString& key, const QString& value){ |
45 | 48 | defaultHeaders.insert(key, value); |
46 | 49 | } |
47 | 50 |
|
48 | | - |
49 | 51 | {{#operations}} |
50 | 52 | {{#operation}} |
51 | 53 | void |
52 | 54 | {{classname}}::{{nickname}}({{#allParams}}const {{{dataType}}}& {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { |
53 | | - QString fullPath; |
54 | | - fullPath.append(this->host).append(this->basePath).append("{{{path}}}"); |
| 55 | + QString fullPath = QString("%0://%1%2%3%4") |
| 56 | + .arg(_scheme) |
| 57 | + .arg(_host) |
| 58 | + .arg(_port ? ":" + QString::number(_port) : "") |
| 59 | + .arg(_basePath) |
| 60 | + .arg("{{{path}}}"); |
55 | 61 | {{#pathParams}} |
56 | 62 | QString {{paramName}}PathParam("{"); |
57 | 63 | {{paramName}}PathParam.append("{{baseName}}").append("}"); |
|
107 | 113 | } |
108 | 114 | {{/collectionFormat}}{{/queryParams}} |
109 | 115 | {{prefix}}HttpRequestWorker *worker = new {{prefix}}HttpRequestWorker(this); |
110 | | - worker->setTimeOut(timeout); |
111 | | - worker->setWorkingDirectory(workingDirectory); |
| 116 | + worker->setTimeOut(_timeOut); |
| 117 | + worker->setWorkingDirectory(_workingDirectory); |
112 | 118 | {{prefix}}HttpRequestInput input(fullPath, "{{httpMethod}}"); |
113 | 119 | {{#formParams}}{{^isFile}} |
114 | 120 | input.add_var("{{baseName}}", ::{{cppNamespace}}::toStringValue({{paramName}}));{{/isFile}}{{#isFile}} |
|
0 commit comments