Commit a5d14308 authored by Colin Kiama's avatar Colin Kiama

Created PostQuery subclass and helper for converting query parameter enums to API field strings

parent 06293575
using System;
using System.Collections.Generic;
using System.Text;
namespace ProductHuntAPI.Helpers
{
public sealed class QueryParameterHelper
{
private static Lazy<QueryParameterHelper> lazy = new Lazy<QueryParameterHelper>(() => new QueryParameterHelper());
public static QueryParameterHelper Instance = lazy.Value;
private QueryParameterHelper() { }
public string CreateApiFieldFromQueryParameterEnum(Enum enumToConvert)
{
string enumAsString = enumToConvert.ToString();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < enumAsString.Length; i++)
{
char charToAdd = enumAsString[i];
if (i == 0)
{
sb.Append(char.ToLower(charToAdd));
}
else
{
sb.Append(charToAdd);
}
}
return sb.ToString();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ProductHuntAPI.Model
{
public class PostQuery : Query
{
public PostQuery(string fieldName) : base(fieldName)
{
}
}
}
using ProductHuntAPI.Interfaces;
using ProductHuntAPI.Enums;
using ProductHuntAPI.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -16,8 +17,9 @@ namespace ProductHuntAPI.Model
FieldName = fieldName;
}
public Query AddParameter()
public Query AddParameter(QueryParameterName paramName, object paramValue)
{
return this;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment