Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 14 Next »

In order to use the Commitments API, your Salesforce Org needs to have API usage activated through having an API usage License. 

The Commitments API is implemented as Apex class and is exposed as REST web service by using Salesforce standard functionality (see Apex Developer Guide for more information). For general information about the dynamic pricing feature, see 4.16 Commitments. The Apply Commitments functionality finds and sets the matching conditions and applies the discounts from the matching Commitment Condition

1. REST web service

1.1. URL

https://<my-domain-name>.my.salesforce.com/services/apexrest/ADvendio/ADvendio__Campaign_Item__c/ApplyCommitments/

1.2. Method

PATCH

1.3. URL Params

1.4. Data Params

A JSON object with the attribute campaignItems, containing a JSON serialized list of Campaign Items.

Example: { "campaignItems":[{<Campaign Item>}, ...]}

1.5. Success Response

Code: 200

Content: A JSON serialized list of the Campaign Items from the request body, but now with updated discount and Commitment Condition fields.

Example: [{<Campaign Item>}, ...]

1.6. Error Response

See Salesforce Apex REST Documentation

1.7. Logic

1.7.1. Matching logic

A Commitment Condition matches if all criteria (Commitment Condition fields) match. If the Commitment Condition field is empty, it matches all Campaign Item values.

ADvendio__CommitmentCondition__c

ADvendio__Campaign_Item__c

Matching

ADvendio__AdvertisingMedium__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__r.ADvendio__Placement__r.ADvendio__Site__c

equals

ADvendio__MediaDifferentiation__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__r.ADvendio__Ad_Type__r.ADvendio__MediaDifferentiation__c

equals

ADvendio__MediaSegment__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__r.ADvendio__Placement__r.ADvendio__MediaSegment__c

equals

ADvendio__MediaType__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__r.ADvendio__Placement__r.ADvendio__Site__r.ADvendio__MediaType__c

equals

ADvendio__Unit__c

ADvendio__Ad_price__r.ADvendio__PriceUnit__c

equals

ADvendio__AdPrice__c

ADvendio__Ad_price__c

equals

ADvendio__AdSpec__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__c

equals

ADvendio__AdType__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__r.ADvendio__Ad_Type__c

equals

ADvendio__Placement__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__r.ADvendio__Placement__c

equals

ADvendio__Content__c

ADvendio__SelectedContents__r

contains

ADvendio__PageEquivalency__c

ADvendio__Ad_price__r.ADvendio__Ad_Spec__r.ADvendio__Ad_Type__r.ADvendio__PageEquivalency__c

equals

1.7.2. Required fields

  • ADvendio__Media_Campaign__r.ADvendio__Commitment__c,ADvendio__AgencyEarningCommitment__c,ADvendio__ThirdPartyCommitment__c or ADvendio__Media_Campaign__c

  • ADvendio__Ad_Price__c

Fields referenced by the Ad Price (Ad Spec, Ad Type, Placement, Site ...) are automatically queried if not set.

1.7.3. Fields set by ApplyCommitments method

Depending on the linked Commitments and the matching Commitment Condition the following fields will be written:

Rebate in Kind:

  • Quantity__c

  • Rate_Discount_4__c

  • Rate_Discount_4_Name__c

  • CommitmentRelevant__c

  • ConditionApplied__c

Special Discount:

  • Rate_Discount_4__c

  • Rate_Discount_4_Name__c

  • SpecialDiscountCondition__c

  • SpecialDiscountCondition__r

  • ConditionApplied__c

Scaled Discount:

  • Rate_Discount_4__c

  • Rate_Discount_3_custom__c

  • Rate_Discount_2_custom__c

  • SpecialDiscountCondition__c

  • Rate_Discount_4_Name__c

  • ScaledDiscountCondition__c

  • ScaledDiscountCondition__r

  • ConditionApplied__c

AgencyEarnings:

  • ADvendio__AgencyEarnings__c

  • ADvendio__AgencyEarningsCondition__c

  • ADvendio__AgencyEarningsCondition__r

Third Party Discount:

  • ThirdPartyCommissionCustom__c

  • TPCCondition__c

  • TPCCondition__r

  • ConditionApplied__c

1.8. Examples

1.8.1. Get a Session-ID

1.8.1.1.1. Get a Session ID
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. Connected App

Get CLIENT_ID and CLIENT_SECRET from any connected app or create a new app in your org: App Manager -> New Connected App


1.8.3. Simple request

A simple request with a Commitment and Commitment Conditions matching the Campaign Item / Ad Price.

1.8.3.1.1. Call Dynamic Pricing web service
curl https://<my-domain-name>.my.salesforce.com/services/apexrest/ADvendio/ADvendio__Campaign_Item__c/ApplyCommitments/ -H 'Authorization: Bearer <SESSION_ID>' -H "Content-Type: application/json" -H 'X-PrettyPrint:1' -d @requestBody.txt --request PATCH


1.8.3.1.2. requestBody.txt
{
	"campaignItems":[
		{
			"ADvendio__Ad_Price__c":"a0HA000000SNYF4MAP",
			"ADvendio__Media_Campaign__r":{
				"ADvendio__Commitment__c":"a252K000003Jf5aQAC"
			}
		}
	]
}


