Skip to content

Latest commit

 

History

History
83 lines (60 loc) · 3.38 KB

create_print_order.md

File metadata and controls

83 lines (60 loc) · 3.38 KB

Creating a Print Order

This tutorial covers creating a print order to be submitted for printing and posting.

If you haven't already, see the README for an initial overview and instructions for adding the SDK to your project.

Overview

  1. Initialise the SDK
  2. Create Asset representations of all the images you want to print
  3. Retrieve an up-to-date catalogue of available products.
  4. Create Job's for the desired products you want to print and attach the assets created in Step 2
  5. Create an Order and attach your job(s) created in Step 4

Sample Code

  1. Initialize the SDK and provide your API Keys (these can be found in the Credentials section of the development dashboard). You'll typically initialize the SDK once at application startup. You will also need to supply a context.

    KiteSDK.initialise( MyActivity.this, "REPLACE_WITH_YOUR_API_KEY", KiteSDK.DefaultEnvironment.TEST );

    Note: Test/Sandbox orders will not be printed and posted. The Test/Sandbox environment is purely for testing during development. If you want to submit a real order that will be printed and posted just use your live API key and the KiteSDK.DefaultEnvironment.LIVE environment

  2. Create Asset representations for every image you want to print. Asset has many constructors (including ones not listed below) to support any use case you may have.

    ArrayList<Asset> assets = new ArrayList<Asset>();
    assets.add(new Asset(R.drawable.photo));
    assets.add(new Asset(new URL("http://psps.s3.amazonaws.com/sdk_static/4.jpg")));
    assets.add(new Asset("/mnt/external_sd/1.png"));
  3. Retrieve an up-to-date catalogue of available products.

    kiteSDK.getCatalogueLoader().requestCatalogue( new ICatalogueConsumer()
      {
      @Override
      public void onCatalogueSuccess( Catalogue catalogue )
        {
        /* Create your order */
        }
    
      @Override
      public void onCatalogueError( Exception exception )
        {
        /* Handle gracefully */
        }
      } );
  4. Create Job's for every type of product you want to print in this order. An order may have multiple jobs attached.

    Job magnets      = Job.createPrintJob( catalogue.getProductById( "magnets" ),   assets );
    Job polaroids    = Job.createPrintJob( catalogue.getProductById( "polaroids" ), assets );
    Job squarePrints = Job.createPrintJob( catalogue.getProductById( "squares" ),   assets );

    Note: The above shows only a small sample of the products available for printing with the SDK. Also, the product ids may vary according to those available for your API key.

  5. Create an Order and attach the job(s) you created in the previous step.

    Order order = new Order();
    order.addJob( magnets );
    order.addJob( polaroids );
    order.addJob( squarePrints );

Next Steps