Created
July 1, 2022 21:36
-
-
Save lobot/cc590b271d48b6bfe8a89994a87816ef to your computer and use it in GitHub Desktop.
qs-ts-code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Configuration, Postcard, PostcardsApi, PostcardEditable, AddressEditable } from "@lob/lob-typescript-sdk" | |
async function demo() { | |
const config: Configuration = new Configuration({ | |
username: "<YOUR_TEST_KEY>" | |
}) | |
const postcardData : PostcardEditable = new PostcardEditable({ | |
to: new AddressEditable({ | |
name: "Harry Zhang", | |
address_line1: "210 King Street", | |
address_city: "San Francisco", | |
address_state: "CA", | |
address_zip: "94107" | |
}), | |
from: new AddressEditable({ | |
name: "Leore Avidar", | |
address_line1: "210 King Street", | |
address_city: "San Francisco", | |
address_state: "CA", | |
address_zip: "94107" | |
}), | |
front: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf", | |
back: "https://s3-us-west-2.amazonaws.com/public.lob.com/assets/templates/4x6_pc_template.pdf" | |
}) | |
try { | |
const result : Postcard = await new PostcardsApi(config).create(postcardData) | |
return result | |
} catch (err: any) { | |
console.error(err) | |
} | |
} | |
demo().then((result)=> console.log(result)).catch() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment