Skip to content

Create endpoint to get polices that should be accepted#1198

Merged
deer-wmde merged 19 commits into
mainfrom
T429591
Jul 16, 2026
Merged

Create endpoint to get polices that should be accepted#1198
deer-wmde merged 19 commits into
mainfrom
T429591

Conversation

@rosalieper

Copy link
Copy Markdown
Contributor

Bug: T429591

@rosalieper
rosalieper marked this pull request as ready for review July 13, 2026 10:29
Comment thread app/Http/Controllers/PoliciesController.php
Comment thread app/Http/Controllers/PoliciesController.php Outdated
Comment thread app/Http/Controllers/PoliciesController.php
Comment thread app/Http/Resources/PoliciesCollection.php Outdated
Comment thread tests/Http/Controllers/PoliciesControllerTest.php Outdated
Comment thread tests/Http/Controllers/PoliciesControllerTest.php Outdated
Comment thread tests/Http/Controllers/PoliciesControllerTest.php
Comment thread database/factories/PolicyFactory.php Outdated
Comment thread tests/Http/Controllers/PoliciesControllerTest.php Outdated
@rosalieper
rosalieper requested a review from dati18 July 15, 2026 06:53
@deer-wmde

deer-wmde commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Currently the data the endpoint returns looks something like this:

{
  "data": [
    {
      "id": 1,
      "policy_type": "hosting-policy",
      "active_from": "2026-07-01T00:00:00.000000Z",
      "content_vue_file": "hosting-policy/version-1.vue",
      "created_at": "2026-07-15T10:23:56.000000Z",
      "updated_at": "2026-07-15T10:23:56.000000Z"
    }
  ]
}

I really like that you use this PoliciesCollection class, as that allows us to map this data in a single place to the shape we want/need. Here would be an example to map it more like the ticket specifies:

    public function toArray(Request $request): Collection {
        return $this->collection->map(function ($policy) {
            return [
              'policy_id' => $policy->id,
              'type' => $policy->policy_type,
              'content_vue_file' => $policy->content_vue_file,
              'active_from' => Carbon::parse($policy->active_from)->format('Y-m-d'),
            ];
        });
    }

would give us:

{
  "data": [
    {
      "policy_id": 1,
      "type": "hosting-policy",
      "content_vue_file": "hosting-policy/version-1.vue",
      "active_from": "2026-07-01"
    }
  ]
}

I also suggest adding tests for this shape in the unit tests. As far as I can see this data shape topic is the only missing bit now, we're almost there ❇️

@dati18 dati18 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now.

@deer-wmde
deer-wmde merged commit 2b02541 into main Jul 16, 2026
4 checks passed
@deer-wmde
deer-wmde deleted the T429591 branch July 16, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants