jspaste 0.0.1 jspaste: ^0.0.1 copied to clipboard
A library to interact with the JSPaste API.
jspaste.dart #
This is a Dart library for interacting with the JSPaste API. It provides a simple way to create, retrieve, update, and delete documents on JSPaste.
Installation #
Add jspaste
to your pubspec.yaml
file:
dependencies:
jspaste: ^1.0.0
Then run dart pub get
.
Usage #
Here is a simple example of how to use the library:
import 'package:jspaste/jspaste.dart';
void main() async {
// Create a new JSPaste client instance
JSPasteClient client = JSPasteClient(secret: 'your_secret_key_here');
try {
// Create a new document
Document createdDocument = await client.createDocument(
'Hello, this is a test document!', 'document_password');
print('Document created with ID: ${createdDocument.id}');
// Get the document by its ID
Document retrievedDocument =
await client.getDocumentById(createdDocument.id!, 'document_password');
print('Retrieved document: ${retrievedDocument.text}');
// Update the document
await client.updateDocument(
createdDocument.id!, 'Updated content for the document.');
print('Document updated successfully.');
// Delete the document
await client.deleteDocument(createdDocument.id!);
print('Document deleted successfully.');
} catch (e) {
print('Error: $e');
}
}
You can find more examples in the example directory.
Testing #
To run the tests, use the following command:
dart test
License #
This project is licensed under the MIT License. See the LICENSE file for details.