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:
Code Block |
---|
"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:
Code Block |
---|
[
{
"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
Refer to Salesforce Apex REST Documentation for error responses.
1.8. Examples
1.8.1. Get a Session-ID
Code Block |
---|
bash |
Copy code
curl -v https://login.salesforce.com/services/oauth2/token \ -d "grant_type=password" \ -d "client_id=<CLIENT_ID>" \ -d "client_secret=<CLIENT_SECRET>" \ -d "username=<USER_NAME>" \ -d "password=<PASSWORD+TOKEN>" \ -H 'X-PrettyPrint:1'
1.8.2. Simple Request
Creating a Standard Campaign Item and a Package with a Header and Component:
Code Block |
---|
bash |
Copy code
curl --location --request PATCH 'https://<MY_DOMAIN_NAME>.my.salesforce.com/services/apexrest/ADvendio/ADvendio__Campaign_Item__c/PackageService/' \ --header 'Authorization: Bearer <SESSION_ID>' \ --header 'Content-Type: application/json' \ --header 'X-PrettyPrint: 1' \ --data '{ "request": { "mediaCampaignId": "a235t000000yMAZAA2", "campaignItems": [ { "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 }, { "Ad_Price__c": "a0T5t000001QpQNEA0", "from_Date__c": "2020-01-01", "until_Date__c": "2030-01-01", "Quantity__c": 44, "Id": "a0wXX00XX000000001" }, { "Ad_Price__c": "a0T5t000001QpPgEAK", "from_Date__c": "2021-01-01", "until_Date__c": "2029-01-01", "Quantity__c": 53, "PacketItem__c": "a0wXX00XX000000001" } ] } }'
1.8.3. Response
Code Block |
---|
json |
Copy code
[ { "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.9. Usage in Apex
Code Block |
---|
apex |
Copy code
List<ADvendio__Campaign_Item__c> cis = ... cis = ADvendio.PackageService.applyPackage(cis);
4o
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 PackagesP
ackages.
Setup
Check this /wiki/spaces/QA/pages/3619913782 Wiki page to know how to configure Postman for your Scratch Org.
...