Sha256: 50f1091a591932e70e5cb5a94693ccb13a2dcf51ac4db4e0a08b689e4b0059dd

Contents?: true

Size: 1.21 KB

Versions: 6

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Mock
  module Twilio
    module Webhooks
      class CustomerProfiles < Base
        URL = "/webhooks/twilio/customer_profiles_compliance"

        def self.trigger(sid, status)
          # Wait simulation from twilio
          sleep DELAY.sample

          request_url = Mock::Twilio.proto + "://" + Mock::Twilio.forwarded_host + URL

          data = { :BundleSid=>sid, :Status=>status }

          signature = build_signature_for_request(request_url, data)

          response = webhook_client.request(Mock::Twilio.host,
                                            Mock::Twilio.port,
                                            'POST',
                                            URL,
                                            nil,
                                            data,
                                            headers.merge!({ 'X-Twilio-Signature': signature }),
                                            auth_twilio,
                                            nil)
          case response.status
          when 200..204
            response
          when 400..600
            raise Webhooks::RestError, response.body
          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/webhooks/customer_profiles.rb
mock-twilio-0.7.1 lib/mock/twilio/webhooks/customer_profiles.rb
mock-twilio-0.7.0 lib/mock/twilio/webhooks/customer_profiles.rb
mock-twilio-0.6.0 lib/mock/twilio/webhooks/customer_profiles.rb
mock-twilio-0.5.0 lib/mock/twilio/webhooks/customer_profiles.rb
mock-twilio-0.4.0 lib/mock/twilio/webhooks/customer_profiles.rb