Importing a javascript object from an external SDK using wasm_bindgen

I'm trying to import and use this ZAFClient object from the Zendesk SDK: https://github.com/zendesk/zendesk_app_framework_sdk/blob/master/lib/index.js

import Client from './client'
import { queryParameters } from './utils'

/**
 * ### ZAFClient API
 *
 * When you include the ZAF SDK on your website, you get access to the `ZAFClient` object.
 *
 * #### ZAFClient.init([callback(context)])
 *
 * Returns a [`client`](#client-object) object.
 *
 * ##### Arguments
 *
 *   * `callback(context)` (optional) a function called as soon as communication with
 *     the Zendesk app is established. The callback receives a context object with
 *     data related to the Zendesk app, including `currentAccount`, `currentUser`, and `location`
 *
 * Example:
 *
 * ```javascript
 * const client = ZAFClient.init((context) => {
 *   const currentUser = context.currentUser;
 *   console.log('Hi ' + currentUser.name);
 * });
 * ```
 */

const ZAFClient = {
  init: function (callback, loc) {
    loc = loc || window.location
    const queryParams = queryParameters(loc.search)
    const hashParams = queryParameters(loc.hash)
    const origin = queryParams.origin || hashParams.origin
    const appGuid = queryParams.app_guid || hashParams.app_guid
    if (!origin || !appGuid) { return false }

    const client = new Client({ origin, appGuid })

    if (typeof callback === 'function') {
      client.on('app.registered', callback.bind(client))
    }

    return client
  }
}

export default ZAFClient

Here is what I've tried:

  1. Included this in my index.html as script:

src="https://static.zdassets.com/zendesk_app_framework_sdk/2.0/zaf_sdk.min.js"

  1. Importing needed items:
#[wasm_bindgen]
extern "C" {
	type ZAFClient;
	type Client;

	#[wasm_bindgen(method)]
	fn init(this: &ZAFClient) -> Client;

	#[wasm_bindgen(method)]
	async fn get(this: &Client, path: String) -> JsValue;
}
  1. Tried
       let client = ZAFClient.init()

But ZAFClient here is a struct and not a value. I've found very few resources explaining javascript object imports using wasm_bindgen. I'd be grateful for any help here.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.