Skip to content

Commit

Permalink
API endpoint to get entity type filters
Browse files Browse the repository at this point in the history
  • Loading branch information
ilestis committed Dec 4, 2023
1 parent 720b86e commit 3321fc0
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 5 deletions.
6 changes: 3 additions & 3 deletions app/Http/Controllers/Api/v1/FilterApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public function index()
}
public function show(EntityType $entityType)
{
return response()->json(
$this->filterService
return response()->json([
'data' => $this->filterService
->entityType($entityType)
->filters()
);
]);
}
}
2 changes: 1 addition & 1 deletion app/Services/Api/FilterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function endpoints()
$types = EntityType::get();
foreach ($types as $type) {
$endpoints[] = [
'type' => $type->code,
'code' => $type->code,
'url' => url('/filters/' . $type->id)
];
}
Expand Down
2 changes: 1 addition & 1 deletion resources/api-docs/1.0/entity-mentions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ You can get a list of all the mentions of an entity by using the following endpo
| `campaign_id` | The campaign ID mentioning this entity. This will always be the entity's campaign ID |
| `target_id` | The entity ID that mentions this entity |

Only one of `post_id`, `campaign_id` or `target_id` will ever be filled out for a mention. If an entity is mentionned several times by another entity, only one mention object is saved.
Only one of `post_id`, `campaign_id` or `target_id` will ever be filled out for a mention. If an entity is mentioned several times by another entity, only one mention object is saved.
66 changes: 66 additions & 0 deletions resources/api-docs/1.0/filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Filters

The various entity endpoints like `/characters`, `/locations` etc support many filters.

To get a list of filters, first call `/filters` to get the endpoint for each [entity type](/api-docs/{{version}}/entity-types.md).

| Method | URI | Headers |
| :- |:----------| :- |
| GET/HEAD | `filters` | Default |

### Results
```json
{
"data": [
{
"code": "character",
"url": ".../filters/1"
},
{
"code": "family",
"url": ".../filters/2"
},
]
}
```

## Character filters

To get a list of available filters for the characters endpoint, call the following endpoint.


| Method | URI | Headers |
| :- |:------------------| :- |
| GET/HEAD | `filters/1` | Default |

### Results
```json
{
"data": [
"title",
"age",
"sex",
"pronouns",
"location_id",
"is_dead",
"member_id",
"race_id",
"family_id",
"races",
"name",
"type",
"is_private",
"template",
"tag_id",
"tags",
"has_image",
"has_posts",
"has_entity_files",
"has_attributes",
"created_by",
"updated_by",
"attribute_name",
"attribute_value"
]
}
```
1 change: 1 addition & 0 deletions resources/api-docs/1.0/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

- ## Other Concepts
- [Last Sync](/api-docs/{{version}}/last-sync)
- [Filters](/api-docs/{{version}}/filters)
- [Pagination](/api-docs/{{version}}/pagination)
- [Bookmarks](/api-docs/{{version}}/bookmark)
- [Dashboard Widgets](/api-docs/{{version}}/dashboard-widgets)
Expand Down

0 comments on commit 3321fc0

Please sign in to comment.