Sha256: 07ab4464784e76978613986ff183db58b07608e4280471fbcadd56fa31b2199f

Contents?: true

Size: 959 Bytes

Versions: 4

Compression:

Stored size: 959 Bytes

Contents

module ForestLiana
  class PermissionsGetter < ForestApiRequester
    def initialize
      @uri = URI.parse("#{forest_api_url}/liana/v1/permissions")
    end

    def perform
      perform_request
    rescue => exception
      FOREST_LOGGER.error "Cannot retrieve the permissions for the project you\'re trying to unlock. Forest API seems to be down right now."
      FOREST_LOGGER.error exception
      nil
    end

    private

    def handle_service_response(response)
      if response.is_a?(Net::HTTPOK)
        JSON.parse(response.body)
      elsif response.is_a?(Net::HTTPNotFound) || response.is_a?(Net::HTTPUnprocessableEntity)
        FOREST_LOGGER.error "Cannot retrieve the permissions from the Forest server. Can you check that you properly set up the forest_env_secret?"
        nil
      else
        FOREST_LOGGER.error "Cannot retrieve the data from the Forest server. An error occured in Forest API."
        nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
forest_liana-2.8.3 app/services/forest_liana/permissions_getter.rb
forest_liana-2.8.2 app/services/forest_liana/permissions_getter.rb
forest_liana-2.8.1 app/services/forest_liana/permissions_getter.rb
forest_liana-2.8.0 app/services/forest_liana/permissions_getter.rb