Skip to content

Commit

Permalink
Add JSON deserialization to Settings class
Browse files Browse the repository at this point in the history
  • Loading branch information
condemil committed Feb 18, 2019
1 parent a865824 commit c6e2ea2
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions Bynder/Api/Settings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Bynder. All rights reserved.
// Copyright (c) Bynder. All rights reserved.
// Licensed under the MIT License. See LICENSE file in the project root for full license information.

using Newtonsoft.Json;
using System.IO;

namespace Bynder.Api
{
/// <summary>
Expand All @@ -11,26 +14,41 @@ public class Settings
/// <summary>
/// Oauth Consumer key
/// </summary>
[JsonProperty("consumer_key")]
public string CONSUMER_KEY { get; set; }

/// <summary>
/// Oauth Consumer secret
/// </summary>
[JsonProperty("consumer_secret")]
public string CONSUMER_SECRET { get; set; }

/// <summary>
/// Oauth token
/// Oauth token
/// </summary>
[JsonProperty("token")]
public string TOKEN { get; set; }

/// <summary>
/// Oauth secret
/// Oauth secret
/// </summary>
[JsonProperty("token_secret")]
public string TOKEN_SECRET { get; set; }

/// <summary>
/// Bynder domain Url we want to communicate with
/// </summary>
[JsonProperty("api_base_url")]
public string URL { get; set; }

/// <summary>
/// Create a <see cref="Settings"/> using the given filepath
/// </summary>
/// <param name="filepath">JSON file path</param>
/// <returns><see cref="Settings"/> instance</returns>
public static Settings FromJson(string filepath)
{
return JsonConvert.DeserializeObject<Settings>(File.ReadAllText(filepath));
}
}
}

0 comments on commit c6e2ea2

Please sign in to comment.