Skip to content

Latest commit

 

History

History
406 lines (322 loc) · 18.9 KB

PromotionsApi.md

File metadata and controls

406 lines (322 loc) · 18.9 KB

PromotionsApi

All URIs are relative to https://api.search.io

Method HTTP request Description
createPromotion POST /v4/collections/{collection_id}/promotions Create promotion
deletePromotion DELETE /v4/collections/{collection_id}/promotions/{promotion_id} Delete promotion
getPromotion GET /v4/collections/{collection_id}/promotions/{promotion_id} Get promotion
listPromotions GET /v4/collections/{collection_id}/promotions List promotions
updatePromotion PATCH /v4/collections/{collection_id}/promotions/{promotion_id} Update promotion

createPromotion

Promotion createPromotion(collectionId, promotion, accountId)

Create promotion

Create a new promotion in a collection.

Example

// Import classes:
import com.sajari.client.ApiClient;
import com.sajari.client.ApiException;
import com.sajari.client.Configuration;
import com.sajari.client.auth.*;
import com.sajari.client.models.*;
import com.sajari.client.api.PromotionsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.search.io");
    
    // Configure HTTP basic authorization: BasicAuth
    HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
    BasicAuth.setUsername("YOUR USERNAME");
    BasicAuth.setPassword("YOUR PASSWORD");

    PromotionsApi apiInstance = new PromotionsApi(defaultClient);
    String collectionId = "collectionId_example"; // String | The collection to create a promotion in, e.g. `my-collection`.
    Promotion promotion = new Promotion(); // Promotion | The promotion to create.
    String accountId = "accountId_example"; // String | The account that owns the collection, e.g. `1618535966441231024`.
    try {
      Promotion result = apiInstance.createPromotion(collectionId, promotion, accountId);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling PromotionsApi#createPromotion");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
collectionId String The collection to create a promotion in, e.g. `my-collection`.
promotion Promotion The promotion to create.
accountId String The account that owns the collection, e.g. `1618535966441231024`. [optional]

Return type

Promotion

Authorization

BasicAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
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. -

deletePromotion

Object deletePromotion(collectionId, promotionId, accountId)

Delete promotion

Delete a promotion and all of its associated data. > Note: This operation cannot be reversed.

Example

// Import classes:
import com.sajari.client.ApiClient;
import com.sajari.client.ApiException;
import com.sajari.client.Configuration;
import com.sajari.client.auth.*;
import com.sajari.client.models.*;
import com.sajari.client.api.PromotionsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.search.io");
    
    // Configure HTTP basic authorization: BasicAuth
    HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
    BasicAuth.setUsername("YOUR USERNAME");
    BasicAuth.setPassword("YOUR PASSWORD");

    PromotionsApi apiInstance = new PromotionsApi(defaultClient);
    String collectionId = "collectionId_example"; // String | The collection the promotion belongs to, e.g. `my-collection`.
    String promotionId = "promotionId_example"; // String | The promotion to delete, e.g. `1234`.
    String accountId = "accountId_example"; // String | The account that owns the collection, e.g. `1618535966441231024`.
    try {
      Object result = apiInstance.deletePromotion(collectionId, promotionId, accountId);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling PromotionsApi#deletePromotion");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
collectionId String The collection the promotion belongs to, e.g. `my-collection`.
promotionId String The promotion to delete, e.g. `1234`.
accountId String The account that owns the collection, e.g. `1618535966441231024`. [optional]

Return type

Object

Authorization

BasicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
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 promotion was not found. -
500 Returned when the API encounters an internal error. -
0 An unexpected error response. -

getPromotion

Promotion getPromotion(collectionId, promotionId, accountId)

Get promotion

Retrieve the details of a promotion.

Example

// Import classes:
import com.sajari.client.ApiClient;
import com.sajari.client.ApiException;
import com.sajari.client.Configuration;
import com.sajari.client.auth.*;
import com.sajari.client.models.*;
import com.sajari.client.api.PromotionsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.search.io");
    
    // Configure HTTP basic authorization: BasicAuth
    HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
    BasicAuth.setUsername("YOUR USERNAME");
    BasicAuth.setPassword("YOUR PASSWORD");

    PromotionsApi apiInstance = new PromotionsApi(defaultClient);
    String collectionId = "collectionId_example"; // String | The collection that owns the promotion, e.g. `my-collection`.
    String promotionId = "promotionId_example"; // String | The promotion to retrieve, e.g. `1234`.
    String accountId = "accountId_example"; // String | The account that owns the collection, e.g. `1618535966441231024`.
    try {
      Promotion result = apiInstance.getPromotion(collectionId, promotionId, accountId);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling PromotionsApi#getPromotion");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
collectionId String The collection that owns the promotion, e.g. `my-collection`.
promotionId String The promotion to retrieve, e.g. `1234`.
accountId String The account that owns the collection, e.g. `1618535966441231024`. [optional]

Return type

Promotion

Authorization

BasicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
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. -

listPromotions

ListPromotionsResponse listPromotions(collectionId, accountId, pageSize, pageToken, view)

List promotions

Retrieve a list of promotions in a collection. Promotion pins, exclusions and filter boosts are not returned in this call.

Example

// Import classes:
import com.sajari.client.ApiClient;
import com.sajari.client.ApiException;
import com.sajari.client.Configuration;
import com.sajari.client.auth.*;
import com.sajari.client.models.*;
import com.sajari.client.api.PromotionsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.search.io");
    
    // Configure HTTP basic authorization: BasicAuth
    HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
    BasicAuth.setUsername("YOUR USERNAME");
    BasicAuth.setPassword("YOUR PASSWORD");

    PromotionsApi apiInstance = new PromotionsApi(defaultClient);
    String collectionId = "collectionId_example"; // String | The collection that owns this set of promotions, e.g. `my-collection`.
    String accountId = "accountId_example"; // String | The account that owns the collection, e.g. `1618535966441231024`.
    Integer pageSize = 56; // Integer | The maximum number of promotions to return. The service may return fewer than this value.  If unspecified, at most 50 promotions are returned.  The maximum value is 1000; values above 1000 are coerced to 1000.
    String pageToken = "pageToken_example"; // String | A page token, received from a previous [ListPromotions](/docs/api#operation/ListPromotions) call.  Provide this to retrieve the subsequent page.  When paginating, all other parameters provided to [ListPromotions](/docs/api#operation/ListPromotions) must match the call that provided the page token.
    String view = "PROMOTION_VIEW_UNSPECIFIED"; // String | The amount of information to include in each retrieved promotion.   - PROMOTION_VIEW_UNSPECIFIED: The default / unset value. The API defaults to the `FULL` view.  - BASIC: Include basic information including name, start time and end time, but not detailed information about the promotion effects.  - FULL: Returns all information about a promotion. This is the default value.
    try {
      ListPromotionsResponse result = apiInstance.listPromotions(collectionId, accountId, pageSize, pageToken, view);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling PromotionsApi#listPromotions");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
collectionId String The collection that owns this set of promotions, e.g. `my-collection`.
accountId String The account that owns the collection, e.g. `1618535966441231024`. [optional]
pageSize Integer The maximum number of promotions to return. The service may return fewer than this value. If unspecified, at most 50 promotions are returned. The maximum value is 1000; values above 1000 are coerced to 1000. [optional]
pageToken String A page token, received from a previous ListPromotions call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to ListPromotions must match the call that provided the page token. [optional]
view String The amount of information to include in each retrieved promotion. - PROMOTION_VIEW_UNSPECIFIED: The default / unset value. The API defaults to the `FULL` view. - BASIC: Include basic information including name, start time and end time, but not detailed information about the promotion effects. - FULL: Returns all information about a promotion. This is the default value. [optional] [default to PROMOTION_VIEW_UNSPECIFIED] [enum: PROMOTION_VIEW_UNSPECIFIED, BASIC, FULL]

Return type

ListPromotionsResponse

Authorization

BasicAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
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. -

updatePromotion

Promotion updatePromotion(collectionId, promotionId, updateMask, promotion, accountId)

Update promotion

Update the details of a promotion. Pass each field that you want to update in the request body. Also specify the name of each field that you want to update in the `update_mask` in the request URL query string. Separate multiple fields with a comma. Fields included in the request body, but not included in the field mask are not updated. For example, to update the `display_name` and `start_time` fields, make a `PATCH` request to the URL: ``` /v4/collections/{collection_id}/promotions/{promotion_id}?update_mask=display_name,start_time ``` With the JSON body: ``` { "display_name": "new value", "start_time": "2006-01-02T15:04:05Z07:00", "end_time": "2006-01-02T15:04:05Z07:00" } ``` > Note: In this example `end_time` is not updated because it is not specified in the `update_mask`.

Example

// Import classes:
import com.sajari.client.ApiClient;
import com.sajari.client.ApiException;
import com.sajari.client.Configuration;
import com.sajari.client.auth.*;
import com.sajari.client.models.*;
import com.sajari.client.api.PromotionsApi;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = Configuration.getDefaultApiClient();
    defaultClient.setBasePath("https://api.search.io");
    
    // Configure HTTP basic authorization: BasicAuth
    HttpBasicAuth BasicAuth = (HttpBasicAuth) defaultClient.getAuthentication("BasicAuth");
    BasicAuth.setUsername("YOUR USERNAME");
    BasicAuth.setPassword("YOUR PASSWORD");

    PromotionsApi apiInstance = new PromotionsApi(defaultClient);
    String collectionId = "collectionId_example"; // String | The collection the promotion belongs to, e.g. `my-collection`.
    String promotionId = "promotionId_example"; // String | The promotion to update, e.g. `1234`.
    String updateMask = "updateMask_example"; // String | The list of fields to be updated, separated by a comma, e.g. `field1,field2`.  Each field should be in snake case, e.g. `display_name`, `filter_boosts`.  For each field that you want to update, provide a corresponding value in the promotion object containing the new value.
    Promotion promotion = new Promotion(); // Promotion | Details of the promotion to update.
    String accountId = "accountId_example"; // String | The account that owns the collection, e.g. `1618535966441231024`.
    try {
      Promotion result = apiInstance.updatePromotion(collectionId, promotionId, updateMask, promotion, accountId);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling PromotionsApi#updatePromotion");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}

Parameters

Name Type Description Notes
collectionId String The collection the promotion belongs to, e.g. `my-collection`.
promotionId String The promotion to update, e.g. `1234`.
updateMask String The list of fields to be updated, separated by a comma, e.g. `field1,field2`. Each field should be in snake case, e.g. `display_name`, `filter_boosts`. For each field that you want to update, provide a corresponding value in the promotion object containing the new value.
promotion Promotion Details of the promotion to update.
accountId String The account that owns the collection, e.g. `1618535966441231024`. [optional]

Return type

Promotion

Authorization

BasicAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 A successful response. -
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 promotion was not found. -
500 Returned when the API encounters an internal error. -
0 An unexpected error response. -