package com.parse;

import android.net.Uri;
import com.parse.ParseObject;
import com.parse.http.ParseHttpRequest;
import org.json.JSONObject;
import p138.p139.p143.p144.C2803;

/* JADX INFO: loaded from: classes.dex */
public class ParseRESTObjectCommand extends ParseRESTCommand {
    public ParseRESTObjectCommand(String str, ParseHttpRequest.Method method, JSONObject jSONObject, String str2) {
        super(str, method, jSONObject, str2);
    }

    public static ParseRESTObjectCommand deleteObjectCommand(ParseObject.State state, String str) {
        String string = String.format("classes/%s", Uri.encode(state.className));
        String str2 = state.objectId;
        if (str2 != null) {
            StringBuilder sbM4889 = C2803.m4889(string);
            sbM4889.append(String.format("/%s", Uri.encode(str2)));
            string = sbM4889.toString();
        }
        return new ParseRESTObjectCommand(string, ParseHttpRequest.Method.DELETE, null, str);
    }

    public static ParseRESTObjectCommand saveObjectCommand(ParseObject.State state, JSONObject jSONObject, String str) {
        String str2 = state.objectId;
        return str2 == null ? new ParseRESTObjectCommand(String.format("classes/%s", Uri.encode(state.className)), ParseHttpRequest.Method.POST, jSONObject, str) : new ParseRESTObjectCommand(String.format("classes/%s/%s", Uri.encode(state.className), Uri.encode(str2)), ParseHttpRequest.Method.PUT, jSONObject, str);
    }
}
