Docs BETA
/

Messages


The messages tab displays useful events occurring within the lifecycle of a vendOS application. These events are usually commands received by the machine; sometimes with the ability to respond. They also show progress of machine processes, and any errors that might be occurring.

Responding to vends

The most useful feature of the DevTools is the ability to respond to vend commands coming from your application. Let's say you were making a simple vendOS request to a machine, while developing locally:

import vendOS from 'vendos-js'

const OS = new VendOS()
const {Machine} = OS

Machine.vend.channel({channel: 0}).then(res => {

  console.log(res)

}).catch(res => {

  console.log(res)

})

If this code were to run with the vendOS DevTools panel open, a new message item would be added to the messages tab. The message item would have a breakdown of the request, along with buttons to respond.

The channel vend command (as demonstrated in the code above) would generate this in the panel:

Vend Response Example 1

Clicking "Succeed" or "Fail" before the countdown bar depletes will indicate to vendOS DevTools that you wish the vend process to succeed when it finally resolves. This way, you can manually test different real-world scenarios.

If the timeout finishes before you make a decision, the tool will default to a successful response.

When you choose how to respond, the machine will attempt to vend, and you will see a countdown message like the one below. This is supposed to replicate how the machine will actually behave, as the machine elevator arms take a number of seconds to travel to-and-from their channels.

Vend Response Example 2

Note that there will always be an attempt to vend; even if you've responded with "Fail". This is because machine elevators need to travel to the channel in order to determine if it has stock. See the vendOS JS documentation about vending for more information.

When the vend has finished, the response will be sent back to vendOS JS and will also be displayed as a sub-message in the messages tab.

Vend Response Example 3

Responding to payments

Payment commands are another area where vendOS DevTools utilises user responses. The payment flows can be quite complicated, so being able to test them locally is important.

A typical command to hold a card will yield a message like the following:

Payment Response Example 1

A user can deem the payment successful, or fail the payment for a number of reasons. See the payment charge documentation for more of an understanding of how payments work.

When a payment is ongoing, the messages are wrapped in a line to the left, which show that any commands are coming in during a payment which has been requested but not yet completed.

Notice in the below image that a random vend is made while a payment is waiting to be confirmed. This is a typical scenario, where a payment may need to be cancelled if a vend does not succeed.

Payment Response Example 2

Other messages

Other commands will be visible in the Messages panel also. For example, any requests to the vendOS Data API will appear here too. These currently won't allow you to give a response, but they could be useful for inspecting any requests that have been made by your application.

Error messages will also appear here - a must for debugging your vendOS application.

Other Request Messages

Clearing messages

All these messages could get a little crowded, so you may decide that you'd like to forget about any previous messages that have been added. Clear messages by clicking the clear icon on the messages tab. See below:

Clearing Messages

Note that the clear messages functionality may be unavailable during certain machine processes, like ongoing vends or payments.