"""Create a time-bound access invite for guests."""
# SDK docs: https://openapp.house/docs/sdk/python/
from openapp_sdk import Client
# Replace the placeholder values below with your org's values from the dashboard.
# OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
OPENAPP_API_KEY = (
"https://openapp.house_openapp_9kHWAeFWbMqPg0hMKshNGba7scA6mfmISG7mgI7Eok8"
)
ORG_ID = "01KSYAX0BS1K7Y6R997XE1EWHY"
INTEGRATION_NAME = "Virtual Access Demo" # name shown in the dashboard
PORTAL_NAME = "Lobby Portal" # name shown in the dashboard
EXPIRES_IN = "1w" # One week; you can also set exact dates with valid_from / valid_to.
def main() -> None:
client = Client.connect(api_key=OPENAPP_API_KEY, org_id=ORG_ID)
integration = client.integrations.get_by_name(INTEGRATION_NAME)
portal = client.integrations.get_access_portal_by_name(
integration["id"], PORTAL_NAME
)
invite = client.integrations.create_access_invite(
integration["id"],
portal_ids=[portal["id"]],
name="Year-end celebration",
expires_in=EXPIRES_IN,
max_uses=50,
invitee_message={"en": "Welcome — use this link during the party hour."},
)
# Share this URL with your guests.
print(invite["invite_url"])
if __name__ == "__main__":
main()
/**
* Create a time-bound access invite for guests.
*
* SDK docs: https://openapp.house/docs/sdk/typescript/
*/
import { AsyncClient } from "@tomers/openapp-sdk";
// Replace the placeholder values below with your org's values from the dashboard.
// OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
const OPENAPP_API_KEY = "https://openapp.house_openapp_9kHWAeFWbMqPg0hMKshNGba7scA6mfmISG7mgI7Eok8";
const ORG_ID = "01KSYAX0BS1K7Y6R997XE1EWHY";
const INTEGRATION_NAME = "Virtual Access Demo"; // name shown in the dashboard
const PORTAL_NAME = "Lobby Portal"; // name shown in the dashboard
const EXPIRES_IN = "1w"; // One week; you can also set exact dates with valid_from / valid_to.
async function main(): Promise<void> {
const client = new AsyncClient(OPENAPP_API_KEY, { org: ORG_ID });
try {
const integration = await client.integrations.getByName(INTEGRATION_NAME);
const portal = await client.integrations.getAccessPortalByName(
String(integration.id),
PORTAL_NAME,
);
const invite = await client.integrations.createAccessInvite(String(integration.id), {
portal_ids: [String(portal.id)],
name: "Year-end celebration",
expires_in: EXPIRES_IN,
max_uses: 50,
invitee_message: { en: "Welcome — use this link during the party hour." },
});
// Share this URL with your guests.
console.log(invite.invite_url);
} finally {
client.close();
}
}
main().catch(console.error);
//! Create a time-bound access invite for guests.
//!
//! SDK docs: https://openapp.house/docs/sdk/rust/
use openapp_sdk::{Client, NameMatch};
use serde_json::json;
// Replace the placeholder values below with your org's values from the dashboard.
// OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
const OPENAPP_API_KEY: &str = "https://openapp.house_openapp_9kHWAeFWbMqPg0hMKshNGba7scA6mfmISG7mgI7Eok8";
const ORG_ID: &str = "01KSYAX0BS1K7Y6R997XE1EWHY";
const INTEGRATION_NAME: &str = "Virtual Access Demo"; // name shown in the dashboard
const PORTAL_NAME: &str = "Lobby Portal"; // name shown in the dashboard
const EXPIRES_IN: &str = "1w"; // One week; you can also set exact dates with valid_from / valid_to.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::builder()
.api_key(OPENAPP_API_KEY)
.org(ORG_ID)
.build()?;
let integration = client
.integrations()
.get_by_name(INTEGRATION_NAME, NameMatch::Exact, None)
.await?;
let integration_id = integration["id"]
.as_str()
.ok_or("integration missing id")?;
let portal = client
.integrations()
.get_access_portal_by_name(integration_id, PORTAL_NAME, NameMatch::Exact)
.await?;
let portal_id = portal["id"].as_str().ok_or("portal missing id")?;
let body = json!({
"portal_ids": [portal_id],
"name": "Year-end celebration",
"expires_in": EXPIRES_IN,
"max_uses": 50,
"invitee_message": { "en": "Welcome — use this link during the party hour." },
});
let invite = client
.integrations()
.create_access_invite(integration_id, &body)
.await?;
// Share this URL with your guests.
println!("{}", invite["invite_url"].as_str().expect("invite_url"));
Ok(())
}
// Create a time-bound access invite for guests.
//
// SDK docs: https://openapp.house/docs/sdk/go/
package main
import (
"context"
"encoding/json"
"fmt"
"os"
openapiclient "github.com/tomers/openapp-sdk/go"
"github.com/tomers/openapp-sdk/go/bridge"
)
// Replace the placeholder values below with your org's values from the dashboard.
// OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
const (
openappAPIKey = "https://openapp.house_openapp_9kHWAeFWbMqPg0hMKshNGba7scA6mfmISG7mgI7Eok8"
orgID = "01KSYAX0BS1K7Y6R997XE1EWHY"
integrationName = "Virtual Access Demo" // name shown in the dashboard
portalName = "Lobby Portal" // name shown in the dashboard
expiresIn = "1w" // One week; you can also set exact dates with valid_from / valid_to.
)
func main() {
ctx := context.Background()
rt, err := bridge.NewRuntime()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer rt.Close()
bc, err := bridge.NewClient(rt, openappAPIKey)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer bc.Close()
scoped, err := bc.WithOrg(orgID)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer scoped.Close()
_, _, integrationJSON, err := scoped.IntegrationsGetByName(integrationName, bridge.NameMatchExact)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
var integration struct {
ID string `json:"id"`
}
if err := json.Unmarshal([]byte(integrationJSON), &integration); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
_, _, portalJSON, err := scoped.IntegrationsGetAccessPortalByName(
integration.ID, portalName, bridge.NameMatchExact,
)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
var portal struct {
ID string `json:"id"`
}
if err := json.Unmarshal([]byte(portalJSON), &portal); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
client, err := openapiclient.NewAPIClient(openappAPIKey)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
defer client.Close()
req := openapiclient.NewCreateAccessInviteRequest([]string{portal.ID})
req.SetName("Year-end celebration")
req.SetExpiresIn(expiresIn)
req.SetMaxUses(50)
req.SetInviteeMessage(map[string]string{"en": "Welcome — use this link during the party hour."})
invite, _, err := client.IntegrationsAPI.CreateIntegrationAccessInvite(ctx, integration.ID).
XOrg(orgID).
CreateAccessInviteRequest(*req).
Execute()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
// Share this URL with your guests.
fmt.Println(invite.GetInviteUrl())
}