public void TestEmailUpdate() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; DefaultQueries.checkout.EmailUpdate(query, checkoutId, "*****@*****.**"); Assert.AreEqual( "mutation{checkoutEmailUpdateV2 (checkoutId:\"an-id\",email:\"[email protected]\"){checkout {email }userErrors {field message }}}", query.ToString() ); }
public void TestShippingLineUpdate() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; DefaultQueries.checkout.ShippingLineUpdate(query, checkoutId, "handle"); Assert.AreEqual( "mutation{checkoutShippingLineUpdate (checkoutId:\"an-id\",shippingRateHandle:\"handle\"){checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready shippingLine {handle title price }}userErrors {field message }}}", query.ToString() ); }
public void TestCheckoutCreate() { MutationQuery query = new MutationQuery(); List <CheckoutLineItemInput> lineItems = new List <CheckoutLineItemInput>(); DefaultQueries.checkout.Create(query, lineItems); Assert.AreEqual( "mutation{checkoutCreate (input:{lineItems:[],allowPartialAddresses:true}){checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready lineItems (first:250){edges {node {id variant {id }}cursor }pageInfo {hasNextPage }}}userErrors {field message }}}", query.ToString() ); }
public void TestCheckoutLineItemsRemove() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; List <string> lineItemIds = new List <string>(); DefaultQueries.checkout.LineItemsRemove(query, checkoutId, lineItemIds); Assert.AreEqual( "mutation{checkoutLineItemsRemove (checkoutId:\"an-id\",lineItemIds:[]){userErrors {field message }}}", query.ToString() ); }
public void TestCheckoutLineItemsAdd() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; List <CheckoutLineItemInput> lineItems = new List <CheckoutLineItemInput>(); DefaultQueries.checkout.LineItemsAdd(query, checkoutId, lineItems); Assert.AreEqual( "mutation{checkoutLineItemsAdd (lineItems:[],checkoutId:\"an-id\"){checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready lineItems (first:250){edges {node {id variant {id }}cursor }pageInfo {hasNextPage }}}userErrors {field message }}}", query.ToString() ); }
public void MutationRootBuildsQuery() { MutationQuery query = new MutationQuery(); query .customerAccessTokenCreate(r => r .customerAccessToken(a => a .accessToken() ), input: new CustomerAccessTokenCreateInput(email: "*****@*****.**", password: "******") ); Assert.AreEqual( "mutation{customerAccessTokenCreate (input:{email:\"[email protected]\",password:\"123456\"}){customerAccessToken {accessToken }}}", query.ToString() ); // check that ToString does not mutate Assert.AreEqual( "mutation{customerAccessTokenCreate (input:{email:\"[email protected]\",password:\"123456\"}){customerAccessToken {accessToken }}}", query.ToString() ); }
/// <summary> /// Sends GraphQL mutations to a GraphQL endpoint. /// </summary> /// <param name="query">mutation to be sent to GraphQL endpoint</param> /// <param name="callback">callback that receives the mutation response</param> public void Mutation(MutationQuery query, MutationResponseHandler callback) { #if SHOPIFY_VERBOSE_DEBUG Console.WriteLine("Sending Mutation: " + query.ToString() + "\n"); #endif Loader.Load(query.ToString(), (string response, string error) => { #if SHOPIFY_VERBOSE_DEBUG Console.WriteLine("Response: " + response + "\n"); Console.WriteLine("Error: " + error + "\n"); #endif if (error != null) { callback(new MutationResponse(error)); } else { callback(new MutationResponse(GetJSON(response))); } }); }
public void TestShippingAddressUpdate() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; var addressInput = new MailingAddressInput("123 Test Street", "456", "Toronto", "Shopify", "Canada", "First", "Last", "1234567890", "Ontario", "A1B2C3"); DefaultQueries.checkout.ShippingAddressUpdate(query, checkoutId, addressInput); Assert.AreEqual( "mutation{checkoutShippingAddressUpdateV2 (shippingAddress:{address1:\"123 Test Street\",address2:\"456\",city:\"Toronto\",company:\"Shopify\",country:\"Canada\",firstName:\"First\",lastName:\"Last\",phone:\"1234567890\",province:\"Ontario\",zip:\"A1B2C3\"},checkoutId:\"an-id\"){checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready }userErrors {field message }}}", query.ToString() ); }
public void TestCheckoutCompleteWithTokenizedPayment() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; var billingAddress = new MailingAddressInput("123 Test Street", "456", "Toronto", "Shopify", "Canada", "First", "Last", "1234567890", "Ontario", "A1B2C3"); var tokenizedPaymentInput = new TokenizedPaymentInput( amount: new decimal(1), idempotencyKey: "unique_id", billingAddress: billingAddress, paymentData: "some_utf8_data_string", type: "apple_pay" ); DefaultQueries.checkout.CheckoutCompleteWithTokenizedPayment(query, checkoutId, tokenizedPaymentInput); Assert.AreEqual( "mutation{checkoutCompleteWithTokenizedPayment (checkoutId:\"an-id\",payment:{amount:1,idempotencyKey:\"unique_id\",billingAddress:{address1:\"123 Test Street\",address2:\"456\",city:\"Toronto\",company:\"Shopify\",country:\"Canada\",firstName:\"First\",lastName:\"Last\",phone:\"1234567890\",province:\"Ontario\",zip:\"A1B2C3\"},type:\"apple_pay\",paymentData:\"some_utf8_data_string\"}){checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready }payment {checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready completedAt }errorMessage id ready }userErrors {field message }}}", query.ToString() ); }
public void TestCheckoutCompleteWithTokenizedPaymentV2() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; var billingAddress = new MailingAddressInput("123 Test Street", "456", "Toronto", "Shopify", "Canada", "First", "Last", "1234567890", "Ontario", "A1B2C3"); var paymentAmount = new MoneyInput(new decimal(1), CurrencyCode.CAD); var tokenizedPaymentInputV2 = new TokenizedPaymentInputV2( paymentAmount: paymentAmount, idempotencyKey: "unique_id", billingAddress: billingAddress, paymentData: "some_utf8_data_string", type: "apple_pay" ); var expectedResult = "mutation{checkoutCompleteWithTokenizedPaymentV2 (checkoutId:\"an-id\",payment:{paymentAmount:{amount:1,currencyCode:CAD},idempotencyKey:\"unique_id\",billingAddress:{address1:\"123 Test Street\",address2:\"456\",city:\"Toronto\",company:\"Shopify\",country:\"Canada\",firstName:\"First\",lastName:\"Last\",phone:\"1234567890\",province:\"Ontario\",zip:\"A1B2C3\"},paymentData:\"some_utf8_data_string\",type:\"apple_pay\"}){checkout {id webUrl currencyCode requiresShipping subtotalPriceV2 {amount currencyCode }totalTaxV2 {amount currencyCode }totalPriceV2 {amount currencyCode }ready }payment {checkout {id webUrl currencyCode requiresShipping subtotalPriceV2 {amount currencyCode }totalTaxV2 {amount currencyCode }totalPriceV2 {amount currencyCode }ready completedAt }errorMessage id ready }checkoutUserErrors {code field message }}}"; DefaultQueries.checkout.CheckoutCompleteWithTokenizedPaymentV2(query, checkoutId, tokenizedPaymentInputV2); Assert.AreEqual( expectedResult, query.ToString(), string.Format("Unexpected mutation response.\n Expected response: {0}\n Actual response: {1}", expectedResult, query) ); }
protected void AddResponse(MutationQuery query, string response) { AddResponse(query.ToString(), response); }