Created
October 28, 2015 12:00
-
-
Save getjump/0728fdd95fd39dc71e2e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| BASE_URL = 'http://our_app/api/' | |
| string getRequestURL(string apiMethod) | |
| { | |
| return BASE_URL + apiMethod; | |
| } | |
| T request<T>(string apiMethod = 'lockbox/list', enum {GET, POST, PUT, ...} httpMethod, Object params[]) | |
| { | |
| string rawData = http.request(self.getRequestURL(apiMethod), httpMethod.toString(), http.buildQuery(params)) | |
| ApiResponse<T> obj = json.unserialize<ApiResponse<T>>(rawData); | |
| if(obj.error != null) | |
| { | |
| throw ApiErrorException(); | |
| } | |
| return obj.object; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment