roadie/Roadie.Api.Library/Configuration/Integrations.cs

142 lines
4.6 KiB
C#
Raw Normal View History

2018-11-04 20:33:37 +00:00
using System.Collections.Generic;
2018-11-02 21:04:49 +00:00
using System.Diagnostics;
using System.Linq;
2018-11-04 20:33:37 +00:00
namespace Roadie.Library.Configuration
2018-11-02 21:04:49 +00:00
{
public class Integrations
{
2018-11-04 20:33:37 +00:00
private string _discogsConsumerKey = null;
private string _discogsConsumerSecret = null;
2018-11-02 21:04:49 +00:00
private bool _discogsEnabled = true;
private string _lastFMApiKey = null;
2018-11-04 20:33:37 +00:00
private bool _lastFmEnabled = true;
2018-11-02 21:04:49 +00:00
private string _lastFMSecret = null;
2018-11-04 20:33:37 +00:00
public List<ApiKey> ApiKeys { get; set; }
2018-11-02 21:04:49 +00:00
2018-11-04 20:33:37 +00:00
public string DiscogsConsumerKey
2018-11-02 21:04:49 +00:00
{
get
{
2018-11-04 20:33:37 +00:00
if (string.IsNullOrEmpty(this._discogsConsumerKey))
2018-11-02 21:04:49 +00:00
{
2018-11-04 20:33:37 +00:00
var keySetting = this.ApiKeys.FirstOrDefault(x => x.ApiName == "DiscogsConsumerKey");
if (keySetting != null)
{
this._discogsConsumerKey = keySetting.Key;
this._discogsConsumerSecret = keySetting.KeySecret;
}
else
{
Trace.WriteLine("Unable To Find Api Key with Key Name of 'DiscogsConsumerKey', Discogs Integration Disabled");
}
2018-11-02 21:04:49 +00:00
}
2018-11-04 20:33:37 +00:00
return this._discogsConsumerKey;
2018-11-02 21:04:49 +00:00
}
}
2018-11-04 20:33:37 +00:00
public string DiscogsConsumerSecret
2018-11-02 21:04:49 +00:00
{
get
{
2018-11-04 20:33:37 +00:00
if (string.IsNullOrEmpty(this._discogsConsumerSecret))
2018-11-02 21:04:49 +00:00
{
2018-11-04 20:33:37 +00:00
var keySetting = this.ApiKeys.FirstOrDefault(x => x.ApiName == "DiscogsConsumerKey");
if (keySetting != null)
{
this._discogsConsumerKey = keySetting.Key;
this._discogsConsumerSecret = keySetting.KeySecret;
}
else
{
Trace.WriteLine("Unable To Find Api Key with Key Name of 'DiscogsConsumerKey', Discogs Integration Disabled");
}
2018-11-02 21:04:49 +00:00
}
2018-11-04 20:33:37 +00:00
return this._discogsConsumerSecret;
2018-11-02 21:04:49 +00:00
}
}
2018-11-04 20:33:37 +00:00
public bool DiscogsProviderEnabled
2018-11-02 21:04:49 +00:00
{
get
{
2018-11-04 20:33:37 +00:00
if (string.IsNullOrEmpty(this.DiscogsConsumerKey) || string.IsNullOrEmpty(this.DiscogsConsumerSecret))
2018-11-02 21:04:49 +00:00
{
2018-11-04 20:33:37 +00:00
return false;
2018-11-02 21:04:49 +00:00
}
2018-11-04 20:33:37 +00:00
return this._discogsEnabled;
2018-11-02 21:04:49 +00:00
}
2018-11-04 20:33:37 +00:00
set
2018-11-02 21:04:49 +00:00
{
2018-11-04 20:33:37 +00:00
this._discogsEnabled = value;
2018-11-02 21:04:49 +00:00
}
}
public short? DiscogsReadWriteTimeout { get; set; }
2018-11-04 20:33:37 +00:00
2018-11-02 21:04:49 +00:00
public short? DiscogsTimeout { get; set; }
public bool ITunesProviderEnabled { get; set; }
2018-11-04 20:33:37 +00:00
public string LastFMApiKey
2018-11-02 21:04:49 +00:00
{
get
{
2018-11-04 20:33:37 +00:00
if (string.IsNullOrEmpty(this._lastFMApiKey))
2018-11-02 21:04:49 +00:00
{
2018-11-04 20:33:37 +00:00
var keySetting = this.ApiKeys.FirstOrDefault(x => x.ApiName == "LastFMApiKey");
if (keySetting != null)
{
this._lastFMApiKey = keySetting.Key;
this._lastFMSecret = keySetting.KeySecret;
}
else
{
Trace.WriteLine("Unable To Find Api Key with Key Name of 'LastFMApiKey', Last FM Integration Disabled");
}
2018-11-02 21:04:49 +00:00
}
2018-11-04 20:33:37 +00:00
return this._lastFMApiKey;
2018-11-02 21:04:49 +00:00
}
2018-11-04 20:33:37 +00:00
}
public string LastFmApiSecret
{
get
2018-11-02 21:04:49 +00:00
{
2018-11-04 20:33:37 +00:00
if (string.IsNullOrEmpty(this._lastFMSecret))
{
var keySetting = this.ApiKeys.FirstOrDefault(x => x.ApiName == "LastFMApiKey");
if (keySetting != null)
{
this._lastFMApiKey = keySetting.Key;
this._lastFMSecret = keySetting.KeySecret;
}
else
{
Trace.WriteLine("Unable To Find Api Key with Key Name of 'LastFMApiKey', Last FM Integration Disabled");
}
}
return this._lastFMSecret;
2018-11-02 21:04:49 +00:00
}
}
public bool LastFmProviderEnabled
{
get
{
if (string.IsNullOrEmpty(this.LastFMApiKey) || string.IsNullOrEmpty(this.LastFmApiSecret))
{
return false;
}
return this._lastFmEnabled;
}
set
{
this._lastFmEnabled = value;
}
}
2018-11-04 20:33:37 +00:00
public bool MusicBrainzProviderEnabled { get; set; }
public bool SpotifyProviderEnabled { get; set; }
2018-11-02 21:04:49 +00:00
}
2018-11-04 20:33:37 +00:00
}