don't know if this new parameter shit is user-friendly :-/
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using PocketSharp;
|
||||
using PocketSharp.Models.Authentification;
|
||||
using PocketSharp.Models.Parameters;
|
||||
|
||||
namespace PocketSharp.Console
|
||||
{
|
||||
@@ -16,7 +17,10 @@ namespace PocketSharp.Console
|
||||
PocketClient client = new PocketClient("15396-f6f92101d72c8e270a6c9bb3");
|
||||
client.AccessCode = "a85134a7-243c-6656-ab82-97c901";
|
||||
|
||||
client.Retrieve();
|
||||
client.Retrieve(new RetrieveParameters()
|
||||
{
|
||||
Favorite = true
|
||||
});
|
||||
|
||||
System.Console.ReadKey();
|
||||
}
|
||||
|
||||
@@ -4,19 +4,28 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using PocketSharp.Models.Parameters;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
public partial class PocketClient
|
||||
{
|
||||
public bool Retrieve()
|
||||
public bool Retrieve(RetrieveParameters para)
|
||||
{
|
||||
var parameters = new List<Parameter>()
|
||||
//var parameters = new List<Parameter>()
|
||||
//{
|
||||
// new Parameter { Name = "favorite", Value = "1", Type = ParameterType.GetOrPost }
|
||||
//};
|
||||
|
||||
var parameters = new RetrieveParameters()
|
||||
{
|
||||
new Parameter { Name = "favorite", Value = "1", Type = ParameterType.GetOrPost }
|
||||
Favorite = true,
|
||||
State = StateEnum.all
|
||||
};
|
||||
|
||||
Retrieve result = GetResource<Retrieve>("get", parameters);
|
||||
var paramss = parameters.Convert();
|
||||
|
||||
Retrieve result = GetResource<Retrieve>("get", parameters.Convert());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace PocketSharp.Models.Parameters
|
||||
{
|
||||
public abstract class ParameterBase
|
||||
{
|
||||
protected Parameter CreateParam(string name, object value, ParameterType type = ParameterType.GetOrPost)
|
||||
{
|
||||
return new Parameter()
|
||||
{
|
||||
Name = name,
|
||||
Value = value,
|
||||
Type = type
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PocketSharp.Models.Parameters
|
||||
{
|
||||
public class RetrieveParameters : ParameterBase
|
||||
{
|
||||
public StateEnum? State { get; set; }
|
||||
|
||||
public bool? Favorite { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
|
||||
public ContentTypeEnum? ContentType { get; set; }
|
||||
|
||||
public SortEnum? Sort { get; set; }
|
||||
|
||||
|
||||
public List<Parameter> Convert()
|
||||
{
|
||||
List<Parameter> parameters = new List<Parameter>();
|
||||
|
||||
if(State != null)
|
||||
{
|
||||
parameters.Add(CreateParam("state", State.ToString()));
|
||||
}
|
||||
if(Favorite != null)
|
||||
{
|
||||
parameters.Add(CreateParam("favorite", (bool)Favorite ? "1" : "0"));
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum StateEnum
|
||||
{
|
||||
unread,
|
||||
archive,
|
||||
all
|
||||
}
|
||||
|
||||
public enum SortEnum
|
||||
{
|
||||
newest,
|
||||
oldest,
|
||||
title,
|
||||
site
|
||||
}
|
||||
|
||||
public enum ContentTypeEnum
|
||||
{
|
||||
article,
|
||||
video,
|
||||
image
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,8 @@
|
||||
<Compile Include="JsonDeserializer.cs" />
|
||||
<Compile Include="Models\Authentification\AccessCode.cs" />
|
||||
<Compile Include="Models\Authentification\RequestCode.cs" />
|
||||
<Compile Include="Models\Parameters\ParameterBase.cs" />
|
||||
<Compile Include="Models\Parameters\RetrieveParameters.cs" />
|
||||
<Compile Include="Models\PocketItem.cs" />
|
||||
<Compile Include="Models\ResponseBase.cs" />
|
||||
<Compile Include="Models\Retrieve.cs" />
|
||||
|
||||
Reference in New Issue
Block a user