|
| 1 | + |
| 2 | +> Converts Postman-SDK Request into code snippet for PHP-Guzzle variant |
| 3 | +
|
| 4 | +#### Prerequisites |
| 5 | +To run Code-Gen, ensure that you have NodeJS >= v8. A copy of the NodeJS installable can be downloaded from https://nodejs.org/en/download/package-manager. |
| 6 | + |
| 7 | +## Using the Module |
| 8 | +The module will expose an object which will have property `convert` which is the function for converting the Postman-SDK request to swift code snippet. |
| 9 | + |
| 10 | +### convert function |
| 11 | +Convert function takes three parameters |
| 12 | + |
| 13 | +* `request` - Postman-SDK Request Object |
| 14 | + |
| 15 | +* `options` - options is an object which hsa following properties |
| 16 | + * `indentType` - String denoting type of indentation for code snippet. eg: 'Space', 'Tab' |
| 17 | + * `indentCount` - The number of indentation characters to add per code level |
| 18 | + * `trimRequestBody` - Whether or not request body fields should be trimmed |
| 19 | + * `asyncType` - String denoting call types. eg: 'async', 'sync' |
| 20 | + * `followRedirect` : Boolean denoting whether to redirect a request (default: true) |
| 21 | + * `requestTimeout` : The number of milliseconds the request should wait for a response before timing out (use 0 for infinity) |
| 22 | + * `includeBoilerplate` - Include class definition and import statements in snippet |
| 23 | + |
| 24 | +* `callback` - callback function with first parameter as error and second parameter as string for code snippet |
| 25 | + |
| 26 | +##### Example: |
| 27 | +```js |
| 28 | +var request = new sdk.Request('www.google.com'), //using postman sdk to create request |
| 29 | + options = { |
| 30 | + indentCount: 3, |
| 31 | + indentType: 'Space', |
| 32 | + requestTimeout: 200, |
| 33 | + trimRequestBody: true |
| 34 | + }; |
| 35 | +convert(request, options, function(error, snippet) { |
| 36 | + if (error) { |
| 37 | + // handle error |
| 38 | + } |
| 39 | + // handle snippet |
| 40 | +}); |
| 41 | +``` |
| 42 | +### Guidelines for using generated snippet |
| 43 | + |
| 44 | +* Since Postman-SDK Request object doesn't provide complete path of the file, it needs to be manually inserted in case of uploading a file. |
| 45 | + |
| 46 | +* This module doesn't support cookies. |
0 commit comments