Sha256: 223af9af9ba856c89de0023fc217ce847197a30bfee2deb740ae8eb3aaaf3a1a
Contents?: true
Size: 724 Bytes
Versions: 2
Compression:
Stored size: 724 Bytes
Contents
# frozen_string_literal: true module Pcli module Services class ApiManager include Depends.on('output', 'authenticate', 'api') def ensure_authenticated(&block) unless api.token return ensure_authenticated(&block) if authenticate.run(true) end response = block.call return if response === false if response.failure? && response.known_error? && response.error.type == 'unauthenticated' output.puts output.puts(Pl.dim("You've been logged out. Please log in again.")) output.puts return ensure_authenticated(&block) if authenticate.run(false) else response end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pcli-0.1.1 | lib/pcli/services/api_manager.rb |
pcli-0.1.0 | lib/pcli/services/api_manager.rb |