Chilkat Online Tools

Android / Marketplacer SELLER API / Get Invoices with Filtering and Ordering

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

    http.put_BasicAuth(true);
    http.put_Login("{{username}}");
    http.put_Password("{{password}}");

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "query": "query GetInvoicesWithFilteringAndOrdering \n(\n\t$pageSize: Int\n\t$endCursor: String\n\t$sort: InvoiceSort\n\t$filters: InvoiceFilters\n){\n\tinvoices(\n\t\tfirst: $pageSize\n\t\tafter: $endCursor\n\t\tfilters: $filters\n\t\tsort: $sort\n\t) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\t...PageInfoPartial\n\t\t}\n\t\tedges {\n\t\t\tnode {\n\t\t\t\tid\n\t\t\t\tlegacyId\n\t\t\t\tcreatedAt\n\t\t\t\tupdatedAt\n\t\t\t\torder {\n\t\t\t\t\tupdatedAt\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t\tstatusFlags\n\t\t\t\tlineItems {\n\t\t\t\t\tid\n\t\t\t\t\tvariantId\n\t\t\t\t\tvariantSku\n\t\t\t\t\tvariantBarcode\n\t\t\t\t\tvariantName\n\t\t\t\t\ttotalCents\n\t\t\t\t}\n\t\t\t\tshipments {\n\t\t\t\t\tid\n\t\t\t\t\tdispatchedAt\n\t\t\t\t\tshippedItems {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tlineItem {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tadvertTitle\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}\n",
    //   "variables": "{\n\t\"pageSize\": 100,\n\t\"endCursor\": \"\",\n\t\"sort\": {\n\t\t\"fields\": [\n\t\t\t\"UPDATED_AT\"\n\t\t],\n\t\t\"ordering\": \"DESCENDING\"\n\t},\n\t\"filters\": {\n\t\t\"updatedSince\": \"2022-01-01\"\n\t}\n}"
    // }

    CkJsonObject json = new CkJsonObject();
    json.UpdateString("query","query GetInvoicesWithFilteringAndOrdering \n(\n	$pageSize: Int\n	$endCursor: String\n	$sort: InvoiceSort\n	$filters: InvoiceFilters\n){\n	invoices(\n		first: $pageSize\n		after: $endCursor\n		filters: $filters\n		sort: $sort\n	) {\n		totalCount\n		pageInfo {\n			...PageInfoPartial\n		}\n		edges {\n			node {\n				id\n				legacyId\n				createdAt\n				updatedAt\n				order {\n					updatedAt\n					id\n				}\n				statusFlags\n				lineItems {\n					id\n					variantId\n					variantSku\n					variantBarcode\n					variantName\n					totalCents\n				}\n				shipments {\n					id\n					dispatchedAt\n					shippedItems {\n						id\n						lineItem {\n							id\n							advertTitle\n						}\n					}\n				}\n			}\n		}\n	}\n}\n\nfragment PageInfoPartial on PageInfo {\n	hasNextPage\n	endCursor\n}\n");
    json.UpdateString("variables","{\n	\"pageSize\": 100,\n	\"endCursor\": \"\",\n	\"sort\": {\n		\"fields\": [\n			\"UPDATED_AT\"\n		],\n		\"ordering\": \"DESCENDING\"\n	},\n	\"filters\": {\n		\"updatedSince\": \"2022-01-01\"\n	}\n}");

    http.SetRequestHeader("Content-Type","application/json");
    http.SetRequestHeader("MARKETPLACER-API-KEY","{{api_key}}");

    CkHttpResponse resp = http.PostJson3("https://bestfriendbazaar.com/graphql","application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    Log.i(TAG, String.valueOf(resp.get_StatusCode()));
    Log.i(TAG, resp.bodyStr());


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Curl Command

curl -X POST
	-u '{{username}}:{{password}}'
	-H "MARKETPLACER-API-KEY: {{api_key}}"
	-H "Content-Type: application/json"
	--data-raw '{"query":"query GetInvoicesWithFilteringAndOrdering \n(\n\t$pageSize: Int\n\t$endCursor: String\n\t$sort: InvoiceSort\n\t$filters: InvoiceFilters\n){\n\tinvoices(\n\t\tfirst: $pageSize\n\t\tafter: $endCursor\n\t\tfilters: $filters\n\t\tsort: $sort\n\t) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\t...PageInfoPartial\n\t\t}\n\t\tedges {\n\t\t\tnode {\n\t\t\t\tid\n\t\t\t\tlegacyId\n\t\t\t\tcreatedAt\n\t\t\t\tupdatedAt\n\t\t\t\torder {\n\t\t\t\t\tupdatedAt\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t\tstatusFlags\n\t\t\t\tlineItems {\n\t\t\t\t\tid\n\t\t\t\t\tvariantId\n\t\t\t\t\tvariantSku\n\t\t\t\t\tvariantBarcode\n\t\t\t\t\tvariantName\n\t\t\t\t\ttotalCents\n\t\t\t\t}\n\t\t\t\tshipments {\n\t\t\t\t\tid\n\t\t\t\t\tdispatchedAt\n\t\t\t\t\tshippedItems {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tlineItem {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tadvertTitle\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}\n","variables":"{\n\t\"pageSize\": 100,\n\t\"endCursor\": \"\",\n\t\"sort\": {\n\t\t\"fields\": [\n\t\t\t\"UPDATED_AT\"\n\t\t],\n\t\t\"ordering\": \"DESCENDING\"\n\t},\n\t\"filters\": {\n\t\t\"updatedSince\": \"2022-01-01\"\n\t}\n}"}'
https://bestfriendbazaar.com/graphql

Postman Collection Item JSON

{
  "name": "Get Invoices with Filtering and Ordering",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "MARKETPLACER-API-KEY",
        "value": "{{api_key}}",
        "type": "text"
      },
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "graphql",
      "graphql": {
        "query": "query GetInvoicesWithFilteringAndOrdering \n(\n\t$pageSize: Int\n\t$endCursor: String\n\t$sort: InvoiceSort\n\t$filters: InvoiceFilters\n){\n\tinvoices(\n\t\tfirst: $pageSize\n\t\tafter: $endCursor\n\t\tfilters: $filters\n\t\tsort: $sort\n\t) {\n\t\ttotalCount\n\t\tpageInfo {\n\t\t\t...PageInfoPartial\n\t\t}\n\t\tedges {\n\t\t\tnode {\n\t\t\t\tid\n\t\t\t\tlegacyId\n\t\t\t\tcreatedAt\n\t\t\t\tupdatedAt\n\t\t\t\torder {\n\t\t\t\t\tupdatedAt\n\t\t\t\t\tid\n\t\t\t\t}\n\t\t\t\tstatusFlags\n\t\t\t\tlineItems {\n\t\t\t\t\tid\n\t\t\t\t\tvariantId\n\t\t\t\t\tvariantSku\n\t\t\t\t\tvariantBarcode\n\t\t\t\t\tvariantName\n\t\t\t\t\ttotalCents\n\t\t\t\t}\n\t\t\t\tshipments {\n\t\t\t\t\tid\n\t\t\t\t\tdispatchedAt\n\t\t\t\t\tshippedItems {\n\t\t\t\t\t\tid\n\t\t\t\t\t\tlineItem {\n\t\t\t\t\t\t\tid\n\t\t\t\t\t\t\tadvertTitle\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfragment PageInfoPartial on PageInfo {\n\thasNextPage\n\tendCursor\n}\n",
        "variables": "{\n\t\"pageSize\": 100,\n\t\"endCursor\": \"\",\n\t\"sort\": {\n\t\t\"fields\": [\n\t\t\t\"UPDATED_AT\"\n\t\t],\n\t\t\"ordering\": \"DESCENDING\"\n\t},\n\t\"filters\": {\n\t\t\"updatedSince\": \"2022-01-01\"\n\t}\n}"
      }
    },
    "url": {
      "raw": "{{base_url}}",
      "host": [
        "{{base_url}}"
      ],
      "path": null
    },
    "description": null
  },
  "response": [
  ]
}