I am using the googleJsonAPIService to manipulate users (CRUD). This is how I get the Directory instance:
def getBuilder() {
def builder
def httpTransport = googleJsonAPIService.makeTransport()
def jsonFactory = googleJsonAPIService.makeJsonFactory()
def requestInitialiser = googleJsonAPIService.getRequestInitialiser()
builder = new Directory.Builder(httpTransport, jsonFactory, requestInitialiser);
return builder
}
Directory getGoogleService() {
Directory googleService = getBuilder().build()
return googleService;
}
Once I have this service, I use it to get a user's details (in my own service) for example:
def query = getGoogleService().users().get(id)
return handleException { query.execute() }
I manually populate a
DTO with the result of that query, and this is where my question comes:
Is there an elegant way to have this
mapping (object returned to DTO) done automatically so all I have to do is pass the class of the object to be returned?
This is the structure of the object returned by google :
["agreedToTerms":true,"changePasswordAtNextLogin":false,
"creationTime":"2013-11-04T04:33:35.000Z", "emails":[{"address":"
[email protected]","primary":true}],...]