Created
March 21, 2012 10:31
-
-
Save jeffdonthemic/2146052 to your computer and use it in GitHub Desktop.
MemberRestSvc - Apex REST Service (v24)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestResource(urlMapping='/v.9/member/*/results/*') | |
global with sharing class MemberRestSvc { | |
@HttpGet | |
global static ReturnClass doGet() { | |
String[] uriKeys = RestContext.request.requestURI.split('/'); | |
// get the member name from the uri | |
String memberName = uriKeys.get(uriKeys.size()-3); | |
// do awesome programming stuff here & catch any exceptions | |
try { | |
List<Contact> contacts = [Select Id From Contact where member_name__c = :memberName]; | |
return new ReturnClass('true', 'Query executed successfully.', contacts); | |
} catch (Exception e) { | |
return new ReturnClass('false', e.getMessage(), null); | |
} | |
} | |
global class ReturnClass { | |
global String success; | |
global String message; | |
global List<Contact> records; | |
global ReturnClass(String success, String message, List<Contact> records) { | |
this.success = success; | |
this.message = message; | |
this.records = records; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment