public async Task WebhookSubscriptions_Delete()
        {
            var shopifyRepo = new ShopifyAdminRepository();
            var query       = @"mutation webhookSubscriptionDelete {
                webhookSubscriptionDelete(id: 'gid:\/\/shopify\/WebhookSubscription\/775024836682') {
                    deletedWebhookSubscriptionId
                    userErrors {
                        field
                        message
                    }
                }
            }";

            var result = await shopifyRepo.ExecuteMutation <WebHookSubscriptionDelete>(query);

            Assert.IsNotNull(result);
        }
        public async Task WebhookSubscriptions_Load()
        {
            var shopifyRepo = new ShopifyAdminRepository();
            var query       = @"{webhookSubscriptions(first:100)
                {
                    pageInfo { hasNextPage hasPreviousPage}
                    edges{
                        cursor
                        node { createdAt format callbackUrl id includeFields topic updatedAt legacyResourceId metafieldNamespaces}
                    }
                }
            }";

            var result = await shopifyRepo.ExecuteQuery <WebHookSubscriptions>(query);

            Assert.IsNotNull(result);
        }
Exemple #3
0
        public async Task DraftOrder_Create()
        {
            var shopifyRepo = new ShopifyAdminRepository();

            //First get the customer
            var query = @"query($queryParams: String!) {
                          customers(first:1, query:$queryParams) {
                            edges {
                              node {
                                id
                                verifiedEmail
                                firstName
                                lastName
                              }
                            }
                          }
                        }";

            var result = await shopifyRepo.ExecuteQuery <CustomersList>(query,
                                                                        new
            {
                queryParams = "email:[email protected]"
            });

            Assert.IsNotNull(result);

            //Now create a draft order
            var customerId = result.Customers.edges[0].node.Id;

            var mutation = @"mutation draftOrderCreate($input: DraftOrderInput!) {
                                draftOrderCreate(input: $input) {
                                    draftOrder {
                                        id
                                    }
                                    userErrors {
                                        field
                                        message
                                    }
                                }
                            }";

            var draftOrderInput = new
            {
                customerId = customerId,
                lineItems  = new[] {
                    new { title = "Test Item 1", quantity = 1, originalUnitPrice = 159.99, requiresShipping = false, sku = "TestSku123", taxable = false }
                }
            };

            var orderResult = await shopifyRepo.ExecuteQuery <DraftOrderCreateResponse>(mutation,
                                                                                        new
            {
                input = draftOrderInput
            });

            //Finally send order to customer for payment
            var orderId = orderResult.DraftOrderCreate.DraftOrder.Id;

            var orderSendMutation = @"mutation draftOrderInvoiceSend($id: ID!) {
                                        draftOrderInvoiceSend(id: $id) {
                                            draftOrder {
                                                id
                                            }
                                            userErrors {
                                                field
                                                message
                                            }
                                        }
                                    }";


            var orderSendResult = await shopifyRepo.ExecuteQuery <DraftOrderInvoiceSendResponse>(orderSendMutation,
                                                                                                 new
            {
                id = orderId
            });

            Assert.IsTrue(orderSendResult.DraftOrderInvoiceSend.DraftOrder.Id == orderId);
        }