Swiftpack.co - Copicake/copicake-swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Copicake.
Copicake/copicake-swift 0.0.6
Copicake Swift Library
⭐️ 2
🕓 29 weeks ago
iOS macOS
.package(url: "https://github.com/Copicake/copicake-swift.git", from: "0.0.6")

copicake-swift

🍰 Copicake, a data-driven image generating service to let you generate any social media material with just ONE CLICK.

Installations

Cocoapods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Copicake into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'copicake-swift'

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Copicake as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/Copicake/copicake-swift", from: "0.0.6")
]

Usage

Initialization

import copicake_swift

let copicake = Copicake(
  CopicakeInitConfig(apiKey: "")
)

Create an Image

copicake.image.create([
  "template_id": "YOU_TEMPLATE_ID",
  "changes": [
    [
      "name": "text-9so09m",
      "text": "hello world",
      "color": "#ff0000"
    ],
    [
      "name": "image-yeavh7",
      "src": "https://your_website.com/test.png"
    ]
  ],
  "options": [
    "webhook_url": "https://your_website.com/webhook_url"
  ]
]) { error, rendering in
  if error != nil {
    debugPrint(error)
  }
  else {
    debugPrint(rendering)
  }
}

Get an Image

let renderingId = "YOUR_RENDERING_ID";

copicake.image.get(renderingId) { error, rendering in
  if error != nil {
    debugPrint(error)
  }
  else {
    debugPrint(rendering)
  }
}

Get an image (long polling)

let renderingId = "YOUR_RENDERING_ID";

copicake.image.getUntilFinished(renderingId) { error, rendering in
  if error != nil {
    debugPrint(error)
  }
  else {
    if rendering?.status == "success" {
      // do something
    }
    else if rendering?.status == "failed" {
      // do something
    }
  }
}

GitHub

link
Stars: 2
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics