Skip to content

Repository files navigation

CuralateKit

CuralateKit is an API client to call Curalate's API methods with Swift.

For questions or support, please contact your Curalate Account Manager or support@curalate.com.

Installation

Minimum Supported Platforms

  • iOS 12.0+
  • tvOS 12.0+
  • watchOS 4.0+
  • macOS 10.13+

Swift Package Manager

.package(url: "https://github.com/curalate/CuralateKit.git", from: "0.3.0"),

Carthage

github "curalate/CuralateKit" ~> 0.3.0

Usage

Creating the API Client

import CuralateKit

let curalate = Curalate(dataSourceId: "<YOUR_DATA_SOURCE_ID>")

Fetch content (no filters)

curalate.getMedia(limit: limit) { (response, error) in
    if let error: Error = error {
        print("Error from Curalate API. \(error)")
    } else if let response = response {
        DispatchQueue.main.async {
            response.data.items.forEach { item in
                switch item.media {
                case .networkPhoto(let networkPhoto):
                    // Process photo
                    break;
                case .networkVideo(let networkVideo):
                    // Process video
                    break;
                case .networkGif(let networkGif):
                    // Process GIF
                    break;
                }
            }
        }
    }
}

Fetch content (using filters)

let filter = MediaFilter(key: .productID, value: "SKU12345")
  .and(MediaFilter(key: .label, value: "streetstyle"))
curalate.getMedia(limit: limit, filter: filter) { (response, error) ... }

Paginate through content

// self.cursors set from previous call. cursors = response.paging.cursors.
curalate.getMedia(limit: limit, after: self.cursors.after) { (response, error) .. }

Recording Events

// Note that events are queued for batch processing
curalate.recordEvent(type: .itemClick, itemId: itemId, position: itemIndex)

About

Curalate's iOS SDK

Resources

Stars

2 stars

Watchers

41 watching

Forks

Releases

Packages

Used by

Contributors

Languages