From 768cda32b2cf859d6e08c9b9a198f00f06b4a153 Mon Sep 17 00:00:00 2001 From: Cassiano Rodrigues <66069923+kszinhu@users.noreply.github.com> Date: Wed, 26 Nov 2025 22:57:02 -0300 Subject: [PATCH 1/3] ci(gemfile): add linux platform (#1) Changes: * Add x86_64-linux platform to Gemfile.lock --- Gemfile.lock | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index d38720b..406c70d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM activesupport (>= 6.1.0) ffi (1.17.2) ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-linux-gnu) ffi-compiler (1.3.2) ffi (>= 1.15.5) rake @@ -101,6 +102,8 @@ GEM minitest (5.26.1) nokogiri (1.18.10-arm64-darwin) racc (~> 1.4) + nokogiri (1.18.10-x86_64-linux-gnu) + racc (~> 1.4) parallel (1.27.0) parser (3.3.10.0) ast (~> 2.4.1) @@ -216,6 +219,7 @@ GEM PLATFORMS arm64-darwin-23 arm64-darwin-24 + x86_64-linux DEPENDENCIES dotenv-rails From e71894488c401ecda1bfa31e60381fc1ddebb3a6 Mon Sep 17 00:00:00 2001 From: Cassiano Rodrigues <66069923+kszinhu@users.noreply.github.com> Date: Wed, 26 Nov 2025 22:59:31 -0300 Subject: [PATCH 2/3] chore: rename mime_type typo (#2) --- lib/chatkit/files/response.rb | 8 ++++---- spec/chatkit/files/response_spec.rb | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/chatkit/files/response.rb b/lib/chatkit/files/response.rb index f816930..9742f09 100644 --- a/lib/chatkit/files/response.rb +++ b/lib/chatkit/files/response.rb @@ -29,14 +29,14 @@ class Response attr_accessor :upload_url # @param id [String] - The file ID. - # @param mime_typee [String] - The MIME type of the file. + # @param mime_type [String] - The MIME type of the file. # @param name [String] - The name of the file. # @param preview_url [String] - The preview URL of the file. # @param type [String] - The type of the file. # @param upload_url [String] - The upload URL of the file. - def initialize(id:, mime_typee:, name:, preview_url:, type:, upload_url:) + def initialize(id:, mime_type:, name:, preview_url:, type:, upload_url:) @id = id - @mime_type = mime_typee + @mime_type = mime_type @name = name @preview_url = preview_url @type = type @@ -47,7 +47,7 @@ class << self def deserialize(data) new( id: data["id"], - mime_typee: data["mime_type"], + mime_type: data["mime_type"], name: data["name"], preview_url: data["preview_url"], type: data["type"], diff --git a/spec/chatkit/files/response_spec.rb b/spec/chatkit/files/response_spec.rb index 0b10653..338122a 100644 --- a/spec/chatkit/files/response_spec.rb +++ b/spec/chatkit/files/response_spec.rb @@ -20,7 +20,7 @@ def sample_response_data it "initializes with all provided values" do response = described_class.new( id: "file_test123", - mime_typee: "application/pdf", + mime_type: "application/pdf", name: "document.pdf", preview_url: "https://example.com/preview/file_test123", type: "document", @@ -40,7 +40,7 @@ def sample_response_data it "raises an ArgumentError when id is missing" do expect do described_class.new( - mime_typee: "application/pdf", + mime_type: "application/pdf", name: "document.pdf", preview_url: "https://example.com/preview", type: "document", @@ -49,7 +49,7 @@ def sample_response_data end.to raise_error(ArgumentError, /missing keyword.*id/) end - it "raises an ArgumentError when mime_typee is missing" do + it "raises an ArgumentError when mime_type is missing" do expect do described_class.new( id: "file_test123", @@ -58,14 +58,14 @@ def sample_response_data type: "document", upload_url: "https://example.com/upload" ) - end.to raise_error(ArgumentError, /missing keyword.*mime_typee/) + end.to raise_error(ArgumentError, /missing keyword.*mime_type/) end it "raises an ArgumentError when name is missing" do expect do described_class.new( id: "file_test123", - mime_typee: "application/pdf", + mime_type: "application/pdf", preview_url: "https://example.com/preview", type: "document", upload_url: "https://example.com/upload" @@ -77,7 +77,7 @@ def sample_response_data expect do described_class.new( id: "file_test123", - mime_typee: "application/pdf", + mime_type: "application/pdf", name: "document.pdf", type: "document", upload_url: "https://example.com/upload" @@ -89,7 +89,7 @@ def sample_response_data expect do described_class.new( id: "file_test123", - mime_typee: "application/pdf", + mime_type: "application/pdf", name: "document.pdf", preview_url: "https://example.com/preview", upload_url: "https://example.com/upload" @@ -101,7 +101,7 @@ def sample_response_data expect do described_class.new( id: "file_test123", - mime_typee: "application/pdf", + mime_type: "application/pdf", name: "document.pdf", preview_url: "https://example.com/preview", type: "document" @@ -216,7 +216,7 @@ def sample_response_data let(:response) do described_class.new( id: "file_test123", - mime_typee: "image/jpeg", + mime_type: "image/jpeg", name: "photo.jpg", preview_url: "https://example.com/preview/file_test123", type: "image", From 6301e3ecefa1b9c28bca350bf0b32b90bce9d6ab Mon Sep 17 00:00:00 2001 From: Cassiano Rodrigues <66069923+kszinhu@users.noreply.github.com> Date: Thu, 27 Nov 2025 00:54:01 -0300 Subject: [PATCH 3/3] fix: methods access causing `NoMethodError` (#3) Changes: * Added a check for required attributes (`id`, `thread_id`, `created_at`) in `Thread::Item.from_event`, raising an `ArgumentError` if any are missing. * Made the `parse_workflow_data` method in `Thread::Item` a class method and updated its usage accordingly for clarity and correctness. * Added a `client` reader attribute to `Session` for easier access to the `ChatKit` client instance. --- lib/chatkit/conversation/response/thread/item.rb | 10 ++++++++-- lib/chatkit/session.rb | 4 ++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/chatkit/conversation/response/thread/item.rb b/lib/chatkit/conversation/response/thread/item.rb index a71cc26..0fe825b 100644 --- a/lib/chatkit/conversation/response/thread/item.rb +++ b/lib/chatkit/conversation/response/thread/item.rb @@ -6,6 +6,8 @@ class Response class Thread # Represents an item in a thread. class Item + REQUIRED_ATTRIBUTES = %w[id thread_id created_at].freeze + # @!attribute [rw] id # @return [String] attr_accessor :id @@ -76,6 +78,10 @@ class << self # @param data [Hash] The item data from the event # @return [Item] def from_event(data) + missing_attrs = REQUIRED_ATTRIBUTES.reject { |attr| data.key?(attr) } + raise ArgumentError, "Missing required attributes: #{missing_attrs.join(', ')}" unless missing_attrs.empty? + + new( id: data["id"], thread_id: data["thread_id"], @@ -118,7 +124,7 @@ def update_from_event!(data) if @workflow @workflow.update!(data["workflow"]) else - @workflow = parse_workflow_data(data) + @workflow = self.class.parse_workflow_data(data) end end @@ -143,7 +149,7 @@ def process_update!(update_data) # Parse workflow data from event # @param data [Hash] The event data # @return [Workflow, nil] - def parse_workflow_data(data) + def self.parse_workflow_data(data) return nil unless data["workflow"] Workflow.from_event(data["workflow"]) diff --git a/lib/chatkit/session.rb b/lib/chatkit/session.rb index 20a63b8..92efff4 100644 --- a/lib/chatkit/session.rb +++ b/lib/chatkit/session.rb @@ -21,6 +21,10 @@ module Defaults ENABLED = true end + # @!attribute [r] client + # @return [Ruby::ChatKit::Client] The ChatKit client instance. + attr_reader :client + # @!attribute [rw] user_id # @return [String] The ID of the user. attr_accessor :user_id