Sha256: 7659aad1086b89678e77bec7728cb409a7c203626f90fddd5940bfb6090ddfb7

Contents?: true

Size: 1.95 KB

Versions: 4

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

require_relative "../decorators/customer_profiles_v1/customer_profile"
require_relative "../decorators/customer_profiles_v1/entity_assignments"
require_relative "../decorators/customer_profiles_v1/evaluations"
require_relative "../decorators/customer_profiles_v1/customer_profile_update"
require_relative "../decorators/customer_profiles_v1/channel_endpoint_assignments"

module Mock
  module Twilio
    module Schemas
      class CustomerProfilesV1
        class << self
          RESOURCES = {
            customer_profile: Mock::Twilio::Decorators::CustomerProfilesV1::CustomerProfile,
            entity_assigments: Mock::Twilio::Decorators::CustomerProfilesV1::EntityAssignments,
            evaluations: Mock::Twilio::Decorators::CustomerProfilesV1::Evaluations,
            customer_profile_update: Mock::Twilio::Decorators::CustomerProfilesV1::CustomerProfileUpdate,
            channel_endpoint_assignments: Mock::Twilio::Decorators::CustomerProfilesV1::ChannelEndpointAssignments,
          }

          def for(body, request)
            url = request.url.split(request.host).last

            case url
            when %r{/v1/CustomerProfiles$}
              RESOURCES[:customer_profile].decorate(body, request)
            when %r{/v1/CustomerProfiles/[A-Za-z0-9]+/EntityAssignments}
              RESOURCES[:entity_assigments].decorate(body, request)
            when %r{/v1/CustomerProfiles/[A-Za-z0-9]+/Evaluations}
              RESOURCES[:evaluations].decorate(body, request)
            when %r{/v1/CustomerProfiles/[A-Za-z0-9]+/ChannelEndpointAssignments}
              if request.method.downcase == 'get'
                RESOURCES[:channel_endpoint_assignments].decorate(body, request)
              else
                body
              end
            when %r{/v1/CustomerProfiles/[A-Za-z0-0]+}
              RESOURCES[:customer_profile_update].decorate(body, request)
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mock-twilio-1.4 lib/mock/twilio/schemas/customer_profiles_v1.rb
mock-twilio-1.3.2 lib/mock/twilio/schemas/customer_profiles_v1.rb
mock-twilio-1.3.1 lib/mock/twilio/schemas/customer_profiles_v1.rb
mock-twilio-1.3.0 lib/mock/twilio/schemas/customer_profiles_v1.rb