@magiclabs.ai/magicbook-client 0.7.5-canary.1 → 0.7.6-canary
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -12
- package/index.cjs +239 -642
- package/index.cjs.map +1 -1
- package/index.d.cts +611 -2428
- package/index.d.ts +611 -2428
- package/index.js +235 -597
- package/index.js.map +1 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
 [](https://www.npmjs.com/package/@magiclabs.ai/magicbook-client)
|
|
3
2
|
|
|
4
3
|
# magicbook-client
|
|
@@ -13,7 +12,7 @@ npm install @magiclabs.ai/magicbook-client
|
|
|
13
12
|
|
|
14
13
|
## Usage
|
|
15
14
|
|
|
16
|
-
Create a Magicbook API client instance with your API key.
|
|
15
|
+
Create a Magicbook API client instance with your API key.
|
|
17
16
|
|
|
18
17
|
```ts
|
|
19
18
|
const client = new MagicBookClient('api-key')`
|
|
@@ -37,13 +36,14 @@ Individual parameters can also be set directly on the design request instance (e
|
|
|
37
36
|
|
|
38
37
|
```ts
|
|
39
38
|
const designRequest = await client.createDesignRequest()
|
|
40
|
-
designRequest.title = 'Australia 2023',
|
|
41
|
-
designRequest.occasion = 'travel',
|
|
42
|
-
designRequest.style = '1234',
|
|
43
|
-
designRequest.bookSize = '8x8',
|
|
44
|
-
designRequest.coverType = 'hc',
|
|
45
|
-
designRequest.pageType = 'sp'
|
|
39
|
+
;(designRequest.title = 'Australia 2023'),
|
|
40
|
+
(designRequest.occasion = 'travel'),
|
|
41
|
+
(designRequest.style = '1234'),
|
|
42
|
+
(designRequest.bookSize = '8x8'),
|
|
43
|
+
(designRequest.coverType = 'hc'),
|
|
44
|
+
(designRequest.pageType = 'sp')
|
|
46
45
|
```
|
|
46
|
+
|
|
47
47
|
As images are getting ready to be handed over to Magicbook, for example when successfully uploaded, add them to the design request object.
|
|
48
48
|
|
|
49
49
|
```ts
|
|
@@ -73,9 +73,12 @@ const designOptions = designRequest.getOptions(selectedImageCount)
|
|
|
73
73
|
Before submitting the design request to Magicbook, register a callback to receive update events.
|
|
74
74
|
|
|
75
75
|
```ts
|
|
76
|
-
window.addEventListener(
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
window.addEventListener(
|
|
77
|
+
'Magicbook.designRequestUpdated',
|
|
78
|
+
async((designRequestEvent: DesignRequestEvent) => {
|
|
79
|
+
console.log(designRequestEvent.detail)
|
|
80
|
+
}) as EventListener
|
|
81
|
+
)
|
|
79
82
|
```
|
|
80
83
|
|
|
81
84
|
Submit the design request. Again, the argument object can receive additional or updated design parameters.
|
|
@@ -102,13 +105,19 @@ Once the design request is complete, retrieve it in JSON format.
|
|
|
102
105
|
await designRequest.getJSON()
|
|
103
106
|
```
|
|
104
107
|
|
|
108
|
+
You can get alternate layouts for a specific page.
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
await designRequest.getAlternateLayouts(-1)
|
|
112
|
+
```
|
|
113
|
+
|
|
105
114
|
When a user performs a specific action, log it by calling the `logEvent` method.
|
|
106
115
|
|
|
107
116
|
```ts
|
|
108
117
|
await designRequest.logEvent('book.viewed', data)
|
|
109
118
|
```
|
|
110
119
|
|
|
111
|
-
|
|
120
|
+
---
|
|
112
121
|
|
|
113
122
|
## Example
|
|
114
123
|
|