59 lines
3.5 KiB
OpenEdge ABL
59 lines
3.5 KiB
OpenEdge ABL
/**
|
|
* ─────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
* This web service class is use for handle Shopify's Location webhook response.
|
|
* Trigger on Location delete.
|
|
* 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='/DeleteLocationFromShopify/*')
|
|
global with sharing class DeleteLocationFromShopify {
|
|
|
|
@HttpPost
|
|
global static void DeleteLocation() {
|
|
Restrequest req = restContext.request;
|
|
|
|
String store = 'Default';
|
|
Map <String, String> params = req.params;
|
|
if(!params.isEmpty() && params.containsKey('store') && params.get('store') != null)
|
|
store = params.get('store');
|
|
|
|
Restresponse res = restContext.response;
|
|
String jSONBody = req.requestbody.toString().Trim();
|
|
|
|
System.debug('jSONBody++ '+jSONBody);
|
|
if(jSONBody == '' || jSONBody == null) return;
|
|
Map<String,Object> main = (Map<String,Object>) JSON.deserializeUntyped(jSONBody);
|
|
|
|
|
|
String locationShopifyid;
|
|
if(!main.isEmpty() && main.containsKey('id')){
|
|
locationShopifyid = String.valueof(main.get('id'));
|
|
}
|
|
|
|
if(locationShopifyid == null || locationShopifyid == '') return;
|
|
|
|
List<HIC_ShopifySync__Location__c> listoflocationtodelete = new List<HIC_ShopifySync__Location__c>();
|
|
if(Schema.sObjectType.HIC_ShopifySync__Location__c.isAccessible() &&
|
|
Schema.sObjectType.HIC_ShopifySync__Location__c.fields.HIC_ShopifySync__Shopify_id__c.isAccessible()){
|
|
listoflocationtodelete = [select id, HIC_ShopifySync__Shopify_id__c from HIC_ShopifySync__Location__c where HIC_ShopifySync__Shopify_id__c =: locationShopifyid WITH SECURITY_ENFORCED LIMIT 9999];
|
|
}
|
|
|
|
list<Database.DeleteResult> deleterecordslist = new list<Database.DeleteResult>();
|
|
if(!listoflocationtodelete.isempty()){
|
|
if(CheckAccessibility.isDeletable('HIC_ShopifySync__Location__c'))
|
|
try{
|
|
deleterecordslist = Database.delete(listoflocationtodelete,false);
|
|
if(!deleterecordslist.isEmpty()) {
|
|
EmailerrorCSV.DeleteRecords('HIC_ShopifySync__Location__c',jSONBody,deleterecordslist,listoflocationtodelete,store);
|
|
}
|
|
}catch(Exception e){
|
|
|
|
}
|
|
}
|
|
}
|
|
} |