All Projects → kylebrowning → Waterwheel.swift

kylebrowning / Waterwheel.swift

Licence: mit
The Waterwheel Swift SDK provides classes to natively connect iOS, macOS, tvOS, and watchOS applications to Drupal 7 and 8.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Waterwheel.swift

Swift Sdk
LeanCloud Swift SDK
Stars: ✭ 110 (-73.49%)
Mutual labels:  sdk, tvos, watchos
Countly Sdk Ios
Countly Product Analytics iOS SDK with macOS, watchOS and tvOS support.
Stars: ✭ 585 (+40.96%)
Mutual labels:  sdk, tvos, watchos
Contentful.swift
A delightful Swift interface to Contentful's content delivery API.
Stars: ✭ 132 (-68.19%)
Mutual labels:  sdk, tvos, watchos
Purchases Ios
In-app purchases and subscriptions made easy. iOS, MacOS, iPadOS, tvOS, and WatchOS support.
Stars: ✭ 614 (+47.95%)
Mutual labels:  sdk, tvos, watchos
Objc Sdk
LeanCloud Objective-C SDK
Stars: ✭ 186 (-55.18%)
Mutual labels:  sdk, tvos, watchos
Impact
Crash capturing library for Apple platforms
Stars: ✭ 395 (-4.82%)
Mutual labels:  tvos, watchos
Wikipediakit
Wikipedia API Client Framework for Swift on macOS, iOS, watchOS, and tvOS
Stars: ✭ 270 (-34.94%)
Mutual labels:  tvos, watchos
X
Easier cross platform Mac & iOS development with Swift
Stars: ✭ 270 (-34.94%)
Mutual labels:  tvos, watchos
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-29.16%)
Mutual labels:  tvos, watchos
SwiftGenStrings
genstrings replacement for Swift that actually works
Stars: ✭ 29 (-93.01%)
Mutual labels:  tvos, watchos
Nshipster.com
A journal of the overlooked bits in Objective-C, Swift, and Cocoa. Updated weekly.
Stars: ✭ 280 (-32.53%)
Mutual labels:  tvos, watchos
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (-28.92%)
Mutual labels:  tvos, watchos
Json
Micro framework for easily parsing JSON in Swift with rich error messages in less than 100 lines of code
Stars: ✭ 395 (-4.82%)
Mutual labels:  tvos, watchos
Xestimonitors
An extensible monitoring framework written in Swift
Stars: ✭ 269 (-35.18%)
Mutual labels:  tvos, watchos
Swiftui Charts
🚀 SwiftUI Charts with custom styles
Stars: ✭ 272 (-34.46%)
Mutual labels:  tvos, watchos
Datez
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!
Stars: ✭ 254 (-38.8%)
Mutual labels:  tvos, watchos
Skeletonui
☠️ Elegant skeleton loading animation in SwiftUI and Combine
Stars: ✭ 275 (-33.73%)
Mutual labels:  tvos, watchos
Solarized Dark For Xcode
Solarized Dark Theme for Xcode. Compatible with all modern versions of Xcode since 2013!
Stars: ✭ 358 (-13.73%)
Mutual labels:  tvos, watchos
Crypto
Swift CommonCrypto wrapper
Stars: ✭ 328 (-20.96%)
Mutual labels:  tvos, watchos
Valet
Valet lets you securely store data in the iOS, tvOS, or macOS Keychain without knowing a thing about how the Keychain works. It’s easy. We promise.
Stars: ✭ 3,712 (+794.46%)
Mutual labels:  tvos, watchos

Waterwheel - Drupal SDK

CocoaPods Carthage compatible Swift version Drupal version CocoaPods

Waterwheel Swift SDK for Drupal

Waterwheel makes using Drupal as a backend with iOS, macOS, tvOS, or watchOS enjoyable by combining the most used features of Drupal's API's in one SDK. - Formerly known as Drupal iOS SDK.

FeaturesConfigurationUsageInstallationRequirements


Features in 4.x

  • [x] Session management
  • [x] Basic Auth
  • [x] Cookie Auth
  • [x] Entity CRUD
  • [x] Local caching
  • [x] LoginViewController
  • [x] AuthButton
  • [x] Views integration into Table Views

Back to Top

Configuration

  1. import waterwheel
  2. (Optional) If you're not using HTTPS you will have to enable the NSAppTransportSecurity

Usage

The code below will give you access to the baseline of features for communicating to a Drupal site.

// Sets the URL to your Drupal site.
waterwheel.setDrupalURL("http://waterwheel-swift.com")

It is important to note that waterwheel makes heavy uses of Closures, which allows us to pass functions as returns, or store them in variables.

Login

The code below will set up Basic Authentication for each API call.

// Sets HTTPS Basic Authentication Credentials.
waterwheel.setBasicAuthUsernameAndPassword("test", password: "test2");

If you do not want to use Basic Auth, and instead use a cookie, waterwheel provides an authentication method for doing so. Sessions are handled for you, and will restore state upon closing an app and reopening it.

waterwheel.login(usernameField.text!, password: passwordField.text!) { (success, response, json, error) in
    if (success) {
        print("logged in")
    } else {
        print("failed to login")
    }
}

