...
 
Commits (5)
......@@ -6,13 +6,15 @@ import std.process;
import devto.api;
@safe:
void main()
{
requestHTTP("https://dev.to/api/articles/me/all",
(scope req) {
(scope req) @safe {
req.headers.addField("api-key", environment["appkey"]);
},
(scope res) {
(scope res) @safe {
logInfo("Response: %d", res.statusCode);
if(res.statusCode != 200)
return;
......
......@@ -199,7 +199,7 @@ out(path) {
* articles = Build from call to `structureArticles()`
* folder = Filesystem folder location to place articles
*
* See Also:
* See_Also:
* structureArticles, Article, articleContentFolder
*/
@safe
......
......@@ -7,6 +7,11 @@ import vibe.data.json;
import devto.api;
version(unittest) {
import unittesting.articlegenerator;
import std.algorithm : map, until, equal;
}
/**
* Provides information about the last execution to pull.
*
......@@ -20,16 +25,25 @@ struct PullState {
}
auto isNewerArticle(ArticleMe am, PullState ps) {
return null;
return am.id > ps.lastArticle;
} unittest {
import unittesting.articlegenerator;
import std.algorithm : map, filter;
PullState ps;
ps.datePulled = SysTime(DateTime(2018, 1, 1, 10, 30, 0), UTC());
ps.lastArticle = 10_000;
alias inPreviousPull = (x) => !x.isNewerArticle(ps);
auto devreq = generate!fakeArticleMe
.seqence(ps.datePulled)
.map!(x => x.deserializeJson!(ArticleMe))
.take(3);
assert(devreq.until!inPreviousPull.empty);
} unittest {
PullState ps;
ps.datePulled = SysTime(DateTime(2018, 1, 1, 10, 30, 0), UTC());
ps.lastArticle = 9_999;
alias inPreviousPull = (x) => !x.isNewerArticle(ps);
auto devreq = generate!fakeArticleMe
.seqence(ps.datePulled)
.map!(x => x.deserializeJson!(ArticleMe))
.take(3);
assert(devreq.filter!(x => x.isNewerArticle(ps)).empty);
assert(devreq.until!inPreviousPull.map!(x => x.id).equal([10_000]));
}