Vereinfacht: sync country with finance contact API
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Moritz 2026-03-04 19:37:19 +01:00
parent face48531f
commit e879958e53
Signed by: moritz
GPG key ID: 1020A035E5DD0824
3 changed files with 5 additions and 3 deletions

View file

@ -25,7 +25,7 @@ When creating an external finance contact, the API only requires:
- **Attributes:** `contactType` (e.g. `"person"`), `isExternal: true` - **Attributes:** `contactType` (e.g. `"person"`), `isExternal: true`
- **Relationship:** `club` (club ID from config) - **Relationship:** `club` (club ID from config)
Additional attributes (firstName, lastName, email, address, zipCode, city) are optional and are sent when present on the member so the contact is filled in. The app does **not** enforce extra required member fields for Vereinfacht; only Settings-based required fields and email apply. Additional attributes (firstName, lastName, email, address, zipCode, city, country) are optional and are sent when present on the member so the contact is filled in. The app does **not** enforce extra required member fields for Vereinfacht; only Settings-based required fields and email apply.
- **Client:** `Mv.Vereinfacht.Client.create_contact/1` builds the JSON:API body from the member; `Mv.Constants.vereinfacht_required_member_fields/0` is an empty list. - **Client:** `Mv.Vereinfacht.Client.create_contact/1` builds the JSON:API body from the member; `Mv.Constants.vereinfacht_required_member_fields/0` is an empty list.

View file

@ -9,7 +9,7 @@ defmodule Mv.Vereinfacht.Changes.SyncContact do
(Mv.Config.vereinfacht_configured?/0). (Mv.Config.vereinfacht_configured?/0).
Only runs when relevant data changed: on create always; on update only when Only runs when relevant data changed: on create always; on update only when
first_name, last_name, email, street, house_number, postal_code, or city changed, first_name, last_name, email, street, house_number, postal_code, city, or country changed,
or when the member has no vereinfacht_contact_id yet (to avoid unnecessary API calls). or when the member has no vereinfacht_contact_id yet (to avoid unnecessary API calls).
""" """
use Ash.Resource.Change use Ash.Resource.Change
@ -26,7 +26,8 @@ defmodule Mv.Vereinfacht.Changes.SyncContact do
:street, :street,
:house_number, :house_number,
:postal_code, :postal_code,
:city :city,
:country
] ]
@impl true @impl true

View file

@ -345,6 +345,7 @@ defmodule Mv.Vereinfacht.Client do
|> put_attr("address", address) |> put_attr("address", address)
|> put_attr("zipCode", member |> Map.get(:postal_code)) |> put_attr("zipCode", member |> Map.get(:postal_code))
|> put_attr("city", member |> Map.get(:city)) |> put_attr("city", member |> Map.get(:city))
|> put_attr("country", member |> Map.get(:country))
|> Map.put("contactType", "person") |> Map.put("contactType", "person")
|> Map.put("isExternal", true) |> Map.put("isExternal", true)
|> Enum.reject(fn {_k, v} -> is_nil(v) end) |> Enum.reject(fn {_k, v} -> is_nil(v) end)