52 lines
3.4 KiB
OpenEdge ABL
52 lines
3.4 KiB
OpenEdge ABL
/**
|
|
* ─────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
* 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 <sumit@hicShopify.com>
|
|
* ──────────────────────────────────────────────────────────────────────────────────────────────────
|
|
*/
|
|
@RestResource(UrlMapping='/DeleteCollectionFromShopify/*')
|
|
global with sharing class DeleteCollectionFromShopify
|
|
{
|
|
@HTTPPost
|
|
global static void deleteCollection(){
|
|
Restrequest request = restContext.request;
|
|
|
|
String store = 'Default';
|
|
Map <String, String> 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<String, Object> meta = (Map<String, Object>) JSON.deserializeUntyped(JSONResponseBody);
|
|
String collectionShopifyidforDelete = String.valueof(meta.get('id'));
|
|
List<HIC_ShopifySync__Collection__c> listOfCollectionForDelete = new List<HIC_ShopifySync__Collection__c>();
|
|
|
|
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<Database.DeleteResult> deleteresult = new list<Database.DeleteResult>();
|
|
|
|
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');
|
|
}
|
|
}
|
|
} |