Sha256: b772d155a3ee373b0b06b02bde2ac40b44e8eecf6cd6f17f0c57153d60cdf24b

Contents?: true

Size: 833 Bytes

Versions: 5

Compression:

Stored size: 833 Bytes

Contents

module XporterOnDemand
  class Token < Client
    def initialize(*args)
      @loaded = false
      @options = args.last.is_a?(Hash) ? args.pop : {}
      @options[:url] ||= STS_PATH

      @request_body = {}
      %w(estab relyingParty password thirdpartyid).each_with_index{ |k, i| @request_body[k] = args[i] }

      @request_body["thirdpartyid"] ||= "XporterOnDemand"
      raise ArgumentError, "must supply all the sniz" unless @request_body.none?{ |k, v| v.nil? }
    end

    def retrieve
      result = post(@options.merge(body: @request_body.to_json))
      assign_attributes(result)
      @loaded =  true
      self
    end

    def validate
      dont_raise_exception{ retrieve }

      if token
        :valid
      elsif try(:authorisation_paused)
        :paused
      else
        :invalid
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
xporter_on_demand-0.2.4 lib/xporter_on_demand/token.rb
xporter_on_demand-0.2.3 lib/xporter_on_demand/token.rb
xporter_on_demand-0.2.2 lib/xporter_on_demand/token.rb
xporter_on_demand-0.2.1 lib/xporter_on_demand/token.rb
xporter_on_demand-0.2.0 lib/xporter_on_demand/token.rb