From e317b860ca2c99063bd0eae5d5fd4e938a052a7e Mon Sep 17 00:00:00 2001 From: Kirill Mokevnin Date: Sun, 27 Sep 2026 14:55:20 -0400 Subject: [PATCH] fix: type note_type and note params 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 --- lib/amocrm.rb | 2 + lib/amocrm/models.rb | 4 + .../models/entity_note_create_params.rb | 12 +- .../models/entity_note_get_by_id_response.rb | 12 +- .../models/entity_note_list_response.rb | 12 +- .../models/entity_note_update_by_id_params.rb | 12 +- .../models/entity_note_update_params.rb | 12 +- ...notes_by_parent_create_by_parent_params.rb | 12 +- ...tes_by_parent_get_by_parent_id_response.rb | 12 +- ...notes_by_parent_list_by_parent_response.rb | 12 +- ...es_by_parent_update_by_parent_id_params.rb | 12 +- ...notes_by_parent_update_by_parent_params.rb | 12 +- lib/amocrm/models/note_params.rb | 243 ++++++++++++ lib/amocrm/models/note_type.rb | 24 ++ lib/amocrm/resources/entity_notes.rb | 4 +- .../resources/entity_notes_by_parent.rb | 4 +- rbi/amocrm/models.rbi | 4 + .../models/entity_note_create_params.rbi | 45 ++- .../models/entity_note_get_by_id_response.rbi | 47 ++- .../models/entity_note_list_response.rbi | 47 ++- .../entity_note_update_by_id_params.rbi | 47 ++- .../models/entity_note_update_params.rbi | 47 ++- ...otes_by_parent_create_by_parent_params.rbi | 45 ++- ...es_by_parent_get_by_parent_id_response.rbi | 47 ++- ...otes_by_parent_list_by_parent_response.rbi | 47 ++- ...s_by_parent_update_by_parent_id_params.rbi | 47 ++- ...otes_by_parent_update_by_parent_params.rbi | 47 ++- rbi/amocrm/models/note_params.rbi | 374 ++++++++++++++++++ rbi/amocrm/models/note_type.rbi | 29 ++ rbi/amocrm/resources/entity_notes.rbi | 13 +- .../resources/entity_notes_by_parent.rbi | 13 +- sig/amocrm/models.rbs | 4 + .../models/entity_note_create_params.rbs | 20 +- .../models/entity_note_get_by_id_response.rbs | 22 +- .../models/entity_note_list_response.rbs | 24 +- .../entity_note_update_by_id_params.rbs | 20 +- .../models/entity_note_update_params.rbs | 22 +- ...otes_by_parent_create_by_parent_params.rbs | 20 +- ...es_by_parent_get_by_parent_id_response.rbs | 22 +- ...otes_by_parent_list_by_parent_response.rbs | 24 +- ...s_by_parent_update_by_parent_id_params.rbs | 20 +- ...otes_by_parent_update_by_parent_params.rbs | 22 +- sig/amocrm/models/note_params.rbs | 188 +++++++++ sig/amocrm/models/note_type.rbs | 32 ++ sig/amocrm/resources/entity_notes.rbs | 4 +- .../resources/entity_notes_by_parent.rbs | 4 +- test/amocrm/models/note_params_test.rb | 73 ++++ 47 files changed, 1573 insertions(+), 248 deletions(-) create mode 100644 lib/amocrm/models/note_params.rb create mode 100644 lib/amocrm/models/note_type.rb create mode 100644 rbi/amocrm/models/note_params.rbi create mode 100644 rbi/amocrm/models/note_type.rbi create mode 100644 sig/amocrm/models/note_params.rbs create mode 100644 sig/amocrm/models/note_type.rbs create mode 100644 test/amocrm/models/note_params_test.rb diff --git a/lib/amocrm.rb b/lib/amocrm.rb index 0791d3f..d839677 100644 --- a/lib/amocrm.rb +++ b/lib/amocrm.rb @@ -224,6 +224,8 @@ require_relative "amocrm/models/lead_update_by_id_response" require_relative "amocrm/models/lead_update_params" require_relative "amocrm/models/lead_update_response" +require_relative "amocrm/models/note_params" +require_relative "amocrm/models/note_type" require_relative "amocrm/models/pipeline_create_params" require_relative "amocrm/models/pipeline_create_response" require_relative "amocrm/models/pipeline_delete_by_id_params" diff --git a/lib/amocrm/models.rb b/lib/amocrm/models.rb index 30fb7e8..2ec4807 100644 --- a/lib/amocrm/models.rb +++ b/lib/amocrm/models.rb @@ -211,6 +211,10 @@ module Amocrm LeadUpdateParams = Amocrm::Models::LeadUpdateParams + NoteParams = Amocrm::Models::NoteParams + + NoteType = Amocrm::Models::NoteType + PipelineCreateParams = Amocrm::Models::PipelineCreateParams PipelineDeleteByIDParams = Amocrm::Models::PipelineDeleteByIDParams diff --git a/lib/amocrm/models/entity_note_create_params.rb b/lib/amocrm/models/entity_note_create_params.rb index ce0da71..e87230d 100644 --- a/lib/amocrm/models/entity_note_create_params.rb +++ b/lib/amocrm/models/entity_note_create_params.rb @@ -37,8 +37,8 @@ module EntityType class Body < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String] - required :note_type, String + # @return [Symbol, Amocrm::Models::NoteType] + required :note_type, enum: -> { Amocrm::NoteType } # @!attribute created_at # @@ -62,8 +62,8 @@ class Body < Amocrm::Internal::Type::BaseModel # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute request_id # Client-side request id @@ -82,7 +82,7 @@ class Body < Amocrm::Internal::Type::BaseModel optional :updated_by, Integer # @!method initialize(note_type:, created_at: nil, created_by: nil, entity_id: nil, is_need_to_trigger_digital_pipeline: nil, params: nil, request_id: nil, responsible_user_id: nil, updated_by: nil) - # @param note_type [String] + # @param note_type [Symbol, Amocrm::Models::NoteType] # # @param created_at [Integer] # @@ -92,7 +92,7 @@ class Body < Amocrm::Internal::Type::BaseModel # # @param is_need_to_trigger_digital_pipeline [Boolean] # - # @param params [Object] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # # @param request_id [String] Client-side request id # diff --git a/lib/amocrm/models/entity_note_get_by_id_response.rb b/lib/amocrm/models/entity_note_get_by_id_response.rb index fe0aa5d..e17027a 100644 --- a/lib/amocrm/models/entity_note_get_by_id_response.rb +++ b/lib/amocrm/models/entity_note_get_by_id_response.rb @@ -53,13 +53,13 @@ class Note < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute responsible_user_id # @@ -85,8 +85,8 @@ class Note < Amocrm::Internal::Type::BaseModel # @param entity_id [Integer] # @param group_id [Integer] # @param is_pinned [Boolean] - # @param note_type [String] - # @param params [Object] + # @param note_type [Symbol, Amocrm::Models::NoteType] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # @param responsible_user_id [Integer] # @param updated_at [Integer] # @param updated_by [Integer] diff --git a/lib/amocrm/models/entity_note_list_response.rb b/lib/amocrm/models/entity_note_list_response.rb index 8c942af..6235251 100644 --- a/lib/amocrm/models/entity_note_list_response.rb +++ b/lib/amocrm/models/entity_note_list_response.rb @@ -85,13 +85,13 @@ class Note < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute responsible_user_id # @@ -117,8 +117,8 @@ class Note < Amocrm::Internal::Type::BaseModel # @param entity_id [Integer] # @param group_id [Integer] # @param is_pinned [Boolean] - # @param note_type [String] - # @param params [Object] + # @param note_type [Symbol, Amocrm::Models::NoteType] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # @param responsible_user_id [Integer] # @param updated_at [Integer] # @param updated_by [Integer] diff --git a/lib/amocrm/models/entity_note_update_by_id_params.rb b/lib/amocrm/models/entity_note_update_by_id_params.rb index d0193c4..10db769 100644 --- a/lib/amocrm/models/entity_note_update_by_id_params.rb +++ b/lib/amocrm/models/entity_note_update_by_id_params.rb @@ -24,13 +24,13 @@ class EntityNoteUpdateByIDParams < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute updated_at # @@ -46,8 +46,8 @@ class EntityNoteUpdateByIDParams < Amocrm::Internal::Type::BaseModel # @param entity_type [Symbol, Amocrm::Models::EntityNoteUpdateByIDParams::EntityType] # @param id [Integer] # @param entity_id [Integer] - # @param note_type [String] - # @param params [Object] + # @param note_type [Symbol, Amocrm::Models::NoteType] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # @param updated_at [Integer] # @param updated_by [Integer] # @param request_options [Amocrm::RequestOptions, Hash{Symbol=>Object}] diff --git a/lib/amocrm/models/entity_note_update_params.rb b/lib/amocrm/models/entity_note_update_params.rb index 149d7db..b6d66c6 100644 --- a/lib/amocrm/models/entity_note_update_params.rb +++ b/lib/amocrm/models/entity_note_update_params.rb @@ -48,13 +48,13 @@ class Body < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute updated_at # @@ -71,9 +71,9 @@ class Body < Amocrm::Internal::Type::BaseModel # # @param entity_id [Integer] # - # @param note_type [String] + # @param note_type [Symbol, Amocrm::Models::NoteType] # - # @param params [Object] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # # @param updated_at [Integer] # diff --git a/lib/amocrm/models/entity_notes_by_parent_create_by_parent_params.rb b/lib/amocrm/models/entity_notes_by_parent_create_by_parent_params.rb index 7a196a9..57ba384 100644 --- a/lib/amocrm/models/entity_notes_by_parent_create_by_parent_params.rb +++ b/lib/amocrm/models/entity_notes_by_parent_create_by_parent_params.rb @@ -44,8 +44,8 @@ module EntityType class Body < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String] - required :note_type, String + # @return [Symbol, Amocrm::Models::NoteType] + required :note_type, enum: -> { Amocrm::NoteType } # @!attribute created_at # @@ -69,8 +69,8 @@ class Body < Amocrm::Internal::Type::BaseModel # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute request_id # Client-side request id @@ -89,7 +89,7 @@ class Body < Amocrm::Internal::Type::BaseModel optional :updated_by, Integer # @!method initialize(note_type:, created_at: nil, created_by: nil, entity_id: nil, is_need_to_trigger_digital_pipeline: nil, params: nil, request_id: nil, responsible_user_id: nil, updated_by: nil) - # @param note_type [String] + # @param note_type [Symbol, Amocrm::Models::NoteType] # # @param created_at [Integer] # @@ -99,7 +99,7 @@ class Body < Amocrm::Internal::Type::BaseModel # # @param is_need_to_trigger_digital_pipeline [Boolean] # - # @param params [Object] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # # @param request_id [String] Client-side request id # diff --git a/lib/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rb b/lib/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rb index 4bd481d..a8ae82c 100644 --- a/lib/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rb +++ b/lib/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rb @@ -53,13 +53,13 @@ class Note < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute responsible_user_id # @@ -85,8 +85,8 @@ class Note < Amocrm::Internal::Type::BaseModel # @param entity_id [Integer] # @param group_id [Integer] # @param is_pinned [Boolean] - # @param note_type [String] - # @param params [Object] + # @param note_type [Symbol, Amocrm::Models::NoteType] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # @param responsible_user_id [Integer] # @param updated_at [Integer] # @param updated_by [Integer] diff --git a/lib/amocrm/models/entity_notes_by_parent_list_by_parent_response.rb b/lib/amocrm/models/entity_notes_by_parent_list_by_parent_response.rb index d2cf422..96f7fd5 100644 --- a/lib/amocrm/models/entity_notes_by_parent_list_by_parent_response.rb +++ b/lib/amocrm/models/entity_notes_by_parent_list_by_parent_response.rb @@ -86,13 +86,13 @@ class Note < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute responsible_user_id # @@ -118,8 +118,8 @@ class Note < Amocrm::Internal::Type::BaseModel # @param entity_id [Integer] # @param group_id [Integer] # @param is_pinned [Boolean] - # @param note_type [String] - # @param params [Object] + # @param note_type [Symbol, Amocrm::Models::NoteType] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # @param responsible_user_id [Integer] # @param updated_at [Integer] # @param updated_by [Integer] diff --git a/lib/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rb b/lib/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rb index b79ade9..fd10f20 100644 --- a/lib/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rb +++ b/lib/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rb @@ -29,13 +29,13 @@ class EntityNotesByParentUpdateByParentIDParams < Amocrm::Internal::Type::BaseMo # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute updated_at # @@ -52,8 +52,8 @@ class EntityNotesByParentUpdateByParentIDParams < Amocrm::Internal::Type::BaseMo # @param path_entity_id [Integer] # @param note_id [Integer] # @param body_entity_id [Integer] - # @param note_type [String] - # @param params [Object] + # @param note_type [Symbol, Amocrm::Models::NoteType] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # @param updated_at [Integer] # @param updated_by [Integer] # @param request_options [Amocrm::RequestOptions, Hash{Symbol=>Object}] diff --git a/lib/amocrm/models/entity_notes_by_parent_update_by_parent_params.rb b/lib/amocrm/models/entity_notes_by_parent_update_by_parent_params.rb index 387d2ba..a9cedb7 100644 --- a/lib/amocrm/models/entity_notes_by_parent_update_by_parent_params.rb +++ b/lib/amocrm/models/entity_notes_by_parent_update_by_parent_params.rb @@ -55,13 +55,13 @@ class Body < Amocrm::Internal::Type::BaseModel # @!attribute note_type # - # @return [String, nil] - optional :note_type, String + # @return [Symbol, Amocrm::Models::NoteType, nil] + optional :note_type, enum: -> { Amocrm::NoteType } # @!attribute params # - # @return [Object, nil] - optional :params, Amocrm::Internal::Type::Unknown + # @return [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment, nil] + optional :params, union: -> { Amocrm::NoteParams } # @!attribute updated_at # @@ -78,9 +78,9 @@ class Body < Amocrm::Internal::Type::BaseModel # # @param entity_id [Integer] # - # @param note_type [String] + # @param note_type [Symbol, Amocrm::Models::NoteType] # - # @param params [Object] + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] # # @param updated_at [Integer] # diff --git a/lib/amocrm/models/note_params.rb b/lib/amocrm/models/note_params.rb new file mode 100644 index 0000000..42ad0a7 --- /dev/null +++ b/lib/amocrm/models/note_params.rb @@ -0,0 +1,243 @@ +# frozen_string_literal: true + +module Amocrm + module Models + # Параметры примечания: состав зависит от его типа (`note_type`). + module NoteParams + extend Amocrm::Internal::Type::Union + + variant -> { Amocrm::NoteParams::Call } + + variant -> { Amocrm::NoteParams::Geolocation } + + variant -> { Amocrm::NoteParams::Attachment } + + variant -> { Amocrm::NoteParams::MessageCashier } + + variant -> { Amocrm::NoteParams::ServiceMessage } + + variant -> { Amocrm::NoteParams::Sms } + + variant -> { Amocrm::NoteParams::Common } + + # Параметры примечания call_in, call_out. + class Call < Amocrm::Internal::Type::BaseModel + # @!attribute uniq + # Уникальный идентификатор звонка. + # + # @return [String] + required :uniq, String + + # @!attribute duration + # Длительность звонка в секундах. + # + # @return [Integer] + required :duration, Integer + + # @!attribute source + # Источник звонка. + # + # @return [String] + required :source, String + + # @!attribute link + # Ссылка на запись звонка. + # + # @return [String] + required :link, String + + # @!attribute phone + # Номер телефона. + # + # @return [String] + required :phone, String + + # @!attribute call_responsible + # Ответственный за звонок: имя или ID пользователя. + # + # @return [String, Integer] + required :call_responsible, union: -> { Amocrm::NoteParams::Call::CallResponsible } + + # @!method initialize(uniq:, duration:, source:, link:, phone:, call_responsible:) + # @param uniq [String] Уникальный идентификатор звонка. + # + # @param duration [Integer] Длительность звонка в секундах. + # + # @param source [String] Источник звонка. + # + # @param link [String] Ссылка на запись звонка. + # + # @param phone [String] Номер телефона. + # + # @param call_responsible [String, Integer] Ответственный за звонок: имя или ID пользователя. + + # Ответственный за звонок: имя или ID пользователя. + # + # @see Amocrm::Models::NoteParams::Call#call_responsible + module CallResponsible + extend Amocrm::Internal::Type::Union + + variant String + + variant Integer + + # @!method self.variants + # @return [Array(String, Integer)] + end + end + + # Параметры примечания geolocation. + class Geolocation < Amocrm::Internal::Type::BaseModel + # @!attribute text + # Текст примечания. + # + # @return [String] + required :text, String + + # @!attribute address + # Адрес. + # + # @return [String] + required :address, String + + # @!attribute longitude + # Долгота. + # + # @return [String] + required :longitude, String + + # @!attribute latitude + # Широта. + # + # @return [String] + required :latitude, String + + # @!method initialize(text:, address:, longitude:, latitude:) + # @param text [String] Текст примечания. + # + # @param address [String] Адрес. + # + # @param longitude [String] Долгота. + # + # @param latitude [String] Широта. + end + + # Параметры примечания attachment. + class Attachment < Amocrm::Internal::Type::BaseModel + # @!attribute file_uuid + # UUID файла. + # + # @return [String] + required :file_uuid, String + + # @!attribute file_name + # Название файла, которое отображается в примечании. + # + # @return [String] + required :file_name, String + + # @!attribute version_uuid + # Версия файла; без неё берётся последняя. + # + # @return [String, nil] + optional :version_uuid, String + + # @!method initialize(file_uuid:, file_name:, version_uuid: nil) + # @param file_uuid [String] UUID файла. + # + # @param file_name [String] Название файла, которое отображается в примечании. + # + # @param version_uuid [String] Версия файла; без неё берётся последняя. + end + + # Параметры примечания message_cashier. + class MessageCashier < Amocrm::Internal::Type::BaseModel + # @!attribute status + # Статус сообщения. + # + # @return [Symbol, Amocrm::Models::NoteParams::MessageCashier::Status] + required :status, enum: -> { Amocrm::NoteParams::MessageCashier::Status } + + # @!attribute text + # Текст примечания. + # + # @return [String] + required :text, String + + # @!method initialize(status:, text:) + # @param status [Symbol, Amocrm::Models::NoteParams::MessageCashier::Status] Статус сообщения. + # + # @param text [String] Текст примечания. + + # Статус сообщения кассиру. + # + # @see Amocrm::Models::NoteParams::MessageCashier#status + module Status + extend Amocrm::Internal::Type::Enum + + CREATED = :created + SHOWN = :shown + CANCELED = :canceled + + # @!method self.values + # @return [Array] + end + end + + # Параметры примечания service_message, extended_service_message. + class ServiceMessage < Amocrm::Internal::Type::BaseModel + # @!attribute service + # Название сервиса. + # + # @return [String] + required :service, String + + # @!attribute text + # Текст примечания. + # + # @return [String] + required :text, String + + # @!method initialize(service:, text:) + # @param service [String] Название сервиса. + # + # @param text [String] Текст примечания. + end + + # Параметры примечания sms_in, sms_out. + class Sms < Amocrm::Internal::Type::BaseModel + # @!attribute text + # Текст сообщения. + # + # @return [String] + required :text, String + + # @!attribute phone + # Номер телефона. + # + # @return [String] + required :phone, String + + # @!method initialize(text:, phone:) + # @param text [String] Текст сообщения. + # + # @param phone [String] Номер телефона. + end + + # Параметры примечания common. + class Common < Amocrm::Internal::Type::BaseModel + # @!attribute text + # Текст примечания. + # + # @return [String] + required :text, String + + # @!method initialize(text:) + # @param text [String] Текст примечания. + end + + # @!method self.variants + # @return [Array(Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Attachment, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Common)] + end + end +end diff --git a/lib/amocrm/models/note_type.rb b/lib/amocrm/models/note_type.rb new file mode 100644 index 0000000..557fca6 --- /dev/null +++ b/lib/amocrm/models/note_type.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Amocrm + module Models + # Тип примечания. + module NoteType + extend Amocrm::Internal::Type::Enum + + COMMON = :common + CALL_IN = :call_in + CALL_OUT = :call_out + SERVICE_MESSAGE = :service_message + MESSAGE_CASHIER = :message_cashier + GEOLOCATION = :geolocation + SMS_IN = :sms_in + SMS_OUT = :sms_out + EXTENDED_SERVICE_MESSAGE = :extended_service_message + ATTACHMENT = :attachment + + # @!method self.values + # @return [Array] + end + end +end diff --git a/lib/amocrm/resources/entity_notes.rb b/lib/amocrm/resources/entity_notes.rb index 9cbfd87..0b92740 100644 --- a/lib/amocrm/resources/entity_notes.rb +++ b/lib/amocrm/resources/entity_notes.rb @@ -163,9 +163,9 @@ def unpin(id, params) # # @param entity_id [Integer] Body param # - # @param note_type [String] Body param + # @param note_type [Symbol, Amocrm::Models::NoteType] Body param # - # @param params [Object] Body param + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] Body param # # @param updated_at [Integer] Body param # diff --git a/lib/amocrm/resources/entity_notes_by_parent.rb b/lib/amocrm/resources/entity_notes_by_parent.rb index b2e31f7..a62cdd6 100644 --- a/lib/amocrm/resources/entity_notes_by_parent.rb +++ b/lib/amocrm/resources/entity_notes_by_parent.rb @@ -145,9 +145,9 @@ def update_by_parent(entity_id, params) # # @param body_entity_id [Integer] Body param # - # @param note_type [String] Body param + # @param note_type [Symbol, Amocrm::Models::NoteType] Body param # - # @param params [Object] Body param + # @param params [Amocrm::Models::NoteParams::Common, Amocrm::Models::NoteParams::Call, Amocrm::Models::NoteParams::ServiceMessage, Amocrm::Models::NoteParams::MessageCashier, Amocrm::Models::NoteParams::Geolocation, Amocrm::Models::NoteParams::Sms, Amocrm::Models::NoteParams::Attachment] Body param # # @param updated_at [Integer] Body param # diff --git a/rbi/amocrm/models.rbi b/rbi/amocrm/models.rbi index 17f9da2..4951bc8 100644 --- a/rbi/amocrm/models.rbi +++ b/rbi/amocrm/models.rbi @@ -190,6 +190,10 @@ module Amocrm LeadUpdateParams = Amocrm::Models::LeadUpdateParams + NoteParams = Amocrm::Models::NoteParams + + NoteType = Amocrm::Models::NoteType + PipelineCreateParams = Amocrm::Models::PipelineCreateParams PipelineDeleteByIDParams = Amocrm::Models::PipelineDeleteByIDParams diff --git a/rbi/amocrm/models/entity_note_create_params.rbi b/rbi/amocrm/models/entity_note_create_params.rbi index 7277133..f9f3bd4 100644 --- a/rbi/amocrm/models/entity_note_create_params.rbi +++ b/rbi/amocrm/models/entity_note_create_params.rbi @@ -87,7 +87,7 @@ module Amocrm ) end - sig { returns(String) } + sig { returns(Amocrm::NoteType::OrSymbol) } attr_accessor :note_type sig { returns(T.nilable(Integer)) } @@ -114,10 +114,23 @@ module Amocrm sig { params(is_need_to_trigger_digital_pipeline: T::Boolean).void } attr_writer :is_need_to_trigger_digital_pipeline - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params # Client-side request id @@ -141,12 +154,21 @@ module Amocrm sig do params( - note_type: String, + note_type: Amocrm::NoteType::OrSymbol, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: T::Boolean, - params: T.anything, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), request_id: String, responsible_user_id: Integer, updated_by: Integer @@ -169,12 +191,21 @@ module Amocrm sig do override.returns( { - note_type: String, + note_type: Amocrm::NoteType::OrSymbol, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: T::Boolean, - params: T.anything, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), request_id: String, responsible_user_id: Integer, updated_by: Integer diff --git a/rbi/amocrm/models/entity_note_get_by_id_response.rbi b/rbi/amocrm/models/entity_note_get_by_id_response.rbi index 8ab35a2..cff6885 100644 --- a/rbi/amocrm/models/entity_note_get_by_id_response.rbi +++ b/rbi/amocrm/models/entity_note_get_by_id_response.rbi @@ -70,16 +70,29 @@ module Amocrm sig { params(is_pinned: T::Boolean).void } attr_writer :is_pinned - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::TaggedSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -110,8 +123,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -145,8 +167,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/rbi/amocrm/models/entity_note_list_response.rbi b/rbi/amocrm/models/entity_note_list_response.rbi index 2799e51..4aee88b 100644 --- a/rbi/amocrm/models/entity_note_list_response.rbi +++ b/rbi/amocrm/models/entity_note_list_response.rbi @@ -186,16 +186,29 @@ module Amocrm sig { params(is_pinned: T::Boolean).void } attr_writer :is_pinned - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::TaggedSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -226,8 +239,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -261,8 +283,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/rbi/amocrm/models/entity_note_update_by_id_params.rbi b/rbi/amocrm/models/entity_note_update_by_id_params.rbi index 172633f..d431aee 100644 --- a/rbi/amocrm/models/entity_note_update_by_id_params.rbi +++ b/rbi/amocrm/models/entity_note_update_by_id_params.rbi @@ -23,16 +23,29 @@ module Amocrm sig { params(entity_id: Integer).void } attr_writer :entity_id - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::OrSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -52,8 +65,17 @@ module Amocrm entity_type: Amocrm::EntityNoteUpdateByIDParams::EntityType::OrSymbol, id: Integer, entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions::OrHash @@ -78,8 +100,17 @@ module Amocrm Amocrm::EntityNoteUpdateByIDParams::EntityType::OrSymbol, id: Integer, entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions diff --git a/rbi/amocrm/models/entity_note_update_params.rbi b/rbi/amocrm/models/entity_note_update_params.rbi index 6324cb7..6a1fd37 100644 --- a/rbi/amocrm/models/entity_note_update_params.rbi +++ b/rbi/amocrm/models/entity_note_update_params.rbi @@ -97,16 +97,29 @@ module Amocrm sig { params(entity_id: Integer).void } attr_writer :entity_id - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::OrSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -125,8 +138,17 @@ module Amocrm params( id: Integer, entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer ).returns(T.attached_class) @@ -147,8 +169,17 @@ module Amocrm { id: Integer, entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer } diff --git a/rbi/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbi b/rbi/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbi index 0735dac..538504c 100644 --- a/rbi/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbi +++ b/rbi/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbi @@ -112,7 +112,7 @@ module Amocrm ) end - sig { returns(String) } + sig { returns(Amocrm::NoteType::OrSymbol) } attr_accessor :note_type sig { returns(T.nilable(Integer)) } @@ -139,10 +139,23 @@ module Amocrm sig { params(is_need_to_trigger_digital_pipeline: T::Boolean).void } attr_writer :is_need_to_trigger_digital_pipeline - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params # Client-side request id @@ -166,12 +179,21 @@ module Amocrm sig do params( - note_type: String, + note_type: Amocrm::NoteType::OrSymbol, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: T::Boolean, - params: T.anything, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), request_id: String, responsible_user_id: Integer, updated_by: Integer @@ -194,12 +216,21 @@ module Amocrm sig do override.returns( { - note_type: String, + note_type: Amocrm::NoteType::OrSymbol, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: T::Boolean, - params: T.anything, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), request_id: String, responsible_user_id: Integer, updated_by: Integer diff --git a/rbi/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbi b/rbi/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbi index ea64add..0e7525d 100644 --- a/rbi/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbi +++ b/rbi/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbi @@ -70,16 +70,29 @@ module Amocrm sig { params(is_pinned: T::Boolean).void } attr_writer :is_pinned - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::TaggedSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -110,8 +123,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -145,8 +167,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/rbi/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbi b/rbi/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbi index 9dfc674..1dd4223 100644 --- a/rbi/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbi +++ b/rbi/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbi @@ -186,16 +186,29 @@ module Amocrm sig { params(is_pinned: T::Boolean).void } attr_writer :is_pinned - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::TaggedSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -226,8 +239,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -261,8 +283,17 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: T::Boolean, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbi b/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbi index 06d8666..28a0e26 100644 --- a/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbi +++ b/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbi @@ -33,16 +33,29 @@ module Amocrm sig { params(body_entity_id: Integer).void } attr_writer :body_entity_id - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::OrSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -64,8 +77,17 @@ module Amocrm path_entity_id: Integer, note_id: Integer, body_entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions::OrHash @@ -92,8 +114,17 @@ module Amocrm path_entity_id: Integer, note_id: Integer, body_entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions diff --git a/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbi b/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbi index 4906ccc..0a91e8c 100644 --- a/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbi +++ b/rbi/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbi @@ -122,16 +122,29 @@ module Amocrm sig { params(entity_id: Integer).void } attr_writer :entity_id - sig { returns(T.nilable(String)) } + sig { returns(T.nilable(Amocrm::NoteType::OrSymbol)) } attr_reader :note_type - sig { params(note_type: String).void } + sig { params(note_type: Amocrm::NoteType::OrSymbol).void } attr_writer :note_type - sig { returns(T.nilable(T.anything)) } + sig { returns(T.nilable(Amocrm::NoteParams::Variants)) } attr_reader :params - sig { params(params: T.anything).void } + sig do + params( + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ) + ).void + end attr_writer :params sig { returns(T.nilable(Integer)) } @@ -150,8 +163,17 @@ module Amocrm params( id: Integer, entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer ).returns(T.attached_class) @@ -172,8 +194,17 @@ module Amocrm { id: Integer, entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer } diff --git a/rbi/amocrm/models/note_params.rbi b/rbi/amocrm/models/note_params.rbi new file mode 100644 index 0000000..bc406be --- /dev/null +++ b/rbi/amocrm/models/note_params.rbi @@ -0,0 +1,374 @@ +# typed: strong + +module Amocrm + module Models + # Параметры примечания: состав зависит от его типа (`note_type`). + module NoteParams + extend Amocrm::Internal::Type::Union + + Variants = + T.type_alias do + T.any( + Amocrm::NoteParams::Call, + Amocrm::NoteParams::Geolocation, + Amocrm::NoteParams::Attachment, + Amocrm::NoteParams::MessageCashier, + Amocrm::NoteParams::ServiceMessage, + Amocrm::NoteParams::Sms, + Amocrm::NoteParams::Common + ) + end + + class Call < Amocrm::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Amocrm::NoteParams::Call, Amocrm::Internal::AnyHash) + end + + # Уникальный идентификатор звонка. + sig { returns(String) } + attr_accessor :uniq + + # Длительность звонка в секундах. + sig { returns(Integer) } + attr_accessor :duration + + # Источник звонка. + sig { returns(String) } + attr_accessor :source + + # Ссылка на запись звонка. + sig { returns(String) } + attr_accessor :link + + # Номер телефона. + sig { returns(String) } + attr_accessor :phone + + # Ответственный за звонок: имя или ID пользователя. + sig { returns(Amocrm::NoteParams::Call::CallResponsible::Variants) } + attr_accessor :call_responsible + + sig do + params( + uniq: String, + duration: Integer, + source: String, + link: String, + phone: String, + call_responsible: + Amocrm::NoteParams::Call::CallResponsible::Variants + ).returns(T.attached_class) + end + def self.new( + # Уникальный идентификатор звонка. + uniq:, + # Длительность звонка в секундах. + duration:, + # Источник звонка. + source:, + # Ссылка на запись звонка. + link:, + # Номер телефона. + phone:, + # Ответственный за звонок: имя или ID пользователя. + call_responsible: + ) + end + + sig do + override.returns( + { + uniq: String, + duration: Integer, + source: String, + link: String, + phone: String, + call_responsible: + Amocrm::NoteParams::Call::CallResponsible::Variants + } + ) + end + def to_hash + end + + # Ответственный за звонок: имя или ID пользователя. + module CallResponsible + extend Amocrm::Internal::Type::Union + + Variants = T.type_alias { T.any(String, Integer) } + + sig do + override.returns( + T::Array[Amocrm::NoteParams::Call::CallResponsible::Variants] + ) + end + def self.variants + end + end + end + + class Geolocation < Amocrm::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Amocrm::NoteParams::Geolocation, Amocrm::Internal::AnyHash) + end + + # Текст примечания. + sig { returns(String) } + attr_accessor :text + + # Адрес. + sig { returns(String) } + attr_accessor :address + + # Долгота. + sig { returns(String) } + attr_accessor :longitude + + # Широта. + sig { returns(String) } + attr_accessor :latitude + + sig do + params( + text: String, + address: String, + longitude: String, + latitude: String + ).returns(T.attached_class) + end + def self.new( + # Текст примечания. + text:, + # Адрес. + address:, + # Долгота. + longitude:, + # Широта. + latitude: + ) + end + + sig do + override.returns( + { + text: String, + address: String, + longitude: String, + latitude: String + } + ) + end + def to_hash + end + end + + class Attachment < Amocrm::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Amocrm::NoteParams::Attachment, Amocrm::Internal::AnyHash) + end + + # UUID файла. + sig { returns(String) } + attr_accessor :file_uuid + + # Название файла, которое отображается в примечании. + sig { returns(String) } + attr_accessor :file_name + + # Версия файла; без неё берётся последняя. + sig { returns(T.nilable(String)) } + attr_reader :version_uuid + + sig { params(version_uuid: String).void } + attr_writer :version_uuid + + sig do + params( + file_uuid: String, + file_name: String, + version_uuid: String + ).returns(T.attached_class) + end + def self.new( + # UUID файла. + file_uuid:, + # Название файла, которое отображается в примечании. + file_name:, + # Версия файла; без неё берётся последняя. + version_uuid: nil + ) + end + + sig do + override.returns( + { file_uuid: String, file_name: String, version_uuid: String } + ) + end + def to_hash + end + end + + class MessageCashier < Amocrm::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Amocrm::NoteParams::MessageCashier, Amocrm::Internal::AnyHash) + end + + # Статус сообщения. + sig do + returns(Amocrm::NoteParams::MessageCashier::Status::TaggedSymbol) + end + attr_accessor :status + + # Текст примечания. + sig { returns(String) } + attr_accessor :text + + sig do + params( + status: Amocrm::NoteParams::MessageCashier::Status::OrSymbol, + text: String + ).returns(T.attached_class) + end + def self.new( + # Статус сообщения. + status:, + # Текст примечания. + text: + ) + end + + sig do + override.returns( + { + status: Amocrm::NoteParams::MessageCashier::Status::TaggedSymbol, + text: String + } + ) + end + def to_hash + end + + # Статус сообщения кассиру. + module Status + extend Amocrm::Internal::Type::Enum + + TaggedSymbol = + T.type_alias do + T.all(Symbol, Amocrm::NoteParams::MessageCashier::Status) + end + OrSymbol = T.type_alias { T.any(Symbol, String) } + + CREATED = + T.let( + :created, + Amocrm::NoteParams::MessageCashier::Status::TaggedSymbol + ) + SHOWN = + T.let( + :shown, + Amocrm::NoteParams::MessageCashier::Status::TaggedSymbol + ) + CANCELED = + T.let( + :canceled, + Amocrm::NoteParams::MessageCashier::Status::TaggedSymbol + ) + + sig do + override.returns( + T::Array[Amocrm::NoteParams::MessageCashier::Status::TaggedSymbol] + ) + end + def self.values + end + end + end + + class ServiceMessage < Amocrm::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Amocrm::NoteParams::ServiceMessage, Amocrm::Internal::AnyHash) + end + + # Название сервиса. + sig { returns(String) } + attr_accessor :service + + # Текст примечания. + sig { returns(String) } + attr_accessor :text + + sig { params(service: String, text: String).returns(T.attached_class) } + def self.new( + # Название сервиса. + service:, + # Текст примечания. + text: + ) + end + + sig { override.returns({ service: String, text: String }) } + def to_hash + end + end + + class Sms < Amocrm::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Amocrm::NoteParams::Sms, Amocrm::Internal::AnyHash) + end + + # Текст сообщения. + sig { returns(String) } + attr_accessor :text + + # Номер телефона. + sig { returns(String) } + attr_accessor :phone + + sig { params(text: String, phone: String).returns(T.attached_class) } + def self.new( + # Текст сообщения. + text:, + # Номер телефона. + phone: + ) + end + + sig { override.returns({ text: String, phone: String }) } + def to_hash + end + end + + class Common < Amocrm::Internal::Type::BaseModel + OrHash = + T.type_alias do + T.any(Amocrm::NoteParams::Common, Amocrm::Internal::AnyHash) + end + + # Текст примечания. + sig { returns(String) } + attr_accessor :text + + sig { params(text: String).returns(T.attached_class) } + def self.new( + # Текст примечания. + text: + ) + end + + sig { override.returns({ text: String }) } + def to_hash + end + end + + sig { override.returns(T::Array[Amocrm::NoteParams::Variants]) } + def self.variants + end + end + end +end diff --git a/rbi/amocrm/models/note_type.rbi b/rbi/amocrm/models/note_type.rbi new file mode 100644 index 0000000..4bfbaa7 --- /dev/null +++ b/rbi/amocrm/models/note_type.rbi @@ -0,0 +1,29 @@ +# typed: strong + +module Amocrm + module Models + # Тип примечания. + module NoteType + extend Amocrm::Internal::Type::Enum + + TaggedSymbol = T.type_alias { T.all(Symbol, Amocrm::NoteType) } + OrSymbol = T.type_alias { T.any(Symbol, String) } + + COMMON = T.let(:common, Amocrm::NoteType::TaggedSymbol) + CALL_IN = T.let(:call_in, Amocrm::NoteType::TaggedSymbol) + CALL_OUT = T.let(:call_out, Amocrm::NoteType::TaggedSymbol) + SERVICE_MESSAGE = T.let(:service_message, Amocrm::NoteType::TaggedSymbol) + MESSAGE_CASHIER = T.let(:message_cashier, Amocrm::NoteType::TaggedSymbol) + GEOLOCATION = T.let(:geolocation, Amocrm::NoteType::TaggedSymbol) + SMS_IN = T.let(:sms_in, Amocrm::NoteType::TaggedSymbol) + SMS_OUT = T.let(:sms_out, Amocrm::NoteType::TaggedSymbol) + EXTENDED_SERVICE_MESSAGE = + T.let(:extended_service_message, Amocrm::NoteType::TaggedSymbol) + ATTACHMENT = T.let(:attachment, Amocrm::NoteType::TaggedSymbol) + + sig { override.returns(T::Array[Amocrm::NoteType::TaggedSymbol]) } + def self.values + end + end + end +end diff --git a/rbi/amocrm/resources/entity_notes.rbi b/rbi/amocrm/resources/entity_notes.rbi index fa78978..da7dca6 100644 --- a/rbi/amocrm/resources/entity_notes.rbi +++ b/rbi/amocrm/resources/entity_notes.rbi @@ -92,8 +92,17 @@ module Amocrm id: Integer, entity_type: Amocrm::EntityNoteUpdateByIDParams::EntityType::OrSymbol, entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions::OrHash diff --git a/rbi/amocrm/resources/entity_notes_by_parent.rbi b/rbi/amocrm/resources/entity_notes_by_parent.rbi index 8e853a1..9396677 100644 --- a/rbi/amocrm/resources/entity_notes_by_parent.rbi +++ b/rbi/amocrm/resources/entity_notes_by_parent.rbi @@ -117,8 +117,17 @@ module Amocrm entity_type: Amocrm::EntityNotesByParentUpdateByParentIDParams::EntityType::OrSymbol, body_entity_id: Integer, - note_type: String, - params: T.anything, + note_type: Amocrm::NoteType::OrSymbol, + params: + T.any( + Amocrm::NoteParams::Common::OrHash, + Amocrm::NoteParams::Call::OrHash, + Amocrm::NoteParams::ServiceMessage::OrHash, + Amocrm::NoteParams::MessageCashier::OrHash, + Amocrm::NoteParams::Geolocation::OrHash, + Amocrm::NoteParams::Sms::OrHash, + Amocrm::NoteParams::Attachment::OrHash + ), updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions::OrHash diff --git a/sig/amocrm/models.rbs b/sig/amocrm/models.rbs index 8566ca6..43ee8eb 100644 --- a/sig/amocrm/models.rbs +++ b/sig/amocrm/models.rbs @@ -171,6 +171,10 @@ module Amocrm class LeadUpdateParams = Amocrm::Models::LeadUpdateParams + module NoteParams = Amocrm::Models::NoteParams + + module NoteType = Amocrm::Models::NoteType + class PipelineCreateParams = Amocrm::Models::PipelineCreateParams class PipelineDeleteByIDParams = Amocrm::Models::PipelineDeleteByIDParams diff --git a/sig/amocrm/models/entity_note_create_params.rbs b/sig/amocrm/models/entity_note_create_params.rbs index cb099b3..dd496f4 100644 --- a/sig/amocrm/models/entity_note_create_params.rbs +++ b/sig/amocrm/models/entity_note_create_params.rbs @@ -42,19 +42,19 @@ module Amocrm type body = { - note_type: String, + note_type: Amocrm::Models::note_type, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: bool, - params: top, + params: Amocrm::Models::note_params, request_id: String, responsible_user_id: Integer, updated_by: Integer } class Body < Amocrm::Internal::Type::BaseModel - attr_accessor note_type: String + attr_accessor note_type: Amocrm::Models::note_type attr_reader created_at: Integer? @@ -72,9 +72,11 @@ module Amocrm def is_need_to_trigger_digital_pipeline=: (bool) -> bool - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader request_id: String? @@ -89,24 +91,24 @@ module Amocrm def updated_by=: (Integer) -> Integer def initialize: ( - note_type: String, + note_type: Amocrm::Models::note_type, ?created_at: Integer, ?created_by: Integer, ?entity_id: Integer, ?is_need_to_trigger_digital_pipeline: bool, - ?params: top, + ?params: Amocrm::Models::note_params, ?request_id: String, ?responsible_user_id: Integer, ?updated_by: Integer ) -> void def to_hash: -> { - note_type: String, + note_type: Amocrm::Models::note_type, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: bool, - params: top, + params: Amocrm::Models::note_params, request_id: String, responsible_user_id: Integer, updated_by: Integer diff --git a/sig/amocrm/models/entity_note_get_by_id_response.rbs b/sig/amocrm/models/entity_note_get_by_id_response.rbs index 88c8d71..35a88f0 100644 --- a/sig/amocrm/models/entity_note_get_by_id_response.rbs +++ b/sig/amocrm/models/entity_note_get_by_id_response.rbs @@ -17,8 +17,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -57,13 +57,15 @@ module Amocrm def is_pinned=: (bool) -> bool - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: (Amocrm::Models::note_type) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader responsible_user_id: Integer? @@ -86,8 +88,8 @@ module Amocrm ?entity_id: Integer, ?group_id: Integer, ?is_pinned: bool, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?responsible_user_id: Integer, ?updated_at: Integer, ?updated_by: Integer @@ -102,8 +104,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/sig/amocrm/models/entity_note_list_response.rbs b/sig/amocrm/models/entity_note_list_response.rbs index 3652b83..e7bfa63 100644 --- a/sig/amocrm/models/entity_note_list_response.rbs +++ b/sig/amocrm/models/entity_note_list_response.rbs @@ -71,8 +71,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -111,13 +111,17 @@ module Amocrm def is_pinned=: (bool) -> bool - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: ( + Amocrm::Models::note_type + ) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader responsible_user_id: Integer? @@ -140,8 +144,8 @@ module Amocrm ?entity_id: Integer, ?group_id: Integer, ?is_pinned: bool, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?responsible_user_id: Integer, ?updated_at: Integer, ?updated_by: Integer @@ -156,8 +160,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/sig/amocrm/models/entity_note_update_by_id_params.rbs b/sig/amocrm/models/entity_note_update_by_id_params.rbs index 1c34861..8b5d3ec 100644 --- a/sig/amocrm/models/entity_note_update_by_id_params.rbs +++ b/sig/amocrm/models/entity_note_update_by_id_params.rbs @@ -5,8 +5,8 @@ module Amocrm entity_type: Amocrm::Models::EntityNoteUpdateByIDParams::entity_type, id: Integer, entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer } @@ -24,13 +24,13 @@ module Amocrm def entity_id=: (Integer) -> Integer - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: (Amocrm::Models::note_type) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: (Amocrm::Models::note_params) -> Amocrm::Models::note_params attr_reader updated_at: Integer? @@ -44,8 +44,8 @@ module Amocrm entity_type: Amocrm::Models::EntityNoteUpdateByIDParams::entity_type, id: Integer, ?entity_id: Integer, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?updated_at: Integer, ?updated_by: Integer, ?request_options: Amocrm::request_opts @@ -55,8 +55,8 @@ module Amocrm entity_type: Amocrm::Models::EntityNoteUpdateByIDParams::entity_type, id: Integer, entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions diff --git a/sig/amocrm/models/entity_note_update_params.rbs b/sig/amocrm/models/entity_note_update_params.rbs index eb3d0e7..841b94d 100644 --- a/sig/amocrm/models/entity_note_update_params.rbs +++ b/sig/amocrm/models/entity_note_update_params.rbs @@ -44,8 +44,8 @@ module Amocrm { id: Integer, entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer } @@ -57,13 +57,15 @@ module Amocrm def entity_id=: (Integer) -> Integer - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: (Amocrm::Models::note_type) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader updated_at: Integer? @@ -76,8 +78,8 @@ module Amocrm def initialize: ( id: Integer, ?entity_id: Integer, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?updated_at: Integer, ?updated_by: Integer ) -> void @@ -85,8 +87,8 @@ module Amocrm def to_hash: -> { id: Integer, entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer } diff --git a/sig/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbs b/sig/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbs index 8dccdfc..bdc2cf2 100644 --- a/sig/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbs +++ b/sig/amocrm/models/entity_notes_by_parent_create_by_parent_params.rbs @@ -47,19 +47,19 @@ module Amocrm type body = { - note_type: String, + note_type: Amocrm::Models::note_type, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: bool, - params: top, + params: Amocrm::Models::note_params, request_id: String, responsible_user_id: Integer, updated_by: Integer } class Body < Amocrm::Internal::Type::BaseModel - attr_accessor note_type: String + attr_accessor note_type: Amocrm::Models::note_type attr_reader created_at: Integer? @@ -77,9 +77,11 @@ module Amocrm def is_need_to_trigger_digital_pipeline=: (bool) -> bool - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader request_id: String? @@ -94,24 +96,24 @@ module Amocrm def updated_by=: (Integer) -> Integer def initialize: ( - note_type: String, + note_type: Amocrm::Models::note_type, ?created_at: Integer, ?created_by: Integer, ?entity_id: Integer, ?is_need_to_trigger_digital_pipeline: bool, - ?params: top, + ?params: Amocrm::Models::note_params, ?request_id: String, ?responsible_user_id: Integer, ?updated_by: Integer ) -> void def to_hash: -> { - note_type: String, + note_type: Amocrm::Models::note_type, created_at: Integer, created_by: Integer, entity_id: Integer, is_need_to_trigger_digital_pipeline: bool, - params: top, + params: Amocrm::Models::note_params, request_id: String, responsible_user_id: Integer, updated_by: Integer diff --git a/sig/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbs b/sig/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbs index d67580e..4ae681f 100644 --- a/sig/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbs +++ b/sig/amocrm/models/entity_notes_by_parent_get_by_parent_id_response.rbs @@ -17,8 +17,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -57,13 +57,15 @@ module Amocrm def is_pinned=: (bool) -> bool - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: (Amocrm::Models::note_type) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader responsible_user_id: Integer? @@ -86,8 +88,8 @@ module Amocrm ?entity_id: Integer, ?group_id: Integer, ?is_pinned: bool, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?responsible_user_id: Integer, ?updated_at: Integer, ?updated_by: Integer @@ -102,8 +104,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/sig/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbs b/sig/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbs index 77cb37f..3e28afc 100644 --- a/sig/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbs +++ b/sig/amocrm/models/entity_notes_by_parent_list_by_parent_response.rbs @@ -71,8 +71,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer @@ -111,13 +111,17 @@ module Amocrm def is_pinned=: (bool) -> bool - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: ( + Amocrm::Models::note_type + ) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader responsible_user_id: Integer? @@ -140,8 +144,8 @@ module Amocrm ?entity_id: Integer, ?group_id: Integer, ?is_pinned: bool, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?responsible_user_id: Integer, ?updated_at: Integer, ?updated_by: Integer @@ -156,8 +160,8 @@ module Amocrm entity_id: Integer, group_id: Integer, is_pinned: bool, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, responsible_user_id: Integer, updated_at: Integer, updated_by: Integer diff --git a/sig/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbs b/sig/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbs index 657dddc..4127f45 100644 --- a/sig/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbs +++ b/sig/amocrm/models/entity_notes_by_parent_update_by_parent_id_params.rbs @@ -6,8 +6,8 @@ module Amocrm path_entity_id: Integer, note_id: Integer, body_entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer } @@ -27,13 +27,13 @@ module Amocrm def body_entity_id=: (Integer) -> Integer - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: (Amocrm::Models::note_type) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: (Amocrm::Models::note_params) -> Amocrm::Models::note_params attr_reader updated_at: Integer? @@ -48,8 +48,8 @@ module Amocrm path_entity_id: Integer, note_id: Integer, ?body_entity_id: Integer, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?updated_at: Integer, ?updated_by: Integer, ?request_options: Amocrm::request_opts @@ -60,8 +60,8 @@ module Amocrm path_entity_id: Integer, note_id: Integer, body_entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer, request_options: Amocrm::RequestOptions diff --git a/sig/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbs b/sig/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbs index d3fe0d4..39dc35c 100644 --- a/sig/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbs +++ b/sig/amocrm/models/entity_notes_by_parent_update_by_parent_params.rbs @@ -49,8 +49,8 @@ module Amocrm { id: Integer, entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer } @@ -62,13 +62,15 @@ module Amocrm def entity_id=: (Integer) -> Integer - attr_reader note_type: String? + attr_reader note_type: Amocrm::Models::note_type? - def note_type=: (String) -> String + def note_type=: (Amocrm::Models::note_type) -> Amocrm::Models::note_type - attr_reader params: top? + attr_reader params: Amocrm::Models::note_params? - def params=: (top) -> top + def params=: ( + Amocrm::Models::note_params + ) -> Amocrm::Models::note_params attr_reader updated_at: Integer? @@ -81,8 +83,8 @@ module Amocrm def initialize: ( id: Integer, ?entity_id: Integer, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?updated_at: Integer, ?updated_by: Integer ) -> void @@ -90,8 +92,8 @@ module Amocrm def to_hash: -> { id: Integer, entity_id: Integer, - note_type: String, - params: top, + note_type: Amocrm::Models::note_type, + params: Amocrm::Models::note_params, updated_at: Integer, updated_by: Integer } diff --git a/sig/amocrm/models/note_params.rbs b/sig/amocrm/models/note_params.rbs new file mode 100644 index 0000000..1c890be --- /dev/null +++ b/sig/amocrm/models/note_params.rbs @@ -0,0 +1,188 @@ +module Amocrm + module Models + type note_params = + Amocrm::NoteParams::Call + | Amocrm::NoteParams::Geolocation + | Amocrm::NoteParams::Attachment + | Amocrm::NoteParams::MessageCashier + | Amocrm::NoteParams::ServiceMessage + | Amocrm::NoteParams::Sms + | Amocrm::NoteParams::Common + + module NoteParams + extend Amocrm::Internal::Type::Union + + type call = + { + uniq: String, + duration: Integer, + source: String, + link: String, + phone: String, + call_responsible: Amocrm::Models::NoteParams::Call::call_responsible + } + + class Call < Amocrm::Internal::Type::BaseModel + attr_accessor uniq: String + + attr_accessor duration: Integer + + attr_accessor source: String + + attr_accessor link: String + + attr_accessor phone: String + + attr_accessor call_responsible: Amocrm::Models::NoteParams::Call::call_responsible + + def initialize: ( + uniq: String, + duration: Integer, + source: String, + link: String, + phone: String, + call_responsible: Amocrm::Models::NoteParams::Call::call_responsible + ) -> void + + def to_hash: -> { + uniq: String, + duration: Integer, + source: String, + link: String, + phone: String, + call_responsible: Amocrm::Models::NoteParams::Call::call_responsible + } + + type call_responsible = String | Integer + + module CallResponsible + extend Amocrm::Internal::Type::Union + + def self?.variants: -> ::Array[Amocrm::Models::NoteParams::Call::call_responsible] + end + end + + type geolocation = + { text: String, address: String, longitude: String, latitude: String } + + class Geolocation < Amocrm::Internal::Type::BaseModel + attr_accessor text: String + + attr_accessor address: String + + attr_accessor longitude: String + + attr_accessor latitude: String + + def initialize: ( + text: String, + address: String, + longitude: String, + latitude: String + ) -> void + + def to_hash: -> { + text: String, + address: String, + longitude: String, + latitude: String + } + end + + type attachment = + { file_uuid: String, file_name: String, version_uuid: String } + + class Attachment < Amocrm::Internal::Type::BaseModel + attr_accessor file_uuid: String + + attr_accessor file_name: String + + attr_reader version_uuid: String? + + def version_uuid=: (String) -> String + + def initialize: ( + file_uuid: String, + file_name: String, + ?version_uuid: String + ) -> void + + def to_hash: -> { + file_uuid: String, + file_name: String, + version_uuid: String + } + end + + type message_cashier = + { + status: Amocrm::Models::NoteParams::MessageCashier::status, + text: String + } + + class MessageCashier < Amocrm::Internal::Type::BaseModel + attr_accessor status: Amocrm::Models::NoteParams::MessageCashier::status + + attr_accessor text: String + + def initialize: ( + status: Amocrm::Models::NoteParams::MessageCashier::status, + text: String + ) -> void + + def to_hash: -> { + status: Amocrm::Models::NoteParams::MessageCashier::status, + text: String + } + + type status = :created | :shown | :canceled + + module Status + extend Amocrm::Internal::Type::Enum + + CREATED: :created + SHOWN: :shown + CANCELED: :canceled + + def self?.values: -> ::Array[Amocrm::Models::NoteParams::MessageCashier::status] + end + end + + type service_message = { service: String, text: String } + + class ServiceMessage < Amocrm::Internal::Type::BaseModel + attr_accessor service: String + + attr_accessor text: String + + def initialize: (service: String, text: String) -> void + + def to_hash: -> { service: String, text: String } + end + + type sms = { text: String, phone: String } + + class Sms < Amocrm::Internal::Type::BaseModel + attr_accessor text: String + + attr_accessor phone: String + + def initialize: (text: String, phone: String) -> void + + def to_hash: -> { text: String, phone: String } + end + + type common = { text: String } + + class Common < Amocrm::Internal::Type::BaseModel + attr_accessor text: String + + def initialize: (text: String) -> void + + def to_hash: -> { text: String } + end + + def self?.variants: -> ::Array[Amocrm::Models::note_params] + end + end +end diff --git a/sig/amocrm/models/note_type.rbs b/sig/amocrm/models/note_type.rbs new file mode 100644 index 0000000..19d0a38 --- /dev/null +++ b/sig/amocrm/models/note_type.rbs @@ -0,0 +1,32 @@ +module Amocrm + module Models + type note_type = + :common + | :call_in + | :call_out + | :service_message + | :message_cashier + | :geolocation + | :sms_in + | :sms_out + | :extended_service_message + | :attachment + + module NoteType + extend Amocrm::Internal::Type::Enum + + COMMON: :common + CALL_IN: :call_in + CALL_OUT: :call_out + SERVICE_MESSAGE: :service_message + MESSAGE_CASHIER: :message_cashier + GEOLOCATION: :geolocation + SMS_IN: :sms_in + SMS_OUT: :sms_out + EXTENDED_SERVICE_MESSAGE: :extended_service_message + ATTACHMENT: :attachment + + def self?.values: -> ::Array[Amocrm::Models::note_type] + end + end +end diff --git a/sig/amocrm/resources/entity_notes.rbs b/sig/amocrm/resources/entity_notes.rbs index 0b93950..d0d853d 100644 --- a/sig/amocrm/resources/entity_notes.rbs +++ b/sig/amocrm/resources/entity_notes.rbs @@ -44,8 +44,8 @@ module Amocrm Integer id, entity_type: Amocrm::Models::EntityNoteUpdateByIDParams::entity_type, ?entity_id: Integer, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?updated_at: Integer, ?updated_by: Integer, ?request_options: Amocrm::request_opts diff --git a/sig/amocrm/resources/entity_notes_by_parent.rbs b/sig/amocrm/resources/entity_notes_by_parent.rbs index 18c395d..569c3a4 100644 --- a/sig/amocrm/resources/entity_notes_by_parent.rbs +++ b/sig/amocrm/resources/entity_notes_by_parent.rbs @@ -36,8 +36,8 @@ module Amocrm Integer note_id, entity_type: Amocrm::Models::EntityNotesByParentUpdateByParentIDParams::entity_type, ?body_entity_id: Integer, - ?note_type: String, - ?params: top, + ?note_type: Amocrm::Models::note_type, + ?params: Amocrm::Models::note_params, ?updated_at: Integer, ?updated_by: Integer, ?request_options: Amocrm::request_opts diff --git a/test/amocrm/models/note_params_test.rb b/test/amocrm/models/note_params_test.rb new file mode 100644 index 0000000..d33f32a --- /dev/null +++ b/test/amocrm/models/note_params_test.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +require_relative "../test_helper" + +class Amocrm::Test::NoteParamsModelTest < Minitest::Test + extend Minitest::Serial + include WebMock::API + + def before_all + super + WebMock.enable! + end + + def teardown + WebMock.reset! + super + end + + def after_all + WebMock.disable! + super + end + + def test_create_by_parent_sends_typed_note + body = nil + stub_request(:post, "http://localhost/api/v4/leads/42/notes") + .with { body = JSON.parse(_1.body) } + .to_return_json(status: 200, body: {}) + + client.entity_notes_by_parent.create_by_parent( + 42, + entity_type: :leads, + body: [{note_type: :common, params: Amocrm::NoteParams::Common.new(text: "Заметка")}] + ) + + assert_equal([{"note_type" => "common", "params" => {"text" => "Заметка"}}], body) + end + + def test_note_params_are_parsed_by_their_shape + call = coerce( + { + uniq: "u", + duration: 60, + source: "pbx", + link: "https://x", + phone: "+7", + call_responsible: 504_141 + } + ) + cashier = coerce({status: "shown", text: "t"}) + + assert_kind_of(Amocrm::NoteParams::Call, call) + assert_equal(504_141, call.call_responsible) + assert_kind_of(Amocrm::NoteParams::MessageCashier, cashier) + assert_equal(:shown, cashier.status) + end + + private + + def client = Amocrm::Client.new(base_url: "http://localhost", token: "t", subdomain: "s", max_retries: 0) + + def coerce(value) + Amocrm::NoteParams.coerce( + value, + state: { + translate_names: false, + strictness: true, + exactness: {yes: 0, no: 0, maybe: 0}, + branched: 0 + } + ) + end +end