partition by org_id and add auth
All checks were successful
Build and Publish / build-release (push) Successful in 3m7s

This commit is contained in:
2026-05-15 10:08:54 -05:00
parent a0b5e0c0b3
commit 4519f797fd
26 changed files with 687 additions and 112 deletions

View File

@@ -0,0 +1,39 @@
defmodule CustomerService.Aggregates.LeadId do
@type t :: %__MODULE__{
org_id: String.t(),
type: String.t(),
lead_id: String.t()
}
@derive {Jason.Encoder, only: [:org_id, :type, :lead_id]}
defstruct [:org_id, :type, :lead_id]
def new(org_id, lead_id) when is_binary(org_id) and is_binary(lead_id) do
%__MODULE__{
org_id: org_id,
type: "lead",
lead_id: lead_id
}
end
def parse(<<_::binary>> = string) do
case String.split(string, ":", parts: 3) do
[org_id, "lead", lead_id] ->
{:ok, %__MODULE__{org_id: org_id, type: "lead", lead_id: lead_id}}
_ ->
{:error, :invalid_lead_id}
end
end
def to_string(%__MODULE__{org_id: org_id, type: "lead", lead_id: lead_id}) do
org_id <> ":" <> "lead" <> ":" <> lead_id
end
defimpl Commanded.Serialization.JsonDecoder do
def decode(%{org_id: org_id, type: "lead", lead_id: lead_id}) do
CustomerService.Aggregates.LeadId.new(org_id, lead_id)
end
def decode(id), do: id
end
end