/** * ─────────────────────────────────────────────────────────────────────────────────────────────────┐ * This web service class is handle collection webhook response. * Trigger when collection delete in Shopify. * Delete collections and collects into the Salesforce. * Shopify API Documentation: https://shopify.dev/docs/admin-api/rest/reference * Create Shopify Store: https://www.shopify.com/signup?itcat=identity&itterm=create-new-store * Shopify API Release 2020: https://www.shopify.in/partners/blog/shopify-api-release-january-2020 * What is Person Account in Salesforce ? https://help.salesforce.com/articleView?id=account_person.htm&type=5 * ────────────────────────────────────────────────────────────────────────────────────────────────── * @author Sumit * ────────────────────────────────────────────────────────────────────────────────────────────────── */ @RestResource(UrlMapping='/DeleteCollectionFromShopify/*') global with sharing class DeleteCollectionFromShopify { @HTTPPost global static void deleteCollection(){ Restrequest request = restContext.request; String store = 'Default'; Map params = request.params; if(!params.isEmpty() && params.containsKey('store') && params.get('store') != null) store = params.get('store'); Restresponse response = restContext.response; String JSONResponseBody = request.requestBody.ToString().Trim(); System.debug('JSONResponseBodyCustomerDelete--->'+JSONResponseBody); Map meta = (Map) JSON.deserializeUntyped(JSONResponseBody); String collectionShopifyidforDelete = String.valueof(meta.get('id')); List listOfCollectionForDelete = new List(); if(Schema.sObjectType.HIC_ShopifySync__Collection__c.isAccessible() && Schema.sObjectType.HIC_ShopifySync__Collection__c.fields.Shopify_id__c.isAccessible()){ listOfCollectionForDelete = [select HIC_ShopifySync__Shopify_id__c from HIC_ShopifySync__Collection__c where HIC_ShopifySync__Shopify_id__c =: collectionShopifyidforDelete ]; } list deleteresult = new list(); try{ if(!listOfCollectionForDelete.isempty()){ if(CheckAccessibility.isDeletable('HIC_ShopifySync__Collection__c')) deleteresult = Database.delete(listOfCollectionForDelete, false); } if(deleteresult.isEmpty()) return; EmailerrorCSV.DeleteRecords('HIC_ShopifySync__Collection__c',JSONResponseBody,deleteresult,listOfCollectionForDelete,store); }catch(Exception e){ System.debug('DML Error'); } } }