How do I refer to an endpoint in another?

The Eve demo creates a collection of people as an endpoint, however there is no identifier for it. So if I want to create a level endpoint to reference "people" it seems tricky.

What I want to do, for example:

Structure: company-> DEPT (people) → person

So, if I go to www.example.com/company, I get an organized list of people grouped by department.

For now I can create a person, create different endpoints for a department (people), but how do I put all of this in a company endpoint?

thank

+1


source to share


1 answer


You probably want to use Sub Resources endpoints. The documentation provides the following example:

invoices = {
    'url': 'people/<regex("[a-f0-9]{24}"):contact_id>/invoices'
     ...

      

Then you can send a GET like this:

people/51f63e0838345b6dcd7eabff/invoices

      



which will translate roughly: give me all the invoices on <contact_id>

. Follow the link above for a detailed explanation of how it works.

UPDATE after reading comment

Since you can have different endpoints that target the same data source, each with its own single filter, you can probably achieve something similar. The endpoints are engineers

and sales

will consume the data source persons

. One could only bring back the engineers, and the other would only bring back the sales people. Then your endpoint departments

can either consume a different data source ( departments

), or have a data relationship to humans, or use the same resource with a filter on the field department

. Haven't tested this, but it might be worth giving it a shot. See Advanced Data Source Templates .

0


source







All Articles