Skip to content

clients.canva #

Canva Module

This module provides a V client for interacting with the Canva API, enabling programmatic access to Canva's platform features.

Setup

  1. Create an account on Canva Developer Portal
  2. Create or select your application
  3. Generate an API token
  4. Configure the client using heroscript:
import freeflowuniverse.crystallib.clients.canva

heroscript := '
!!canva.configure
    name:'my_instance'
    secret:'your-api-token-here'
'

// Apply the configuration (only needs to be done once)
canva.play(heroscript: heroscript)!

Usage

Initialize Client

// Get a configured client instance
mut cl := canva.get(name: 'my_instance')!

Examples

Download a Design

// Get client instance
mut cl := canva.get('my_instance')!

// Download a design by ID
design_result := cl.download('your-design-id')!
println('Design downloaded: ${design_result}')

Constants #

const version = '1.0.0'

fn get #

fn get(args_ ArgsGet) !&CanvaClient

fn heroscript_default #

fn heroscript_default() !string

Todo: THIS IS EXAMPLE CODE AND NEEDS TO BE CHANGED IN LINE TO STRUCT BELOW, IS STRUCTURED AS HEROSCRIPT

fn play #

fn play(args_ PlayArgs) !

fn switch #

fn switch(name string)

switch instance to be used for canva

struct ArgsGet #

@[params]
struct ArgsGet {
pub mut:
	name string = 'default'
}

///////FACTORY

struct CanvaClient #

struct CanvaClient {
pub mut:
	name   string = 'default'
	secret string
}

THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED

fn (CanvaClient) download #

fn (c CanvaClient) download(design_id string) !string

Download a design from Canva using the design ID

struct PlayArgs #

@[params]
struct PlayArgs {
pub mut:
	name       string = 'default'
	heroscript string // if filled in then plbook will be made out of it
	plbook     ?playbook.PlayBook
	reset      bool
	start      bool
	stop       bool
	restart    bool
	delete     bool
	configure  bool // make sure there is at least one installed
}