Skip to content

Commit

Permalink
Merge pull request #47 from lana/feature-13796-aries
Browse files Browse the repository at this point in the history
Feature 13796 aries
  • Loading branch information
jantocv authored May 27, 2021
2 parents 06cd769 + 09d5558 commit 27adc8a
Show file tree
Hide file tree
Showing 9 changed files with 315 additions and 5 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Messages are sent from the webview with a specific event type that the native ap
| [scan.identity](docs/scan.md#ariessdkscanidentitysettings-object) | µApp | Launch a view to scan an identification document and verify the identity of the user for KYC purposes. | |
| [scan.document](docs/scan.md#ariessdkscandocument) | µApp | Launch a view to scan a document. | |
| [selfie.enrole](docs/selfie.md#ariessdkcreateselfieuserId-string) | µApp | Launch a view that will be used to enrole a new selfie, usually used in signup. | |
| [selfie.verify](docs/selfie.md#ariessdkverifyselfieuserId-string) | µApp | Launch a view to verify an existing selfie. |
| [selfie.verify](docs/selfie.md#ariessdkverifyselfieuserId-string) | µApp | Launch a view to verify an existing selfie. ||
| [user.fetch](docs/user.md#ariessdkfetchuser) | µApp | Request data on the current user. | |
| [user.region-id](docs/user.md#ariessdksetdefaultregionidregionid-string) | µApp | Sets the default region for the current microapp. This will be used as a fallback when the user is logged out. | |
| [account.fetch](docs/account.md#ariessdkfetchaccount) | µApp | Request data on the currently selected account. | |
Expand All @@ -30,11 +30,15 @@ Messages are sent from the webview with a specific event type that the native ap
| [session.token](docs/session.md#ariessdksessiontoken) | µApp | Generate a JSON Web Token, with no additional payload, for the current microapp suitable for authenticating the user from an external service with the OAuth Applications secret client key. | |
| [session.sign](docs/session.md#ariessdksessionsign) | µApp | Like for `session.token`, will generate a JSON Web Signature for the current microapp, but containing additional signed data provided in the params. *NOTE:* In the future, this request *may* cause a popup to be launched for the user's permission. | |
| [analytics.event](docs/analytics.md#ariessdkanalyticseventevent-object) | µApp | Sends event using the native SDKs. | |
| [aries.is-topic-supported](docs/aries.md#ariessdkistopicsupported-string) | µApp | Checks if the provided topic is supported by the native app. | Supported in android > 1.0.565 |µ
| [aries.is-topic-supported](docs/aries.md#ariessdkistopicsupported-string) | µApp | Checks if the provided topic is supported by the native app. | Supported in android > 1.0.565 |
| [email.inbox](docs/email.md#ariessdkopenemailinbox) | µApp | Opens the native email inbox (or the activity picker if there is no default email app) | Supported in android > 1.0.565 |
| [chat.create-case](docs/chat.md#createcaseproperties-object) | µApp | Opens the native flow to create support tickets | Supported from version... 1.3.X |
| [sms.retrieve-otp](docs/sms.md#retieve-otp) | µApp | Ask native to listen for auth sms and retrive the otp code | Supported in Android > 1.5.X |
| [view.show-support-icon](docs/view.md#ariessdkopenwithdedicatedappfileandtype-object(docs/sms.md#retieve-otp) | µApp | Ask native to open file with the best app installed to handle the given url and mimeType | Supported in Android > 1.7.X |
| [view.show-support-icon](docs/view.md#ariessdkopenwithdedicatedappfileandtype-object) | µApp | Ask native to open file with the best app installed to handle the given url and mimeType | Supported in Android > 1.7.X |
| [contacts.fetch](docs/contacts.md#contacts-fetch) | µApp | Ask the native for the contacts stored on the device. | Supported in Android > v1.7.805 |
| [permissions.check](docs/permissions.md#permissions-check) | µApp | Ask native, if the app has been granted the permission granted by parameter. It only supports: `contacts`, `camera` and `location` | Supported in Android > v1.7.805 |
| [settings.open](docs/settings.md#settings-open) | µApp | Launch the native application settings screen. | Supported in Android > v1.7.805 |
| [device-info.fetch](docs/device.md#deviceinfo-fetch) | µApp | It obtains information from the device, from Lana's own app and the list of installed apps. | Supported in Android > 1.7.811 |

Messages are published in a standardised format that must include a `topic` and `params` if there are any. For example:

Expand Down
9 changes: 9 additions & 0 deletions dist/AriesSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ var AriesSDK = (function (uuidv4) {

const openWithDedicatedApp = (options) => publishMessageToBusAndWaitForResponseWithMatchingId('view.open-with-dedicated-app', options);

const checkDevicePermissions = (permission) => publishMessageToBusAndWaitForResponseWithMatchingId('permissions.check', { permission });

const fetchContacts = () => publishMessageToBusAndWaitForResponseWithMatchingId('contacts.fetch');

const openSettings = () => publishMessageToBusAndWaitForResponseWithMatchingId('settings.open');

const sdk = {
analyticsEvent,
updateAnalyticsUserInfo,
Expand Down Expand Up @@ -139,6 +145,9 @@ var AriesSDK = (function (uuidv4) {
chatCreateCase,
retrieveSmsOtp,
openWithDedicatedApp,
checkDevicePermissions,
fetchContacts,
openSettings,
};

return sdk;
Expand Down
192 changes: 192 additions & 0 deletions docs/contacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
### AriesSDK.fetchContacts()

```js readonly
AriesSDK.fetchContacts();
```

Ask the native for the contacts stored on the device.

Response:

| Field | Type | Description |
| ----- | ---- | ----------- |
| `contacts` | List<Contact> | List with device contacts. |

A successful response body will contain the following information:
```js readonly
{
response: {
"contacts": [
{
"id": 1,
"name": "Name",
"note": "Notes",
"company": "Company",
"jobTitle": "Job Title",
"department": "Department",
"phones": [
{
"phone": "+XX XXXXXXXXX",
"type": "Mobile"
},
{
"phone": "+XX XXXXXXXXX",
"type": "Home"
}
],
"addresses": [
{
"city": "City 1",
"country": "Country 1",
"label": "Home 1",
"region": "Region 1",
"street": "Stret 1"
}
],
"emails": [
{
"email": "[email protected]",
"type": "Home"
},
{
"email": "[email protected]",
"type": "Work"
}
],
"ims": [
{
"type": "@username",
"value": "Skype"
}
],
"websites": [
{
"type": "Website",
"url": "www.lana.xyz"
}
]
}
]
}
}
```
#### Contact model details ####

| Field | Type | Description |
| ----- | ---- | ----------- |
| id | Long | Contact id in local device |
| name | String | Name |
| note | String | Note |
| company | String | Company |
| department | String | Department |
| jobTitle | String | Job Title |
| phones | List<Phone> | Address list |
| addresses | List<Address> | Address list |
| emails | List<Email> | Email list |
| ims | List<Im> | List of instant messaging services |
| websites | List<Website> | List of instant messaging services |

### Models details (Phone, Address, Email, Im and Website)

#### Phone fields
| Field | Type | Description |
| ----- | ---- | ----------- |
| `phone` | String | Phone |
| `type` | String | Type |

#### Address fields
| Field | Type | Description |
| ----- | ---- | ----------- |
| `street` | String | Street |
| `city` | String | City |
| `region` | String | Region |
| `contry` | String | Country |
| `label` | String | Label |

#### Email fields
| Field | Type | Description |
| ----- | ---- | ----------- |
| `email` | String | Email |
| `type` | String | Type |

#### Im fields
| Field | Type | Description |
| ----- | ---- | ----------- |
| `type` | String | Type |
| `value` | String | Value |

#### Website fields
| Field | Type | Description |
| ----- | ---- | ----------- |
| `type` | String | Type |
| `url` | String | Url |

### Types

#### Phone Types -> More info: [Android Developers](https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Phone)
| Field | Type | Description |
| ----- | ---- | ----------- |
| `Home` | String | Home |
| `Assistant` | String | Assistant |
| `Callback` | String | Callback |
| `Car` | String | Car |
| `Company Main` | String | Company Main |
| `Fax Home` | String | Fax Home |
| `Fax Work` | String | Fax Work |
| `Isdn` | String | Isdn |
| `Main` | String | Main |
| `Mms` | String | Mms |
| `Mobile` | String | Mobile |
| `Other` | String | Other |
| `Other Fax` | String | Other Fax |
| `Radio` | String | Radio |
| `Telex` | String | Telex |
| `Tty TDD` | String | Tty TDD |
| `Work` | String | Work |
| `Work Mobile` | String | Work Mobile |
| `Work Pager` | String | Work Pager |
| `unknown_$type` | String | Default value when phone type is not found. `$type` is Int (Example: unkwnown_1) |

#### Address Types -> More info: [Android Developers](https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.StructuredPostal)
| Field | Type | Description |
| ----- | ---- | ----------- |
| `Home` | String | Home |
| `Other` | String | Other |
| `Work` | String | Work |
| `unknown_$type` | String | Default value when address type is not found. `$type` is Int (Example: unkwnown_1) |


#### Email Types -> More info: [Android Developers](https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Email)
| Field | Type | Description |
| ----- | ---- | ----------- |
| `Home` | String | Home |
| `Mobile` | String | Mobile |
| `Other` | String | Other |
| `Work` | String | Work |
| `unknown_$type` | String | Default value when email type is not found. `$type` is Int (Example: unkwnown_1) |

#### Im Types -> More info: [Android Developers](https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Im)
| Field | Type | Description |
| ----- | ---- | ----------- |
| `Aim` | String | Aim |
| `Msn` | String | Msn |
| `Yahoo` | String | Yahoo |
| `Skype` | String | Skype |
| `Qq` | String | Qq |
| `Google Talk` | String | Google Talk |
| `Icq` | String | Icq |
| `Jabber` | String | Jabber |
| `Netmeeting` | String | Netmeeting |
| `unknown_$type` | String | Default value when im type is not found. `$type` is Int (Example: unkwnown_1) |

#### Website Types -> More info: [Android Developers](https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Website)
| Field | Type | Description |
| ----- | ---- | ----------- |
| `HomePage` | String | HomePage |
| `Blog` | String | Blog |
| `Profile` | String | Profile |
| `Home` | String | Home |
| `Work` | String | Work |
| `Ftp` | String | Ftp |
| `Other` | String | Other |
| `unknown_$type` | String | Default value when website type is not found. `$type` is Int (Example: unkwnown_1) |
48 changes: 48 additions & 0 deletions docs/device.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
### AriesSDK.fetchDeviceInfo()

```js readonly
AriesSDK.fetchDeviceInfo();
```

It obtains information from the device, from Lana's own app and the list of installed apps.

Sends events to the different analytics provider configured in the native app.

| Field | Type | Description |
| ----- | ---- | ----------- |
| `device` | Object | Information about device |
| `lanaApplication` | Object | Information about Lana App installed |
| `packagesList` | Object | List of applications installed on the device |

```js readonly
{
"device": {
"brand": "google",
"country": "US",
"language": "es",
"manufacturer": "Google",
"model": "sdk_gphone64_x86_64",
"name": "emulator64_x86_64_arm64",
"systemName": "Android",
"systemVersion": "30",
"uuid": "6e87ef6e149493a4"
},
"lanaApplication": {
"appInstallerPackageName": "",
"appIsInstalledViaGooglePlay": false,
"flavor": "staging",
"isDebug": true,
"name": "xyz.lana.b2c.staging",
"version": "1.7.1-staging"
},
"packagesList": [
{
"className": "xyz.lana.b2c.LanaApplication",
"name": "Lana",
"packageName": "xyz.lana.b2c",
"targetSdkVersion": 30
}
]
}
```

38 changes: 38 additions & 0 deletions docs/permissions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
### AriesSDK.checkPermission(permission: String)

```js readonly
AriesSDK.checkPermission('permission');
```

Ask native, if the app has been granted the permission granted by parameter.

#### Permissions supported:

| Field | Type | Description |
| ----- | ---- | ----------- |
| `contacts` | string | READ_CONTACTS |
| `camera` | string | CAMERA |
| `location` | string | ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION |

#### Response:

| Field | Type | Description |
| ----- | ---- | ----------- |
| `result` | string | The result if you have the permission granted in native. `result` , `result` or `result` |

#### Result types:

| Result | Type | Description |
| ----- | ---- | ----------- |
| `granted` | string | The user has explicitly granted permission. |
| `denied` | string | The user explicitly and permanently denied permission. |
| `unknown` | string | The user has not yet granted or permanently denied permission. |

A successful response body will contain the following information:
```js readonly
{
response: {
"result": "granted"
}
}
```
7 changes: 7 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### AriesSDK.openAppSettings()

```js readonly
AriesSDK.openAppSettings();
```

Launch the native application settings screen.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lana/b2c-mapp-sdk",
"version": "0.11.0",
"version": "0.12.0",
"description": "Lana B2C MicroApp SDK for interacting with the Mobile Aries browser.",
"repository": {
"type": "git",
Expand Down
12 changes: 12 additions & 0 deletions src/AriesSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ const retrieveSmsOtp = () => publishMessageToBusAndWaitForResponseWithMatchingId

const openWithDedicatedApp = (options) => publishMessageToBusAndWaitForResponseWithMatchingId('view.open-with-dedicated-app', options);

const checkPermission = (permission) => publishMessageToBusAndWaitForResponseWithMatchingId('permissions.check', { permission });

const fetchContacts = () => publishMessageToBusAndWaitForResponseWithMatchingId('contacts.fetch');

const openSettings = () => publishMessageToBusAndWaitForResponseWithMatchingId('settings.open');

const fetchDeviceInfo = () => publishMessageToBusAndWaitForResponseWithMatchingId('device-info.fetch');

const sdk = {
analyticsEvent,
updateAnalyticsUserInfo,
Expand Down Expand Up @@ -134,6 +142,10 @@ const sdk = {
chatCreateCase,
retrieveSmsOtp,
openWithDedicatedApp,
checkPermission,
fetchContacts,
openSettings,
fetchDeviceInfo,
};

export default sdk;

0 comments on commit 27adc8a

Please sign in to comment.