Sha256: 165c0d1b8547df12a73eb0a91ede19ed33653a20db4e9f911e1aae95a60383d9

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

module VIISP
  module Auth
    module Requests
      class Ticket
        include Soap
        include Signature

        NODE_ID = 'uniqueNodeId'

        def initialize(providers: nil, attributes: nil, user_information: nil, postback_url: nil,
                       custom_data: '')
          @providers = providers || configuration.providers
          @attributes = attributes || configuration.attributes
          @user_information = user_information || configuration.user_information
          @postback_url = postback_url || configuration.postback_url
          @custom_data = custom_data
        end

        def build
          builder = Nokogiri::XML::Builder.new do |builder|
            soap_envelope(builder) do
              build_request(builder)
            end
          end

          builder.doc
        end

        private

        def build_request(builder)
          builder[:authentication].authenticationRequest(id: NODE_ID) do
            builder.pid(configuration.pid)

            @providers.each do |provider|
              builder.authenticationProvider(provider)
            end

            @attributes.each do |attribute|
              builder.authenticationAttribute(attribute)
            end

            @user_information.each do |val|
              builder.userInformation(val)
            end

            builder.postbackUrl(@postback_url)
            builder.customData(@custom_data)

            build_signature(builder, NODE_ID)
          end
        end

        def configuration
          Auth.configuration
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
viisp-auth-custom-0.1.0 lib/viisp/auth/requests/ticket.rb