-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
09803ec
commit 4565049
Showing
17 changed files
with
544 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,4 @@ target/ | |
|
||
#Ipython Notebook | ||
.ipynb_checkpoints | ||
/.openapi-generator-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# sajari_client.EventsApi | ||
|
||
All URIs are relative to *https://api-gateway.sajari.com* | ||
|
||
Method | HTTP request | Description | ||
------------- | ------------- | ------------- | ||
[**send_event**](EventsApi.md#send_event) | **POST** /v4/events:sendEvent | Send event | ||
|
||
|
||
# **send_event** | ||
> {str: (bool, date, datetime, dict, float, int, list, str, none_type)} send_event(send_event_request) | ||
Send event | ||
|
||
Send an event to the ranking system after a user interacts with a search result. When querying a collection, you can set the tracking type of the query request. When it is `CLICK` or `POS_NEG`, a token is generated for each result in the query response. You can use this token to provide feedback to the ranking system. Each time you want to record an event on a particular search result, use the send event call and provide: - The `name` of the event, e.g. `click`, `purchase`. - The `token` from the search result. - The `weight` to assign to the event, e.g. `1`. - An object containing any additional `metadata`. For example, to send an event where a customer purchased a product, use the following call: ```json { \"name\": \"purchase\", \"token\": \"eyJ...\", \"weight\": 1, \"metadata\": { \"discount\": 0.2, \"margin\": 30.0, \"customer_id\": \"12345\", \"ui_test_segment\": \"A\" } } ``` | ||
|
||
### Example | ||
|
||
* Basic Authentication (BasicAuth): | ||
```python | ||
import time | ||
import sajari_client | ||
from com.sajari.client.api import events_api | ||
from sajari_client.model.send_event_request import SendEventRequest | ||
from sajari_client.model.error import Error | ||
from pprint import pprint | ||
# Defining the host is optional and defaults to https://api-gateway.sajari.com | ||
# See configuration.py for a list of all supported configuration parameters. | ||
configuration = sajari_client.Configuration( | ||
host = "https://api-gateway.sajari.com" | ||
) | ||
|
||
# The client must configure the authentication and authorization parameters | ||
# in accordance with the API server security policy. | ||
# Examples for each auth method are provided below, use the example that | ||
# satisfies your auth use case. | ||
|
||
# Configure HTTP basic authorization: BasicAuth | ||
configuration = sajari_client.Configuration( | ||
username = 'YOUR_USERNAME', | ||
password = 'YOUR_PASSWORD' | ||
) | ||
|
||
# Enter a context with an instance of the API client | ||
with sajari_client.ApiClient(configuration) as api_client: | ||
# Create an instance of the API class | ||
api_instance = events_api.EventsApi(api_client) | ||
send_event_request = SendEventRequest( | ||
name="name_example", | ||
token="token_example", | ||
weight=1, | ||
metadata={ | ||
"key": {}, | ||
}, | ||
) # SendEventRequest | | ||
|
||
# example passing only required values which don't have defaults set | ||
try: | ||
# Send event | ||
api_response = api_instance.send_event(send_event_request) | ||
pprint(api_response) | ||
except sajari_client.ApiException as e: | ||
print("Exception when calling EventsApi->send_event: %s\n" % e) | ||
``` | ||
|
||
|
||
### Parameters | ||
|
||
Name | Type | Description | Notes | ||
------------- | ------------- | ------------- | ------------- | ||
**send_event_request** | [**SendEventRequest**](SendEventRequest.md)| | | ||
|
||
### Return type | ||
|
||
**{str: (bool, date, datetime, dict, float, int, list, str, none_type)}** | ||
|
||
### Authorization | ||
|
||
[BasicAuth](../README.md#BasicAuth) | ||
|
||
### HTTP request headers | ||
|
||
- **Content-Type**: application/json | ||
- **Accept**: application/json | ||
|
||
|
||
### HTTP response details | ||
| Status code | Description | Response headers | | ||
|-------------|-------------|------------------| | ||
**200** | A successful response. | - | | ||
**400** | Returned when the request contains violations for one or more fields. | - | | ||
**401** | Returned when the request does not have valid authentication credentials. | - | | ||
**403** | Returned when the user does not have permission to access the resource. | - | | ||
**404** | Returned when the resource does not exist. | - | | ||
**500** | Returned when the API encounters an internal error. | - | | ||
**0** | An unexpected error response | - | | ||
|
||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SendEventRequest | ||
|
||
A request to send an event to the ranking system after a user interacts with a search result. | ||
|
||
## Properties | ||
Name | Type | Description | Notes | ||
------------ | ------------- | ------------- | ------------- | ||
**name** | **str** | The name of event, e.g. `click`, `purchase`. | | ||
**token** | **str** | The token corresponding to the search result that was interacted with, e.g. `eyJ...`. | | ||
**weight** | **int** | The weight assigned to the event. Generally a sensible weight is 1. If you want to weight an event in a certain way you can use a value other than 1. For example, if you want to capture profit in an event, you could set the weight to a value that represents the profit. | [optional] | ||
**metadata** | **{str: ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},)}** | An object made up of field-value pairs that contains additional metadata to record with the event. Every value in the object must be one of the following primitive types: - boolean - number - string | [optional] | ||
|
||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
""" | ||
Sajari API | ||
Sajari is a smart, highly-configurable, real-time search service that enables thousands of businesses worldwide to provide amazing search experiences on their websites, stores, and applications. # noqa: E501 | ||
The version of the OpenAPI document: v4 | ||
Contact: [email protected] | ||
Generated by: https://openapi-generator.tech | ||
""" | ||
|
||
|
||
import re # noqa: F401 | ||
import sys # noqa: F401 | ||
|
||
from sajari_client.api_client import ApiClient, Endpoint as _Endpoint | ||
from sajari_client.model_utils import ( # noqa: F401 | ||
check_allowed_values, | ||
check_validations, | ||
date, | ||
datetime, | ||
file_type, | ||
none_type, | ||
validate_and_convert_types | ||
) | ||
from sajari_client.model.error import Error | ||
from sajari_client.model.send_event_request import SendEventRequest | ||
|
||
|
||
class EventsApi(object): | ||
"""NOTE: This class is auto generated by OpenAPI Generator | ||
Ref: https://openapi-generator.tech | ||
Do not edit the class manually. | ||
""" | ||
|
||
def __init__(self, api_client=None): | ||
if api_client is None: | ||
api_client = ApiClient() | ||
self.api_client = api_client | ||
|
||
def __send_event( | ||
self, | ||
send_event_request, | ||
**kwargs | ||
): | ||
"""Send event # noqa: E501 | ||
Send an event to the ranking system after a user interacts with a search result. When querying a collection, you can set the tracking type of the query request. When it is `CLICK` or `POS_NEG`, a token is generated for each result in the query response. You can use this token to provide feedback to the ranking system. Each time you want to record an event on a particular search result, use the send event call and provide: - The `name` of the event, e.g. `click`, `purchase`. - The `token` from the search result. - The `weight` to assign to the event, e.g. `1`. - An object containing any additional `metadata`. For example, to send an event where a customer purchased a product, use the following call: ```json { \"name\": \"purchase\", \"token\": \"eyJ...\", \"weight\": 1, \"metadata\": { \"discount\": 0.2, \"margin\": 30.0, \"customer_id\": \"12345\", \"ui_test_segment\": \"A\" } } ``` # noqa: E501 | ||
This method makes a synchronous HTTP request by default. To make an | ||
asynchronous HTTP request, please pass async_req=True | ||
>>> thread = api.send_event(send_event_request, async_req=True) | ||
>>> result = thread.get() | ||
Args: | ||
send_event_request (SendEventRequest): | ||
Keyword Args: | ||
_return_http_data_only (bool): response data without head status | ||
code and headers. Default is True. | ||
_preload_content (bool): if False, the urllib3.HTTPResponse object | ||
will be returned without reading/decoding response data. | ||
Default is True. | ||
_request_timeout (float/tuple): timeout setting for this request. If one | ||
number provided, it will be total request timeout. It can also | ||
be a pair (tuple) of (connection, read) timeouts. | ||
Default is None. | ||
_check_input_type (bool): specifies if type checking | ||
should be done one the data sent to the server. | ||
Default is True. | ||
_check_return_type (bool): specifies if type checking | ||
should be done one the data received from the server. | ||
Default is True. | ||
_host_index (int/None): specifies the index of the server | ||
that we want to use. | ||
Default is read from the configuration. | ||
async_req (bool): execute request asynchronously | ||
Returns: | ||
{str: (bool, date, datetime, dict, float, int, list, str, none_type)} | ||
If the method is called asynchronously, returns the request | ||
thread. | ||
""" | ||
kwargs['async_req'] = kwargs.get( | ||
'async_req', False | ||
) | ||
kwargs['_return_http_data_only'] = kwargs.get( | ||
'_return_http_data_only', True | ||
) | ||
kwargs['_preload_content'] = kwargs.get( | ||
'_preload_content', True | ||
) | ||
kwargs['_request_timeout'] = kwargs.get( | ||
'_request_timeout', None | ||
) | ||
kwargs['_check_input_type'] = kwargs.get( | ||
'_check_input_type', True | ||
) | ||
kwargs['_check_return_type'] = kwargs.get( | ||
'_check_return_type', True | ||
) | ||
kwargs['_host_index'] = kwargs.get('_host_index') | ||
kwargs['send_event_request'] = \ | ||
send_event_request | ||
return self.call_with_http_info(**kwargs) | ||
|
||
self.send_event = _Endpoint( | ||
settings={ | ||
'response_type': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), | ||
'auth': [ | ||
'BasicAuth' | ||
], | ||
'endpoint_path': '/v4/events:sendEvent', | ||
'operation_id': 'send_event', | ||
'http_method': 'POST', | ||
'servers': None, | ||
}, | ||
params_map={ | ||
'all': [ | ||
'send_event_request', | ||
], | ||
'required': [ | ||
'send_event_request', | ||
], | ||
'nullable': [ | ||
], | ||
'enum': [ | ||
], | ||
'validation': [ | ||
] | ||
}, | ||
root_map={ | ||
'validations': { | ||
}, | ||
'allowed_values': { | ||
}, | ||
'openapi_types': { | ||
'send_event_request': | ||
(SendEventRequest,), | ||
}, | ||
'attribute_map': { | ||
}, | ||
'location_map': { | ||
'send_event_request': 'body', | ||
}, | ||
'collection_format_map': { | ||
} | ||
}, | ||
headers_map={ | ||
'accept': [ | ||
'application/json' | ||
], | ||
'content_type': [ | ||
'application/json' | ||
] | ||
}, | ||
api_client=api_client, | ||
callable=__send_event | ||
) |
Oops, something went wrong.