Sha256: e24056a0f3f9973cd4a12b65111ce3ae5595a1b60bc10ed6c2191b6c2873b9b6

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module Mock
  module Twilio
    module Decorators
      module CustomerProfilesV1
        class CustomerProfile
          class << self
            def decorate(body, request)
              body["date_updated"] = Time.current.rfc2822 if body["date_updated"]
              body["date_created"] = Time.current.rfc2822 if body["date_created"]
              customer_profile_sid(body, request) if body["sid"]
              body["account_sid"] = ::Twilio.account_sid if body["account_sid"]
              body["friendly_name"] = request.data["FriendlyName"] if body["friendly_name"]
              body["email"] = request.data["Email"] if body["email"]
              body["policy_sid"] = request.data["PolicySid"] if body["policy_sid"]
              body["status_callback"] = request.data["StatusCallback"] if body["status_callback"]
              body["status"] = "in-review" if body["status"]

              body
            end

            def customer_profile_sid(body, request)
              prefix = "BU"
              sid = prefix + SecureRandom.hex(16)
              scheduler = Rufus::Scheduler.new
              scheduler.in '2s' do
                Mock::Twilio::Webhooks::CustomerProfiles.trigger(sid, "in-review")
              end
              body["sid"] = sid
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mock-twilio-0.7.2 lib/mock/twilio/decorators/customer_profiles_v1/customer_profile.rb
mock-twilio-0.7.1 lib/mock/twilio/decorators/customer_profiles_v1/customer_profile.rb
mock-twilio-0.7.0 lib/mock/twilio/decorators/customer_profiles_v1/customer_profile.rb
mock-twilio-0.6.0 lib/mock/twilio/decorators/customer_profiles_v1/customer_profile.rb
mock-twilio-0.5.0 lib/mock/twilio/decorators/customer_profiles_v1/customer_profile.rb
mock-twilio-0.4.0 lib/mock/twilio/decorators/customer_profiles_v1/customer_profile.rb