0.11.6 • Published 1 year ago

@proptexx/widget-sdk v0.11.6

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
1 year ago

Proptexx SDK Documentation

Introduction

The Proptexx SDK provides an interface for interacting with the Proptexx widget services. To begin using the SDK, you need to initialize it using initProptexx and then utilize the methods provided by the object returned from useProptexx. A reference to the types used in this SDK can be found near the bottom of this page.

Installation

To install the Proptexx SDK, run:

npm install @proptexx/widget-sdk

Initialization

Before accessing any methods in the SDK, you must initialize it with your API key. The initialization function also accepts an optional configuration object.

initProptexx

initProptexx(apiKey: string, options?: ProptexxOptions): void
  • apiKey: Your API key for Proptexx services.
  • options: Optional configuration object.
    • localStorageToken: Custom token for local storage.

Example:

import { initProptexx, useProptexx } from 'proptexx-sdk';
initProptexx('your-api-key', {
  localStorageToken: '_ptCache'
});

Usage

After initializing, you'd have to call the useProptexx function to get access to the available SDK functionality.

useProptexx

useProptexx(): { authAsync, batch, lead }

Example:

const { authAsync, batch, lead } = useProptexx();

Methods

Authentication

authAsync

authAsync(): Promise<WidgetAuthResponse | undefined>

Authenticates the user asynchronously. Example:

const authResponse = await authAsync();

Batch Operations

submitImagesAsync

submitImagesAsync(imageUrls: string[], options: SubmitImagesOption): Promise<ICommandResult | undefined>

Submits images for processing.

  • imageUrls: Array of image URLs to be submitted by the current location.
  • options: Configuration options for submitting images.
  • forceReload: Should only be called when you want to reprocess the images of the current location. Example:
const result = await batch.submitImagesAsync(['image1.jpg', 'image2.jpg'], { forceReload: true });

getImagesAsync

getImagesAsync(): Promise<Batch>

Retrieves processed images. Example:

const imagesBatch = await batch.getImagesAsync();

addFurnitureAsync

addFurnitureAsync(imageUrl: string, roomType: string, architectureStyle: string, additionalData?: Record<string, any>): Promise<string | undefined>

Adds furniture to the image - also called room staging.

  • imageUrl: URL of the image.
  • roomType: Type of room.
  • architectureStyle: Style of architecture.
  • additionalData: Optional additional data. Example:
const resultUrl = await batch.addFurnitureAsync('image.jpg', 'living_room', 'modern');

redecorateAsync

redecorateAsync(imageUrl: string, roomType: string, architectureStyle: string, additionalData?: Record<string, any>): Promise<string | undefined>

Redecorates / refurnishes the room in the image. Example:

const resultUrl = await batch.redecorateAsync('image.jpg', 'bedroom', 'contemporary');

indoorStagingOrRefurnishing

indoorStagingOrRefurnishing(imageUrl: string, roomType: string, architectureStyle: string, additionalData?: Record<string, any>): Promise<IndoorStagingOrRefurnishingResponse | undefined>

Stages or refurnishes the interior of the room in the image. This function can be called instead of addFurnitureAsync or redecorateAsync allowing the Proptexx computer vision algoritms to assess if the room is empty or not, before executing the generative workload. This function includes some additional metrics in the output Example:

const stagingResult = await batch.indoorStagingOrRefurnishing('image.jpg', 'office', 'industrial');

submitFeedback

submitFeedback(sourceImgUrl: string, outputImgUrl: string, type: string, value?: string): Promise<boolean>

Submits feedback on the processed image. Example:

const feedbackSuccess = await batch.submitFeedback('source.jpg', 'output.jpg', 'feedback', 'like');

Lead Management

registerAsync

registerAsync(name: string, email: string, phone?: string, password?: string, additionalData?: Record<string, any>)

Registers a new lead. Example:

const registrationResult = await lead.registerAsync('John Doe', 'john@example.com', '1234567890', 'securepassword');

existsAsync

existsAsync(email: string)

Checks if an email is already registered. Example:

const emailExists = await lead.existsAsync('john@example.com');

loginAsync

loginAsync(config: LoginConfig)

Enabled a user account to log in Example:

const loginConfig = { authType: 'credentials', email: 'john@example.com', password: 'securepassword' };
await lead.loginAsync(loginConfig);

logoutAsync

logoutAsync()

Enables the current user to log out. Example:

await lead.logoutAsync();

changePasswordAsync

changePasswordAsync(password: string, confirmPassword: string)

Changes the password of the current user. Example:

await lead.changePasswordAsync('newpassword', 'newpassword');

Types

WidgetAuthResponse

interface WidgetAuthResponse {
    batch: Batch;
    options: Record<string, any>;
}

ProptexxOptions

interface ProptexxOptions {
    authServerUrl?: string;
    localStorageToken?: string;
}

LoginConfig

interface LoginConfig {
    authType: 'credentials' | 'otp' | 'secret';
    email: string;
    password?: string;
}

WidgetOptions

interface WidgetOptions extends Record<string, any> {}

Batch

interface Batch {
    batchId: string;
    entries: BatchImage[];
    status: number;
}

BatchImage

interface BatchImage {
    isEmptyRoom: boolean;
    url: string;
}

SubmitImagesOption

interface SubmitImagesOption extends Record<string, any> {
    forceReload?: boolean;
}

IndoorStagingOrRefurnishingResponse

interface IndoorStagingOrRefurnishingResponse {
    responseUrl: string;
    inputScenesWithScores: Record<string, number>;
    inputRoomTypesWithScores: Record<string, number>;
}

Conclusion

This SDK provides a set of tools to interact with the Proptexx widget services. Make sure to initialize the SDK properly and utilize the provided methods to handle various operations related to authentication, batch processing, and lead management.

License

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Additional Terms:

This software is intended to be used with a valid API key provided by Proptexx Inc. Any use of this software without a valid API key is strictly prohibited.

0.11.6

1 year ago

0.11.5

1 year ago

0.11.4

1 year ago

0.10.4

1 year ago

0.10.3

1 year ago

0.10.2

1 year ago

0.10.1

1 year ago

0.9.8

1 year ago

0.9.7

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.9.4

1 year ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.1

1 year ago

0.9.0

1 year ago

0.8.29

1 year ago

0.8.28

1 year ago

0.8.27

1 year ago

0.8.26

1 year ago

0.8.25

1 year ago

0.8.24

1 year ago

0.8.23

1 year ago

0.8.22

1 year ago

0.8.21

1 year ago

0.8.20

1 year ago

0.8.19

1 year ago

0.8.18

1 year ago

0.8.17

1 year ago

0.8.16

1 year ago

0.8.15

1 year ago

0.8.14

1 year ago

0.8.13

1 year ago

0.8.12

1 year ago

0.8.11

1 year ago

0.8.10

1 year ago

0.8.9

1 year ago

0.8.8

1 year ago

0.8.7

1 year ago

0.8.6

1 year ago

0.8.5

1 year ago

0.8.4

1 year ago

0.8.3

1 year ago

0.8.2

1 year ago

0.8.1

1 year ago