Skip to content

Commit 6b2489e

Browse files
satwikareddy3meta-codesync[bot]
authored andcommitted
Fix generated professional services PUT method
Summary: Add standalone Node.js codegen support for non-node PUT APIs. The generator now flags PUT methods, emits typed methods that delegate to a reusable putEdge helper, and includes the helper in the checked-in Node.js runtime so later SDK generation can reproduce PUT endpoints correctly. Reviewed By: liliarizona Differential Revision: D116964349 fbshipit-source-id: e80656d08e8419a228e65e2aac834ada510c9b90
1 parent ebd272a commit 6b2489e

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

‎src/abstract-crud-object.js‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,52 @@ export class AbstractCrudObject extends AbstractObject {
277277
});
278278
}
279279

280+
/**
281+
* Put edge object
282+
* @param {String} [endpoint]
283+
* @param {Array} [fields]
284+
* @param {Object} [params]
285+
* @param {Function} [targetClassConstructor]
286+
* @param {String} [pathOverride]
287+
* @param {String} [basePath]
288+
* @return {Promise}
289+
*/
290+
putEdge(
291+
endpoint: string,
292+
fields: Array<string>,
293+
params: Object = {},
294+
targetClassConstructor: Function = null,
295+
pathOverride?: ?string = null,
296+
basePath: ?string = null,
297+
): Promise<*> {
298+
if (fields && fields.length > 0) {
299+
params['fields'] = fields.join(',');
300+
}
301+
const api = this.getApi();
302+
let path;
303+
if (pathOverride != null) {
304+
path = pathOverride;
305+
} else if (basePath != null) {
306+
path = [Utils.removePreceedingSlash(basePath), this.getNodePath()];
307+
} else {
308+
path = [this.getNodePath(), Utils.removePreceedingSlash(endpoint)];
309+
}
310+
params = Object.assign(params, this.exportData());
311+
return new Promise((resolve, reject) => {
312+
api
313+
.call('PUT', path, params)
314+
.then(data => {
315+
resolve(
316+
/* eslint new-cap: "off" */
317+
targetClassConstructor === null
318+
? this.setData(data)
319+
: new targetClassConstructor(data.id, data),
320+
);
321+
})
322+
.catch(reject);
323+
});
324+
}
325+
280326
/**
281327
* Delete edge object
282328
* @param {String} [endpoint]

0 commit comments

Comments
 (0)