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: 2.16.0
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.http.HttpMethod;
import io.sphere.sdk.http.HttpResponse;
import io.sphere.sdk.models.Base;

/**
 Command for creating or updating a custom object using a custom JSON mapper.

 

Example using Google GSON (multiple code snippets):

The execution of the command:

{@include.example io.sphere.sdk.customobjects.commands.CustomObjectCustomJsonMappingUpsertCommandIntegrationTest#execution()}

The command class:

{@include.example io.sphere.sdk.customobjects.demo.GsonFooCustomObjectUpsertCommand}

The draft containing container, key and value:

{@include.example io.sphere.sdk.customobjects.demo.GsonFooCustomObjectDraft}

The resulting custom object class:

{@include.example io.sphere.sdk.customobjects.demo.GsonFooCustomObject}

The class of the value:

{@include.example io.sphere.sdk.customobjects.demo.GsonFoo} @param The type of the value of this custom object. @see CustomObject */ public abstract class CustomObjectCustomJsonMappingUpsertCommand extends Base implements CreateCommand> { protected CustomObjectCustomJsonMappingUpsertCommand() { } @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