Order.fromGraphJson constructor

Order.fromGraphJson(
  1. Map<String, dynamic> json
)

The order from graph json

Implementation

factory Order.fromGraphJson(Map<String, dynamic> json) => Order(
      id: json['node']['id'],
      email: json['node']['email'] ?? '',
      currencyCode: json['node']['currencyCode'],
      customerUrl: json['node']['customerUrl'] ?? '',
      lineItems: LineItemsOrder.fromGraphJson(json['node']['lineItems']),
      name: json['node']['name'] ?? '',
      orderNumber: json['node']['orderNumber'] ?? 0,
      phone: json['node']['phone'],
      processedAt: json['node']['processedAt'],
      financialStatus: json['node']['financialStatus'] ?? '',
      fulfillmentStatus: json['node']['fulfillmentStatus'],
      shippingAddress: json['node']['shippingAddress'] == null
          ? null
          : ShippingAddress.fromJson(json['node']['shippingAddress']),
      billingAddress: json['node']['billingAddress'] == null
          ? null
          : ShippingAddress.fromJson(json['node']['billingAddress']),
      statusUrl: json['node']['statusUrl'],
      // subtotalPrice and totalTax are nullable on the Storefront API; keep
      // the order's own currency code on the zero fallback.
      subtotalPrice: _priceOrZeroIn(
        json['node']['subtotalPrice'],
        json['node']['currencyCode'],
      ),
      totalPrice: PriceV2.fromJson(json['node']['totalPrice']),
      totalRefunded: json['node']['totalRefunded'] == null
          ? null
          : PriceV2.fromJson(json['node']['totalRefunded']),
      totalShippingPrice:
          PriceV2.fromJson(json['node']['totalShippingPrice']),
      totalTax: _priceOrZeroIn(
        json['node']['totalTax'],
        json['node']['currencyCode'],
      ),
      cursor: json['cursor'],
      canceledAt: json['node']['canceledAt'],
      cancelReason: json['node']['cancelReason'],
      successfulFulfillments: _getSuccessfulFulfilments(
        json['node']['successfulFulfillments'] ?? [],
      ),
    );