Tutorial
The tutorial below, written in Javascript, outlines how to:
- set up a "client" which talks to the Curri API
- programmatically get a delivery quote
- programmatically book a delivery using the provided quote
  import {
    QUOTES_MUTATION,
    BOOK_MUTATION
  } from './mutations'
  import { ApolloClient } from 'apollo-client';
  import { HttpLink } from 'apollo-link-http';
  import { ApolloLink, concat } from 'apollo-link';
  const link = new HttpLink({ uri: 'https://api.curri.com/graphql' });
  const authMiddleware = new ApolloLink((operation, forward) => {
    operation.setContext({
      headers: {
        Authorization: 'Basic INSERT_BASE_64_USERID_AND_APIKEY',
      }
    });
    return forward(operation);
  })
  const client = new ApolloClient({
    link: concat(authMiddleware, httpLink),
  });
  // Get a quote.
  const { data: quoteData } = await client.mutate({
    mutation: QUOTE_MUTATION,
    variables: {
      destination: {
        name: "Y Combinator",
        addressLine1: "335 Pioneer Way",
        city: "Mountain View",
        state: "CA",
        postalCode: 94041
      },
      origin: {
        name: "305 South Kalorama Street",
        addressLine1: "305 S Kalorama St",
        city: "Ventura",
        state: "CA",
        postalCode: 93001
      },
      deliveryMethod: "truck"
    }
  })
  const deliveryQuoteId = quoteData.deliveryQuote.id
  // Book the delivery.
  const { data: bookData } = await client.mutate({
    mutation: BOOK_MUTATION,
    variables: {
      data: {
        deliveryQuoteId,
        dropoffContact: {
          name: "Bob Jones",
          phoneNumber: "+15553213265"
        },
        pickupContact: {
          name: "Alice Khan",
          phoneNumber: "+15553213264"
        },
        pointOfContact: {
          name: "Carlos Lee",
          phoneNumber: "+15553213263"
        },
        manifestItems: [
          {
            height: 5,
            width: 5,
            length: 100,
            weight: 1,
            quantity: 1,
            description: "This is a small pipe"
          }
        ]
      }
    }
  })
`