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

com.dft.api.shopify.v202410.ShopifyGraphQlOrderAPI Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package com.dft.api.shopify.v202410;

import com.dft.api.shopify.ShopifyGraphQLSdk;
import com.dft.api.shopify.model.auth.AccessCredential;
import com.dft.api.shopify.v202410.model.common.GraphQlQuery;
import com.dft.api.shopify.v202410.model.common.GraphQlVariable;
import com.dft.api.shopify.v202410.model.common.QueryResponse;
import com.dft.api.shopify.v202410.model.order.OrderData;
import com.dft.api.shopify.v202410.model.order.OrderInput;
import com.dft.api.shopify.v202410.model.order.OrdersData;
import com.dft.api.shopify.v202410.model.order.fulfillmentOrders.FulfillmentOrdersResponse;
import com.fasterxml.jackson.core.type.TypeReference;

public class ShopifyGraphQlOrderAPI extends ShopifyGraphQLSdk {

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

    public QueryResponse updateOrderCustomAttributes(OrderInput orderInput) {
        GraphQlVariable variables = new GraphQlVariable<>();
        variables.setInput(orderInput);

        GraphQlQuery graphQlQuery = new GraphQlQuery();
        graphQlQuery.setQuery("mutation updateOrderMetafields($input: OrderInput!) { orderUpdate(input: $input) { order { id } userErrors { message field } } }");
        graphQlQuery.setVariables(variables);

        return getQueryData(graphQlQuery, new TypeReference<>() {});
    }

    public QueryResponse getOrderById(GraphQlVariable variable) {
        GraphQlQuery graphQlQuery = new GraphQlQuery();
        graphQlQuery.setQuery("query CALL($id: ID!){ order(id:$id) { legacyResourceId shippingAddress{ address1 city provinceCode zip } shippingLine{ code } shippingLines(first: 10){ nodes{ code } } customer{ firstName lastName } lineItems(first: 10){ nodes{ customAttributes{ key value } product{ legacyResourceId } variant{ legacyResourceId } title originalUnitPriceSet{ shopMoney{ amount } } quantity sku variantTitle } } name } }");
        graphQlQuery.setVariables(variable);
        return getQueryData(graphQlQuery, new TypeReference<>() {});
    }

    public QueryResponse getfulfillmentOrdersByOrderId(GraphQlVariable variable) {
        GraphQlQuery graphQlQuery = new GraphQlQuery();
        graphQlQuery.setQuery("query getFulfillmentOrdersByOrderId($orderId: ID!) { order(id: $orderId) { id fulfillmentOrders(first: 250) { nodes { id orderId status createdAt updatedAt assignedLocation { location { legacyResourceId } } destination {firstName lastName address1 address2 city countryCode company phone province zip } lineItems(first: 250) { nodes { id totalQuantity remainingQuantity inventoryItemId variant { legacyResourceId } lineItem { id } } } } } } }");
        graphQlQuery.setVariables(variable);
        return getQueryData(graphQlQuery, new TypeReference<>() {});
    }

    public QueryResponse getOrders(GraphQlVariable variable) {
        GraphQlQuery graphQlQuery = new GraphQlQuery();
        graphQlQuery.setQuery("query CALL($query: String){ orders(first: 250, query:$query) { nodes { totalPriceSet{ shopMoney{ amount } } subtotalPriceSet{ shopMoney{ amount } } totalTaxSet{ shopMoney{ amount } } lineItems(first:250){ nodes{ id title quantity originalUnitPriceSet{ shopMoney{ amount } } name customAttributes{ key value } } } billingAddress{ address1 city country firstName lastName province zip provinceCode countryCodeV2 } shippingAddress{ address1 city country firstName lastName province zip provinceCode countryCodeV2 } shippingLines(first:250){ nodes{ originalPriceSet { shopMoney{ amount } } title } } } } }");
        graphQlQuery.setVariables(variable);
        return getQueryData(graphQlQuery, new TypeReference<>() {});
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy