use of io.jawg.osmcontributor.rest.dtos.osm.ChangeSetDto in project osm-contributor by jawg.
the class OsmBackend method initializeTransaction.
/**
* {@inheritDoc}
*/
@Override
public String initializeTransaction(String comment) {
final OsmDto osmDto = new OsmDto();
ChangeSetDto changeSetDto = new ChangeSetDto();
List<TagDto> tagDtos = new ArrayList<>();
osmDto.setChangeSetDto(changeSetDto);
tagDtos.add(new TagDto(comment, "comment"));
tagDtos.add(new TagDto(BuildConfig.APP_NAME + " " + BuildConfig.VERSION_NAME, "created_by"));
changeSetDto.setTagDtoList(tagDtos);
Call<ResponseBody> callChangeSet;
if (loginPreferences.retrieveOAuthParams() != null) {
callChangeSet = osmRestClient.addChangeSet(AuthenticationRequestInterceptor.getOAuthRequest(loginPreferences, BuildConfig.BASE_OSM_URL + "changeset/create", Verb.PUT).getOAuthHeader(), osmDto);
} else {
callChangeSet = osmRestClient.addChangeSet(osmDto);
}
try {
Response<ResponseBody> response = callChangeSet.execute();
if (response.isSuccessful() && response.body() != null) {
return response.body().string();
}
} catch (IOException e) {
Timber.e("Retrofit error, couldn't create Changeset!");
}
bus.post(new SyncUploadRetrofitErrorEvent(-1L));
return null;
}
Aggregations