@@ -88,7 +88,7 @@ class Client {
88
88
if (contentType.startsWith('multipart/form-data')) {
89
89
const form = new FormData();
90
90
91
- let flatParams = this .flatten(params);
91
+ let flatParams = Client .flatten(params);
92
92
93
93
for (const key in flatParams) {
94
94
form.append(key, flatParams[key])
@@ -122,26 +122,25 @@ class Client {
122
122
} else {
123
123
throw new {{spec .title | caseUcfirst }}Exception(error.response.data.message, error.response.status, error.response.data);
124
124
}
125
- }else{
125
+ } else {
126
126
throw new {{spec .title | caseUcfirst }}Exception(error.response.statusText, error.response.status, error.response.data);
127
127
}
128
- }else{
128
+ } else {
129
129
throw new {{spec .title | caseUcfirst }}Exception(error.message);
130
130
}
131
131
}
132
132
}
133
133
134
- flatten(data, prefix = '') {
134
+ static flatten(data, prefix = '') {
135
135
let output = {};
136
136
137
137
for (const key in data) {
138
138
let value = data[key];
139
139
let finalKey = prefix ? prefix + '[' + key +']' : key;
140
140
141
141
if (Array.isArray(value)) {
142
- output = Object.assign(output, this.flatten(value, finalKey)); // @todo: handle name collision here if needed
143
- }
144
- else {
142
+ output = Object.assign(output, Client.flatten(value, finalKey)); // @todo: handle name collision here if needed
143
+ } else {
145
144
output[finalKey] = value;
146
145
}
147
146
}
@@ -150,4 +149,4 @@ class Client {
150
149
}
151
150
}
152
151
153
- module.exports = Client;
152
+ module.exports = Client;
0 commit comments