Skip to content

Conversation

julienbourdeau
Copy link
Contributor

@julienbourdeau julienbourdeau commented Jul 2, 2025

This PR follows #3873

It adds a way to attach features and privilges to a plan.

In serialized plans, you get

"entitlements" => [
  {
    "code"        => "seats",
    "name"        => "Seats",
    "description" => "Nb users",
    "privileges"  => {
      "max" => {
        "code"       => "max",
        "name"       => nil,
        "value_type" => "integer",
        "value"      => 100,     # <<-------
        "config"     => {}
      }
    }
  }
]

Now, the core is only missing the subscription override.

drawSQL-image-export-2025-06-28 (2)

                           Prefix Verb                      URI Pattern                                                                        Controller#Action
api_v1_plan_entitlement_privilege DELETE                    /api/v1/plans/:plan_code/entitlements/:entitlement_code/privileges/:code(.:format) api/v1/plans/entitlements/privileges#destroy {code: /.*/, plan_code: /.*/, entitlement_code: /.*/}
         api_v1_plan_entitlements GET                       /api/v1/plans/:plan_code/entitlements(.:format)                                    api/v1/plans/entitlements#index {plan_code: /.*/}
                                  POST                      /api/v1/plans/:plan_code/entitlements(.:format)                                    api/v1/plans/entitlements#create {plan_code: /.*/}
          api_v1_plan_entitlement GET                       /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#show {code: /.*/, plan_code: /.*/}
                                  PATCH                     /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#update {code: /.*/, plan_code: /.*/}
                                  PUT                       /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#update {code: /.*/, plan_code: /.*/}
                                  DELETE                    /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#destroy {code: /.*/, plan_code: /.*/}

Next PR

  • Dispatch plan.updated webhooks
  • Create and dispatch feature.* webhooks

@julienbourdeau julienbourdeau self-assigned this Jul 2, 2025
@julienbourdeau julienbourdeau force-pushed the ent/plan-entitlement branch 5 times, most recently from fde9347 to a610e09 Compare July 2, 2025 13:03
@julienbourdeau julienbourdeau marked this pull request as ready for review July 2, 2025 14:14
@julienbourdeau julienbourdeau force-pushed the ent/plan-entitlement branch 2 times, most recently from 524910c to 3e42154 Compare July 3, 2025 09:31
@julienbourdeau julienbourdeau force-pushed the ent/plan-entitlement branch 2 times, most recently from 3bc26fb to e384459 Compare July 3, 2025 14:09
@julienbourdeau julienbourdeau force-pushed the ent/plan-entitlement branch from e384459 to ee20620 Compare July 4, 2025 07:48
@julienbourdeau julienbourdeau force-pushed the ent/plan-entitlement branch from ee20620 to 8144804 Compare July 4, 2025 07:57
@julienbourdeau julienbourdeau force-pushed the ent/plan-entitlement branch from 8144804 to 8262634 Compare July 4, 2025 08:00
@julienbourdeau julienbourdeau merged commit 133e820 into main Jul 4, 2025
14 checks passed
@julienbourdeau julienbourdeau deleted the ent/plan-entitlement branch July 4, 2025 08:37
diegocharles pushed a commit that referenced this pull request Jul 11, 2025
This PR follows #3873

It adds a way to attach features and privilges to a plan.

In serialized plans, you get

```rb
"entitlements" => [
  {
    "code"        => "seats",
    "name"        => "Seats",
    "description" => "Nb users",
    "privileges"  => {
      "max" => {
        "code"       => "max",
        "name"       => nil,
        "value_type" => "integer",
        "value"      => 100,     # <<-------
        "config"     => {}
      }
    }
  }
]
```

**Now, the core is only missing the subscription override.**

![drawSQL-image-export-2025-06-28
(2)](https://github.com/user-attachments/assets/4d728a7d-cb1e-43bc-ac44-486f0e681f73)

```
                           Prefix Verb                      URI Pattern                                                                        Controller#Action
api_v1_plan_entitlement_privilege DELETE                    /api/v1/plans/:plan_code/entitlements/:entitlement_code/privileges/:code(.:format) api/v1/plans/entitlements/privileges#destroy {code: /.*/, plan_code: /.*/, entitlement_code: /.*/}
         api_v1_plan_entitlements GET                       /api/v1/plans/:plan_code/entitlements(.:format)                                    api/v1/plans/entitlements#index {plan_code: /.*/}
                                  POST                      /api/v1/plans/:plan_code/entitlements(.:format)                                    api/v1/plans/entitlements#create {plan_code: /.*/}
          api_v1_plan_entitlement GET                       /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#show {code: /.*/, plan_code: /.*/}
                                  PATCH                     /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#update {code: /.*/, plan_code: /.*/}
                                  PUT                       /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#update {code: /.*/, plan_code: /.*/}
                                  DELETE                    /api/v1/plans/:plan_code/entitlements/:code(.:format)                              api/v1/plans/entitlements#destroy {code: /.*/, plan_code: /.*/}
```


### Next PR

* Dispatch `plan.updated` webhooks
* Create and dispatch `feature.*` webhooks
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.

2 participants