Skip to content

A complete Pastebin.com API wrapper written in Scala.

License

Notifications You must be signed in to change notification settings

lare96/pastebin4scala

Repository files navigation

Pastebin.com 4 Scala

Pastebin4scala is a complete Pastebin.com API wrapper written in Scala. You'll need a developer key in order to use the Pastebin API. You can find yours here afer creating a Pastebin account.


Overview

All user-relevant methods are contained in Pastebin and PastebinAccount classes. Pastebin, for "anonymous" API features and PastebinAccount for features that require authentication.

All methods within those classes return a result wrapped within a Try instance. This allows for clean and functional handling of successful and unsuccessful operations. Take for example, this block of code that uploads an authenticated paste

valpastebin=newPastebin("developer_key") pastebin.login("username", "password").flatMap(_.upload ( title ="A test paste.", content ="object Test { val example = 25 }", format ="scala" )).foreach(it => println(s"Upload complete, link: $it"))

And the same code, using pattern matching to handle any exceptions that might have been thrown during the chain of operations

valpastebin=newPastebin("developer_key") pastebin.login("username", "password").flatMap(_.upload ( title ="A test paste.", content ="object Test { val example = 25 }", format ="scala" )) match { caseSuccess(it) => println(s"Upload complete, link: $it") caseFailure(it) => handleErrorSomehow(it) }

Deleting a paste and printing off an indication of that in just a few lines...

valpastebin=newPastebin("your_developer_key") pastebin.login("some_username", "some_password").flatMap(_.delete("aBcDeF")).foreach(it => println(s"Paste $it successfully deleted."))

More examples of anonymous and authenticated Pastebin API features can be found here.

Issues

If you encounter any issues with pastebin4scala please open a new issue describing the problem or a pull request with a potential fix to the problem.

About

A complete Pastebin.com API wrapper written in Scala.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

close