Sha256: 13a24ea3abbc3ae04e83e8509bd162e2dd70d31613af11429dcf21d301247e0a

Contents?: true

Size: 1.12 KB

Versions: 10

Compression:

Stored size: 1.12 KB

Contents

# typed: strict
# frozen_string_literal: true

require_relative "data_response"
require_relative "phone_number_data_response"

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)
          @phone_numbers = T.let(
            response['data']&.map { |phone_number| parse_phone_number(phone_number) },
            T::Array[PhoneNumberDataResponse]
          )
          super(response)
        end

        sig { override.params(response: T::Hash[T.untyped, T.untyped]).returns(T.nilable(PhoneNumbersDataResponse)) }
        def self.build_from_response(response:)
          return unless response["data"]

          new(response)
        end

        private

        sig { params(phone_number: T::Hash[T.untyped, T.untyped]).returns(PhoneNumberDataResponse) }
        def parse_phone_number(phone_number)
          PhoneNumberDataResponse.new(phone_number)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
whatsapp_sdk-0.12.1 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.12.0 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.11.0 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.10.0 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.9.2 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.9.1 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.9.0 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.8.0 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.7.3 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb
whatsapp_sdk-0.7.2 lib/whatsapp_sdk/api/responses/phone_numbers_data_response.rb