Sha256: eb0b80ea61bdfb0904a92a0549d53763d1a7f9683d5543c018e1975810ea1a57

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

module RelayApiClient
  class Base

    def self.client
      @client ||= Savon.client(wsdl: RelayApiClient.wsdl)
    end

    # returns a guid or nil
    def self.create_account(username, password, first_name, last_name)
      password = password.gsub('&', '&amp;').gsub('<', '&lt;').gsub('>','&gt;').gsub("'", "&apos;").gsub("\"", "&quot;")
      begin
        response = client.call(:signup, message: {username: username, password: password, passwordConfirm: password, firstName: first_name, lastName: last_name})

        h = response.to_hash

        if response.success?
          puts h.inspect
          return h[:signup_response][:user][:id]
        else
          case h[:fault][:faultstring]
          when "password does not meet with policy requirements."
            raise h[:fault][:faultstring]
          else
            logger.debug response.inspect
          end
        end
      rescue => e
        if e.message == "(S:Client) user already exists"
          # check identity linking
          if RelayApiClient.linker_username &&
             RelayApiClient.linker_password &&
             l = IdentityLinker::Linker.find_linked_identity('username',username,'ssoguid')
            return l[:identity][:id_value]
          end
        else
          raise
        end
      end

      nil
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relay_api_client-0.0.2 lib/relay_api_client/base.rb