1. REST Web Service
1.1. URL
https://<my-domain-name>.my.salesforce.com/services/apexrest/ADvendio/ADvendio__Campaign_Item__c/PackageService/
1.2. Method
PATCH
1.3. URL Params
None
1.4. Data Params
A JSON object with the attribute request
, containing mediaCampaignId
and a JSON serialized list of campaignItems
.
Example:
"request": { "mediaCampaignId": "a235t000000yMAZAA2", "campaignItems": [ { "Ad_Price__c": "a0T5t000001QpPYEA0", "from_Date__c": "20-01-01", "until_Date__c": "20-01-01", "Rate_Discount_4__c": 4.2, "Quantity__c": 3 }, { "Ad_Price__c": "a0T5t000001QpQNEA0", "from_Date__c": "20-01-01", "until_Date__c": "30-01-01", "Quantity__c": 44, "Id": "a0wXX00XX000000001" }, { "Ad_Price__c": "a0T5t000001QpPgEAK", "from_Date__c": "21-01-01", "until_Date__c": "29-01-01", "Quantity__c": 53, "PacketItem__c": "a0wXX00XX000000001" } ] } }'
1.5. Success Response
Code: 200
Content: A JSON serialized list of the Campaign Items from the request body with their details.
Example:
[ { "attributes": { "type": "ADvendio__Campaign_Item__c", "url": "/services/data/v59.0/sobjects/ADvendio__Campaign_Item__c/a0wXX00XX000000006" }, "ADvendio__Ad_Price__c": "a0T5t000001QpPYEA0", "from_Date__c": "2020-01-01", "until_Date__c": "2020-01-01", "Rate_Discount_4__c": 4.2, "Quantity__c": 3 }, ... ]
1.6. Error Response
See Salesforce Apex REST Documentation
1.8. Examples
1.8.1. Simple Request
Creating a Standard Campaign Item and a Package with a Header and Component:
"request": { "mediaCampaignId": "a235t000000yMAZAA2", "campaignItems": [ { "Ad_Price__c": "a0T5t000001QpPYEA0", "from_Date__c": "20-01-01", "until_Date__c": "20-01-01", "Rate_Discount_4__c": 4.2, "Quantity__c": 3 }, { "Ad_Price__c": "a0T5t000001QpQNEA0", "from_Date__c": "20-01-01", "until_Date__c": "30-01-01", "Quantity__c": 44, "Id": "a0wXX00XX000000001" }, { "Ad_Price__c": "a0T5t000001QpPgEAK", "from_Date__c": "21-01-01", "until_Date__c": "29-01-01", "Quantity__c": 53, "PacketItem__c": "a0wXX00XX000000001" } ] } }'
1.8.3. Response
}, "ADvendio__Ad_Price__c": "a0T5t000001QpPYEA0", "from_Date__c": "2020-01-01", "until_Date__c": "2020-01-01", "Rate_Discount_4__c": 4.2, "Quantity__c": 3 },
1.9. Usage in Apex
List<ADvendio__Campaign_Item__c> cis = ... cis = ADvendio.PackageService.applyPackage(cis);
1.7. Logic
Technical Documentation - Package Creation
The Package Service API creates Virtual Campaign Items which can be either Standard or Packages.
Matching Logic:
A Package Header Campaign Item must link to an Ad Spec with a Package Header Record Type.
A Package Component Campaign Item must link to the Package Header Campaign Item using the
PacketItem__c
attribute.
Required Fields:
For Standard Campaign Items:
Ad_Price__c
from_Date__c
until_Date__c
Quantity__c
For Package Header Campaign Items:
Ad_Price__c
from_Date__c
until_Date__c
Quantity__c
Id
(must be unique within the request)
For Package Component Campaign Items:
Ad_Price__c
from_Date__c
until_Date__c
Quantity__c
PacketItem__c
(must match the Id of the corresponding Package Header Campaign Item)
Optional Surcharge and Discount Fields:
Sales_Price__c
SurchargeB2__c
SurchargeB2Abs__c
SurchargeB3__c
SurchargeB3Abs__c
SurchargeSalesPrice__c
SurchargeSalesPricePct__c
RateDiscount1AbsCustom__c
RateDiscount2AbsCustom__c
RateDiscount3AbsCustom__c
RateDiscount4AbsCustom__c
Rate_Discount_2_custom__c
Rate_Discount_3_custom__c
Rate_Discount_4__c
Quantity_Discount_custom__c
The Package Service API is an API service where you can create Virtual Campaign Items, either Standard or Package.