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

com.dft.api.shopify.v202401.InventoryLevelAPI Maven / Gradle / Ivy

The newest version!
package com.dft.api.shopify.v202401;

import com.dft.api.shopify.ShopifySdkNew;
import com.dft.api.shopify.model.auth.AccessCredential;
import com.dft.api.shopify.v202307.model.inventorylevel.ShopifyInventoryLevelWrapper;
import com.dft.api.shopify.v202401.model.inventoryLevel.ShopifyInventoryLevel;

import java.net.URI;
import java.net.http.HttpRequest;

import static com.dft.api.shopify.constantcode.ConstantCodes.HTTPS;

public class InventoryLevelAPI extends ShopifySdkNew {

    private static final String VERSION_2024_01 = "/admin/api/2024-01";
    private static final String INVENTORY_LEVELS = "/inventory_levels";
    private static final String INVENTORY_LEVELS_SET = INVENTORY_LEVELS + "/set.json";

    public InventoryLevelAPI(AccessCredential accessCredential) {
        super(accessCredential);
    }

    public ShopifyInventoryLevelWrapper updateInventoryLevel(Long inventoryItemId, Long locationId, Integer quantity) {

        ShopifyInventoryLevel shopifyInventoryLevel = new ShopifyInventoryLevel();
        shopifyInventoryLevel.setAvailable(quantity);
        shopifyInventoryLevel.setLocationId(locationId);
        shopifyInventoryLevel.setInventoryItemId(inventoryItemId);

        URI uri = URI.create(HTTPS + accessCredential.getStoreDomain() + VERSION_2024_01 + INVENTORY_LEVELS_SET);

        HttpRequest request = postWithObject(uri, shopifyInventoryLevel);

        return getRequestWrapped(request, ShopifyInventoryLevelWrapper.class);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy