Skip to content

Latest commit

 

History

History
90 lines (71 loc) · 2.23 KB

README.md

File metadata and controls

90 lines (71 loc) · 2.23 KB

MenuDocs paste client

Installation

You can install the wrapper with the following dependency managers.

The repo can be downloaded from jcenter.

The docs are available here

The current latest version is: version

Gradle

repositories {
    mavenCentral()
    maven {
        name 'duncte123-jfrog'
        url 'https://duncte123.jfrog.io/artifactory/maven'
    }
}
dependencies {
    implementation group: 'org.menudocs', name: 'paste-client-java', version: '[VERSION]'
}

Maven

<repository>
    <id>jfrog-duncte123</id>
    <name>jfrog-duncte123</name>
    <url>https://duncte123.jfrog.io/artifactory/maven</url>
</repository>

<dependency>
	<groupId>org.menudocs</groupId>
	<artifactId>paste-client-java</artifactId>
	<version>[VERSION]</version>
</dependency>

Examples

Creating the client

import org.menudocs.paste.PasteClient;
import org.menudocs.paste.PasteClientBuilder;
import org.menudocs.paste.PasteHost;


PasteClient client = new PasteClientBuilder()
                .setUserAgent("Example paste client")
                .setDefaultExpiry("10m")
                .setPasteHost(PasteHost.MENUDOCS) // Optional
                .build();

Creating a paste

// Sync operation
String pasteID = client.createPaste("html", "<h1>testing</h1>").execute();

// Async operation
client.createPaste("html", "<h1>testing</h1>").async((pasteID) -> {
    // Use pasteID here
});

Getting the paste url

String pasteUrl = client.getPasteUrl(pasteID);

Retrieving a paste

// Sync operation
Paste paste = client.getPaste(pasteID).execute();
System.out.println(paste.getPasteUrl());
System.out.println(paste.getBody());

// Async operation
client.getPaste(pasteID).async((paste) -> {
    System.out.println(paste.getPasteUrl());
    System.out.println(paste.getBody());
});