/*
 *   Copyright (C) 2016 Karumi.
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package com.karumi.todoapiclient;

import com.karumi.todoapiclient.dto.TaskDto;
import com.karumi.todoapiclient.exception.ItemNotFoundException;
import com.karumi.todoapiclient.exception.NetworkErrorException;
import com.karumi.todoapiclient.exception.TodoApiClientException;
import com.karumi.todoapiclient.exception.UnknownErrorException;
import com.karumi.todoapiclient.interceptor.DefaultHeadersInterceptor;
import java.io.IOException;
import java.util.List;
import okhttp3.OkHttpClient;
import retrofit2.Response;
import retrofit2.Retrofit;

import static com.karumi.todoapiclient.TodoApiClientConfig.BASE_ENDPOINT;

public class TodoApiClient {

  private final TodoService todoService;

  public TodoApiClient() {
    OkHttpClient okHttpClient = new OkHttpClient();
    okHttpClient.interceptors().add(new DefaultHeadersInterceptor());
    Retrofit retrofit = new Retrofit.Builder().baseUrl(BASE_ENDPOINT).client(okHttpClient).build();
    this.todoService = retrofit.create(TodoService.class);
  }

  public List<TaskDto> getAllTasks() throws TodoApiClientException{
    try {
      Response<List<TaskDto>> response = todoService.getAll().execute();
      inspectResponseForErrors(response);
      return response.body();
    } catch (IOException e) {
      throw new NetworkErrorException();
    }
  }

  public TaskDto getTaskById(String taskId) throws TodoApiClientException {
    try {
      Response<TaskDto> response = todoService.getById(taskId).execute();
      inspectResponseForErrors(response);
      return response.body();
    } catch (IOException e) {
      throw new NetworkErrorException();
    }
  }

  public TaskDto updateTaskById(TaskDto task) throws TodoApiClientException {
    try {
      Response<TaskDto> response = todoService.updateById(task.getId(), task).execute();
      inspectResponseForErrors(response);
      return response.body();
    } catch (IOException e) {
      throw new NetworkErrorException();
    }
  }

  private void inspectResponseForErrors(Response response) throws TodoApiClientException {
    int code = response.code();
    if (code == 404) {
      throw new ItemNotFoundException();
    }else {
      throw new UnknownErrorException(code);
    }
  }
}

@@ -2249,237 +2249,818 @@
 Dto 
-updateTaskById(TaskDto task) throws TodoApiClientException %7B%0A    try %7B%0A      Response%3CTaskDto%3E response = todoService.updateById(task.getId(), task).execute();%0A      inspectResponseForErrors(response);%0A      return response.body(
+addTask(TaskDto task) throws TodoApiClientException %7B%0A    try %7B%0A      Response%3CTaskDto%3E response = todoService.add(task).execute();%0A      inspectResponseForErrors(response);%0A      return response.body();%0A    %7D catch (IOException e) %7B%0A      throw new NetworkErrorException();%0A    %7D%0A  %7D%0A%0A  public TaskDto updateTaskById(TaskDto task) throws TodoApiClientException %7B%0A    try %7B%0A      Response%3CTaskDto%3E response = todoService.updateById(task.getId(), task).execute();%0A      inspectResponseForErrors(response);%0A      return response.body();%0A    %7D catch (IOException e) %7B%0A      throw new NetworkErrorException();%0A    %7D%0A  %7D%0A%0A  public void deleteTaskById(String taskId) throws TodoApiClientException %7B%0A    try %7B%0A      Response response = todoService.deleteById(taskId).execute();%0A      inspectResponseForErrors(response
 );%0A 

Add the last methods to the api client