function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EQ AdminEQ Admin 

Need help for writing test class of callout. New to integration.

public class PegaCallbackService 
{
private static Response res;
    public class Response {
        public  string access_token;
        public  string token_type;
        
    }
    
    
    private static string token_type;
    private static string token;
    
    public static void RequestAuthorizationToken(){
        try{
            HttpRequest request = new HttpRequest();
            HttpResponse response = new HttpResponse();
            Http http = new Http();
            String client_id = '10863622547421372260';
            String client_secret = 'DEB45EBE65B13D86D13E28F002C01D35';
            String grant_type = 'client_credentials';
            String reqbody = 'client_id='+client_id+'&client_secret='+client_secret+'&grant_type='+ grant_type;
            system.debug('req body--'+reqbody);
             
           // request.setEndpoint('https://equini-eqbill-dt1.pegacloud.net/prweb/PRRestService/oauth2/v1/token');
            request.setHeader('Content-Type','application/x-www-form-urlencoded'); 
           request.setMethod('POST');
            request.setBody(reqbody);
           	response = http.send(request);
          
            
           system.debug('--response'+response.getBody());
            res = (Response)JSON.deserialize(response.getBody(), Response.class);
			system.debug(res);
            if (response.getStatusCode() == 200) {
                System.debug('Response-' + response);
            }
        }
        catch(System.CalloutException e){
            System.debug('Error-' + e.getMessage());  
        }
    }
   @future(callout=true) 
   public static void SendValidationStatus(String json) {
        	res = new Response();
            RequestAuthorizationToken();
            HttpRequest request = new HttpRequest();
            HttpResponse response = new HttpResponse();
            Http http = new Http();
             
            request.setEndpoint('https://equini-eqbill-dt1.pegacloud.net/prweb/PRRestService/BillingUsagePackage/v1/ManageBillingUsage');
            request.setHeader('Content-Type','application/json');
       		system.debug(res);
       		request.setHeader('Authorization', res.token_type+' ' +res.access_token);
            request.setMethod('POST');
            request.setBody(json);
            response = http.send(request);
            if (response.getStatusCode() == 200) {
                System.debug('Response-' + response);
            }
        }  
  }