-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleWebServiceClient_002.cls
More file actions
26 lines (25 loc) · 927 Bytes
/
SimpleWebServiceClient_002.cls
File metadata and controls
26 lines (25 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
public with sharing class SimpleWebServiceClient_002 {
private static final String ENDPOINT = 'https://api.example.com/002';
/**
* Simulate a callout:
* - throws on BAD IDs
* - returns a String payload otherwise
*/
public String fetchData(String recordId) {
try {
if (String.isBlank(recordId) || recordId.startsWith('BAD')) {
System.debug('Bad Request Client_001 SimpleWebServiceClient_002 -- RecID --- : '+recordId);
throw new CalloutException('Client_002: Cannot fetch for ' + recordId);
}
return 'Client_002 result for ' + recordId;
} catch (Exception ex) {
// Log async with fixed code 501
WSLogger.recordLogAsync(
'SimpleWebServiceClient_002.fetchData',
ex.getMessage(),
501
);
throw ex;
}
}
}