"""Create a time-bound access invite for guests."""
# SDK docs: https://openapp.house/docs/sdk/python/
import os
from openapp_sdk import Client
# Required environment variables:
# OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
# OPENAPP_ORG_ID: your organization ID, shown in the dashboard
OPENAPP_API_KEY = os.environ["OPENAPP_API_KEY"]
ORG_ID = os.environ["OPENAPP_ORG_ID"]
# Replace these with the names shown in your dashboard.
INTEGRATION_NAME = "Virtual Access Demo" # name shown in the dashboard
PORTAL_NAME = "Lobby Portal" # name shown in the dashboard
EXPIRES_IN = (
"1w" # One week; a schedule entry can also set exact valid_from / valid_to dates.
)
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",
schedules=[{"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";
function requireEnv(name: string): string {
const value = process.env[name];
if (!value) {
throw new Error(`${name} is not set`);
}
return value;
}
// Required environment variables:
// OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
// OPENAPP_ORG_ID: your organization ID, shown in the dashboard
const OPENAPP_API_KEY = requireEnv("OPENAPP_API_KEY");
const ORG_ID = requireEnv("OPENAPP_ORG_ID");
// Replace these with the names shown in your dashboard.
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; a schedule entry can also set exact valid_from / valid_to dates.
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",
schedules: [{ 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((err: unknown) => {
console.error(err);
process.exitCode = 1;
});
//! 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;
// Required environment variables:
// OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
// OPENAPP_ORG_ID: your organization ID, shown in the dashboard
// Replace these with the names shown in your dashboard.
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; a schedule entry can also set exact valid_from / valid_to dates.
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("OPENAPP_API_KEY").map_err(|_| "OPENAPP_API_KEY is not set")?;
let org_id = std::env::var("OPENAPP_ORG_ID").map_err(|_| "OPENAPP_ORG_ID is not set")?;
let client = Client::builder().api_key(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",
"schedules": [{ "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"
)
// Required environment variables:
//
// OPENAPP_API_KEY: generate at https://openapp.house/dashboard/settings/api-keys
// OPENAPP_ORG_ID: your organization ID, shown in the dashboard
//
// Replace these with the names shown in your dashboard.
const (
integrationName = "Virtual Access Demo" // name shown in the dashboard
portalName = "Lobby Portal" // name shown in the dashboard
expiresIn = "1w" // One week; a schedule entry can also set exact valid_from / valid_to dates.
)
func requireEnv(name string) string {
value := os.Getenv(name)
if value == "" {
fmt.Fprintf(os.Stderr, "%s is not set\n", name)
os.Exit(1)
}
return value
}
func main() {
ctx := context.Background()
openappAPIKey := requireEnv("OPENAPP_API_KEY")
orgID := requireEnv("OPENAPP_ORG_ID")
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()
schedule := openapiclient.NewInviteScheduleEntryInput()
schedule.SetExpiresIn(expiresIn)
req := openapiclient.NewCreateAccessInviteRequest(
[]string{portal.ID}, []openapiclient.InviteScheduleEntryInput{*schedule},
)
req.SetName("Year-end celebration")
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())
}