You need to sign in to do that
Don't have an account?
Spencer Widman 9
High Level APEX Class for HTTP Callout
I am writing my first APEX class and I need some high level help if anyone is willing. This is what I am trying to accomplish:
Org is an NPSP org. Using the Salesforce Labs Event package to house events. Events have associated Registration records. There is a custom field on the Contact record containing a Strava Member Id. I would like to build an APEX class that makes a call out to the Strava API and query the organization Strava Club with the Club Id Number.
I would like to return Strava data for club members who have an active Registration for the Event. If they have a registration then I want to return Strava member data for the time period associated with the event. If the Strava Activity record exists, then update the record, if not create the record. The record should be related with a master detail relationship with the Event Registration.
I anticipate this class being executed manually with a Lightning Component on the Event Lighting Page.
I have attempted to write this but can't seem to pull it all together. If anyone wants to take a look I can post the Strava Class and Helper classes that I have.
I guess I am looking for Highlevel steps on what best practices are to accomplish this to make sure I am on the right track. Hopefully this is detailed enough. Thanks for any thoughts.
Org is an NPSP org. Using the Salesforce Labs Event package to house events. Events have associated Registration records. There is a custom field on the Contact record containing a Strava Member Id. I would like to build an APEX class that makes a call out to the Strava API and query the organization Strava Club with the Club Id Number.
I would like to return Strava data for club members who have an active Registration for the Event. If they have a registration then I want to return Strava member data for the time period associated with the event. If the Strava Activity record exists, then update the record, if not create the record. The record should be related with a master detail relationship with the Event Registration.
I anticipate this class being executed manually with a Lightning Component on the Event Lighting Page.
I have attempted to write this but can't seem to pull it all together. If anyone wants to take a look I can post the Strava Class and Helper classes that I have.
I guess I am looking for Highlevel steps on what best practices are to accomplish this to make sure I am on the right track. Hopefully this is detailed enough. Thanks for any thoughts.
Define a method that will retrieve the necessary event and registration data. You can use SOQL queries to retrieve the event and registration data related to the Contact record.
Define a method that will make a callout to the Strava API using the Strava member ID and club ID. You can use the Http class in Apex to make the callout.
Parse the response from the Strava API to extract the necessary data, such as the Strava activity data.
Define a method that will update or create a new Strava Activity record associated with the Event Registration. You can use the Database class in Apex to perform the DML operation.
Add error handling and logging to ensure that any errors or issues are properly handled and logged for debugging purposes.
Finally, create a Lightning component that will allow the user to execute the Apex class manually on the Event page. You can use the lightning:button component to trigger the execution of the Apex class.
Here's some sample code to get you started:
to make the callout to the Strava API, you'll need to create a new Apex class with a method that will handle the callout. Here's an example of what that might look like:
If you find my answer helpful, please mark it as the best answer. Thanks!
All Answers
You can reach out to Salesforce nonprofit group on
https://trailhead.salesforce.com/trailblazer-community/groups/0F9300000001ocxCAA?tab=discussion&sort=LAST_MODIFIED_DATE_DESC
Please close the thread by selected as Best Answer so that we can keep our community clean
Thanks,
Define a method that will retrieve the necessary event and registration data. You can use SOQL queries to retrieve the event and registration data related to the Contact record.
Define a method that will make a callout to the Strava API using the Strava member ID and club ID. You can use the Http class in Apex to make the callout.
Parse the response from the Strava API to extract the necessary data, such as the Strava activity data.
Define a method that will update or create a new Strava Activity record associated with the Event Registration. You can use the Database class in Apex to perform the DML operation.
Add error handling and logging to ensure that any errors or issues are properly handled and logged for debugging purposes.
Finally, create a Lightning component that will allow the user to execute the Apex class manually on the Event page. You can use the lightning:button component to trigger the execution of the Apex class.
Here's some sample code to get you started:
to make the callout to the Strava API, you'll need to create a new Apex class with a method that will handle the callout. Here's an example of what that might look like:
If you find my answer helpful, please mark it as the best answer. Thanks!