Create the Offer Purchase REST Service

In this task, you define the offer purchase REST service. You must name the REST service and define a class name for the service. You must also define the URL of your call to handle and how the input parameters will be retrieved.

About this task

Note that GET operations can include all input elements using arguments on the URL.

Procedure

  1. Create a file rsgwextension/src/main/resources/rest/extensions.xml.
  2. Add the REST definitions to the file.
    <MtxRestServices xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://www.matrixxsw.com/XML_Schema/rest_service' xsi:schemaLocation='http://www.matrixxsw.com/XML_Schema/rest_service http://www.matrixxsw.com/XML_Schema/rest_service.xsd rest_service.xsd ../rest_service.xsd'>
      <info>
          <class>com.matrixx.rsgateway.configuration</class>
          <filename>src/main/resources/rest/extension.xml</filename>
          <date>2020-08-02</date>
      </info>
      <path_array>
        <path url='/demo/subscriber/{SearchTerm}/offer'>
          <service id='POST'>
            <name>demo_purchase</name>
            <description>Perform query, purchase and query ops</description>
            <request>DemoRequestSubscriberPurchaser</request>
            <response>DemoResponseSubscriberPurchase</response>
            <parameters>
                <RequestParameterArray>
                    <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 TRA </description>
                       <name>TrafficRouteData</name>
                       <type>String</type>
                       <use>optional</use>
                    </request_param>
               </RequestParameterArray>
           </parameters>
           <code_generation>
              <mapping>readData</mapping>
              <mapping>attachVersion 1</mapping>
              <patch>route = setRoute(route, SearchTerm)</patch>
              <callout_statement>
                com.matrixx.rsgateway.purchase.DemoServices svc =
                (com.matrixx.rsgateway.purchase.DemoServices)m_appContext.getBean(“DemoServices”);
                svc.queryAndPurchase(SearchTerm, reqMsg, rspMsg);
              </callout_statement>
           </code_generation>
           <MetadataArray>
               <metadata>
                  <name>mtx:result_filter</name>
                  <type>string</type>
                  <value>{}</value>
               </metadata>
           </MetadataArray>
         </service>
        </path>
      </path_array>
    </MtxRestServices>
  3. Save the file.