Sha256: 91f57624ac788e1ebf71badc2598c1f951ffb42ed68db11db5cb41d28f7e6cbe
Contents?: true
Size: 1.24 KB
Versions: 3
Compression:
Stored size: 1.24 KB
Contents
module Socialcast module CommandLine class Authenticate attr_accessor :authenticate_type, :options, :params, :headers def initialize(authenticate_type, options, params, headers = {}) self.authenticate_type = authenticate_type self.options = options self.params = params self.headers = headers end def request @request ||= send_request end private def send_request puts "Authenticating to #{url}" RestClient.log = Logger.new($stdout) if options[:trace] RestClient.proxy = options[:proxy] if options[:proxy] resource = RestClient::Resource.new url, headers response = resource.post params, :accept => :json puts "API response: #{response.body.to_s}" if options[:trace] set_default_credentials response end def set_default_credentials Socialcast::CommandLine.credentials = { :domain => domain, :proxy => options[:proxy] } end def url @url ||= File.join("https://", domain, 'api', (authenticate_type == :external_system ? 'external_systems/' : ''), 'authentication') end def domain options[:domain] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
socialcast-1.3.9 | lib/socialcast/command_line/authenticate.rb |
socialcast-1.3.8 | lib/socialcast/command_line/authenticate.rb |
socialcast-1.3.7 | lib/socialcast/command_line/authenticate.rb |