diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..8d8b351b --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# The following team is the owner for everything in the repo. Everyone in +# the team will be requested for review when someone opens a pull request. +* @wildfork/us-mobile-app diff --git a/example/pubspec.lock b/example/pubspec.lock index 170e77aa..8ffef529 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -91,7 +91,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -119,7 +119,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -145,7 +145,7 @@ packages: path: ".." relative: true source: path - version: "0.0.25-alpha" + version: "0.0.26-alpha" flutter_test: dependency: "direct dev" description: flutter @@ -260,7 +260,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: transitive description: @@ -295,7 +295,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -323,7 +323,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider_linux: dependency: transitive description: @@ -468,7 +468,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -503,7 +503,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" typed_data: dependency: transitive description: @@ -580,7 +580,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" watcher: dependency: transitive description: @@ -617,5 +617,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.15.0 <3.0.0" - flutter: ">=2.10.1" + dart: ">=2.17.0-0 <3.0.0" + flutter: ">=2.10.0" diff --git a/lib/graphql_operations/mutations/customer_create.dart b/lib/graphql_operations/mutations/customer_create.dart index 823fd7f4..c0b142fa 100644 --- a/lib/graphql_operations/mutations/customer_create.dart +++ b/lib/graphql_operations/mutations/customer_create.dart @@ -48,6 +48,7 @@ mutation MyMutation($firstName: String, $lastName: String, $email: String!, $pas displayName email firstName + lastName id lastIncompleteCheckout { completedAt diff --git a/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart b/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart index 935e00b5..9ad5e449 100644 --- a/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart +++ b/lib/graphql_operations/queries/get_all_products_from_collection_by_id.dart @@ -83,7 +83,6 @@ query($id : ID!, $cursor : String, $sortKey: ProductCollectionSortKeys){ } availableForSale id - quantityAvailable unitPrice { amount currencyCode diff --git a/lib/graphql_operations/queries/get_all_products_on_query.dart b/lib/graphql_operations/queries/get_all_products_on_query.dart index c7ffdf2c..998ed35c 100644 --- a/lib/graphql_operations/queries/get_all_products_on_query.dart +++ b/lib/graphql_operations/queries/get_all_products_on_query.dart @@ -57,7 +57,6 @@ query( $cursor: String, $sortKey : ProductSortKeys, $query: String, $reverse: Bo value } id - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_collections.dart b/lib/graphql_operations/queries/get_collections.dart index 589cddca..45acf3e4 100644 --- a/lib/graphql_operations/queries/get_collections.dart +++ b/lib/graphql_operations/queries/get_collections.dart @@ -47,7 +47,6 @@ query($cursor: String, $sortKey: CollectionSortKeys, $reverse: Boolean){ value } availableForSale - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_customer.dart b/lib/graphql_operations/queries/get_customer.dart index 46ba3faf..6035f6b1 100644 --- a/lib/graphql_operations/queries/get_customer.dart +++ b/lib/graphql_operations/queries/get_customer.dart @@ -49,6 +49,16 @@ query($customerAccessToken : String!){ firstName id lastName + metafields(first:250) { + edges { + node { + id + key + namespace + value + } + } + } lastIncompleteCheckout { completedAt createdAt diff --git a/lib/graphql_operations/queries/get_featured_collections.dart b/lib/graphql_operations/queries/get_featured_collections.dart index 85e5ab4e..322bf5f2 100644 --- a/lib/graphql_operations/queries/get_featured_collections.dart +++ b/lib/graphql_operations/queries/get_featured_collections.dart @@ -39,7 +39,6 @@ query getFeaturedCollectionQuery($query: String!){ sku requiresShipping availableForSale - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_meta_field.dart b/lib/graphql_operations/queries/get_meta_field.dart new file mode 100644 index 00000000..48a4efb0 --- /dev/null +++ b/lib/graphql_operations/queries/get_meta_field.dart @@ -0,0 +1,38 @@ +const String getMetaField = r''' +query ProductMetafields($ownerId : ID!){ + product(id: $ownerId) { + id + title + metafields(namespace: "wildfox", first: 50) { + edges { + node { + id + namespace + key + value + valueType + description + } + } + } + variants(first : 50){ + edges { + node { + id + title + metafields (first : 50, namespace: "wildfox"){ + edges { + node { + id + namespace + key + value + } + } + } + } + } + } + } +} +'''; diff --git a/lib/graphql_operations/queries/get_n_products.dart b/lib/graphql_operations/queries/get_n_products.dart index eff74cf3..ac066aff 100644 --- a/lib/graphql_operations/queries/get_n_products.dart +++ b/lib/graphql_operations/queries/get_n_products.dart @@ -35,7 +35,6 @@ query($n : Int, $sortKey : ProductSortKeys, $reverse: Boolean){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_product_recommendations.dart b/lib/graphql_operations/queries/get_product_recommendations.dart index 711f1cc2..7820d037 100644 --- a/lib/graphql_operations/queries/get_product_recommendations.dart +++ b/lib/graphql_operations/queries/get_product_recommendations.dart @@ -51,7 +51,6 @@ query getProductRecommentationsQuery($id: ID!){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_products.dart b/lib/graphql_operations/queries/get_products.dart index cdbe90b6..32934a92 100644 --- a/lib/graphql_operations/queries/get_products.dart +++ b/lib/graphql_operations/queries/get_products.dart @@ -47,7 +47,6 @@ query($cursor : String, $metafieldsNamespace : String){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_products_by_handle.dart b/lib/graphql_operations/queries/get_products_by_handle.dart index 920461fe..c7d90f74 100644 --- a/lib/graphql_operations/queries/get_products_by_handle.dart +++ b/lib/graphql_operations/queries/get_products_by_handle.dart @@ -17,10 +17,9 @@ query getProductByHandle($handle : String!){ amount currencyCode } - quantityAvailable } } } } } -'''; \ No newline at end of file +'''; diff --git a/lib/graphql_operations/queries/get_products_by_ids.dart b/lib/graphql_operations/queries/get_products_by_ids.dart index 8a014ea1..c753aeba 100644 --- a/lib/graphql_operations/queries/get_products_by_ids.dart +++ b/lib/graphql_operations/queries/get_products_by_ids.dart @@ -62,7 +62,6 @@ query($ids : [ID!]!){ value } id - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart b/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart index 61fbd2e4..8c87869e 100644 --- a/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart +++ b/lib/graphql_operations/queries/get_x_collections_and_n_products_sorted.dart @@ -47,7 +47,6 @@ query($cursor: String, $sortKey: CollectionSortKeys, $sortKeyProduct: ProductCol value } availableForSale - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_x_products_after_cursor.dart b/lib/graphql_operations/queries/get_x_products_after_cursor.dart index 53fc80eb..d5eff096 100644 --- a/lib/graphql_operations/queries/get_x_products_after_cursor.dart +++ b/lib/graphql_operations/queries/get_x_products_after_cursor.dart @@ -35,7 +35,6 @@ query($cursor : String, $x : Int, $reverse: Boolean, $sortKey: ProductSortKeys){ availableForSale sku requiresShipping - quantityAvailable selectedOptions { name value diff --git a/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart b/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart index d2cc95ff..eb584969 100644 --- a/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart +++ b/lib/graphql_operations/queries/get_x_products_after_cursor_within_collection.dart @@ -83,7 +83,6 @@ query($id : ID!, $cursor : String, $limit : Int, $sortKey : ProductCollectionSor } availableForSale id - quantityAvailable } } } diff --git a/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart b/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart index 1e630814..a7ddcc5d 100644 --- a/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart +++ b/lib/graphql_operations/queries/get_x_products_on_query_after_cursor.dart @@ -57,7 +57,6 @@ query( $cursor: String, $limit : Int, $sortKey : ProductSortKeys, $query: String value } id - quantityAvailable } } } diff --git a/lib/models/src/order/line_item_order/line_item_order.dart b/lib/models/src/order/line_item_order/line_item_order.dart index efc0fe0c..388036ac 100644 --- a/lib/models/src/order/line_item_order/line_item_order.dart +++ b/lib/models/src/order/line_item_order/line_item_order.dart @@ -27,14 +27,16 @@ class LineItemOrder with _$LineItemOrder { return LineItemOrder( currentQuantity: (json['node'] ?? const {})['currentQuantity'], discountAllocations: _getDiscountAllocationsList(json), - discountedTotalPrice: PriceV2.fromJson( - (json['node'] ?? const {})['discountedTotalPrice']), + discountedTotalPrice: PriceV2.fromJson((json['node'] ?? + const {})['discountedTotalPrice'] as Map), originalTotalPrice: PriceV2.fromJson((json['node'] ?? const {})['originalTotalPrice']), quantity: (json['node'] ?? const {})['quantity'], title: (json['node'] ?? const {})['title'], - variant: ProductVariantCheckout.fromJson( - (json['node'] ?? const {})['variant'] ?? const {})); + variant: json['node']!['variant'] == null + ? null + : ProductVariantCheckout.fromJson( + (json['node'] ?? const {})['variant'] ?? const {})); } static _getDiscountAllocationsList(Map json) { diff --git a/lib/models/src/order/line_items_order/line_items_order.dart b/lib/models/src/order/line_items_order/line_items_order.dart index 2f89320f..e646711c 100644 --- a/lib/models/src/order/line_items_order/line_items_order.dart +++ b/lib/models/src/order/line_items_order/line_items_order.dart @@ -18,8 +18,8 @@ class LineItemsOrder with _$LineItemsOrder { static _getLineItemOrderList(Map json) { List lineItemListOrder = []; - json['edges']?.forEach((lineItemOrder) => - lineItemListOrder.add(LineItemOrder.fromGraphJson(lineItemOrder))); + json['edges']?.forEach((lineItemOrder) => lineItemListOrder.add( + LineItemOrder.fromGraphJson(lineItemOrder as Map))); return lineItemListOrder; } } diff --git a/lib/models/src/order/order.dart b/lib/models/src/order/order.dart index 0b68cea5..c2cd3bc3 100644 --- a/lib/models/src/order/order.dart +++ b/lib/models/src/order/order.dart @@ -37,7 +37,7 @@ class Order with _$Order { email: (json['node'] ?? const {})['email'], currencyCode: (json['node'] ?? const {})['currencyCode'], customerUrl: (json['node'] ?? const {})['customerUrl'], - lineItems: LineItemsOrder.fromJson( + lineItems: LineItemsOrder.fromGraphJson( (json['node'] ?? const {})['lineItems'] ?? const {}), name: (json['node'] ?? const {})['name'], orderNumber: (json['node'] ?? const {})['orderNumber'], diff --git a/lib/models/src/order/order.g.dart b/lib/models/src/order/order.g.dart index 042177ac..deef1355 100644 --- a/lib/models/src/order/order.g.dart +++ b/lib/models/src/order/order.g.dart @@ -7,18 +7,18 @@ part of 'order.dart'; // ************************************************************************** _$_Order _$$_OrderFromJson(Map json) => _$_Order( - id: json['id'] as String, - email: json['email'] as String, - currencyCode: json['currencyCode'] as String, - customerUrl: json['customerUrl'] as String, - lineItems: - LineItemsOrder.fromJson(json['lineItems'] as Map), - name: json['name'] as String, - orderNumber: json['orderNumber'] as int, - processedAt: json['processedAt'] as String, + id: json['node']['id'] as String, + email: json['node']['email'] as String, + currencyCode: json['node']['currencyCode'] as String, + customerUrl: json['node']['customerUrl'] as String, + lineItems: LineItemsOrder.fromJson( + json['node']['lineItems'] as Map), + name: json['node']['name'] as String, + orderNumber: json['node']['orderNumber'] as int, + processedAt: json['node']['processedAt'] as String, shippingAddress: ShippingAddress.fromJson( - json['shippingAddress'] as Map), - statusUrl: json['statusUrl'] as String, + json['node']['shippingAddress'] as Map), + statusUrl: json['node']['statusUrl'] as String, subtotalPriceV2: PriceV2.fromJson(json['subtotalPriceV2'] as Map), totalPriceV2: diff --git a/lib/models/src/order/orders/orders.dart b/lib/models/src/order/orders/orders.dart index 0134901c..0a9fad56 100644 --- a/lib/models/src/order/orders/orders.dart +++ b/lib/models/src/order/orders/orders.dart @@ -9,13 +9,13 @@ part 'orders.g.dart'; class Orders with _$Orders { factory Orders({required List orderList, required bool hasNextPage}) = _Orders; - + factory Orders.fromJson(Map json) => _$OrdersFromJson(json); static Orders fromGraphJson(Map json) { return Orders( orderList: _getOrderList(json), - hasNextPage: (json['pageInfo'] ?? const {})['hasNextPage']); + hasNextPage: false); //(json['pageInfo'] ?? const {})['hasNextPage']); } static List _getOrderList(Map json) { diff --git a/lib/models/src/order/orders/orders.g.dart b/lib/models/src/order/orders/orders.g.dart index 36cc9fd7..f9afb7bc 100644 --- a/lib/models/src/order/orders/orders.g.dart +++ b/lib/models/src/order/orders/orders.g.dart @@ -7,10 +7,10 @@ part of 'orders.dart'; // ************************************************************************** _$_Orders _$$_OrdersFromJson(Map json) => _$_Orders( - orderList: (json['orderList'] as List) - .map((e) => Order.fromJson(e as Map)) - .toList(), - hasNextPage: json['hasNextPage'] as bool, + orderList: (json['edges'] as List) + .map((e) => Order.fromGraphJson(e as Map)) + .toList(), + hasNextPage: false //json['hasNextPage'] as bool, ); Map _$$_OrdersToJson(_$_Orders instance) => { diff --git a/lib/models/src/product/metafield/metafield.dart b/lib/models/src/product/metafield/metafield.dart index d924b1ef..a9e361b4 100644 --- a/lib/models/src/product/metafield/metafield.dart +++ b/lib/models/src/product/metafield/metafield.dart @@ -12,8 +12,7 @@ class Metafield with _$Metafield { required String namespace, required String key, required String value, - required String valueType, - @Default('') String description, + }) = _Metafield; static Metafield fromGraphJson(Map json) { @@ -22,8 +21,8 @@ class Metafield with _$Metafield { namespace: (json['node'] ?? const {})['namespace'], key: (json['node'] ?? const {})['key'], value: (json['node'] ?? const {})['value'], - valueType: (json['node'] ?? const {})['valueType'], - description: (json['node'] ?? const {})['description']); + + ); } factory Metafield.fromJson(Map json) => diff --git a/lib/models/src/product/metafield/metafield.freezed.dart b/lib/models/src/product/metafield/metafield.freezed.dart index cffd8cd2..5f7980f3 100644 --- a/lib/models/src/product/metafield/metafield.freezed.dart +++ b/lib/models/src/product/metafield/metafield.freezed.dart @@ -26,16 +26,12 @@ class _$MetafieldTearOff { {required String id, required String namespace, required String key, - required String value, - required String valueType, - String description = ''}) { + required String value}) { return _Metafield( id: id, namespace: namespace, key: key, value: value, - valueType: valueType, - description: description, ); } @@ -53,8 +49,6 @@ mixin _$Metafield { String get namespace => throw _privateConstructorUsedError; String get key => throw _privateConstructorUsedError; String get value => throw _privateConstructorUsedError; - String get valueType => throw _privateConstructorUsedError; - String get description => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -66,13 +60,7 @@ mixin _$Metafield { abstract class $MetafieldCopyWith<$Res> { factory $MetafieldCopyWith(Metafield value, $Res Function(Metafield) then) = _$MetafieldCopyWithImpl<$Res>; - $Res call( - {String id, - String namespace, - String key, - String value, - String valueType, - String description}); + $Res call({String id, String namespace, String key, String value}); } /// @nodoc @@ -89,8 +77,6 @@ class _$MetafieldCopyWithImpl<$Res> implements $MetafieldCopyWith<$Res> { Object? namespace = freezed, Object? key = freezed, Object? value = freezed, - Object? valueType = freezed, - Object? description = freezed, }) { return _then(_value.copyWith( id: id == freezed @@ -109,14 +95,6 @@ class _$MetafieldCopyWithImpl<$Res> implements $MetafieldCopyWith<$Res> { ? _value.value : value // ignore: cast_nullable_to_non_nullable as String, - valueType: valueType == freezed - ? _value.valueType - : valueType // ignore: cast_nullable_to_non_nullable - as String, - description: description == freezed - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, )); } } @@ -127,13 +105,7 @@ abstract class _$MetafieldCopyWith<$Res> implements $MetafieldCopyWith<$Res> { _Metafield value, $Res Function(_Metafield) then) = __$MetafieldCopyWithImpl<$Res>; @override - $Res call( - {String id, - String namespace, - String key, - String value, - String valueType, - String description}); + $Res call({String id, String namespace, String key, String value}); } /// @nodoc @@ -151,8 +123,6 @@ class __$MetafieldCopyWithImpl<$Res> extends _$MetafieldCopyWithImpl<$Res> Object? namespace = freezed, Object? key = freezed, Object? value = freezed, - Object? valueType = freezed, - Object? description = freezed, }) { return _then(_Metafield( id: id == freezed @@ -171,14 +141,6 @@ class __$MetafieldCopyWithImpl<$Res> extends _$MetafieldCopyWithImpl<$Res> ? _value.value : value // ignore: cast_nullable_to_non_nullable as String, - valueType: valueType == freezed - ? _value.valueType - : valueType // ignore: cast_nullable_to_non_nullable - as String, - description: description == freezed - ? _value.description - : description // ignore: cast_nullable_to_non_nullable - as String, )); } } @@ -190,9 +152,7 @@ class _$_Metafield extends _Metafield { {required this.id, required this.namespace, required this.key, - required this.value, - required this.valueType, - this.description = ''}) + required this.value}) : super._(); factory _$_Metafield.fromJson(Map json) => @@ -206,15 +166,10 @@ class _$_Metafield extends _Metafield { final String key; @override final String value; - @override - final String valueType; - @JsonKey() - @override - final String description; @override String toString() { - return 'Metafield(id: $id, namespace: $namespace, key: $key, value: $value, valueType: $valueType, description: $description)'; + return 'Metafield(id: $id, namespace: $namespace, key: $key, value: $value)'; } @override @@ -225,10 +180,7 @@ class _$_Metafield extends _Metafield { const DeepCollectionEquality().equals(other.id, id) && const DeepCollectionEquality().equals(other.namespace, namespace) && const DeepCollectionEquality().equals(other.key, key) && - const DeepCollectionEquality().equals(other.value, value) && - const DeepCollectionEquality().equals(other.valueType, valueType) && - const DeepCollectionEquality() - .equals(other.description, description)); + const DeepCollectionEquality().equals(other.value, value)); } @override @@ -237,9 +189,7 @@ class _$_Metafield extends _Metafield { const DeepCollectionEquality().hash(id), const DeepCollectionEquality().hash(namespace), const DeepCollectionEquality().hash(key), - const DeepCollectionEquality().hash(value), - const DeepCollectionEquality().hash(valueType), - const DeepCollectionEquality().hash(description)); + const DeepCollectionEquality().hash(value)); @JsonKey(ignore: true) @override @@ -257,9 +207,7 @@ abstract class _Metafield extends Metafield { {required String id, required String namespace, required String key, - required String value, - required String valueType, - String description}) = _$_Metafield; + required String value}) = _$_Metafield; _Metafield._() : super._(); factory _Metafield.fromJson(Map json) = @@ -274,10 +222,6 @@ abstract class _Metafield extends Metafield { @override String get value; @override - String get valueType; - @override - String get description; - @override @JsonKey(ignore: true) _$MetafieldCopyWith<_Metafield> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/models/src/product/metafield/metafield.g.dart b/lib/models/src/product/metafield/metafield.g.dart index 5528c00e..2f14b4cc 100644 --- a/lib/models/src/product/metafield/metafield.g.dart +++ b/lib/models/src/product/metafield/metafield.g.dart @@ -11,8 +11,6 @@ _$_Metafield _$$_MetafieldFromJson(Map json) => _$_Metafield( namespace: json['namespace'] as String, key: json['key'] as String, value: json['value'] as String, - valueType: json['valueType'] as String, - description: json['description'] as String? ?? '', ); Map _$$_MetafieldToJson(_$_Metafield instance) => @@ -21,6 +19,4 @@ Map _$$_MetafieldToJson(_$_Metafield instance) => 'namespace': instance.namespace, 'key': instance.key, 'value': instance.value, - 'valueType': instance.valueType, - 'description': instance.description, }; diff --git a/lib/models/src/product/product_variant/product_variant.dart b/lib/models/src/product/product_variant/product_variant.dart index 10cb6414..fa0e9ca8 100644 --- a/lib/models/src/product/product_variant/product_variant.dart +++ b/lib/models/src/product/product_variant/product_variant.dart @@ -19,7 +19,6 @@ class ProductVariant with _$ProductVariant { required String sku, required bool requiresShipping, required String id, - required int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -45,7 +44,6 @@ class ProductVariant with _$ProductVariant { sku: nodeJson['sku'], requiresShipping: nodeJson['requiresShipping'], id: nodeJson['id'], - quantityAvailable: nodeJson['quantityAvailable'], unitPrice: nodeJson['unitPrice'] != null ? PriceV2.fromJson(nodeJson['unitPrice']) : null, diff --git a/lib/models/src/product/product_variant/product_variant.freezed.dart b/lib/models/src/product/product_variant/product_variant.freezed.dart index fd063b44..60611fb8 100644 --- a/lib/models/src/product/product_variant/product_variant.freezed.dart +++ b/lib/models/src/product/product_variant/product_variant.freezed.dart @@ -31,7 +31,6 @@ class _$ProductVariantTearOff { required String sku, required bool requiresShipping, required String id, - required int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -46,7 +45,6 @@ class _$ProductVariantTearOff { sku: sku, requiresShipping: requiresShipping, id: id, - quantityAvailable: quantityAvailable, unitPrice: unitPrice, unitPriceMeasurement: unitPriceMeasurement, selectedOptions: selectedOptions, @@ -73,7 +71,6 @@ mixin _$ProductVariant { String get sku => throw _privateConstructorUsedError; bool get requiresShipping => throw _privateConstructorUsedError; String get id => throw _privateConstructorUsedError; - int get quantityAvailable => throw _privateConstructorUsedError; PriceV2? get unitPrice => throw _privateConstructorUsedError; UnitPriceMeasurement? get unitPriceMeasurement => throw _privateConstructorUsedError; @@ -102,7 +99,6 @@ abstract class $ProductVariantCopyWith<$Res> { String sku, bool requiresShipping, String id, - int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -135,7 +131,6 @@ class _$ProductVariantCopyWithImpl<$Res> Object? sku = freezed, Object? requiresShipping = freezed, Object? id = freezed, - Object? quantityAvailable = freezed, Object? unitPrice = freezed, Object? unitPriceMeasurement = freezed, Object? selectedOptions = freezed, @@ -175,10 +170,6 @@ class _$ProductVariantCopyWithImpl<$Res> ? _value.id : id // ignore: cast_nullable_to_non_nullable as String, - quantityAvailable: quantityAvailable == freezed - ? _value.quantityAvailable - : quantityAvailable // ignore: cast_nullable_to_non_nullable - as int, unitPrice: unitPrice == freezed ? _value.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable @@ -271,7 +262,6 @@ abstract class _$ProductVariantCopyWith<$Res> String sku, bool requiresShipping, String id, - int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -311,7 +301,6 @@ class __$ProductVariantCopyWithImpl<$Res> Object? sku = freezed, Object? requiresShipping = freezed, Object? id = freezed, - Object? quantityAvailable = freezed, Object? unitPrice = freezed, Object? unitPriceMeasurement = freezed, Object? selectedOptions = freezed, @@ -351,10 +340,6 @@ class __$ProductVariantCopyWithImpl<$Res> ? _value.id : id // ignore: cast_nullable_to_non_nullable as String, - quantityAvailable: quantityAvailable == freezed - ? _value.quantityAvailable - : quantityAvailable // ignore: cast_nullable_to_non_nullable - as int, unitPrice: unitPrice == freezed ? _value.unitPrice : unitPrice // ignore: cast_nullable_to_non_nullable @@ -391,7 +376,6 @@ class _$_ProductVariant extends _ProductVariant { required this.sku, required this.requiresShipping, required this.id, - required this.quantityAvailable, this.unitPrice, this.unitPriceMeasurement, this.selectedOptions, @@ -419,8 +403,6 @@ class _$_ProductVariant extends _ProductVariant { @override final String id; @override - final int quantityAvailable; - @override final PriceV2? unitPrice; @override final UnitPriceMeasurement? unitPriceMeasurement; @@ -433,7 +415,7 @@ class _$_ProductVariant extends _ProductVariant { @override String toString() { - return 'ProductVariant(price: $price, title: $title, weight: $weight, weightUnit: $weightUnit, availableForSale: $availableForSale, sku: $sku, requiresShipping: $requiresShipping, id: $id, quantityAvailable: $quantityAvailable, unitPrice: $unitPrice, unitPriceMeasurement: $unitPriceMeasurement, selectedOptions: $selectedOptions, compareAtPrice: $compareAtPrice, image: $image)'; + return 'ProductVariant(price: $price, title: $title, weight: $weight, weightUnit: $weightUnit, availableForSale: $availableForSale, sku: $sku, requiresShipping: $requiresShipping, id: $id, unitPrice: $unitPrice, unitPriceMeasurement: $unitPriceMeasurement, selectedOptions: $selectedOptions, compareAtPrice: $compareAtPrice, image: $image)'; } @override @@ -452,8 +434,6 @@ class _$_ProductVariant extends _ProductVariant { const DeepCollectionEquality() .equals(other.requiresShipping, requiresShipping) && const DeepCollectionEquality().equals(other.id, id) && - const DeepCollectionEquality() - .equals(other.quantityAvailable, quantityAvailable) && const DeepCollectionEquality().equals(other.unitPrice, unitPrice) && const DeepCollectionEquality() .equals(other.unitPriceMeasurement, unitPriceMeasurement) && @@ -475,7 +455,6 @@ class _$_ProductVariant extends _ProductVariant { const DeepCollectionEquality().hash(sku), const DeepCollectionEquality().hash(requiresShipping), const DeepCollectionEquality().hash(id), - const DeepCollectionEquality().hash(quantityAvailable), const DeepCollectionEquality().hash(unitPrice), const DeepCollectionEquality().hash(unitPriceMeasurement), const DeepCollectionEquality().hash(selectedOptions), @@ -503,7 +482,6 @@ abstract class _ProductVariant extends ProductVariant { required String sku, required bool requiresShipping, required String id, - required int quantityAvailable, PriceV2? unitPrice, UnitPriceMeasurement? unitPriceMeasurement, List? selectedOptions, @@ -531,8 +509,6 @@ abstract class _ProductVariant extends ProductVariant { @override String get id; @override - int get quantityAvailable; - @override PriceV2? get unitPrice; @override UnitPriceMeasurement? get unitPriceMeasurement; diff --git a/lib/models/src/product/product_variant/product_variant.g.dart b/lib/models/src/product/product_variant/product_variant.g.dart index a1de48ae..1c3f512d 100644 --- a/lib/models/src/product/product_variant/product_variant.g.dart +++ b/lib/models/src/product/product_variant/product_variant.g.dart @@ -16,7 +16,6 @@ _$_ProductVariant _$$_ProductVariantFromJson(Map json) => sku: json['sku'] as String, requiresShipping: json['requiresShipping'] as bool, id: json['id'] as String, - quantityAvailable: json['quantityAvailable'] as int, unitPrice: json['unitPrice'] == null ? null : PriceV2.fromJson(json['unitPrice'] as Map), @@ -45,7 +44,6 @@ Map _$$_ProductVariantToJson(_$_ProductVariant instance) => 'sku': instance.sku, 'requiresShipping': instance.requiresShipping, 'id': instance.id, - 'quantityAvailable': instance.quantityAvailable, 'unitPrice': instance.unitPrice, 'unitPriceMeasurement': instance.unitPriceMeasurement, 'selectedOptions': instance.selectedOptions, diff --git a/lib/shopify/src/shopify_checkout.dart b/lib/shopify/src/shopify_checkout.dart index e3b7d554..45776a6e 100644 --- a/lib/shopify/src/shopify_checkout.dart +++ b/lib/shopify/src/shopify_checkout.dart @@ -133,9 +133,7 @@ class ShopifyCheckout with ShopifyError { final QueryResult result = await ShopifyConfig.graphQLClient!.query(_options); checkForError(result); - Orders orders = Orders.fromJson( - (((result.data ?? const {})['customer'] ?? const {})['orders'] ?? - const {})); + Orders orders = Orders.fromGraphJson(result.data!['customer']!['orders']!); if (deleteThisPartOfCache) { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); } diff --git a/lib/shopify/src/shopify_customer.dart b/lib/shopify/src/shopify_customer.dart index 1e5f13ba..21522c68 100644 --- a/lib/shopify/src/shopify_customer.dart +++ b/lib/shopify/src/shopify_customer.dart @@ -2,10 +2,13 @@ import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_add import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_address_delete.dart'; import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_address_update.dart'; import 'package:flutter_simple_shopify/graphql_operations/mutations/customer_update.dart'; +import 'package:flutter_simple_shopify/graphql_operations/queries/get_customer.dart'; import 'package:flutter_simple_shopify/mixins/src/shopfiy_error.dart'; +import 'package:flutter_simple_shopify/models/src/product/metafield/metafield.dart'; import 'package:flutter_simple_shopify/models/src/shopify_user/address/address.dart'; import 'package:graphql/client.dart'; +import '../../models/src/shopify_user/shopify_user.dart'; import '../../shopify_config.dart'; /// ShopifyCustomer class provides various methods for working with a user/customer. @@ -92,7 +95,22 @@ class ShopifyCustomer with ShopifyError { _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); } } + Future getCustomerMetaFields(String? customerAccessToken) async{ + // call query to get customer metafields + /*final MutationOptions _options = MutationOptions( + document: gql(getCustomerQuery), + variables: { + 'customerAccessToken': customerAccessToken, + //'id': addressId + });*/ + final WatchQueryOptions _getCustomer = WatchQueryOptions( + document: gql(getCustomerQuery), + variables: {'customerAccessToken': await customerAccessToken}); + final QueryResult result = (await _graphQLClient!.query(_getCustomer)); + checkForError(result); + return Metafield.fromJson(result.data!['customer']['metafields']); + } /// Creates a address for the customer to which [customerAccessToken] belongs to. Future
customerAddressCreate( {String? address1, diff --git a/lib/shopify/src/shopify_store.dart b/lib/shopify/src/shopify_store.dart index df6a2fd2..4f448b43 100644 --- a/lib/shopify/src/shopify_store.dart +++ b/lib/shopify/src/shopify_store.dart @@ -4,6 +4,7 @@ import 'package:flutter_simple_shopify/graphql_operations/queries/get_all_collec import 'package:flutter_simple_shopify/graphql_operations/queries/get_all_products_from_collection_by_id.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_all_products_on_query.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_collections_by_ids.dart'; +import 'package:flutter_simple_shopify/graphql_operations/queries/get_meta_field.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_metafileds_from_product.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_product_recommendations.dart'; import 'package:flutter_simple_shopify/graphql_operations/queries/get_products_by_ids.dart'; @@ -445,4 +446,44 @@ class ShopifyStore with ShopifyError { .map((e) => Metafield.fromGraphJson(e as Map)) .toList(); } + + Future> getMetaFields( + String id, {bool deleteThisPartOfCache = false}) async { + final WatchQueryOptions _options = WatchQueryOptions( + document: gql(getMetaField), + variables: { + 'ownerId': "gid://shopify/Product/$id"}); + final QueryResult result = + await ShopifyConfig.graphQLClient!.query(_options); + checkForError(result); + if (deleteThisPartOfCache) { + _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); + } + return (result.data!['product']['metafields']['edges'] + as List) + .map((e) => Metafield.fromGraphJson(e as Map)) + .toList(); + + } + + Future> getProductVariantMetaFields( + String id, {bool deleteThisPartOfCache = false}) async { + final WatchQueryOptions _options = WatchQueryOptions( + document: gql(getMetaField), + variables: { + 'ownerId': "gid://shopify/Product/$id"}); + final QueryResult result = + await ShopifyConfig.graphQLClient!.query(_options); + checkForError(result); + if (deleteThisPartOfCache) { + _graphQLClient!.cache.writeQuery(_options.asRequest, data: {}); + } + return (result.data!['product']['variants']['edges'][0]['node']['metafields']['edges'] + as List) + .map((e) => Metafield.fromGraphJson(e as Map)) + .toList(); + + } + + } diff --git a/pubspec.lock b/pubspec.lock index 8044c08b..3b8cda15 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -140,7 +140,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" convert: dependency: transitive description: @@ -168,7 +168,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -344,7 +344,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: transitive description: @@ -379,7 +379,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -414,7 +414,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider_linux: dependency: transitive description: @@ -449,7 +449,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.1.2" + version: "3.1.0" plugin_platform_interface: dependency: transitive description: @@ -519,7 +519,7 @@ packages: name: shared_preferences_linux url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" shared_preferences_macos: dependency: transitive description: @@ -547,7 +547,7 @@ packages: name: shared_preferences_windows url: "https://pub.dartlang.org" source: hosted - version: "2.1.2" + version: "2.1.1" shelf: dependency: transitive description: @@ -587,7 +587,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -629,7 +629,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" timing: dependency: transitive description: @@ -713,7 +713,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" watcher: dependency: transitive description: @@ -750,5 +750,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.15.0 <3.0.0" - flutter: ">=2.10.1" + dart: ">=2.17.0-0 <3.0.0" + flutter: ">=2.10.0"