Sha256: 03c6b83fb34b19bdf8f39e447d15a3ff8023284398c0376949438c603930a3b7
Contents?: true
Size: 1.44 KB
Versions: 8
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true module Mock module Twilio module Decorators module CustomerProfilesV1 class CustomerProfileUpdate 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"] parse_customer_profile_sid(body, request) if body["sid"] body["account_sid"] = ::Twilio.account_sid if body["account_sid"] # Usually from pending-review to in-review body["status"] = request.data["Status"] if body["status"] body end def parse_customer_profile_sid(body, request) uri = URI(request.url) customer_profile_sid = uri.path.split('/')[3].split('.').first scheduler = Rufus::Scheduler.new scheduler.in '2s' do begin response = Mock::Twilio::Webhooks::CustomerProfiles.trigger(customer_profile_sid, "in-review") if response.status == 200 Mock::Twilio::Webhooks::CustomerProfiles.trigger(customer_profile_sid, "twilio-approved") end rescue => e puts e end end body["sid"] = customer_profile_sid end end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems