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

com.dft.api.shopify.v202401.ShopifyUsageChargeAPI 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.v202401.model.usagecharge.ShopifyUsageCharge;
import com.dft.api.shopify.v202401.model.usagecharge.ShopifyUsageChargeWrapper;
import com.dft.api.shopify.v202401.model.usagecharge.ShopifyUsageChargesWrapper;

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

public class ShopifyUsageChargeAPI extends ShopifySdkNew {

    public static final String VERSION_2024_01 = "/2024-01";
    public static final String RECURRING_APPLICATION_CHARGES_PATH = "/recurring_application_charges/";
    public static final String USAGE_CHARGE_PATH = "/usage_charges";

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

    public ShopifyUsageChargeWrapper createShopifyUsageCharge(ShopifyUsageCharge shopifyUsageCharge, String recurringApplicationChargeId) {
        URI uri = baseUrl(VERSION_2024_01, RECURRING_APPLICATION_CHARGES_PATH + recurringApplicationChargeId + USAGE_CHARGE_PATH);

        ShopifyUsageChargeWrapper shopifyUsageChargeWrapper = new ShopifyUsageChargeWrapper();
        shopifyUsageChargeWrapper.setUsageCharge(shopifyUsageCharge);
        HttpRequest request = postWithObject(uri, shopifyUsageChargeWrapper);
        return getRequestWrapped(request, ShopifyUsageChargeWrapper.class);
    }

    public ShopifyUsageChargesWrapper getAllShopifyUsageCharges(String recurringApplicationChargeId) {
        URI uri = baseUrl(VERSION_2024_01, RECURRING_APPLICATION_CHARGES_PATH + recurringApplicationChargeId + USAGE_CHARGE_PATH);
        HttpRequest request = get(uri);
        return getRequestWrapped(request, ShopifyUsageChargesWrapper.class);
    }

    public ShopifyUsageChargeWrapper getShopifyUsageCharge(String recurringApplicationChargeId, String usageChargeId) {
        URI uri = baseUrl(VERSION_2024_01, RECURRING_APPLICATION_CHARGES_PATH + recurringApplicationChargeId + USAGE_CHARGE_PATH + "/" + usageChargeId);
        HttpRequest request = get(uri);
        return getRequestWrapped(request, ShopifyUsageChargeWrapper.class);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy