class Blockmason::Link::ManagedSession

Public Class Methods

new(session:) click to toggle source
# File lib/blockmason/link/managed_session.rb, line 6
def initialize(session:)
  @session = session
end

Public Instance Methods

get(path, inputs) click to toggle source
# File lib/blockmason/link/managed_session.rb, line 23
def get(path, inputs)
  begin
    @session.get(path, inputs)
  rescue error
    if error["errors"].any? { |it| it['detail'] =~ /Authentication failed/ }
      @session = @session.refresh!
      @session.get(path, inputs)
    else
      raise error
    end
  end
end
post(path, inputs) click to toggle source
# File lib/blockmason/link/managed_session.rb, line 10
def post(path, inputs)
  begin
    @session.post(path, inputs)
  rescue error
    if error["errors"].any? { |it| it['detail'] =~ /Authentication failed/ }
      @session = @session.refresh!
      @session.post(path, inputs)
    else
      raise error
    end
  end
end