1.8.3.1.3. Response
[
 {
  "attributes" : {
    "type" : "ADvendio__Campaign_Item__c"
  },
  "ADvendio__Ad_Price__r" : {
    "attributes" : {
      "type" : "ADvendio__Ad_price__c",
      "url" : "/services/data/v45.0/sobjects/ADvendio__Ad_price__c/a0HA000000SNYF4MAP"
    },
    "ADvendio__NoThirdPartyCommission__c" : false,
    "ADvendio__NoCustomerDiscount__c" : false,
    "ADvendio__NoAgencyDiscount__c" : false,
    "ADvendio__Ad_Spec__c" : "a0FA000000LsEviMAF",
    "ADvendio__Ad_Spec__r" : {
      "attributes" : {
        "type" : "ADvendio__Ad_Specs__c",
        "url" : "/services/data/v45.0/sobjects/ADvendio__Ad_Specs__c/a0FA000000LsEviMAF"
      },
      "ADvendio__NoThirdPartyCommission__c" : false,
      "ADvendio__No_Agency_Discount__c" : false,
      "ADvendio__Placement__r" : {
        "attributes" : {
          "type" : "ADvendio__Placement__c",
          "url" : "/services/data/v45.0/sobjects/ADvendio__Placement__c/a1MA000000BQWW1MAP"
        },
        "Id" : "a1MA000000BQWW1MAP",
        "ADvendio__MediaSegment__c" : "InApp",
        "ADvendio__Site__c" : "a1kA0000002oO2NIAU",
        "ADvendio__Site__r" : {
          "attributes" : {
            "type" : "ADvendio__Site__c",
            "url" : "/services/data/v45.0/sobjects/ADvendio__Site__c/a1kA0000002oO2NIAU"
          },
          "ADvendio__MediaType__c" : "TV",
          "Id" : "a1kA0000002oO2NIAU"
        }
      },
      "ADvendio__No_Customer_Discount__c" : false,
      "ADvendio__Placement__c" : "a1MA000000BQWW1MAP",
      "ADvendio__Ad_Type__c" : "a0GA0000016Ec4aMAC",
      "Id" : "a0FA000000LsEviMAF",
      "ADvendio__Ad_Type__r" : {
        "attributes" : {
          "type" : "ADvendio__Ad_Type__c",
          "url" : "/services/data/v45.0/sobjects/ADvendio__Ad_Type__c/a0GA0000016Ec4aMAC"
        },
        "ADvendio__MediaDifferentiation__c" : "InStream",
        "Id" : "a0GA0000016Ec4aMAC"
      }
    },
    "Id" : "a0HA000000SNYF4MAP"
  },
  "ADvendio__Rate_Discount_2_custom__c" : 5.00000000000,
  "ADvendio__Ad_Price__c" : "a0HA000000SNYF4MAP",
  "ADvendio__ConditionApplied__c" : true,
  "ADvendio__Media_Campaign__r" : {
    "attributes" : {
      "type" : "ADvendio__MediaCampaign__c"
    },
    "ADvendio__Commitment__c" : "a252K000003Jf5aQAC"
  },
  "ADvendio__ScaledDiscountCondition__r" : {
    "attributes" : {
      "type" : "ADvendio__CommitmentCondition__c",
      "url" : "/services/data/v45.0/sobjects/ADvendio__CommitmentCondition__c/a222K000002Im1KQAS"
    },
    "Id" : "a222K000002Im1KQAS",
    "Name" : "Scaled Discount Level 1",
    "RecordTypeId" : "012A00000012lJfIAI",
    "ADvendio__AdPrice__c" : "a0HA000000SNYF4MAP",
    "ADvendio__CashDiscountAdvertiser__c" : 5.00000000000,
    "ADvendio__CashDiscountAgency__c" : 5.00000000000,
    "ADvendio__Commitment__c" : "a252K000003Jf5aQAC",
    "ADvendio__Progressive__c" : false,
    "ADvendio__RebateInKindUnitsAvailable__c" : 0.00,
    "ADvendio__ScaledDiscountFrom__c" : 0.00,
    "ADvendio__ScaledDiscountTo__c" : 1000.00,
    "ADvendio__TotalRebateInKindUnitsEarned__c" : 0.00,
    "ADvendio__TotalRevenue__c" : 902.50,
    "ADvendio__TotalRevenueApplied__c" : 0.00,
    "ADvendio__TotalUnitCount__c" : 1,
    "ADvendio__TotalUnitCountApplied__c" : 0,
    "ADvendio__PackageHeaderMatchingRelevant__c" : false
  },
  "ADvendio__Rate_Discount_3_custom__c" : 5.00000000000,
  "ADvendio__ScaledDiscountCondition__c" : "a222K000002Im1KQAS"
 } 
]


1.9. Usage in Apex

List<ADvendio__Campaign_Item__c> cis = ...
cis = ADvendio.CommitmentsApplier.applyCommitments(cis);



  • No labels