use of dz.easy.androidclient.Model.RequestBody in project easy by MehdiBenmesa.
the class RegistrationIntentService method registerDeviceProcess.
private void registerDeviceProcess(String deviceName, String deviceId, String registrationId) {
RequestBody requestBody = new RequestBody();
requestBody.setDeviceId(deviceId);
requestBody.setDeviceName(deviceName);
requestBody.setRegistrationId(registrationId);
requestBody.setEmail(App.getInstance().getEmail());
Retrofit retrofit = new Retrofit.Builder().baseUrl(SERVER_URL).addConverterFactory(GsonConverterFactory.create()).build();
RequestInterface request = retrofit.create(RequestInterface.class);
Call<ResponseBody> call = request.registerDevice(requestBody);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
ResponseBody responseBody = response.body();
Intent intent = new Intent(App.REGISTRATION_PROCESS);
intent.putExtra("result", responseBody.getResult());
intent.putExtra("message", responseBody.getMessage());
LocalBroadcastManager.getInstance(RegistrationIntentService.this).sendBroadcast(intent);
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_SHORT).show();
}
});
}
Aggregations