Waterwheel provides a waterwheelAuthButton to place anywhere in your app. The code below is iOS specific because of its dependence on UIKit.

let loginButton = waterwheelAuthButton()
// When we press Login, lets show our Login view controller.
loginButton.didPressLogin = {
  waterwheel.login(usernameField.text!, password: passwordField.text!) { (success, response, json, error) in
      if (success) {
          print("successful login")
      } else {
          print("failed to login")
      }
  }
}

loginButton.didPressLogout = { (success, error) in
    print("logged out")
}
self.view.addSubview(loginButton)

Taking this one step further, waterwheel also provides a waterwheelLoginViewController. You can subclass this controller and overwrite if needed. For our purposes we will use the default implementation.

First, we build our waterwheelLoginViewController and set our loginRequestCompleted and logoutRequestCompleted closures:

// Lets build our default waterwheelLoginViewController.
let vc = waterwheelLoginViewController()

//Lets add our closure that will be run when the request is completed.
vc.loginRequestCompleted = { (success, error) in
    if (success) {
        // Do something related to a successful login
        print("successful login")
        self.dismissViewControllerAnimated(true, completion: nil)
    } else {
        print (error)
    }
}
vc.logoutRequestCompleted = { (success, error) in
    if (success) {
        print("successful logout")
        // Do something related to a successful logout
        self.dismissViewControllerAnimated(true, completion: nil)
    } else {
        print (error)
    }
}

Once that is done we can now tell our waterwheelAuthButton what to do when someone presses Login. Of course this can all be handled manually in your own implementation, but for our purposes, were just using what waterwheel provides.

Here we instantiate a new waterwheelAuthButton and tell it what we want to happen when someone presses login, and logout.

let loginButton = waterwheelAuthButton()
// When we press Login, lets show our Login view controller.
loginButton.didPressLogin = {
    // Lets Present our Login View Controller since this closure is for the loginButton press
    self.presentViewController(vc, animated: true, completion: nil)
}

loginButton.didPressLogout = { (success, error) in
    print("logged out")
}
self.view.addSubview(loginButton)

Because these two Views know whether you are logged in or out, they will always show the correct state of buttons(Login, or Logout) and perform the approriate actions. The UI is up to you, but at its default you get username, password, submit, and cancel button. With all that said, you can ingore these classes and use the methods that waterwheel provides and deeply integrate into your own UI.

Node Methods

Get

// Get Node 36
waterwheel.nodeGet(nodeId: "36", params: nil, completionHandler: { (success, response, json, error) in
  print(response)
})

Create/post

//build our node body
let body = [
    "type": [
        [
            "target_id": "article"
        ]
    ],
    "title": [
        [
            "value": "Hello World"
        ]
    ],
    "body": [
        [
            "value": "How are you?"
        ]
    ]
]

// Create a new node.
waterwheel.entityPost(entityType: .Node, params: body) { (success, response, json, error) in
    if (success) {
        print(response)
    } else {
        print(error)
    }
}

Update/Put/PATCH

// Update an existing node
waterwheel.nodePatch(nodeId: "36", node: body) { (success, response, json, error) in
    print(response);
}

Delete

// Delete an existing node
waterwheel.nodeDelete(nodeId: "36", params: nil, completionHandler: { (success, response, json, error) in
    print(response)
})

Entity Requests

Since Node is rather specific, Watherweel provides entity methods as well for all entityTypes

Entity Get

waterwheel.entityGet(entityType: .Node, entityId: "36", params: params, completionHandler: completionHandler)

Entity Post

waterwheel.sharedInstance.entityPost(entityType: .Node, params: node, completionHandler: completionHandler)

Entity Patch

waterwheel.entityPatch(entityType: .Node, entityId: "36", params: nodeObject, completionHandler: completionHandler)

Entity Delete

waterwheel.entityDelete(entityType: .Node, entityId: entityId, params: params, completionHandler: completionHandler)

Installation

Waterwheel offers two installations paths. Pick your poison!

Installation

CocoaPods

If you're using CocoaPods, just add this line to your Podfile:

pod 'waterwheel'

Install by running this command in your terminal:

pod install

Then import the library in all files where you use it:

import waterwheel

Carthage

Just add to your Cartfile:

github "acquia/waterwheel-swift"

Run carthage update to build the framework and drag the built waterwheel.framework into your Xcode project.

Communication

  • If you need help, use Stack Overflow. (Tag 'waterwheel-swift')
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Back to Top

Drupal Compatibility

The framework is tracking Drupal 8. As new features come out in 8, they will be added ASAP. Since Drupal 7 and Drupal 8 are completely different in terms of API's, you will need to use the correct version of waterwheel depending on your Drupal version.

Requirements

  • iOS 8.0+ / Mac OS X 10.9+ / tvOS 9.0+ / watchOS 2.0+
  • Xcode 7.3+
waterwheel version Drupal Version
4.x Drupal 8 (Swift)
3.x Drupal 8 (Obj-C)
2.x Drupal 6-7 (Obj-C)

Back to Top

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].