Last active
August 29, 2015 14:14
-
-
Save gowrishankarin/4a1d5070e0ee28b759b7 to your computer and use it in GitHub Desktop.
Pronet find-simple API - Sample Program
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
@RequestMapping(method = RequestMethod.GET, value = {"/meters"}) | |
public ResponseEntity<Object> getMetersInfo( | |
@RequestParam(value = "containerId", required = true) | |
String meterInfoContainerId, | |
@RequestParam(value = "resourceType", required = true)String resourceType, | |
@RequestParam(value = "key", required = true)String key, | |
@RequestParam(value = "value", required = true)String name, | |
@RequestParam(value = "type" , required = true)String type) { | |
String url = Application.m2mPoC + "/pronet/find-simple"; | |
HashMap<String, Object> params = new HashMap<String, Object>(); | |
params.put("resourceId", meterInfoContainerId); | |
params.put("resourceType", resourceType); | |
params.put("key", key); | |
params.put("value", name); | |
params.put("type", type); | |
url = DataGenerators.addQueryParams(url, params); | |
ResponseEntity<HashMap> map = restTemplate.getForEntity(url, HashMap.class); | |
Object content = map.getBody().get("results"); | |
return new ResponseEntity<Object>(content, HttpStatus.OK); | |
} | |
public static String addQueryParams(String baseUrl, HashMap<String, Object> params) { | |
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(baseUrl); | |
Iterator<Map.Entry<String, Object>> iterator = params.entrySet().iterator(); | |
while(iterator.hasNext()){ | |
Map.Entry<String, Object> entry = iterator.next(); | |
uriBuilder.queryParam(entry.getKey(),entry.getValue()); | |
} | |
String newUrl = uriBuilder.build(false).encode().toUriString(); | |
return newUrl; | |
} |
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
Response Sample | |
{ | |
"results": [ | |
{ | |
"id": "54c1cc5be4b04a0513508d8e", | |
"content": { | |
"netTopup": 500, | |
"status": "ONLINE", | |
"location": "Reading", | |
"postCode": "RG1 2AF", | |
"userEmail": "lakshmi.pasupathy@prodapt.com", | |
"daAppId": null, | |
"meterType": 1, | |
"mode": 1, | |
"id": null, | |
"creationDate": null, | |
"meterId": "54c1cc5be4b04a0513508d6b", | |
"address": "6. Reading Road", | |
"userMobile": "44-0-9600000000", | |
"userName": "lakshmi", | |
"lastModifiedDate": null, | |
"unitsConsumed": 0, | |
"smisId": "54c1cc5be4b04a0513508d8e", | |
"topupHistory": [ | |
{ | |
"creationtime": 1421986907292, | |
"noOfUnits": 0 | |
}, | |
{ | |
"creationtime": 1421986907305, | |
"noOfUnits": 500 | |
} | |
], | |
"meterVendor": "1", | |
"paymentOption": "0" | |
} | |
}, | |
{ | |
"id": "54c1cc5be4b04a0513508dbe", | |
"content": { | |
"netTopup": 300, | |
"status": "ONLINE", | |
"location": "Bracknell", | |
"postCode": "RG12 1LL", | |
"userEmail": "ragunath.k@prodapt.com", | |
"daAppId": null, | |
"meterType": 1, | |
"mode": 1, | |
"id": null, | |
"creationDate": null, | |
"meterId": "54c1cc5be4b04a0513508d7c", | |
"address": "1. Bracknell Road", | |
"userMobile": "44-0-9600000000", | |
"userName": "ragunath", | |
"lastModifiedDate": null, | |
"unitsConsumed": 0, | |
"smisId": "54c1cc5be4b04a0513508dbe", | |
"topupHistory": [ | |
{ | |
"creationtime": 1421986907335, | |
"noOfUnits": 0 | |
}, | |
{ | |
"creationtime": 1421986907390, | |
"noOfUnits": 300 | |
} | |
], | |
"meterVendor": "1", | |
"paymentOption": "0" | |
} | |
}, | |
{ | |
"id": "54c1cc5be4b04a0513508dc9", | |
"content": { | |
"netTopup": 400, | |
"status": "ONLINE", | |
"location": "Swindon", | |
"postCode": "SN5 7DL", | |
"userEmail": "meena.k@prodapt.com", | |
"daAppId": null, | |
"meterType": 0, | |
"mode": 1, | |
"id": null, | |
"creationDate": null, | |
"meterId": "54c1cc5be4b04a0513508da9", | |
"address": "8. Swindon Road", | |
"userMobile": "44-0-9600000000", | |
"userName": "meena", | |
"lastModifiedDate": null, | |
"unitsConsumed": 0, | |
"smisId": "54c1cc5be4b04a0513508dc9", | |
"topupHistory": [ | |
{ | |
"creationtime": 1421986907372, | |
"noOfUnits": 0 | |
}, | |
{ | |
"creationtime": 1421986907392, | |
"noOfUnits": 400 | |
} | |
], | |
"meterVendor": "0", | |
"paymentOption": "0" | |
} | |
}, | |
{ | |
"id": "54c1cc5be4b04a0513508dcd", | |
"content": { | |
"netTopup": 300, | |
"status": "ONLINE", | |
"location": "Bracknell", | |
"postCode": "RG12 1LL", | |
"userEmail": "ragunath.k@prodapt.com", | |
"daAppId": null, | |
"meterType": 0, | |
"mode": 1, | |
"id": null, | |
"creationDate": null, | |
"meterId": "54c1cc5be4b04a0513508db5", | |
"address": "1. Bracknell Road", | |
"userMobile": "44-0-9600000000", | |
"userName": "ragunath", | |
"lastModifiedDate": null, | |
"unitsConsumed": 0, | |
"smisId": "54c1cc5be4b04a0513508dcd", | |
"topupHistory": [ | |
{ | |
"creationtime": 1421986907407, | |
"noOfUnits": 0 | |
}, | |
{ | |
"creationtime": 1421986907432, | |
"noOfUnits": 300 | |
} | |
], | |
"meterVendor": "0", | |
"paymentOption": "0" | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment