Sending

Seal a UFTP message, POST it with the http crate types, and decide from the status whether it was delivered, should be retried or has failed.

On this page

Seal#

let signed = seal(&message, Role::Dso, &key)?; // validates first: you cannot sign an invalid message
let document = signed.to_xml();

seal checks three things before it signs:

  • the role may send this type;
  • every rule of the type holds;
  • the free text holds only characters XML can carry.

The result is the SignedMessage document to POST.

POST#

The specification's path is /USEF/2019/SignedMessage (transport::SPEC_PATH). Shapeshifter deployments commonly use /shapeshifter/api/v3/message (transport::SHAPESHIFTER_PATH). The Content-Type is text/xml; charset=utf-8.

With the http feature:

let request = uftp::http::request(&"https://agr.example/USEF/2019/SignedMessage".parse()?, &signed);
// … send it with reqwest, hyper or ureq …
match uftp::http::delivery(&response) {
    Delivery::Delivered => {} // the business answer comes later, as a message of its own
    Delivery::Retry => {}     // back off and try again, for at least an hour
    Delivery::Failed => {}    // it will never be accepted as it is
}

Without the feature, transport::Delivery::of(status) classifies a bare status code:

  • Delivered: any 2xx.
  • Retry: 404, 408, 419 (the receiver could not look up your key), 425, 429, 5xx, and anything unknown.
  • Failed: every other 4xx.

Record what you send#

If your endpoint has an outbox, record every message you send, so that its response is matched to it and responses to anything else are refused:

endpoint.sent(&message, now);

Settlements#

Build the month's FlexSettlement from your orders with order.settlement(isps) and FlexSettlement::new; see Settling.

Prices#

Amount keeps the scale you write. Shapeshifter receivers refuse a price that does not have exactly the currency's minor digits, so write EUR prices as 180.00, not 180. The specification does not require this; see Interoperability.