public static IServiceCollection AddTransipApi(this IServiceCollection services, Action <TransipApiOptions> options) { var opt = new TransipApiOptions(); options.Invoke(opt); services.AddSingleton <ITransipApi, TransipApi>((servicePrivider) => new TransipApi(opt)); return(services); }
public TransipBaseApi(TransipApiOptions options) { _options = options; ValidateOptions(_options); _client = new HttpClient { BaseAddress = new Uri(TransipConstants.BaseUrl) }; CheckRegistryValues(); }
private void ValidateOptions(TransipApiOptions options) { if (!options.HasPrivateKeyPath) { throw new Exception("Private key path is not set"); } if (!File.Exists(options.PrivateKeyPath)) { throw new FileNotFoundException($"Private key file is not found in: {options.PrivateKeyPath}"); } }
public TransipApi(TransipApiOptions options) : base(options) { }