# S20.AI - Capture SDK

This is the npm package for S20.AI's capture-sdk

## Contents

- [Overview](#overview)
  - [Installation](#installation)
  - [Usage](#usage)
  - [Advanced Usage](#advanced-usage)
- [Credits](#credits)

## Overview

### Installation

For Proper Installation of the SDK, make sure following steps are followed:

- `npm i react-native-camera react-native-vision-camera` (look into setup for both packages on their respective npmjs pages)

- `npm install @s20.ai/capture-sdk @react-native-camera-roll/camera-roll @react-native-community/slider react-native-fs react-native-orientation-locker react-native-vector-icons react-native-video deprecated-react-native-prop-types uuid react-native-get-random-values react-native-digest-fetch react-native-blob-util react-native-canvas react-native-webview react-native-fs @react-native-async-storage/async-storage react-native-vector-icons @s20.ai/safecam-360-rn-lite react-native-drop-shadow react-native-haptic-feedback @react-native-community/blur react-native-linear-gradient react-native-snap-carousel --legacy-peer-deps` (additional setup is required for react-native-vector-icons, react-native-orientation-locker, react-native-fs)

- delete the _node_modules_ directory created for @s20.ai/capture-sdk

- (optional) if your app does not use **redux**, you need to install react-redux `npm i react-redux`

### Usage

```jsx
import SafecamCapture from "@s20.ai/capture-sdk";

const MySafecamCapture = () => {
  return (
    <View style={{ flex: 1 }}>
      <SafecamCapture productID={productID} sop={SOP_Config} />
    </View>
  );
};
export default MySafecamCapture;
```

### Advanced Usage

The sdk can add dynamic slots to the given SOP, for the process to work a few steps need to be done.

- import the SafecamCaptureRef type from sdk
- create a ref and attach it to the sdk
- on the ref object, imperatively invoke the function _addDynamic()_ with a valid SOP slot array

**NOTE**

- The slot array specified will be appended to the _first_ step containing a slotType of _IMPERFECTION or FEATURE_
- If such a step does not exist in the provided SOP, then it will be created for you, under the title _Imperfections_, and the given slot array will be appended to it

```jsx
import SafecamCapture, { SafecamCaptureRef } from "@s20.ai/capture-sdk";

const MySafecamCapture = () => {
  const ref = useRef < SafecamCaptureRef > null;

  useEffect(() => {
    setTimeout(() => {
      ref.current?.addDynamic([
        {
          refKey: "exterior-360-spin",
          postprocessingServices: [
            {
              service_id: "hotspot_tracking",
            },
          ],
          action: {
            captureType: "Image",
            title: "exterior-imperfection-1",
            sourceType: "DeviceCamera",
          },
          slotType: "IMPERFECTION",
          title: "windshield wiper broken",
        },
      ]);
    }, 10000);
  }, []);

  return (
    <View style={{ flex: 1 }}>
      <SafecamCapture productID={productID} sop={SOP_Config} ref={ref} />
    </View>
  );
};
export default MySafecamCapture;
```

# Credits

Written by [Gaurav Singh] at [S20.ai](https://www.s20.ai/)
