Skip to main content
Hi, I have a requirment, I have a different class for every different path. I got a requirment to give a static Json Response. Do i need to do anything with those all classes or should i easily just put these things in the strings and expose as a Json Response. 

 

This get Endpoint should deliver latest versions of Endpoints for different functions.

 

So static JSON response should be at the moment:

 

{

 

"latest": [

 

{

 

"getCustomerOverview": {

 

"method": "GET",

 

"path": "0.1/customer/"

 

},

 

"getCustomerById": {

 

"method": "GET",

 

"path": "0.1/customer/{{ACCOUNT_ID}}/"

 

},

 

"getSubscriptionsByCustomerId": {

 

"method": "GET",

 

"path": "0.1/customer/{{ACCOUNT_ID}}/subscriptions/"

 

},

 

"getSubscriptionOverview": {

 

"method": "GET",

 

"path": "0.1/subscription/"

 

},

 

"getSubscriptionById": {

 

"method": "GET",

 

"path": "0.1/subscription/{{SUBSCRIPTION_ID}}/"

 

}

 

}

 

]

 

}

 

I shall be grateful to you for your kind cooperation.

 

Thanks and regards
4 个回答
  1. 2020年8月20日 14:35
    here i put several mapping url in string like this you mean:

     

    @RestResource(urlMapping='/0.1/')

     

    global with sharing class API_Version_1 {

     

        @HttpGet

     

        global static void getSubs() {

     

            RestRequest request = RestContext.request;

     

            List<string> GET = New List<string>{'customer/','customer/{accountId}/','customer/{accountId}/subscriptions/','subscription/','subscription/{subscriptionId}'};

     

                Map<string,Object> Mapp = new Map<String,Object>();

     

                Mapp.put('get',GET);

     

                RestResponse res = RestContext.response;

     

                res.responseBody = blob.valueOf(json.serialize(Mapp));

     

                

     

        }

     

        }
0/9000