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

com.scayle.adminapi.service.ProductImageService Maven / Gradle / Ivy

There is a newer version: 1.24.0
Show newest version
package com.scayle.adminapi.service;

import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import java.util.List;

import com.scayle.adminapi.exception.ApiErrorException;
import com.scayle.adminapi.exception.ConnectionException;
import com.scayle.adminapi.http.HttpClient;
import com.scayle.adminapi.model.*;

@SuppressWarnings("unchecked")
public class ProductImageService extends AbstractService {
    public ProductImageService(HttpClient httpClient) {
        super(httpClient);
    }

    
    public ProductImage create(Identifier productIdentifier, ProductImage model) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)ProductImage.class;

        return this.request("post", this.resolvePath("/products/%s/images", productIdentifier), null, null, responseModel, model);
    }

    
    public ProductImage create(Identifier productIdentifier, ProductImage model, ApiOptions options) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)ProductImage.class;

        Map query = options.all();

        return this.request("post", this.resolvePath("/products/%s/images", productIdentifier), query, null, responseModel, model);
    }

    
    public ApiCollection all(Identifier productIdentifier) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)ProductImage.class;

        return this.requestCollection("get", this.resolvePath("/products/%s/images", productIdentifier), null, null, responseModel);
    }

    
    public ApiCollection all(Identifier productIdentifier, ApiOptions options) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)ProductImage.class;

        Map query = options.all();

        return this.requestCollection("get", this.resolvePath("/products/%s/images", productIdentifier), query, null, responseModel);
    }

    
    public ProductImage updatePosition(Identifier productIdentifier, Identifier imageIdentifier, ProductImagePosition model) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)ProductImage.class;

        return this.request("patch", this.resolvePath("/products/%s/images/%s", productIdentifier, imageIdentifier), null, null, responseModel, model);
    }

    
    public ProductImage updatePosition(Identifier productIdentifier, Identifier imageIdentifier, ProductImagePosition model, ApiOptions options) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)ProductImage.class;

        Map query = options.all();

        return this.request("patch", this.resolvePath("/products/%s/images/%s", productIdentifier, imageIdentifier), query, null, responseModel, model);
    }

    
    public void delete(Identifier productIdentifier, Identifier imageIdentifier) throws ApiErrorException, ConnectionException {

        this.request("delete", this.resolvePath("/products/%s/images/%s", productIdentifier, imageIdentifier), null, null, null);
    }

    
    public void delete(Identifier productIdentifier, Identifier imageIdentifier, ApiOptions options) throws ApiErrorException, ConnectionException {

        Map query = options.all();

        this.request("delete", this.resolvePath("/products/%s/images/%s", productIdentifier, imageIdentifier), query, null, null);
    }

    
    public Attribute updateOrCreateAttribute(Identifier productIdentifier, Identifier imageIdentifier, Attribute model) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)Attribute.class;

        return this.request("post", this.resolvePath("/products/%s/images/%s/attributes", productIdentifier, imageIdentifier), null, null, responseModel, model);
    }

    
    public Attribute updateOrCreateAttribute(Identifier productIdentifier, Identifier imageIdentifier, Attribute model, ApiOptions options) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)Attribute.class;

        Map query = options.all();

        return this.request("post", this.resolvePath("/products/%s/images/%s/attributes", productIdentifier, imageIdentifier), query, null, responseModel, model);
    }

    
    public void deleteAttribute(Identifier productIdentifier, Identifier imageIdentifier, String attributeGroupName) throws ApiErrorException, ConnectionException {

        this.request("delete", this.resolvePath("/products/%s/images/%s/attributes/%s", productIdentifier, imageIdentifier, attributeGroupName), null, null, null);
    }

    
    public void deleteAttribute(Identifier productIdentifier, Identifier imageIdentifier, String attributeGroupName, ApiOptions options) throws ApiErrorException, ConnectionException {

        Map query = options.all();

        this.request("delete", this.resolvePath("/products/%s/images/%s/attributes/%s", productIdentifier, imageIdentifier, attributeGroupName), query, null, null);
    }

    
    public Attribute getAttribute(Identifier productIdentifier, Identifier imageIdentifier, String attributeGroupName) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)Attribute.class;

        return this.request("get", this.resolvePath("/products/%s/images/%s/attributes/%s", productIdentifier, imageIdentifier, attributeGroupName), null, null, responseModel);
    }

    
    public Attribute getAttribute(Identifier productIdentifier, Identifier imageIdentifier, String attributeGroupName, ApiOptions options) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)Attribute.class;

        Map query = options.all();

        return this.request("get", this.resolvePath("/products/%s/images/%s/attributes/%s", productIdentifier, imageIdentifier, attributeGroupName), query, null, responseModel);
    }

    
    public ApiCollection allAttributes(Identifier productIdentifier, Identifier imageIdentifier) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)Attribute.class;

        return this.requestCollection("get", this.resolvePath("/products/%s/images/%s/attributes", productIdentifier, imageIdentifier), null, null, responseModel);
    }

    
    public ApiCollection allAttributes(Identifier productIdentifier, Identifier imageIdentifier, ApiOptions options) throws ApiErrorException, ConnectionException {
        Class responseModel = (Class)(Class)Attribute.class;

        Map query = options.all();

        return this.requestCollection("get", this.resolvePath("/products/%s/images/%s/attributes", productIdentifier, imageIdentifier), query, null, responseModel);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy