Created
January 13, 2019 17:39
-
-
Save anilsomasundaran/1730563c9db94e414b01c1d40e0b0284 to your computer and use it in GitHub Desktop.
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='/Accounts/*') | |
global with sharing class AccountManager { | |
@HttpGet | |
global static Account getAccountById() { | |
RestRequest request = RestContext.request; | |
String accountId = request.requestURI.substring( | |
request.requestURI.lastIndexOf('/')+1); | |
Account result = [SELECT Name,AccountNumber,Type,BillingAddress | |
FROM Account | |
WHERE Id = :accountId]; | |
return result; | |
} | |
@HttpPost | |
global static ID createAccount(String Name,String accountNumber) { | |
Account thisAccount= new Account( | |
Name=Name, AccountNumber = accountNumber); | |
insert thisAccount; | |
return thisAccount.Id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment