Skip to content

Commit

Permalink
Update to support the SendEvent API + security version bump for RestS…
Browse files Browse the repository at this point in the history
…harp
  • Loading branch information
justinkoke committed Sep 9, 2021
1 parent 879910a commit 5b6964a
Show file tree
Hide file tree
Showing 6 changed files with 784 additions and 0 deletions.
89 changes: 89 additions & 0 deletions docs/EventsApi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Com.Sajari.Sdk.Api.EventsApi

All URIs are relative to *https://api-gateway.sajari.com*

Method | HTTP request | Description
------------- | ------------- | -------------
[**SendEvent**](EventsApi.md#sendevent) | **POST** /v4/events:sendEvent | Send event


<a name="sendevent"></a>
# **SendEvent**
> Object SendEvent (SendEventRequest sendEventRequest)
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
```csharp
using System.Collections.Generic;
using System.Diagnostics;
using Com.Sajari.Sdk.Api;
using Com.Sajari.Sdk.Client;
using Com.Sajari.Sdk.Model;

namespace Example
{
public class SendEventExample
{
public static void Main()
{
Configuration config = new Configuration();
config.BasePath = "https://api-gateway.sajari.com";
// Configure HTTP basic authorization: BasicAuth
config.Username = "YOUR_USERNAME";
config.Password = "YOUR_PASSWORD";

var apiInstance = new EventsApi(config);
var sendEventRequest = new SendEventRequest(); // SendEventRequest |
try
{
// Send event
Object result = apiInstance.SendEvent(sendEventRequest);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling EventsApi.SendEvent: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
```

### Parameters

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**sendEventRequest** | [**SendEventRequest**](SendEventRequest.md)| |

### Return type

**Object**

### 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)

13 changes: 13 additions & 0 deletions docs/SendEventRequest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Com.Sajari.Sdk.Model.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** | **string** | The name of event, e.g. &#x60;click&#x60;, &#x60;purchase&#x60;. |
**Token** | **string** | The token corresponding to the search result that was interacted with, e.g. &#x60;eyJ...&#x60;. |
**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** | **Dictionary&lt;string, Object&gt;** | 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)

70 changes: 70 additions & 0 deletions src/Com.Sajari.Sdk.Test/Api/EventsApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.
*
* The version of the OpenAPI document: v4
* Contact: [email protected]
* Generated by: https://github.com/openapitools/openapi-generator.git
*/

using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using RestSharp;
using Xunit;

using Com.Sajari.Sdk.Client;
using Com.Sajari.Sdk.Api;
// uncomment below to import models
//using Com.Sajari.Sdk.Model;

namespace Com.Sajari.Sdk.Test.Api
{
/// <summary>
/// Class for testing EventsApi
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the API endpoint.
/// </remarks>
public class EventsApiTests : IDisposable
{
private EventsApi instance;

public EventsApiTests()
{
instance = new EventsApi();
}

public void Dispose()
{
// Cleanup when everything is done.
}

/// <summary>
/// Test an instance of EventsApi
/// </summary>
[Fact]
public void InstanceTest()
{
// TODO uncomment below to test 'IsType' EventsApi
//Assert.IsType<EventsApi>(instance);
}

/// <summary>
/// Test SendEvent
/// </summary>
[Fact]
public void SendEventTest()
{
// TODO uncomment below to test the method and replace null with proper value
//SendEventRequest sendEventRequest = null;
//var response = instance.SendEvent(sendEventRequest);
//Assert.IsType<Object>(response);
}
}
}
95 changes: 95 additions & 0 deletions src/Com.Sajari.Sdk.Test/Model/SendEventRequestTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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.
*
* The version of the OpenAPI document: v4
* Contact: [email protected]
* Generated by: https://github.com/openapitools/openapi-generator.git
*/


using Xunit;

using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
using Com.Sajari.Sdk.Api;
using Com.Sajari.Sdk.Model;
using Com.Sajari.Sdk.Client;
using System.Reflection;
using Newtonsoft.Json;

namespace Com.Sajari.Sdk.Test.Model
{
/// <summary>
/// Class for testing SendEventRequest
/// </summary>
/// <remarks>
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
/// Please update the test case below to test the model.
/// </remarks>
public class SendEventRequestTests : IDisposable
{
// TODO uncomment below to declare an instance variable for SendEventRequest
//private SendEventRequest instance;

public SendEventRequestTests()
{
// TODO uncomment below to create an instance of SendEventRequest
//instance = new SendEventRequest();
}

public void Dispose()
{
// Cleanup when everything is done.
}

/// <summary>
/// Test an instance of SendEventRequest
/// </summary>
[Fact]
public void SendEventRequestInstanceTest()
{
// TODO uncomment below to test "IsType" SendEventRequest
//Assert.IsType<SendEventRequest>(instance);
}


/// <summary>
/// Test the property 'Name'
/// </summary>
[Fact]
public void NameTest()
{
// TODO unit test for the property 'Name'
}
/// <summary>
/// Test the property 'Token'
/// </summary>
[Fact]
public void TokenTest()
{
// TODO unit test for the property 'Token'
}
/// <summary>
/// Test the property 'Weight'
/// </summary>
[Fact]
public void WeightTest()
{
// TODO unit test for the property 'Weight'
}
/// <summary>
/// Test the property 'Metadata'
/// </summary>
[Fact]
public void MetadataTest()
{
// TODO unit test for the property 'Metadata'
}

}

}
Loading

0 comments on commit 5b6964a

Please sign in to comment.