Sha256: 4d229039f02bc34f1dc335601f279abe58b4bc673bad6923600df7a1a71c53ae

Contents?: true

Size: 886 Bytes

Versions: 8

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

module Mock
  module Twilio
    module Decorators
      module TrustProductsV1
        class Update
          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"]

              trust_product_sid(body) if body["sid"]
              body["account_sid"] = ::Twilio.account_sid if body["account_sid"]

              body["status"] = request.data["Status"] if body["status"]
              body["valid_until"] = nil if body["valid_until"]

              body
            end

            def trust_product_sid(body)
              prefix = "BU"
              sid = prefix + SecureRandom.hex(16)
              body["sid"] = sid
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mock-twilio-1.4 lib/mock/twilio/decorators/trust_products_v1/update.rb
mock-twilio-1.3.2 lib/mock/twilio/decorators/trust_products_v1/update.rb
mock-twilio-1.3.1 lib/mock/twilio/decorators/trust_products_v1/update.rb
mock-twilio-1.3.0 lib/mock/twilio/decorators/trust_products_v1/update.rb
mock-twilio-1.2.0 lib/mock/twilio/decorators/trust_products_v1/update.rb
mock-twilio-1.1.0 lib/mock/twilio/decorators/trust_products_v1/update.rb
mock-twilio-1.0.0 lib/mock/twilio/decorators/trust_products_v1/update.rb
mock-twilio-0.8.0 lib/mock/twilio/decorators/trust_products_v1/update.rb