Skip to content

fix: type note_type and note params - #20

Merged
mokevnin merged 1 commit into
mainfrom
fix/typed-notes
Sep 27, 2026
Merged

mokevnin merged 1 commit into
mainfrom
fix/typed-notes

Conversation

@mokevnin

Copy link
Copy Markdown
Member

Note models typed note_type as String and params as Unknown. The amoCRM docs define ten note types and a params shape for each.

  • New Amocrm::NoteType: an enum of the ten documented values.
  • New Amocrm::NoteParams: a union of Call, Geolocation, Attachment, MessageCashier (its status is an enum), ServiceMessage, Sms and Common. The fields come from the documented examples. The union has no discriminator of its own, so the variants go from most specific to Common; otherwise {status:, text:} would parse as Common.
  • Retyped models: note_type and params in the ten note request and response models, and in the entity_notes and entity_notes_by_parent resource signatures, in lib, rbi and rbs.
  • Unchanged: params stays optional, as it was.
  • Test: covers the request body of create_by_parent and parsing params by their shape.
client.entity_notes_by_parent.create_by_parent(
  lead_id,
  entity_type: :leads,
  body: [{note_type: :common, params: Amocrm::NoteParams::Common.new(text: "…")}]
)

The spec side is Hexlet/amocrm-api#3.

rake lint (rubocop, Sorbet, Steep) and rake test (211 runs, 0 failures) pass.

🤖 Generated with Claude Code

Note models typed note_type as String and params as Unknown, so callers
built notes from raw hashes and a typo in the type went unnoticed. amoCRM
documents ten note types and a params shape for each.

note_type is now the NoteType enum and params the NoteParams union of
per-type models, in requests, responses and the resource signatures.
The union has no discriminator of its own, so its variants go from the most
specific to Common.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mokevnin
mokevnin merged commit 0a0796f into main Sep 27, 2026
@github-actions github-actions Bot mentioned this pull request Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant