webscientist/postman

dev-main 2022-04-04 18:09 UTC

This package is auto-updated.

Last update: 2024-05-04 22:47:15 UTC


README

This is a package intended to create JSON export for Postman Collection.

Disclaimer

  • This project is still work in progress

Object Terminologies

Postman has a slightly different convention when it comes to the front end, as when compared to the JSON import/export schema. Here is a list of objects used and it's usage with reference to Postman.

Name Description
Collection Top level container for all requests
Item Alias for Folder. Used for directory like structure
Event Contains pre-request and post-request (tests) scripts
Url All url related data, including path variables
Header Custom headers key value pair
Body Request data, in case of POST, PUT and PATCH requests
Variable Collection variables data

Postman Collection

A Postman collection can contain many Item (Folder) or Request objects

use WebScientist\Postman\Services\PostmanService as Postman;

$postman = new Postman();

$collection = $postman->collection('My Collection Name');

Creating Child Objects

Item (Folder)

$folder = $collection->folder($folderName);

Request

$request = $postman->request($requestName)
    ->url($url)
    ->header($key, $value)
    ->body($mode, $data)
    ->description($description);

Header

Header can be applied to either Collection, Item or Request object by using the header() method.

$collection->header($key, $value);
$item->header($key, $value);
$request->header($key, $value);