Testing Purchase Schema Definition

The following code shows the final purchase-schema.xml definition for the request and response MATRIXX Data Containers (MDCs), the MDC relationship definition, and the REST call.

<configuration>

    <!--Define the Request MDC -->

    <container id="DemoRequestSubscriberPurchase">
        <doc_description>Demonstration of a custom offer purchase</doc_description>
        <created_schema_version>2</created_schema_version>
        <base_container id="2">MtxRequest</base_container>
        <field id="SubscriberSearchData">
            <created_schema_version>2</created_schema_version>
            <doc_description>Subscriber search data structure</doc_description>
            <doc_required/>
            <datatype>struct</datatype>
            <struct_id>MtxSubscriberSearchData</struct_id>
        </field>
        <field id="Offer">
            <created_schema_version>2</created_schema_version>
            <doc_description>Offer being purchased.</doc_description>
            <doc_required/>
            <datatype>struct</datatype>
            <struct_id>MtxPurchasedOfferData</struct_id>
        </field>
        <field id="Type">
            <created_schema_version>2</created_schema_version>
            <doc_description>Type of offer being created.</doc_description>
            <datatype>string</datatype>
            <max_size>15</max_size>
        </field>
        <field id="Amount">
            <created_schema_version>2</created_schema_version>
            <doc_description>Amount of the offer.</doc_description>
            <datatype>decimal</datatype>
        </field>
        <field id="Color">
            <created_schema_version>2</created_schema_version>
            <doc_description>Color of the offer.</doc_description>
            <datatype>string</datatype>
            <max_size>15</max_size>
        </field>
        <storage_size>large</storage_size>
    </container>

    <!--Define the Response MDC -->

    <container id="DemoResponseSubscriberPurchase">
        <doc_description>Demonstration of a custom offer purchase</doc_description>
        <created_schema_version>2</created_schema_version>
        <base_container id="2">MtxResponse</base_container>
        <field id="PrePurchase">
            <created_schema_version>2</created_schema_version>
            <doc_description>Subscriber before the purchase</doc_description>
            <datatype>struct</datatype>
            <struct_id>SubscriberResponse</struct_id>
        </field>
        <field id="Purchase">
            <created_schema_version>2</created_schema_version>
            <doc_description>Response from the offer purchase</doc_description>
            <doc_required/>
            <datatype>struct</datatype>
            <struct_id>MtxResponsePurchase</struct_id>
        </field>
        <field id="PostPurchase">
            <created_schema_version>2</created_schema_version>
            <doc_description>Subscriber after the purchase</doc_description>
            <datatype>struct</datatype>
            <struct_id>SubscriberResponse</struct_id>
        </field>
        <storage_size>large</storage_size>
    </container>

    <!--Define the MDC Relationship and REST Service -->

    <container_relationship id='op_return_type">
        <relationship id='DemoRequestSubscriberPurchase'>
            <target_container>DemoResponseSubscriberPurchase</target_container>
            <REST_service>
                <name>demo_purchase</name>
                <description>Perform query, purchase and query ops</description>
                <class>demo</class>
                <url>/demo/subscriber/{SearchTerm}/offer</url>
                <method>POST</method>
                <mapping>readData</mapping>
                <mapping>attachVersion 1</mapping>
                <mapping>buildSubscriberSearch SearchTerm</mapping>
                <patch>route = setRoute(route, SearchTerm)</patch>
                <callout_statement>
                    com.matrixx.rsgateway.configuration.DemoServices svc =
                    (com.matrixx.rsgateway.configuration.DemoServices)m_appContext.getBean(“DemoServices”);
                </callout_statement>
                <url_param>
                    <description>The object id of the subscriber.</description>
                    <name>SearchTerm</name>
                    <type>RestQueryTerm</type>
                </url_param>
                <request_param>
                    <description>Optional routing data used by the TRA</description>
                    <name>TrafficRouteData</name>
                    <type>String</type>
                    <use>optional</use>
                </request_param>
                <metadata>
                  <name>mtx:result_filter</name>
                  <type>string</type>
                  <value>{}</value>
                </metadata>
            </REST_service>
        </relationship>
    </container_relationship>
</configuration>