393 lines
114 KiB
OpenEdge ABL
393 lines
114 KiB
OpenEdge ABL
@isTest
|
|
public with sharing class UpdateOrderFromShopify_Test {
|
|
|
|
|
|
static testmethod void TestRestPost(){
|
|
|
|
//CustomSettingRecordInsert.InsertingFieldMapping();
|
|
//CustomSettingRecordInsert.InsertingConfiguration();
|
|
//CustomSettingRecordInsert.InsertingWebhook();
|
|
|
|
Account acc = new Account();
|
|
acc.Name = 'test';
|
|
insert acc;
|
|
|
|
SObject sobj = Schema.getGlobalDescribe().get('Opportunity').newSobject();
|
|
sobj.put('name','test');
|
|
|
|
|
|
if(Schema.getGlobalDescribe().containsKey('CurrencyType') && Schema.getGlobalDescribe().get('Opportunity').getDescribe().fields.getMap().containsKey('CurrencyIsoCode'))
|
|
sobj.put('CurrencyIsoCode','USD');
|
|
|
|
sobj.put('CloseDate',system.today());
|
|
sobj.put('StageName','StageName');
|
|
sobj.put('HIC_ShopifySync__Shopify_Id__c','618960158774');
|
|
|
|
|
|
insert sobj;
|
|
|
|
SObject ord = Schema.getGlobalDescribe().get('Order').newSobject();
|
|
ord.put('Name','test');
|
|
ord.put('EffectiveDate',system.today());
|
|
ord.put('Status','Draft');
|
|
if(Schema.getGlobalDescribe().containsKey('CurrencyType') && Schema.getGlobalDescribe().get('Order').getDescribe().fields.getMap().containsKey('CurrencyIsoCode'))
|
|
ord.put('CurrencyIsoCode','USD');
|
|
|
|
ord.put('HIC_ShopifySync__Shopify_Id__c','618960158794');
|
|
ord.put('AccountId',acc.Id);
|
|
insert ord;
|
|
|
|
List<HIC_ShopifySync__HIC_Field_Mapping__c> fieldMappingList = new List<HIC_ShopifySync__HIC_Field_Mapping__c>();
|
|
HIC_ShopifySync__HIC_Field_Mapping__c fm = new HIC_ShopifySync__HIC_Field_Mapping__c();
|
|
fm.Name = 'Testing123';
|
|
fm.HIC_ShopifySync__SF_Field__c = 'Accountid';
|
|
fm.HIC_ShopifySync__Default_Value__c = false;
|
|
fm.HIC_ShopifySync__Object_Name__c = 'Order';
|
|
fm.HIC_ShopifySync__Shopify_Fields__c = 'Id';
|
|
fm.HIC_ShopifySync__Nested__c = 'customer';
|
|
fm.HIC_ShopifySync__IsSFID__c = false;
|
|
fm.HIC_ShopifySync__Store__c = '123';
|
|
fieldMappingList.add(fm);
|
|
insert fieldMappingList;
|
|
|
|
|
|
List<HIC_ShopifySync__HIC_Configuration__c> configuration = New List<HIC_ShopifySync__HIC_Configuration__c>();
|
|
HIC_ShopifySync__HIC_Configuration__c shopifyConfiguration = New HIC_ShopifySync__HIC_Configuration__c();
|
|
shopifyConfiguration.Name = 'Default';
|
|
shopifyConfiguration.HIC_ShopifySync__Account_Contact__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Opportunity_Sync__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Order_Sync__c = false;
|
|
shopifyConfiguration.HIC_ShopifySync__Person_Account__c = false;
|
|
shopifyConfiguration.HIC_ShopifySync__Default_Account__c = false;
|
|
shopifyConfiguration.HIC_ShopifySync__Shopify_URL__c = '123@gmail.com';
|
|
shopifyConfiguration.HIC_ShopifySync__API_Key__c = 'test';
|
|
shopifyConfiguration.HIC_ShopifySync__Private_Key_Password__c = 'Test';
|
|
shopifyConfiguration.HIC_ShopifySync__Opportunity__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Order__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Opportunity_Line_Item__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Order_Line_Item__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Account_Record_Type__c = acc.Id;
|
|
shopifyConfiguration.HIC_ShopifySync__Store__c = '123';
|
|
configuration.add(shopifyConfiguration);
|
|
insert configuration;
|
|
|
|
UpdateOrderFromShopify reqst = new UpdateOrderFromShopify();
|
|
|
|
system.debug('**reqst' + reqst);
|
|
String JsonMsg='{"id":994189803566,"email":"discount@gmail.com","closed_at":null,"created_at":"2019-05-02T20:38:53+05:30","updated_at":"2019-05-02T20:38:53+05:30","number":25,"note":"","token":"972ee3aa1b4f62f9e58d42dd6e59f240","gateway":"manual","test":false,"total_price":"345.00","subtotal_price":"345.00","total_weight":0,"total_tax":"0.00","taxes_included":false,"currency":"INR","financial_status":"paid","confirmed":true,"total_discounts":"0.00","total_line_items_price":"345.00","cart_token":null,"buyer_accepts_marketing":false,"name":"#1025","referring_site":null,"landing_site":null,"cancelled_at":null,"cancel_reason":null,"total_price_usd":"4.95","checkout_token":null,"reference":null,"user_id":27797225518,"location_id":null,"source_identifier":null,"source_url":null,"processed_at":"2019-05-02T20:38:53+05:30","device_id":null,"phone":null,"customer_locale":null,"app_id":1354745,"browser_ip":null,"landing_site_ref":null,"order_number":1025,"discount_applications":[],"discount_codes":[],"note_attributes":[],"payment_gateway_names":["manual"],"processing_method":"manual","checkout_id":null,"source_name":"shopify_draft_order","fulfillment_status":null,"tax_lines":[],"tags":"","contact_email":"discount@gmail.com","order_status_url":"https:checkout.shopify.com3153821742orders972ee3aa1b4f62f9e58d42dd6e59f240authenticate?key=133dd04da5844a64225155d4d7658fd7","presentment_currency":"INR","total_line_items_price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_discounts_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"total_shipping_price_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"subtotal_price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_tax_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"total_tip_received":"0.0","line_items":[{"id":1934525661230,"variant_id":16344594186286,"title":"abc","quantity":1,"sku":"","variant_title":null,"vendor":"SyncMyStore8","fulfillment_service":"manual","product_id":1771653529646,"requires_shipping":true,"taxable":true,"gift_card":false,"name":"abc","variant_inventory_management":"shopify","properties":[],"product_exists":true,"fulfillable_quantity":1,"grams":0,"price":"345.00","total_discount":"0.00","fulfillment_status":null,"price_set":{"shop_money":{"amount":"345.00","currency_code":"INR"},"presentment_money":{"amount":"345.00","currency_code":"INR"}},"total_discount_set":{"shop_money":{"amount":"0.00","currency_code":"INR"},"presentment_money":{"amount":"0.00","currency_code":"INR"}},"discount_allocations":[],"tax_lines":[]}],"shipping_lines":[],"billing_address":{"first_name":"online1","address1":"add","phone":"+912322222222","city":"Adda Saran ( Kandhala Jattan )","zip":"76567","province":"Punjab","country":"India","last_name":"online2","address2":"lajpatnagar","company":"shopifihic@gmail.com","latitude":null,"longitude":null,"name":"online1 online2","country_code":"IN","province_code":"PB"},"shipping_address":{"first_name":"online1","address1":"add","phone":"+912322222222","city":"Adda Saran ( Kandhala Jattan )","zip":"76567","province":"Punjab","country":"India","last_name":"online2","address2":"lajpatnagar","company":"shopifihic@gmail.com","latitude":null,"longitude":null,"name":"online1 online2","country_code":"IN","province_code":"PB"},"fulfillments":[{"id":"0001", "line_items":[{"item1":"test1"}, {"item2":"test2"}]}],"refunds":[],"customer":{"id":1314583674926,"email":"discount@gmail.com","accepts_marketing":false,"created_at":"2019-05-02T18:25:02+05:30","updated_at":"2019-05-02T20:38:53+05:30","first_name":"online1","last_name":"online2","orders_count":1,"state":"disabled","total_spent":"345.00","last_order_id":994189803566,"note":"bottlessssssssssss","verified_email":true,"multipass_identifier":null,"tax_exempt":true,"phone":"+919990755793","tags":"channellllllllll","last_order_name":"#1025","currency":"INR","accepts_marketing_updated_at":"2019-05-02T18:25:03+05:30","marketing_opt_in_level":null,"default_address":{"id":1385885630510,"customer_id":1314583674926,"first_name":"online1","last_name":"online2","company":"shopifihic@gmail.com","address1":"add","address2":"lajpatnagar","city":"Adda Saran ( Kandhala Jattan )","province":"Punjab","country":"India","zip":"76567","phone":"+912322222222","name":"online1 online2","province_code":"PB","country_code":"IN","country_name":"India","default":true}}}';
|
|
|
|
//Test.startTest();
|
|
RestRequest req = new RestRequest();
|
|
RestResponse res = new RestResponse();
|
|
req.requestURI = '/services/apexrest/DemoUrl'; //Request URL
|
|
req.httpMethod = 'POST';//HTTP Request Type
|
|
req.requestBody = Blob.valueof(JsonMsg);
|
|
req.addParameter('store', '123');
|
|
RestContext.request = req;
|
|
RestContext.response= res;
|
|
UpdateOrderFromShopify.updateOrder();
|
|
|
|
UpdateOrderFromShopify.CreateOrderAndOpportuity(JsonMsg,'123');
|
|
UpdateOrderFromShopify.processInsertOpportunity(JsonMsg, fieldMappingList, configuration,'123');
|
|
//Test.stopTest();
|
|
Restrequest req1 = new Restrequest();
|
|
req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }');
|
|
|
|
Restresponse res1 = new Restresponse();
|
|
req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopify';
|
|
req.httpMethod = 'POST';
|
|
|
|
RestContext.request = req;
|
|
RestContext.response= res;
|
|
res.statusCode = 200;
|
|
|
|
|
|
Restrequest authenticationReq = new Restrequest();
|
|
authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }');
|
|
Restresponse authenticationRes = new Restresponse();
|
|
authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopifyAuthentication';
|
|
authenticationReq.httpMethod = 'POST';
|
|
authenticationReq.addParameter('store', '123');
|
|
|
|
RestContext.request = authenticationReq;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
Test.startTest();
|
|
UpdateOrderFromShopify.updateOrder() ;
|
|
system.assertequals(200, res.statuscode);
|
|
UpdateOrderFromShopifyAuthentication.updateOrderWithAuthentication();
|
|
system.assertequals(200, authenticationRes.statuscode);
|
|
Test.stopTest();
|
|
}
|
|
|
|
@isTest static void TestRestPost1(){
|
|
SObject sobj = Schema.getGlobalDescribe().get('Opportunity').newSobject();
|
|
sobj.put('name','test');
|
|
|
|
|
|
if(Schema.getGlobalDescribe().containsKey('CurrencyType') && Schema.getGlobalDescribe().get('Opportunity').getDescribe().fields.getMap().containsKey('CurrencyIsoCode'))
|
|
sobj.put('CurrencyIsoCode','USD');
|
|
|
|
sobj.put('CloseDate',system.today());
|
|
sobj.put('StageName','Prospecting');
|
|
sobj.put('HIC_ShopifySync__Shopify_Id__c','618960158794');
|
|
|
|
|
|
insert sobj;
|
|
|
|
|
|
List<HIC_ShopifySync__HIC_Configuration__c> ConList = new List<HIC_ShopifySync__HIC_Configuration__c>();
|
|
HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c();
|
|
con.name = 'Default';
|
|
con.Opportunity__c = True;
|
|
con.HIC_ShopifySync__Order__c = false;
|
|
con.HIC_ShopifySync__Opportunity_Line_Item__c = True;
|
|
con.HIC_ShopifySync__Order_Line_Item__c = True;
|
|
con.HIC_ShopifySync__Person_Account__c = true;
|
|
con.HIC_ShopifySync__Order_Fulfillment__c = true;
|
|
con.HIC_ShopifySync__Store__c = '123';
|
|
ConList.add(con);
|
|
insert ConList;
|
|
|
|
Restrequest req = new Restrequest();
|
|
req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }');
|
|
|
|
Restresponse res = new Restresponse();
|
|
req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopify';
|
|
req.httpMethod = 'POST';
|
|
req.addParameter('store', '123');
|
|
|
|
RestContext.request = req;
|
|
RestContext.response= res;
|
|
res.statusCode = 200;
|
|
|
|
Restrequest authenticationReq = new Restrequest();
|
|
authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }');
|
|
Restresponse authenticationRes = new Restresponse();
|
|
authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopifyAuthentication';
|
|
authenticationReq.httpMethod = 'POST';
|
|
authenticationReq.addParameter('store', '123');
|
|
|
|
RestContext.request = authenticationReq;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
Test.startTest();
|
|
UpdateOrderFromShopify.updateOrder() ;
|
|
system.assertequals(200, res.statuscode);
|
|
UpdateOrderFromShopifyAuthentication.updateOrderWithAuthentication();
|
|
system.assertequals(200, authenticationRes.statuscode);
|
|
Test.stopTest();
|
|
|
|
}
|
|
@isTest
|
|
static void TestRestPost2(){
|
|
|
|
Account acc = new Account();
|
|
acc.Name = 'test';
|
|
insert acc;
|
|
|
|
SObject ord = Schema.getGlobalDescribe().get('Order').newSobject();
|
|
ord.put('Name','test');
|
|
ord.put('Status','Draft');
|
|
ord.put('EffectiveDate',system.today());
|
|
if(Schema.getGlobalDescribe().containsKey('CurrencyType') && Schema.getGlobalDescribe().get('Order').getDescribe().fields.getMap().containsKey('CurrencyIsoCode'))
|
|
ord.put('HIC_ShopifySync__Shopify_Id__c','');
|
|
ord.put('AccountId',acc.Id);
|
|
insert ord;
|
|
|
|
|
|
List<HIC_ShopifySync__HIC_Configuration__c> ConList = new List<HIC_ShopifySync__HIC_Configuration__c>();
|
|
|
|
HIC_ShopifySync__HIC_Configuration__c con = new HIC_ShopifySync__HIC_Configuration__c();
|
|
con.name = 'Default';
|
|
con.HIC_ShopifySync__Opportunity__c = true;
|
|
con.HIC_ShopifySync__Order__c = true;
|
|
con.Opportunity_Line_Item__c = True;
|
|
con.HIC_ShopifySync__Order_Line_Item__c = True;
|
|
con.HIC_ShopifySync__Person_Account__c = true;
|
|
con.HIC_ShopifySync__Order_Fulfillment__c = true;
|
|
con.HIC_ShopifySync__Store__c = '123';
|
|
ConList.add(con);
|
|
insert ConList;
|
|
|
|
Restrequest req = new Restrequest();
|
|
req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default,,,": true } } }');
|
|
|
|
Restresponse res = new Restresponse();
|
|
req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopify';
|
|
req.httpMethod = 'POST';
|
|
req.addParameter('store', '123');
|
|
|
|
RestContext.request = req;
|
|
RestContext.response= res;
|
|
res.statusCode = 200;
|
|
|
|
|
|
Restrequest authenticationReq = new Restrequest();
|
|
authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }');
|
|
Restresponse authenticationRes = new Restresponse();
|
|
authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopifyAuthentication';
|
|
authenticationReq.httpMethod = 'POST';
|
|
authenticationReq.addParameter('store', '123');
|
|
|
|
RestContext.request = authenticationReq;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
string body = '{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } } ';
|
|
List<HIC_ShopifySync__HIC_Field_Mapping__c> fieldMapList = new List<HIC_ShopifySync__HIC_Field_Mapping__c>(); // FOR FIELDMAPPING DML
|
|
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','Accountid','id','customer','REFERENCE','Reference','id'));// NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','HIC_ShopifySync__Billing_Customer_Name__c','name','billing_address','STRING','string','name'));
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutFields('Order','HIC_ShopifySync__Total_Tax__c','total_tax','NUMBER','number','total_tax'));//new************ 29 April
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','BillingCity','city','billing_address','STRING','string','billing_address'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','BillingCountry','country','billing_address','STRING','string','country'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','BillingLatitude','latitude','billing_address','DOUBLE','string','latitude'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','BillingLongitude','longitude','billing_address','DOUBLE','string','longitude'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','BillingPostalCode','zip','billing_address','STRING','Number','zip'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','BillingState','province','billing_address','STRING','string','province'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','BillingStreet','address1,address2','billing_address','TEXTAREA','string','address1,address2'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','ShippingCity','city','shipping_address','STRING','string','city'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','ShippingCountry','country','shipping_address','STRING','string','country'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','ShippingLatitude','latitude','shipping_address','DOUBLE','string','latitude'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','ShippingLongitude','longitude','shipping_address','DOUBLE','string','longitude'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','ShippingPostalCode','zip','shipping_address','STRING','Number','zip'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','ShippingState','province','shipping_address','STRING','string','province'));//NEW
|
|
fieldMapList.add(CustomSettingRecordInsert.processFieldMappingSobjectWithoutBoolean('Order','ShippingStreet','address1,address2','shipping_address','TEXTAREA','string','address1,address2'));//NEW
|
|
insert fieldMapList;
|
|
|
|
Test.startTest();
|
|
UpdateOrderFromShopify.updateOrder() ;
|
|
UpdateOrderFromShopify.processOrder(body,fieldMapList,ConList,'123');
|
|
system.assertequals(200, res.statuscode);
|
|
UpdateOrderFromShopifyAuthentication.updateOrderWithAuthentication();
|
|
system.assertequals(200, authenticationRes.statuscode);
|
|
Test.stopTest();
|
|
}
|
|
|
|
|
|
@isTest
|
|
static void TestRestPost3(){
|
|
|
|
//CustomSettingRecordInsert.InsertingFieldMapping();
|
|
//CustomSettingRecordInsert.InsertingConfiguration();
|
|
//CustomSettingRecordInsert.InsertingWebhook();
|
|
|
|
Account acc = new Account();
|
|
acc.Name = 'test';
|
|
insert acc;
|
|
|
|
SObject sobj = Schema.getGlobalDescribe().get('Opportunity').newSobject();
|
|
sobj.put('name','test');
|
|
|
|
|
|
if(Schema.getGlobalDescribe().containsKey('CurrencyType') && Schema.getGlobalDescribe().get('Opportunity').getDescribe().fields.getMap().containsKey('CurrencyIsoCode'))
|
|
sobj.put('CurrencyIsoCode','USD');
|
|
|
|
sobj.put('CloseDate',system.today());
|
|
sobj.put('StageName','StageName');
|
|
sobj.put('HIC_ShopifySync__Shopify_Id__c','618960158774');
|
|
|
|
|
|
insert sobj;
|
|
|
|
SObject ord = Schema.getGlobalDescribe().get('Order').newSobject();
|
|
ord.put('Name','test');
|
|
ord.put('EffectiveDate',system.today());
|
|
ord.put('Status','Draft');
|
|
if(Schema.getGlobalDescribe().containsKey('CurrencyType') && Schema.getGlobalDescribe().get('Order').getDescribe().fields.getMap().containsKey('CurrencyIsoCode'))
|
|
ord.put('CurrencyIsoCode','USD');
|
|
|
|
ord.put('HIC_ShopifySync__Shopify_Id__c','618960158794');
|
|
ord.put('AccountId',acc.Id);
|
|
insert ord;
|
|
List<HIC_ShopifySync__HIC_Field_Mapping__c> fieldMappingList = new List<HIC_ShopifySync__HIC_Field_Mapping__c>();
|
|
HIC_ShopifySync__HIC_Field_Mapping__c fm = new HIC_ShopifySync__HIC_Field_Mapping__c();
|
|
fm.Name = 'Testing123';
|
|
fm.HIC_ShopifySync__SF_Field__c = 'Accountid';
|
|
fm.HIC_ShopifySync__Default_Value__c = false;
|
|
fm.HIC_ShopifySync__Object_Name__c = 'order';
|
|
fm.HIC_ShopifySync__Shopify_Fields__c = 'Id';
|
|
fm.HIC_ShopifySync__Nested__c = 'customer';
|
|
fm.HIC_ShopifySync__IsSFID__c = false;
|
|
fm.HIC_ShopifySync__Store__c = '123';
|
|
fieldMappingList.add(fm);
|
|
|
|
|
|
insert fieldMappingList;
|
|
|
|
|
|
List<HIC_ShopifySync__HIC_Configuration__c> configuration = New List<HIC_ShopifySync__HIC_Configuration__c>();
|
|
HIC_ShopifySync__HIC_Configuration__c shopifyConfiguration = New HIC_ShopifySync__HIC_Configuration__c();
|
|
shopifyConfiguration.Name = 'Default';
|
|
shopifyConfiguration.HIC_ShopifySync__Account_Contact__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Opportunity_Sync__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Order_Sync__c = false;
|
|
shopifyConfiguration.HIC_ShopifySync__Person_Account__c = false;
|
|
shopifyConfiguration.HIC_ShopifySync__Default_Account__c = false;
|
|
shopifyConfiguration.HIC_ShopifySync__Shopify_URL__c = '123@gmail.com';
|
|
shopifyConfiguration.HIC_ShopifySync__API_Key__c = 'test';
|
|
shopifyConfiguration.HIC_ShopifySync__Private_Key_Password__c = 'Test';
|
|
shopifyConfiguration.HIC_ShopifySync__Opportunity__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Order__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Opportunity_Line_Item__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Order_Line_Item__c = true;
|
|
shopifyConfiguration.HIC_ShopifySync__Account_Record_Type__c = acc.Id;
|
|
shopifyConfiguration.HIC_ShopifySync__Store__c = '123';
|
|
configuration.add(shopifyConfiguration);
|
|
insert configuration;
|
|
|
|
UpdateOrderFromShopify reqst = new UpdateOrderFromShopify();
|
|
|
|
system.debug('**reqst' + reqst);
|
|
String JsonMsg = '{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } } ';
|
|
|
|
//Test.startTest();
|
|
RestRequest req = new RestRequest();
|
|
RestResponse res = new RestResponse();
|
|
req.requestURI = '/services/apexrest/DemoUrl'; //Request URL
|
|
req.httpMethod = 'POST';//HTTP Request Type
|
|
req.requestBody = Blob.valueof(JsonMsg);
|
|
req.addParameter('store', '123');
|
|
RestContext.request = req;
|
|
RestContext.response= res;
|
|
UpdateOrderFromShopify.updateOrder();
|
|
|
|
UpdateOrderFromShopify.CreateOrderAndOpportuity(JsonMsg,'123');
|
|
UpdateOrderFromShopify.processInsertOpportunity(JsonMsg, fieldMappingList, configuration,'123');
|
|
//Test.stopTest();
|
|
Restrequest req1 = new Restrequest();
|
|
req.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }');
|
|
|
|
Restresponse res1 = new Restresponse();
|
|
req.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopify';
|
|
req.httpMethod = 'POST';
|
|
req.addParameter('store', '123');
|
|
|
|
RestContext.request = req;
|
|
RestContext.response= res;
|
|
res.statusCode = 200;
|
|
|
|
|
|
Restrequest authenticationReq = new Restrequest();
|
|
authenticationReq.requestBody = Blob.valueOf('{ "id": 618960158784, "email": "uv@gmail.com", "closed_at": null, "created_at": "2018-12-21T15:54:18+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "number": 11, "note": "", "token": "7ad316e8c59b1d18877b242d8244eea3", "gateway": "manual", "test": false, "total_price": "5280.50", "subtotal_price": "4475.00", "total_weight": 195, "total_tax": "805.50", "taxes_included": false, "currency": "INR", "financial_status": "paid", "confirmed": true, "total_discounts": "0.00", "total_line_items_price": "4475.00", "cart_token": null, "buyer_accepts_marketing": false, "name": "#1011", "referring_site": null, "landing_site": null, "cancelled_at": "2018-12-21T15:54:18+05:30", "cancel_reason": "N/A", "total_price_usd": "74.70", "checkout_token": null, "reference": null, "user_id": 18963628096, "location_id": null, "source_identifier": null, "source_url": null, "processed_at": "2018-12-21T15:54:18+05:30", "device_id": null, "phone": null, "customer_locale": null, "app_id": 1354745, "browser_ip": null, "landing_site_ref": null, "order_number": 1011, "discount_applications": [], "discount_codes": [], "note_attributes": [], "payment_gateway_names": [ "manual" ], "processing_method": "manual", "checkout_id": null, "source_name": "shopify_draft_order", "fulfillment_status": null, "tax_lines": [ { "price": "805.50", "rate": 0.18, "title": "IGST", "price_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } } } ], "tags": "", "contact_email": "uv@gmail.com", "order_status_url": "https://checkout.shopify.com/10269687872/orders/7ad316e8c59b1d18877b242d8244eea3/authenticate?key=5415e623338fd5f08b77268cc72456b6", "presentment_currency": "INR", "total_line_items_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "total_shipping_price_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "subtotal_price_set": { "shop_money": { "amount": "4475.00", "currency_code": "INR" }, "presentment_money": { "amount": "4475.00", "currency_code": "INR" } }, "total_price_set": { "shop_money": { "amount": "5280.50", "currency_code": "INR" }, "presentment_money": { "amount": "5280.50", "currency_code": "INR" } }, "total_tax_set": { "shop_money": { "amount": "805.50", "currency_code": "INR" }, "presentment_money": { "amount": "805.50", "currency_code": "INR" } }, "total_tip_received": "0.0", "admin_graphql_api_id": "gid://shopify/Order/618960158784", "line_items": [ { "id": 1468974956608, "variant_id": 17740291244096, "title": "Product", "quantity": 1, "price": "255.00", "sku": "57", "variant_title": "25gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 25gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 1, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "255.00", "currency_code": "INR" }, "presentment_money": { "amount": "255.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974956608", "tax_lines": [ { "title": "IGST", "price": "45.90", "rate": 0.18, "price_set": { "shop_money": { "amount": "45.90", "currency_code": "INR" }, "presentment_money": { "amount": "45.90", "currency_code": "INR" } } } ] }, { "id": 1468974989376, "variant_id": 17740291342400, "title": "Product", "quantity": 2, "price": "535.00", "sku": "58", "variant_title": "50gm", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1799382958144, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "Product - 50gm", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 2, "grams": 55, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "535.00", "currency_code": "INR" }, "presentment_money": { "amount": "535.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468974989376", "tax_lines": [ { "title": "IGST", "price": "192.60", "rate": 0.18, "price_set": { "shop_money": { "amount": "192.60", "currency_code": "INR" }, "presentment_money": { "amount": "192.60", "currency_code": "INR" } } } ] }, { "id": 1468975022144, "variant_id": 17732618125376, "title": "TestProduct", "quantity": 3, "price": "550.00", "sku": "50506", "variant_title": "5mm / black", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / black", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "550.00", "currency_code": "INR" }, "presentment_money": { "amount": "550.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975022144", "tax_lines": [ { "title": "IGST", "price": "297.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "297.00", "currency_code": "INR" }, "presentment_money": { "amount": "297.00", "currency_code": "INR" } } } ] }, { "id": 1468975054912, "variant_id": 17732618027072, "title": "TestProduct", "quantity": 3, "price": "500.00", "sku": "50505", "variant_title": "5mm / red", "vendor": "SyncMyStore", "fulfillment_service": "manual", "product_id": 1798809452608, "requires_shipping": true, "taxable": true, "gift_card": false, "name": "TestProduct - 5mm / red", "variant_inventory_management": "shopify", "properties": [], "product_exists": true, "fulfillable_quantity": 3, "grams": 5, "total_discount": "0.00", "fulfillment_status": null, "price_set": { "shop_money": { "amount": "500.00", "currency_code": "INR" }, "presentment_money": { "amount": "500.00", "currency_code": "INR" } }, "total_discount_set": { "shop_money": { "amount": "0.00", "currency_code": "INR" }, "presentment_money": { "amount": "0.00", "currency_code": "INR" } }, "discount_allocations": [], "admin_graphql_api_id": "gid://shopify/LineItem/1468975054912", "tax_lines": [ { "title": "IGST", "price": "270.00", "rate": 0.18, "price_set": { "shop_money": { "amount": "270.00", "currency_code": "INR" }, "presentment_money": { "amount": "270.00", "currency_code": "INR" } } } ] } ], "shipping_lines": [], "billing_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "shipping_address": { "first_name": "firstname1", "address1": "Noida City Centre Metro Sector 39", "phone": null, "city": "Noida", "zip": "201301", "province": "Uttar Pradesh", "country": "India", "last_name": "lastname1", "address2": "noida", "company": "test", "latitude": 28.57447, "longitude": 77.35561, "name": "firstname1 lastname1", "country_code": "IN", "province_code": "UP" }, "fulfillments": [], "refunds": [], "customer": { "id": 926016995392, "email": "uv@gmail.com", "accepts_marketing": false, "created_at": "2018-12-12T16:43:59+05:30", "updated_at": "2018-12-21T15:54:18+05:30", "first_name": "firstname1", "last_name": "lastname1", "orders_count": 5, "state": "disabled", "total_spent": "18732.50", "last_order_id": 618960158784, "note": "Noteee", "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "phone": "+918604065624", "tags": "Tagsss", "last_order_name": "#1011", "currency": "INR", "admin_graphql_api_id": "gid://shopify/Customer/926016995392", "default_address": { "id": 1041332338752, "customer_id": 926016995392, "first_name": "firstname1", "last_name": "lastname1", "company": "test", "address1": "Noida City Centre Metro Sector 39", "address2": "noida", "city": "Noida", "province": "Uttar Pradesh", "country": "India", "zip": "201301", "phone": "", "name": "firstname1 lastname1", "province_code": "UP", "country_code": "IN", "country_name": "India", "default": true } } }');
|
|
Restresponse authenticationRes = new Restresponse();
|
|
authenticationReq.requestURI = 'https://hicsfshopify-developer-edition.ap4.force.com/services/apexrest/UpdateOrderFromShopifyAuthentication';
|
|
authenticationReq.httpMethod = 'POST';
|
|
authenticationReq.addParameter('store', '123');
|
|
|
|
RestContext.request = authenticationReq;
|
|
RestContext.response= authenticationRes ;
|
|
authenticationRes.statusCode = 200;
|
|
|
|
Test.startTest();
|
|
UpdateOrderFromShopify.updateOrder() ;
|
|
system.assertequals(200, res.statuscode);
|
|
UpdateOrderFromShopifyAuthentication.updateOrderWithAuthentication();
|
|
system.assertequals(200, authenticationRes.statuscode);
|
|
Test.stopTest();
|
|
}
|
|
|
|
} |