CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.
TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Jan 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Mattias Jähnke.
A library wrapping the Pastebin.com API.
Xcode 8 or greater
Pastr.swift
into your projectimport Pastr
(if using CocoaPods)
Configure Pastr with your Pastebin api key. Read more about it and how you obtain one here
pasteBinApiKey = "<Your API key>"
Pastr.post(text: "Hey I'm posting this to Pastebin!") { result in
switch result {
case .failure(let error): fatalError() // Handle
case .success(let key): print("Posted paste with key \(key)")
}
}
This function accepts the following parameters:
name
- To give the paste a namescope
- Private, public or unlisted (enum PastrScope
)format
- Pastebin supports syntax highlighting. A list of supported types are available in Pastr.Format
expiration
- Sets when the post should expire (default is never) (enum PastrExpiration
).Pastr.get(paste: "<a paste key>") { result in
switch result {
case .failure(let error): fatalError() // Handle
case .success(let content): print("Retrieved: \(content)")
}
}
This function will authenticate a user with pastebin and return a “user key” to be used for functions that require this token.
Pastr.delete(paste: "<a paste key>") { result in
…
}
Pastr.delete(paste: "<a paste key>") { result in
…
}
Pastr.getUserPastes { result in
…
}
Will return a raw string containing XML.
Retrieves the 18 currently trending pastes.
Pastr.getTrendingPastes { result in
…
}
Will return a raw string containing XML.
Pastr.getUserInfo { result in
…
}
Will return a raw string containing XML.
If you find a bug or have some ideas for improvements, create a new issue or open a pull request.
Pastr is available under the MIT license. See the LICENSE file for more info.