Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

ScentreGroup/braze-mock-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Braze-mock-server

This offers a very simple way to setup a local Braze mock server with all the Braze endpoints mocked and the ability to send back custom responses if necessary.

Setup

You'll need to install the prism npm package by

npm install -g @stoplight/prism-cli

And clone this repository locally and run

prism mock braze_swagger.json

If everything goes well, you should have a Braze mock server running locally.

Note that the braze_swagger.json file is based on the one provided by Braze at https://www.braze.com/docs/assets/js/swagger/braze_swagger.json

Add custom responses

In order to add custom responses for various HTTP status codes, you'll need to edit the braze_swagger.json file and here are some simple examples:

  • add a 200 response
  "200": {
    "description": "Sometimes seen as `success`, this code indicates that the request was successfully made.",
    "content": {
      "application/json": {
        "examples": {
          "success": {
            "value": {
              "message": "success"
            }
          }
        }
      }
    }
  }
  • add a 400 response
  "400": {
    "description": "Simulating failure cases",
    "content": {
      "application/json": {
        "examples": {
          "failure": {
            "value": {
              "message": "Bad Request",
              "errors": [
                "required field `first_name` not present"
              ]
            }
          }
        }
      }
    }
  }

Since it confirms to the OpenAPI 3.0 specification, please refer to the official documentation for OpenAPI for more information.

Braze Postman collection

Now that we have a local Braze mock server with all the endpoints, it's time to send some sample requests. Of course you could create all the requests manually in your favorite HTTP client, but luckily for us, Braze also offers a Postman collection. If you use Postman you can import it directly, or there might be a plugin/extension for importing Postman collections.

After importing the Postman collection, you'll also need to setup the environment and use variables from the environment in Postman. Please refer to the following screenshots:

  • Environment configuration

Environment configuration

  • Use variables from environment

Use variables from environment

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published