Day 6: Orders feed

Objective for Day 6

Create an Orders RPDE feed, respecting temporary authentication credentials.

Rationale

The table used to store Orders should have been populated in Day 5. Day 6 exposes these Orders as an RPDE feed.

Step 1: Create Orders RPDE Feed Generator

The StoreBookingEngine handles the serialisation and parameter validation that would usually be required when implementing an RPDE feed. All that is required to implement the Orders feed is to implement a single method within a new class that inherits from the abstractOrdersRPDEFeedIncrementingUniqueChangeNumber or OrdersRPDEFeedModifiedTimestampAndID classes, which are very similar to the IOpportunityDataRPDEFeedGenerator class from Day 2.

Within BookingEngineSettings within EngineConfig.cs the OrderFeedGenerator setting configures which generator is called by the controller.

OrderFeedGenerator = new AcmeOrdersFeedRPDEGenerator()

Two implementations of OrdersRPDEFeedGenerator are available depending on your prefered RPDE Ordering Strategy:

  • OrdersRPDEFeedIncrementingUniqueChangeNumber

  • OrdersRPDEFeedModifiedTimestampAndID

Any of the above would require the same GetRPDEItems method be implemented, as below, noting that the feed returned should be specific to the specified clientId, and that updates to customerNotice cause an item to be updated in the RPDE feed.

public class AcmeOrdersFeedRPDEGenerator : OrdersRPDEFeedModifiedTimestampAndID
{
    protected override List<RpdeItem> GetRPDEItems(string clientId, long? afterTimestamp, string afterId)
    {
        ...
    }
}

The appropriate query for the database for your chosen RPDE Ordering Strategy must be used, and the ordering of the items returned from your overridden method is automatically validated to ensure consistency with the specification.

Within the mapping of your data to the OpenActive model, there are a few helper methods available from the base class to construct IDs specific for the feed:

Method

Example

RenderOpportunityWithOnlyId

OrderedItem = RenderOpportunityWithOnlyId(orderItemRow.OpportunityJsonLdType, new Uri(orderItemRow.OpportunityJsonLdId)),

RenderOrderId

Id = this.RenderOrderId(OrderType.Order, uuid),

RenderOrderItemId

Id = this.RenderOrderItemId(OrderType.Order, uuid, orderItemRow.Id),

RenderSellerId

(for Multiple Sellers)

Id = this.RenderSellerId(new SellerIdComponents

{

SellerIdLong = orderItemRow.sellerId

}),

RenderSingleSellerId (for Single Seller)

Id = this.RenderSingleSellerId(),

Step 2: Implement Test Interface

The OpenActive Test Interface Actions Endpoint allows the test suite to test behaviours that are usually triggered by the Seller.

To support seller requested cancellation and customer notification tests, implement the appropriate Actions with the following cases within the TriggerTestAction method in the OrderStore.cs:

case SellerRequestedCancellationSimulateAction _:
    ...
    break;
case CustomerNoticeSimulateAction _:
    ...
    break;

Step 3: Run Test Suite

The order-deletion, seller-requested-cancellation, and customer-notice-notifications (if implemented) features within the openactive-integration-tests test suite should pass.

Note that headers are used in the tests to provide a temporary clientId in place of authentication credentials.

Run these tests in isolation as follows:

npm start -- --runInBand test/features/core/order-deletion/ test/features/cancellation/seller-requested-cancellation/ test/features/notifications/customer-notice-notifications/

Last updated