Skip to content

Salesforce: Partner Reviews

denvergreene edited this page Dec 14, 2020 · 3 revisions

Partner Reviews

Partner reviews are entered on the frontend through the Partner Marketplace.

SF documentation for this (LINK)

Review States

There are five states a review can be (from the CMS perspective):

  • New
    The review was created in the CMS by the FE and has never been synced with Salesforce. This is the only time a review is in this state.

  • Edited
    The review has been edited but not synced with Salesforce yet.

  • Awaiting Approval
    The review has been synced with Salesforce and is awaiting approval from someone in Salesforce.

  • Rejected
    The review has been rejected. It can be edited and resubmitted for approval.

  • Deleted
    The review has been deleted by the user. Once it is synced with Salesforce, it will be permanently deleted.

API Endpoints

/apps/cms/api/salesforce/reviews/
The reviews endpoint uses a standard django-restframework ModelSerializer.\ The reviews endpoint uses a general django-restframework ViewSet (instead of the more common on this site, ModelViewSet), with the list, post, patch, and delete methods defined manually so we can do special things for each one.

GET /apps/cms/api/salesforce/reviews/
Takes an optional ?user_id=xx parameter to filter reviews by submitted_by_account_id.
Without the user_id parameter, returns all reviews for partners marked as visible on the website.

Note: This is really only used with the user_id parameter, reviews are returned on the partner endpoint (documented below), which are used on the Partner Marketplace page.

POST /apps/cms/api/salesforce/reviews/
Looks if any reviews exist for the partner/submitted_by_account_id combination - if so, it returns it, otherwise, it creates it, dumps the cloudfront cache, and returns it.
If for some reason a user was able to submit more than one review, it only returns the first review object (oldest).

PATCH /apps/cms/api/salesforce/reviews/
Used to updated/edit reviews. Returns the review object after a successful request.

DELETE /apps/cms/api/salesforce/reviews/
The most complex of all the endpoints because it uses the SSO cookie to verify the user requesting deletion is actually the user who submitted it.
The delete method uses the get_logged_in_user_id() function from ox_auth, which decrypts the cookie and returns the logged in user's id from the oxa cookie. If no cookie is set, it returns None - which causes the delete method to return a 403./ If the user matches the submitter, the review is marked with the status 'Deleted', which allows time to undo or edit the delete. During the next Salesforce sync, the review will be permanently deleted.

GET /apps/cms/api/salesforce/partners/
Returns the list of partners in the CMS, marked visible on the website in the admin.
This also includes the average star rating and review count for each partner.

GET /apps/cms/api/salesforce/partners/<id>
Returns the partner based on the ID passed in. This includes the star rating and review count for each partner - as well as all the reviews for the partner.