Created
June 9, 2022 11:05
-
-
Save amunim/f5e4e2faed6bbda611c70d7e14931738 to your computer and use it in GitHub Desktop.
Import all Flagsmith flags as enum with description
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#@ template debug="false" hostspecific="true" language="C#" #> | |
<#@ output extension=".cs" #> | |
<#@ assembly name="System.Net.Http" #> | |
<#@ assembly name="System.Core" #> | |
<#@ assembly name="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" #> | |
<#@ assembly name="Newtonsoft.Json" #> | |
<#@ assembly name="Microsoft.CSharp" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ import namespace="System.Net.Http" #> | |
<#@ import namespace="Newtonsoft.Json.Linq" #> | |
namespace YOURNAMESPACE | |
{ | |
public enum AllFlags | |
{ | |
<# | |
HttpClient client = new HttpClient(); | |
HttpRequestMessage msg = new HttpRequestMessage(new HttpMethod("GET"), "https://api.flagsmith.com/api/v1/flags/"); | |
msg.Headers.Add("X-Environment-Key", "XXXXXXXXXXXX"); //replace with your environment key | |
var result = client.SendAsync(msg).Result.Content.ReadAsStringAsync().Result; | |
dynamic obj = JArray.Parse(result); | |
foreach(var flag in obj) | |
{ | |
#> | |
<# if(!string.IsNullOrEmpty((string)flag.feature.description)) | |
{ | |
#> | |
///<summary> | |
/// <#= flag.feature.description #> | |
///</summary> | |
<# | |
} | |
#> | |
<#= flag.feature.name #>, | |
<# | |
} | |
#> | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment