CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

Pastr 0.2.0

Pastr 0.2.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Mattias Jähnke.



Pastr 0.2.0

Pastr

A library wrapping the Pastebin.com API.

Requirements

Xcode 8 or greater

Installation

Manually

  • Clone the repository
  • Copy Pastr.swift into your project

Usage

Setup

import 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>"

Create a Paste

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 name
  • scope - 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).

Retrieve a Paste

Pastr.get(paste: "<a paste key>") { result in
    switch result {
    case .failure(let error): fatalError() // Handle
    case .success(let content): print("Retrieved: \(content)")
  }
}

Login to pastebin

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
    
}

Delete paste (User key required)

Pastr.delete(paste: "<a paste key>") { result in
    
}

Retrieve users pastes (User key required)

Pastr.getUserPastes { result in
    
}

Will return a raw string containing XML.

Retrieve trending pastes

Retrieves the 18 currently trending pastes.

Pastr.getTrendingPastes { result in
    
}

Will return a raw string containing XML.

Retrieve user information

Pastr.getUserInfo { result in
    
}

Will return a raw string containing XML.

Contribute

If you find a bug or have some ideas for improvements, create a new issue or open a pull request.

License

Pastr is available under the MIT license. See the LICENSE file for more info.