Skip to content

Commit

Permalink
Added required API token parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
herychok-quintagroup committed May 9, 2019
1 parent 671cb0c commit cca96ce
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 10 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This subsystem is designed to provide suggestions based on machine learning models.

**Notice! It is recommended to use this library starting from version 1.1.0 that introduces authentication via an API key.**

## Installation

### Node
Expand All @@ -16,7 +18,7 @@ Install with npm:
Include the latest script directly from npm.

```js
<script src="https://cdn.jsdelivr.net/npm/prozorro_ai@1.0.2/prozorro_ai.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/prozorro_ai@1.1.0/prozorro_ai.min.js"></script>
```

OR
Expand All @@ -28,6 +30,20 @@ OR

## Usage

### Authentication

This library requires authentication via an API key.
The API key is issued after the registration confirmation on the [https://ocdsanalytics.com/](https://ocdsanalytics.com/register/) website.
You can find it in the API section on the [Account page](https://ocdsanalytics.com/account/).

Use API key as follows:

```js
Prozorro_AI.client({apiKey: 'Insert your API_KEY here'}).units.suggest({
...
})
```

### Unit prediction

Based on the inputs, you can get the most probable unit of measurement.
Expand All @@ -46,11 +62,12 @@ Based on the inputs, you can get the most probable unit of measurement.
The example would be as follows:

**Find unit of measurement based on tender's title and description, item's description and classification.**

Request:
```js
import Prozorro_AI from "prozorro_ai";
// const Prozorro_AI = require('prozorro_ai');
Prozorro_AI.client().units.suggest({
Prozorro_AI.client({apiKey: 'Insert your API_KEY here'}).units.suggest({
tenderTitle: 'Тканини бавовняні',
tenderDescription: 'Відбілений сатин',
itemDescription: 'Сатин відбілений. Склад - 100% бавовна, ширина 200 см',
Expand Down Expand Up @@ -103,11 +120,12 @@ Based on the inputs, you can get the most probable classification.


**Find classification based on tender's title and description, item's description and unit of measure.**

Request:
```js
import Prozorro_AI from "prozorro_ai";
// const Prozorro_AI = require('prozorro_ai');
Prozorro_AI.client().classifications.suggest({
Prozorro_AI.client({apiKey: 'Insert your API_KEY here'}).classifications.suggest({
tenderTitle: 'Технічне обслуговування і ремонт офісної техніки',
tenderDescription: 'Послуги з технічного обслуговування принтерів та картриджів',
itemDescription: 'Послуги з технічного обслуговування принтерів',
Expand Down
7 changes: 5 additions & 2 deletions examples/classification_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
}
.main-block {background-color: #f2f4f5;}
</style>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/prozorro_ai.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/prozorro_ai.min.js"></script>-->
<script src="../prozorro_ai.min.js"></script>
<script>
Vue.component('demo-component', {
template: '#demo-component',
Expand Down Expand Up @@ -215,7 +216,9 @@
}
}

Prozorro_AI.client().classification.suggest({
// In order to get an API key, please register on the https://ocdsanalytics.com/ website and you will be able to find your API key on the Account page.

Prozorro_AI.client({apiKey: 'Insert your API_KEY here'}).classifications.suggest({
tenderTitle: this.form.tenderName,
tenderDescription: this.form.tenderDescription,
itemDescription: itemDescription,
Expand Down
7 changes: 5 additions & 2 deletions examples/unit_example.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@
.main-block {background-color: #f2f4f5;}
</style>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/prozorro_ai.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/[email protected]/prozorro_ai.min.js"></script>-->
<script src="../prozorro_ai.min.js"></script>
<script>
Vue.component('demo-component', {
template: '#demo-component',
Expand Down Expand Up @@ -214,7 +215,9 @@
}
}

Prozorro_AI.client().units.suggest({
// In order to get an API key, please register on the https://ocdsanalytics.com/ website and you will be able to find your API key on the Account page.

Prozorro_AI.client({apiKey: 'Insert your API_KEY here'}).units.suggest({
tenderTitle: this.form.tenderName,
tenderDescription: this.form.tenderDescription,
itemDescription: itemDescription,
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ request = function (data, settings, itemType) {
method: 'POST',
headers: {
"Content-Type": "application/json",
'accept': '*/*'
'accept': '*/*',
"Authorization": "Bearer " + params.apiKey
},
body: query
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prozorro_ai",
"version": "1.0.2",
"version": "1.1.0",
"description": "This subsystem is designed to provide predictions based on machine learning modules.",
"main": "index.js",
"directories": {
Expand Down
2 changes: 1 addition & 1 deletion prozorro_ai.min.js

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

0 comments on commit cca96ce

Please sign in to comment.