Latest 0.0.1
Homepage https://github.com/OlafAndreas/RestFire
License The MIT License (MIT)
Platforms ios 9.0, requires ARC
Dependencies Alamofire, SwiftyJSON
Authors

A REST client wrapper around Alamofire.
It also takes advantage of SwiftyJSON.

Supported methods so far:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
Initiate the RestFire client
    import RestFire

    // Initiate the RestFire client
    let restFire = RestFire(baseUrl: "https://some.website.com/api")
Get a resource from the server
    restFire["comments"].get().response {
      value, error in

      if let error = error {
        return print("Error fetching comments: (error)")
      }

      if let value = value {

        let firstComment = value[0]
        print(firstComment["author"])
      }
    }
Post a resource to the server
  let newComment = ["author": "John Doe", "message": "This is really cool!"]

    restFire["comments"].post(newComment).response {
      value, error in

      if let error = error {
        return print("Error posting comment: (error)")
      }

      if let value = value {

        print(value)
      }
    }

Get a resource through a relationship

  restFire["posts"][3]["comments"].get().response {
    value, error in

    print(error)

    print(value)
  }

Server response object

The value variable in the response closure is of type JSON, this type comes from SwiftyJSON.

The error variable is of type NSError. This may contain a ‘reason’ within the ‘userInfo’ dictionary.

Integration

CocoaPods

You can use CocoaPods to install RestFire by adding it to your Podfile:

  source '[email protected]:OlafAndreas/RestFire.git'

  platform :ios, '9.0'
  use_frameworks!

  target 'MyApp' do
    pod 'RestFire'
  end

Latest podspec

{
    "name": "RestFire",
    "version": "0.0.1",
    "summary": "A simple REST wrapper based on Alamofire.",
    "description": "This wrapper extends Alamofire and makes for easy access to your REST API.",
    "homepage": "https://github.com/OlafAndreas/RestFire",
    "license": "The MIT License (MIT)",
    "authors": {
        "Olaf Andreas u00d8vrum": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/OlafAndreas/RestFire.git",
        "tag": "0.0.1"
    },
    "source_files": [
        "Classes",
        "Classes/**/*.{h,m,swift}",
        "Tests/*.{swift}"
    ],
    "exclude_files": "Classes/Exclude",
    "requires_arc": true,
    "dependencies": {
        "Alamofire": [],
        "SwiftyJSON": []
    }
}

Pin It on Pinterest

Share This