pastemyst-d 1.0.0

an api wrapper for pastemyst


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

pastemyst-d

pastemyst api wrapper written in D

data

@("getting a language by name")
unittest
{
    assert(getLanguageByName("non existing lang").isNull());
    assert(getLanguageByName("asdasdasd").isNull());

    const lang = getLanguageByName("d").get();

    assert(lang.name == "D");
}

@("getting a language by extension")
unittest
{
    assert(getLanguageByExtension("brokey").isNull());

    const lang = getLanguageByExtension("d").get();

    assert(lang.name == "D");
}

time

@("converting expires in value")
unittest
{
    assert(getExpiresInToUnixTime(1_588_441_258, ExpiresIn.oneWeek) == 1_589_046_058);
}

user

@("user exists")
unittest
{
    assert(userExists("codemyst"));
}

@("getting a user")
unittest
{
    assert(getUser("codemyst").get().publicProfile);
}

paste

@("getting a paste")
unittest
{
    const paste = getPaste("cwy615yg").get();

    assert(paste.title == "DONT DELETE - api example");
}

@("creating a paste")
unittest
{
    const pastyCreateInfo = PastyCreateInfo("pasty1", "plain text", "asd asd asd");

    const createInfo = PasteCreateInfo("api test paste",
            ExpiresIn.never,
            false,
            false,
            "",
            [pastyCreateInfo]);

    const paste = createPaste(createInfo);

    assert(paste.title == createInfo.title);
}

@("creating a private paste")
unittest
{
    import std.process : environment;

    const token = environment.get("TOKEN");

    const pastyCreateInfo = PastyCreateInfo("pasty1", "plain text", "asd asd asd");

    const createInfo = PasteCreateInfo("api test paste",
            ExpiresIn.never,
            true,
            false,
            "",
            [pastyCreateInfo]);

    const paste = createPaste(createInfo, token);

    assert(paste.isPrivate);
}

@("deleting a paste")
unittest
{
    import std.process : environment;

    const token = environment.get("TOKEN");

    const pastyCreateInfo = PastyCreateInfo("pasty1", "plain text", "asd asd asd");

    const createInfo = PasteCreateInfo("api test paste",
            ExpiresIn.never,
            false,
            false,
            "",
            [pastyCreateInfo]);

    const paste = createPaste(createInfo, token);

    deletePaste(paste.id, token);

    assert(getPaste(paste.id, token).isNull());
}

@("editing a paste")
unittest
{
    import std.process : environment;

    const token = environment.get("TOKEN");

    const pastyCreateInfo = PastyCreateInfo("pasty1", "plain text", "asd asd asd");

    const createInfo = PasteCreateInfo("api test paste",
            ExpiresIn.never,
            false,
            false,
            "",
            [pastyCreateInfo]);

    auto paste = createPaste(createInfo, token);

    paste.title = "edited title";

    editPaste(paste, token);
}
Authors:
  • codemyst
Dependencies:
vibe-d, silly
Versions:
1.1.0 2022-May-26
1.0.0 2021-Feb-06
~main 2022-May-26
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 20 downloads total

Score:
0.7
Short URL:
pastemyst-d.dub.pm