ruby_whatsapp_sdk
ruby_whatsapp_sdk copied to clipboard
Replace Sorbet with RBS type signatures
Replace Sorbet Signatures with .rbs Files
Description
This pull request replaces the Sorbet signatures in the ruby_whatsapp_sdk
gem with .rbs
files. The changes include:
- Creating a new
.rbs
file forlib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
and moving the Sorbet signatures from the Ruby file to the.rbs
file. - Modifying
lib/whatsapp_sdk/api/messages.rb
to remove the Sorbet signatures and replace them with appropriate type annotations.
Changes
-
Created
lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rbs
with the following content:module WhatsappSdk module Api module Responses class PhoneNumbersDataResponse < DataResponse sig { returns(T::Array[PhoneNumberDataResponse]) } attr_reader :phone_numbers sig { params(response: T::Hash[T.untyped, T.untyped]).void } def initialize(response); end sig { override.params(response: T::Hash[T.untyped, T.untyped]).returns(T.nilable(PhoneNumbersDataResponse)) } def self.build_from_response(response:); end private sig { params(phone_number: T::Hash[T.untyped, T.untyped]).returns(PhoneNumberDataResponse) } def parse_phone_number(phone_number); end end end end end
-
Modified
lib/whatsapp_sdk/api/messages.rb
to replace the Sorbet signature forDEFAULT_HEADERS
:DEFAULT_HEADERS = T.let({ 'Content-Type' => 'application/json' }.freeze, T::Hash[T.untyped, T.untyped])
Verification
- Ran
srb tc
to verify the correctness of the.rbs
files and ensure the gem works as expected. - Addressed any errors identified during the Sorbet typecheck.
Notes
- This is part of the ongoing effort to replace Sorbet signatures with
.rbs
files in theruby_whatsapp_sdk
gem. - Further changes may be required to complete the transition for all files in the gem.