Sha256: 058681379b4f731e0080d42b74e96ebb758bdc53daec4bdd5885a8b36d05089e

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Mock
  module Twilio
    module Decorators
      module CustomerProfilesV1
        class EntityAssignments
          class << self
            def decorate(body, request)
              body["date_created"] = Time.current.rfc2822 if body["date_created"]
              entity_sid(body, request) if body["sid"]
              body["account_sid"] = ::Twilio.account_sid
              body["object_sid"] = request.data["ObjectSid"]
              parse_customer_profile_sid(body, request) if body["customer_profile_sid"]

              body
            end

            def entity_sid(body, request)
              prefix = "BV"
              sid = prefix + SecureRandom.hex(16)
              body["sid"] = sid
            end

            def parse_customer_profile_sid(body, request)
              uri = URI(request.url)
              customer_profile_sid = uri.path.split('/')[3].split('.').first
              body["customer_profile_sid"] = customer_profile_sid
            end
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mock-twilio-1.4 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-1.3.2 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-1.3.1 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-1.3.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-1.2.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-1.1.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-1.0.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-0.8.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-0.7.2 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-0.7.1 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-0.7.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-0.6.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-0.5.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb
mock-twilio-0.4.0 lib/mock/twilio/decorators/customer_profiles_v1/entity_assignments.rb