Sha256: 290009dd43019929e8e00fce9972bc020f99147ea388cc7e06f3201ec40bb576
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
# frozen_string_literal: true require 'json' module Diffend # Module responsible for fetching diffend verdict on local context module RequestVerdict class << self # @param command [String] either install or update # @param definition [Bundler::Definition] definition for your source # @param config [OpenStruct] diffend config def call(command, config, definition) payload = Diffend::LocalContext.call(command, config.project_id, definition) response = Diffend::Request.call( build_request_object(command, config, payload) ) JSON.parse(response.body) rescue Bundler::GemNotFound raise ::Diffend::Errors::DependenciesResolveException rescue StandardError => e Diffend::HandleErrors::Report.call( exception: e, payload: payload || {}, config: config, message: :unhandled_exception, report: true ) end # @param command [String] either install or update # @param config [OpenStruct] diffend config # @param payload [Hash] # # @return [Diffend::RequestObject] def build_request_object(command, config, payload) Diffend::RequestObject.new( config: config, url: commands_url(command, config.project_id), payload: payload, request_method: :post ) end # Provides diffend command endpoint url # # @param command [String] either install or update # @param project_id [String] diffend project_id # # @return [String] diffend endpoint def commands_url(command, project_id) return ENV['DIFFEND_COMMAND_URL'] if ENV.key?('DIFFEND_COMMAND_URL') "https://my.diffend.io/api/projects/#{project_id}/bundle/#{command}" end end end end
Version data entries
4 entries across 4 versions & 2 rubygems