Skip to content

Commit b2f5415

Browse files
authored
feat: probability to purchase (#289)
1 parent 8a9919f commit b2f5415

9 files changed

Lines changed: 646 additions & 597 deletions

source/includes/_predict.md.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Predict
2+
3+
A set of features to predict visitor's behavior.
4+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Probability to purchase
2+
3+
```shell
4+
curl https://<%= config[:api_endpoint] %>/predict/probability-to-purchase?shop_id=SHOPID&did=DEVICE_ID
5+
```
6+
7+
```javascript
8+
// TBD
9+
```
10+
11+
```swift
12+
// TBD
13+
```
14+
15+
```kotlin
16+
// TBD
17+
```
18+
19+
```java
20+
// TBD
21+
```
22+
23+
```jsx
24+
// TBD
25+
```
26+
27+
> API response example:
28+
29+
```json
30+
31+
{
32+
"probability": 33,
33+
"message": "...",
34+
"did": "..."
35+
}
36+
```
37+
38+
39+
Tries to predict visitor's probability to purchase according to user's behavior.
40+
41+
`GET https://<%= config[:api_endpoint] %>/predict/probability-to-purchase`
42+
43+
### Query Parameters
44+
45+
| Parameter | Type | Required | Description |
46+
|------------------------------|--------|------------|--------------------------------------------------------------------------------------------------------------|
47+
| shop_id | String | true | Your API key |
48+
| did | String | true | Device ID |
49+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Force change email
2+
3+
```shell
4+
curl -d "shop_id=SHOPID&shop_secret=SHOP_SECRET&new_email=NEW_EMAIL&old_email=OLD_EMAIL" https://<%= config[:api_endpoint] %>/profile/force_change_email
5+
```
6+
7+
```javascript
8+
// Not supported
9+
```
10+
11+
```swift
12+
// Not supported
13+
```
14+
15+
```kotlin
16+
// Not supported
17+
```
18+
19+
```java
20+
// Not supported
21+
```
22+
23+
```jsx
24+
// Not supported
25+
```
26+
27+
Force change email of user with `old_email` to `new_email`. If a user with `new_email` exists, removes email from that user.
28+
29+
If user with `old_email` is not found, returns 404.
30+
31+
<aside class="notice">
32+
Use it carefully, because wrong usage of this method can lose old profile data. Mass uncontrolled action can break everything.
33+
</aside>
34+
35+
It's S2S method.
36+
37+
### Query Parameters
38+
39+
| Parameter | Type | Required | Description |
40+
|------------------------------|--------|------------|--------------------------------------------------------------------------------------------------------------|
41+
| shop_id | String | true | Your API key |
42+
| shop_secret | String | true | Your API secret key |
43+
| new_email | String | true | User's new email |
44+
| old_email | String | true | User's current email |
45+
| i_understand_what_i_am_doing | String | true | Must present with any `true` value (`true`, `"true"`, `1`, `yes`, `believe me I know what I am doing`, etc). |
46+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Force change phone
2+
3+
```shell
4+
curl -d "shop_id=SHOPID&shop_secret=SHOP_SECRET&new_phone=NEW_PHONE&old_phone=OLD_PHONE" https://<%= config[:api_endpoint] %>/profile/force_change_phone
5+
```
6+
7+
```javascript
8+
// Not supported
9+
```
10+
11+
```swift
12+
// Not supported
13+
```
14+
15+
```kotlin
16+
// Not supported
17+
```
18+
19+
```java
20+
// Not supported
21+
```
22+
23+
```jsx
24+
// Not supported
25+
```
26+
27+
Force change phone of user with `old_phone` to `new_phone`. If a user with `new_phone` exists, removes phone from that user.
28+
29+
If user with `old_phone` is not found, returns 404.
30+
31+
<aside class="notice">
32+
Use it carefully, because wrong usage of this method can lose old profile data. Mass uncontrolled action can break everything.
33+
</aside>
34+
35+
It's S2S method.
36+
37+
### Query Parameters
38+
39+
| Parameter | Type | Required | Description |
40+
|------------------------------|--------|----------|--------------------------------------------------------------------------------------------------------------|
41+
| shop_id | String | true | Your API key |
42+
| shop_secret | String | true | Your API secret key |
43+
| new_phone | String | true | User's new phone |
44+
| old_phone | String | true | User's current phone |
45+
| i_understand_what_i_am_doing | String | true | Must present with any `true` value (`true`, `"true"`, `1`, `yes`, `believe me I know what I am doing`, etc). |
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
## Read profile info
2+
3+
```shell
4+
# Using email as user identifier
5+
curl https://<%= config[:api_endpoint] %>/profile?email=...&shop_id=...&shop_secret=...
6+
7+
# Using phone as user identifier
8+
curl https://<%= config[:api_endpoint] %>/profile?phone=...&shop_id=...&shop_secret=...
9+
```
10+
11+
```javascript
12+
<%= config[:js_sdk_name] %>('profile', 'get', function(profile) {
13+
// Here you can use all properties of profile's object
14+
console.log(profile.gender);
15+
console.log(profile.fashion.sizes.shoe);
16+
},
17+
// Use `true`, to work in single page sites.
18+
// Default - `false`
19+
false
20+
);
21+
```
22+
23+
> The REST method returns this JSON structure for requests where a secret key was provided
24+
25+
```json
26+
{
27+
"first_name": "...",
28+
"last_name": "...",
29+
"email": "...",
30+
"phone": "...",
31+
"fb_id": "...",
32+
"vk_id": "...",
33+
"telegram_id": "...",
34+
"loyalty_id": "...",
35+
"loyalty_card_location": "...",
36+
"loyalty_status": "...",
37+
"loyalty_bonuses": "...",
38+
"loyalty_bonuses_to_next_level": "...",
39+
"gender": "...",
40+
"location": "...",
41+
"age": "...",
42+
"birthday": "...",
43+
"bought_something": "...",
44+
"tags": [
45+
"...",
46+
"..."
47+
],
48+
"custom_properties": {
49+
"prop_key_1": "prop_value",
50+
"prop_key_2": "prop_value"
51+
},
52+
"additional_phones": [],
53+
"additional_emails": [],
54+
"additional_loyalty_ids": [],
55+
"orders": [
56+
{
57+
"id": "...",
58+
"value": "...",
59+
"status": "...",
60+
"items": [
61+
{
62+
"id": "...",
63+
"price": "...",
64+
"name": "...",
65+
"quantity": "..."
66+
},
67+
{
68+
"id": "...",
69+
"price": "...",
70+
"name": "...",
71+
"quantity": "..."
72+
}
73+
]
74+
}
75+
]
76+
}
77+
```
78+
79+
> The REST method returns this JSON structure with publicly available profile data if a secret key was not provided in the request
80+
81+
```json
82+
{
83+
"has_email": true,
84+
"computed_gender": "male",
85+
"gender": "male",
86+
"bought_something": true,
87+
"id": "YOUR ID",
88+
"custom_properties": {
89+
"favorite_color": "blue",
90+
"subscription_level": "premium"
91+
}
92+
}
93+
```
94+
95+
> JS SDK method returns simplified anonymous structure to prevent data stealing
96+
97+
```json
98+
{
99+
"fashion_sizes": ["..."],
100+
101+
"gender": "m or f",
102+
103+
"cosmetic_hair": ["..."],
104+
"allergy": "bool",
105+
"cosmetic_skin": ["..."],
106+
"cosmetic_perfume": ["..."],
107+
108+
"compatibility": null,
109+
"vds": null,
110+
111+
"jewelry": null,
112+
113+
"realty": ["..."],
114+
115+
"children": ["..."],
116+
"child_gender": "m or f",
117+
118+
"pets": ["..."],
119+
120+
"income_level": "cheap"
121+
}
122+
```
123+
124+
125+
You can read profile info from the CRM using an API or SDK.
126+
127+
In the case of using the REST API (when using an email or phone number as the user ID), you must provide a secret key to the method to get a full response.
128+
129+
However, there is publicly available data you can retrieve without providing a secret key in your request.

0 commit comments

Comments
 (0)