Sha256: be1bf666bd77c4993409a0267f8d966de0ff25c23d8e1503942a9e7cdcd6d634
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true module Mock module Twilio module Schemas class Api2010 class << self PAGES_KEYS = [ "end", "first_page_uri", "next_page_uri", "last_page_uri", "page", "page_size", "previous_page_uri", "total", "num_pages", "start", "uri" ].freeze def decorate(body, request) body["date_updated"] = Time.current.rfc2822 if body["date_updated"] body["date_sent"] = Time.current.rfc2822 if body["date_sent"] body["date_created"] = Time.current.rfc2822 if body["date_created"] body["start_time"] = Time.current.rfc2822 if body["start_time"] body["end_time"] = Time.current.rfc2822 if body["end_time"] message_sid(body, request) if body["sid"] pagination(body) if body["available_phone_numbers"] body end def pagination(body) # Params returned in mock_server but not on real twilio request for the moment. # Not needed for us now. PAGES_KEYS.each do |key| body.delete(key) if body[key] end end def message_sid(body, request) prefix = request.data["MediaUrl"] ? "MM" : "SM" sid = prefix + SecureRandom.hex(16) scheduler = Rufus::Scheduler.new scheduler.in '2s' do Mock::Twilio::Webhooks::Messages.trigger(sid) end body["sid"] = sid end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mock-twilio-0.2.0 | lib/mock/twilio/schemas/api_2010.rb |