// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
//     @NonNull
//     public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
//         return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
//     }
// 
//     @SerializedName("id")
//     public abstract int id();
// 
//     @SerializedName("user_id")
//     public abstract Integer userId();
// 
//     @SerializedName("name")
//     public abstract String name();
// 
//     @Nullable
//     @SerializedName("description")
//     public abstract String description();
// 
//     @SerializedName("width")
//     public abstract int width();
// 
//     @SerializedName("height")
//     public abstract int height();
// 
//     @SerializedName("image_url")
//     public abstract String imageUrl();
// 
//     @SerializedName("images")
//     public abstract List<ImageJSONModel> images();
// 
//     @SerializedName("user")
//     public abstract UserJSONModel user();
// }
// 
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
//     @NonNull
//     public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
//         return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
//     }
// 
//     @SerializedName("photo")
//     public abstract PhotoJSONModel photo();
// }
// 
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/store/UploadService.java
// public interface UploadService<T> {
//     /**
//      * Uploads multipart content to a remote endpoint.
//      *
//      * @param metadata Optional information to be associated with the upload operation
//      * @param data A file to upload
//      * @return The response received from the upload operation
//      */
//     Single<T> upload(@NonNull Map<String, Object> metadata, @NonNull MultipartBody.Part data);
// }


import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import com.jagsaund.rxuploader.store.UploadService;
import java.util.Map;
import okhttp3.MultipartBody;
import rx.Single;
package com.jagsaund.rxuploader.sample.service;


public class PhotoUploadService implements UploadService<PhotoJSONModel> {
    @NonNull private final ApiService apiService;

    @VisibleForTesting
    PhotoUploadService(@NonNull ApiService apiService) {
        this.apiService = apiService;
    }

    @NonNull
    public static UploadService create(@NonNull ApiService apiService) {
        return new PhotoUploadService(apiService);
    }

    @Override
    public Single<PhotoJSONModel> upload(@NonNull Map<String, Object> metadata,
            @NonNull MultipartBody.Part data) {
        final String name = (String) metadata.get("name");
        final String description = (String) metadata.get("description");
        final Double privacy = (Double) metadata.get("privacy");

        return apiService
                .uploadPhoto(name, description, privacy != null ? privacy.intValue() : 0, data)
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/PhotoJSONModel.java
// @AutoValue
// public abstract class PhotoJSONModel {
//     @NonNull
//     public static TypeAdapter<PhotoJSONModel> typeAdapter(Gson gson) {
//         return new AutoValue_PhotoJSONModel.GsonTypeAdapter(gson);
//     }
// 
//     @SerializedName("id")
//     public abstract int id();
// 
//     @SerializedName("user_id")
//     public abstract Integer userId();
// 
//     @SerializedName("name")
//     public abstract String name();
// 
//     @Nullable
//     @SerializedName("description")
//     public abstract String description();
// 
//     @SerializedName("width")
//     public abstract int width();
// 
//     @SerializedName("height")
//     public abstract int height();
// 
//     @SerializedName("image_url")
//     public abstract String imageUrl();
// 
//     @SerializedName("images")
//     public abstract List<ImageJSONModel> images();
// 
//     @SerializedName("user")
//     public abstract UserJSONModel user();
// }
// 
// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/model/wire/UploadPhotoJSONModel.java
// @AutoValue
// public abstract class UploadPhotoJSONModel {
//     @NonNull
//     public static TypeAdapter<UploadPhotoJSONModel> typeAdapter(Gson gson) {
//         return new AutoValue_UploadPhotoJSONModel.GsonTypeAdapter(gson);
//     }
// 
//     @SerializedName("photo")
//     public abstract PhotoJSONModel photo();
// }
// 
// Path: rxuploader/src/main/java/com/jagsaund/rxuploader/store/UploadService.java
// public interface UploadService<T> {
//     /**
//      * Uploads multipart content to a remote endpoint.
//      *
//      * @param metadata Optional information to be associated with the upload operation
//      * @param data A file to upload
//      * @return The response received from the upload operation
//      */
//     Single<T> upload(@NonNull Map<String, Object> metadata, @NonNull MultipartBody.Part data);
// }


// Path: rxuploader-sample/src/main/java/com/jagsaund/rxuploader/sample/service/PhotoUploadService.java
import android.support.annotation.NonNull;
import android.support.annotation.VisibleForTesting;
import com.jagsaund.rxuploader.sample.model.wire.PhotoJSONModel;
import com.jagsaund.rxuploader.sample.model.wire.UploadPhotoJSONModel;
import com.jagsaund.rxuploader.store.UploadService;
import java.util.Map;
import okhttp3.MultipartBody;
import rx.Single;

package com.jagsaund.rxuploader.sample.service;


public class PhotoUploadService implements UploadService<PhotoJSONModel> {
    @NonNull private final ApiService apiService;

    @VisibleForTesting
    PhotoUploadService(@NonNull ApiService apiService) {
        this.apiService = apiService;
    }

    @NonNull
    public static UploadService create(@NonNull ApiService apiService) {
        return new PhotoUploadService(apiService);
    }

    @Override
    public Single<PhotoJSONModel> upload(@NonNull Map<String, Object> metadata,
            @NonNull MultipartBody.Part data) {
        final String name = (String) metadata.get("name");
        final String description = (String) metadata.get("description");
        final Double privacy = (Double) metadata.get("privacy");

        return apiService
                .uploadPhoto(name, description, privacy != null ? privacy.intValue() : 0, data)
                .map(UploadPhotoJSONModel::photo)