Sha256: 82cf3cc8e820694baacfde059ef48c4c30758bf57fe8b5e6af239a9894d7f4cb

Contents?: true

Size: 796 Bytes

Versions: 2

Compression:

Stored size: 796 Bytes

Contents

module Stackify::Authorizable
  class AuthorizationClient < Stackify::HttpClient

    BASE_URI = URI("#{Stackify.configuration.base_api_url}/Metrics/IdentifyApp")

    def initialize
      super
      @worker = Stackify::AuthWorker.new
    end

    def auth attempts, delay_time= 20
      task = auth_task attempts
      @worker.perform delay_time, task
    end

    def auth_task attempts
      properties = {
        limit: 1,
        attempts: attempts,
        success_condition: lambda do |result|
          result.try(:code) == '200'
        end
      }
      Stackify::ScheduleTask.new properties do
        Stackify.internal_log :debug, 'AthorizationClient: trying to athorize...'
        send_request BASE_URI, Stackify::EnvDetails.instance.auth_info.to_json
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stackify-api-ruby-1.0.2 lib/stackify/authorization/authorization_client.rb
stackify-api-ruby-1.0.1 lib/stackify/authorization/authorization_client.rb