package com.cloudmine.api.rest;

import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.Response;
import com.cloudmine.api.LibrarySpecificClassCreator;
import com.cloudmine.api.rest.options.CMServerFunction;
import com.cloudmine.api.rest.response.CMResponse;
import me.cloudmine.annotations.Optional;

import java.util.Map;

/**
 *
 */
public class BaseChangeUserPasswordRequest extends CloudMineRequest<CMResponse> {

    public static final int REQUEST_TYPE = 411;

    private final String emailOrUsername;
    private final String oldPassword;

    public BaseChangeUserPasswordRequest(String emailOrUsername, String oldPassword, String newPassword, @Optional CMServerFunction serverFunction, @Optional Response.Listener<CMResponse> successListener, @Optional Response.ErrorListener errorListener) {
        super(Method.POST, "/account/password/change", "{\"password\":\"" + newPassword + "\"}", null, serverFunction, successListener, errorListener);
        this.emailOrUsername = emailOrUsername;
        this.oldPassword = oldPassword;

    }

    public Map<String, String> getHeaders() throws AuthFailureError {
        Map<String, String> headerMap = super.getHeaders();
        headerMap.put("Authorization", LibrarySpecificClassCreator.getCreator().getEncoder().encode(emailOrUsername + ":" + oldPassword));
        return headerMap;
    }

    @Override
    protected Response<CMResponse> parseNetworkResponse(NetworkResponse networkResponse) {
        return Response.success(new CMResponse(new String(networkResponse.data), networkResponse.statusCode), getCacheEntry(networkResponse));
    }

    @Override
    public int getRequestType() {
        return REQUEST_TYPE;
    }
}

@@ -346,265 +346,807 @@
 ons.
-Optional;%0A%0Aimport java.util.Map;%0A%0A/**%0A *%0A */%0Apublic class BaseChangeUserPasswordRequest extends CloudMineRequest%3CCMResponse%3E %7B%0A%0A    public static final int REQUEST_TYPE = 411;%0A%0A    private final String emailOrUsername;%0A    private final String oldPassword;%0A
+Expand;%0Aimport me.cloudmine.annotations.Optional;%0A%0Aimport java.util.Map;%0A%0A/**%0A * A Request for changing a user's password.%0A * %3Cbr%3ECopyright CloudMine LLC. All rights reserved%0A * %3Cbr%3E See LICENSE file included with SDK for details.%0A */%0Apublic class BaseChangeUserPasswordRequest extends CloudMineRequest%3CCMResponse%3E %7B%0A%0A    public static final int REQUEST_TYPE = 411;%0A%0A    private final String emailOrUsername;%0A    private final String oldPassword;%0A%0A    /**%0A     * Create a new BaseChangeUserPasswordRequest%0A     * @param emailOrUsername the username or password the user uses to log in%0A     * @param oldPassword the user's current password%0A     * @param newPassword the user's desired password%0A     * @param serverFunction%0A     * @param successListener%0A     * @param errorListener%0A     */%0A    @Expand
 %0A   

Comment changeuserpasswordrequest