Upstart for Laravel
Features
Installation and Webhook Management
To use this package with upcoach, you will need to provide an Installation URL and a Webhook URL in the upcoach developer portal. This package provides two endpoints in the routes/api.php
file to handle these URLs automatically:
POST /api/upcoach-install
POST /api/upcoach-webhooks:
To set up your application, use the following URLs:
https://your-application-address.com/api/upcoach-install for the Installation URL.
https://your-application-address.com/api/upcoach-webhooks for the Webhook URL.
Middleware for upcoach Requests
To validate incoming requests from upcoach, you can use the Upcoach\UpstartForLaravel\Http\Middleware\EnsureUpcoachRequestIsValid
middleware. This middleware will validate the signature of the request, and if it is valid, it will add the installation to the request object.
API Client
Once the app is installed, an installation request is initiated that includes an API token. This token is saved in the database through the installation model, along with other relevant information. You can utilize this token to access the required API endpoints (scoped to the installed organization) when querying the upcoach API.
Here's how you can use the provided upcoach API client:
$installation = Upcoach\UpstartForLaravel\Models\Installation::query()
->forOrganization($organizationId)
->firstOrFail();
Or if you are using the Upcoach\UpstartForLaravel\Http\Middleware\EnsureUpcoachRequestIsValid
middleware, you can access the installation via the request object:
$installation = $request->installation;
Then you can use the upcoach API client to query the API:
$client = app(Upcoach\UpstartForLaravel\Api\Client::class, [$installation]);
$programInfo = $client->getProgramInfo($programId);