4chan command - the beginning

This commit is contained in:
Runebaas 2017-05-07 22:45:16 +02:00
parent 8703a64556
commit fd7ea886d4
3 changed files with 101 additions and 0 deletions

View 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; }
}
}
}

View 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;
}
}
}