All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.customobjects.commands.CustomObjectCustomJsonMappingUpsertCommand Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.customobjects.commands;

import io.sphere.sdk.client.HttpRequestIntent;
import io.sphere.sdk.commands.CreateCommand;
import io.sphere.sdk.customobjects.CustomObject;
import io.sphere.sdk.client.SphereRequestBase;
import io.sphere.sdk.http.HttpMethod;
import io.sphere.sdk.http.HttpResponse;

/**
 Command for creating or updating a custom object using a custom JSON mapper.
 */
public abstract class CustomObjectCustomJsonMappingUpsertCommand extends SphereRequestBase implements CreateCommand> {

    @Override
    public abstract CustomObject deserialize(final HttpResponse httpResponse);

    @Override
    public final HttpRequestIntent httpRequestIntent() {
        return HttpRequestIntent.of(HttpMethod.POST, "/custom-objects", bodyAsJsonString());
    }

    /**
     * Produces JSON to create or update a custom object.
     * It must have the fields of a {@link io.sphere.sdk.customobjects.CustomObject}:
     *
     * Example:
     *
     * 
{@code
       {
            "container": "myNamespace",
            "key": "myKey",
            "value": {
                "baz": 3,
                "bar": "a String"
            }
        }
     * }
* * @return JSON as String */ protected abstract String bodyAsJsonString(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy