4chan command - the beginning
This commit is contained in:
parent
8703a64556
commit
fd7ea886d4
3 changed files with 101 additions and 0 deletions
20
Geekbot.net/Lib/Dtos/FourChanDto.cs
Normal file
20
Geekbot.net/Lib/Dtos/FourChanDto.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Geekbot.net.Lib.Dtos
|
||||
{
|
||||
class FourChanDto
|
||||
{
|
||||
public class BoardList
|
||||
{
|
||||
public List<Board> Boards { get; set; }
|
||||
}
|
||||
|
||||
public class Board
|
||||
{
|
||||
public string board { get; set; }
|
||||
public string title { get; set; }
|
||||
public string ws_board { get; set; }
|
||||
public string meta_description { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
38
Geekbot.net/Lib/IClients/FourChanBoardClient.cs
Normal file
38
Geekbot.net/Lib/IClients/FourChanBoardClient.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Geekbot.net.Lib.Dtos.FourChanDto;
|
||||
|
||||
namespace Geekbot.net.Lib.IClients
|
||||
{
|
||||
|
||||
class FourChanBoardClient
|
||||
{
|
||||
private BoardList boards;
|
||||
private static FourChanBoardClient instace;
|
||||
|
||||
private FourChanBoardClient()
|
||||
{
|
||||
Console.WriteLine("Fetching Boards");
|
||||
var boardClient = new RestClient("https://a.4cdn.org");
|
||||
var boardRequest = new RestRequest("boards.json", Method.GET);
|
||||
var boardResult = boardClient.Execute<BoardList>(boardRequest);
|
||||
this.boards = boardResult.Data;
|
||||
}
|
||||
|
||||
public static FourChanBoardClient Boards()
|
||||
{
|
||||
if (instace == null)
|
||||
{
|
||||
instace = new FourChanBoardClient();
|
||||
}
|
||||
|
||||
return instace;
|
||||
}
|
||||
|
||||
public List<Board> getBoards()
|
||||
{
|
||||
return this.boards.Boards;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue