Sha256: de88b6ca75954769629ca10df88d710550308713d5ac810a4b62f77fc3018259

Contents?: true

Size: 1.18 KB

Versions: 8

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require_relative "../decorators/messaging_v1/phone_number_list"
require_relative "../decorators/messaging_v1/phone_number_create"
require_relative "../decorators/messaging_v1/phone_number_fetch"

module Mock
  module Twilio
    module Schemas
      class MessagingV1
        class << self
          RESOURCES = {
            phone_number_list: Mock::Twilio::Decorators::MessagingV1::PhoneNumberList,
            phone_number_create: Mock::Twilio::Decorators::MessagingV1::PhoneNumberCreate,
            phone_number_fetch: Mock::Twilio::Decorators::MessagingV1::PhoneNumberFetch,
          }
          def for(body, request)
            url = request.url.split(request.host).last

            case url
            when %r{\/v1\/Services\/\w{34}\/PhoneNumbers$}
              return RESOURCES[:phone_number_list].decorate(body, request) if request.method == "GET"
              return RESOURCES[:phone_number_create].decorate(body, request) if request.method == "POST"
            when %r{\/v1\/Services\/\w{34}\/PhoneNumbers\/\w{34}}
              RESOURCES[:phone_number_fetch].decorate(body, request)
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mock-twilio-1.4 lib/mock/twilio/schemas/messaging_v1.rb
mock-twilio-1.3.2 lib/mock/twilio/schemas/messaging_v1.rb
mock-twilio-1.3.1 lib/mock/twilio/schemas/messaging_v1.rb
mock-twilio-1.3.0 lib/mock/twilio/schemas/messaging_v1.rb
mock-twilio-1.2.0 lib/mock/twilio/schemas/messaging_v1.rb
mock-twilio-1.1.0 lib/mock/twilio/schemas/messaging_v1.rb
mock-twilio-1.0.0 lib/mock/twilio/schemas/messaging_v1.rb
mock-twilio-0.8.0 lib/mock/twilio/schemas/messaging_v1.rb