#Getting started
The generated code uses a few NuGet Packages e.g., Newtonsoft.Json, UniRest, and Microsoft Base Class Library. The reference to these packages is already added as in the packages.config file. If the automatic NuGet package restore is enabled, these dependencies will be installed automatically. Therefore, you will need internet access for build.
- Open the solution (SuggestGrid.sln) file.
- Invoke the build process using
Ctrl+Shift+B
shortcut key or using theBuild
menu as shown below.
The build process generates a portable class library, which can be used like a normal class library. The generated library is compatible with Windows Forms, Windows RT, Windows Phone 8, Silverlight 5, Xamarin iOS, Xamarin Android and Mono. More information on how to use can be found at the MSDN Portable Class Libraries documentation.
The following section explains how to use the SuggestGrid library in a new console project.
For starting a new project, right click on the current solution from the solution explorer and choose Add -> New Project
.
Next, choose "Console Application", provide a TestConsoleProject
as the project name and click OK
.
The new console project is the entry point for the eventual execution. This requires us to set the TestConsoleProject
as the start-up project. To do this, right-click on the TestConsoleProject
and choose Set as StartUp Project
form the context menu.
In order to use the SuggestGrid library in the new project, first we must add a projet reference to the TestConsoleProject
. First, right click on the References
node in the solution explorer and click Add Reference...
.
Next, a window will be displayed where we must set the checkbox
on SuggestGrid.PCL
and click OK
. By doing this, we have added a reference of the SuggestGrid.PCL
project into the new TestConsoleProject
.
Once the TestConsoleProject
is created, a file named Program.cs
will be visible in the solution explorer with an empty Main
method. This is the entry point for the execution of the entire solution.
Here, you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.
The generated SDK also contain one or more Tests, which are contained in the Tests project. In order to invoke these test cases, you will need NUnit 3.0 Test Adapter Extension for Visual Studio. Once the SDK is complied, the test cases should appear in the Test Explorer window. Here, you can click Run All to execute these test cases.
In order to setup authentication and initialization of the API client, you need the following information.
Parameter | Description |
---|---|
basicAuthUserName | The username to use with basic authentication |
basicAuthPassword | The password to use with basic authentication |
API client can be initialized as following.
// Configuration parameters and credentials
string basicAuthUserName = "basicAuthUserName"; // The username to use with basic authentication
string basicAuthPassword = "basicAuthPassword"; // The password to use with basic authentication
SuggestGridClient client = new SuggestGridClient(basicAuthUserName, basicAuthPassword);
The singleton instance of the TypeController
class can be accessed from the API Client.
TypeController type = client.Type;
Get All Types
Task<GetTypesResponse> GetAllTypes()
GetTypesResponse result = await type.GetAllTypes();
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Delete All Types
Task<MessageResponse> DeleteAllTypes()
MessageResponse result = await type.DeleteAllTypes();
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Get Properties of a Type
Task<GetTypeResponse> GetType(string type)
Parameter | Tags | Description |
---|---|---|
type | Required |
The name of the type to get properties. |
string type = "type";
GetTypeResponse result = await type.GetType(type);
Error Code | Error Description |
---|---|
404 | Type not found. |
429 | Too many requests. |
500 | Unexpected internal error. |
Create a New Type
Task<MessageResponse> CreateType(string type, TypeRequestBody settings = null)
Parameter | Tags | Description |
---|---|---|
type | Required |
The name of the type. |
settings | Optional |
Optional settings for the rating parameter. |
string type = "type";
var settings = new TypeRequestBody();
MessageResponse result = await type.CreateType(type, settings);
Error Code | Error Description |
---|---|
402 | Type limit reached. |
409 | Type already exists. |
422 | Rating type is not implicit or explicit . |
429 | Too many requests. |
500 | Unexpected internal error. |
Delete a Type
Task<MessageResponse> DeleteType(string type)
Parameter | Tags | Description |
---|---|---|
type | Required |
The name of the type to be deleted. |
string type = "type";
MessageResponse result = await type.DeleteType(type);
Error Code | Error Description |
---|---|
404 | Type does not exists. |
429 | Too many requests. |
500 | Unexpected internal error. |
The singleton instance of the ActionController
class can be accessed from the API Client.
ActionController action = client.Action;
Get Actions
Task<ActionsResponse> GetActions(
string type = null,
string userId = null,
string itemId = null,
string olderThan = null,
int? size = null,
int? mfrom = null)
Parameter | Tags | Description |
---|---|---|
type | Optional |
The type of the actions. |
userId | Optional |
The user id of the actions. |
itemId | Optional |
The item id of the actions. |
olderThan | Optional |
Maxium timestamp of the actions. |
Valid times are 1s, 1m, 1h, 1d, 1M, 1y, or unix timestamp (like 1443798195). | ||
size | Optional |
The number of the users response. |
Defaults to 10. Must be between 1 and 10.000 inclusive. | ||
This parameter must be string represetation of an integer like "1". | ||
mfrom | Optional |
The number of users to be skipped for response. |
Defaults to 0. Must be bigger than or equal to 0. | ||
This parameter must be string represetation of an integer like "1". |
string type = "type";
string userId = "user_id";
string itemId = "item_id";
string olderThan = "older_than";
int? size = 124;
int? mfrom = 124;
ActionsResponse result = await action.GetActions(type, userId, itemId, olderThan, size, mfrom);
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Post an Action
Task<MessageResponse> PostAction(Action action)
Parameter | Tags | Description |
---|---|---|
action | Required |
The action to be posted. |
var action = new Action();
MessageResponse result = await action.PostAction(action);
Error Code | Error Description |
---|---|
400 | Required user_id or item_id parameters are missing from the request body. |
402 | Action limit exceeded. |
404 | Type does not exists. |
429 | Too many requests. |
500 | Unexpected internal error. |
Delete Actions
Task<DeleteSuccessResponse> DeleteActions(
string type = null,
string userId = null,
string itemId = null,
string olderThan = null)
Parameter | Tags | Description |
---|---|---|
type | Optional |
The type of the actions. |
userId | Optional |
The user id of the actions. |
itemId | Optional |
The item id of the actions. |
olderThan | Optional |
Delete all actions of a type older than the given timestamp or time. |
Valid times are 1s, 1m, 1h, 1d, 1M, 1y, or unix timestamp (like 1443798195). |
string type = "type";
string userId = "user_id";
string itemId = "item_id";
string olderThan = "older_than";
DeleteSuccessResponse result = await action.DeleteActions(type, userId, itemId, olderThan);
Error Code | Error Description |
---|---|
400 | Required user_id or item_id parameters are missing from the request body. |
404 | Delete actions not found. |
422 | No query parameter (user_id , item_id , or older_than ) is given. In order to delete all actionsdelete the type. |
429 | Too many requests. |
505 | Request timed out. |
500 | Unexpected internal error. |
Post Bulk Actions
Task<BulkPostResponse> PostBulkActions(string actions)
Parameter | Tags | Description |
---|---|---|
actions | Required |
A number of action objects separated with newlines. |
Note that this is not a valid JSON data structure. | ||
The body size is limited to 10 thousand lines. |
string actions = "actions";
BulkPostResponse result = await action.PostBulkActions(actions);
Error Code | Error Description |
---|---|
400 | Body is missing. |
402 | Action limit exceeded. |
429 | Too many requests. |
500 | Unexpected internal error. |
The singleton instance of the MetadataController
class can be accessed from the API Client.
MetadataController metadata = client.Metadata;
Get A User
Task<Metadata> GetUser(string userId)
Parameter | Tags | Description |
---|---|---|
userId | Required |
The user id to delete its metadata. |
string userId = "user_id";
Metadata result = await metadata.GetUser(userId);
Error Code | Error Description |
---|---|
404 | User not found. |
500 | Unexpected internal error. |
Delete a User
Task<MessageResponse> DeleteUser(string userId)
Parameter | Tags | Description |
---|---|---|
userId | Required |
The user id to delete its metadata. |
string userId = "user_id";
MessageResponse result = await metadata.DeleteUser(userId);
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Get Users
Task<UsersResponse> GetUsers(int? size = null, int? mfrom = null)
Parameter | Tags | Description |
---|---|---|
size | Optional |
The number of the users response. |
Defaults to 10. Must be between 1 and 10.000 inclusive. | ||
This parameter must be string represetation of an integer like "1". | ||
mfrom | Optional |
The number of users to be skipped for response. |
Defaults to 0. Must be bigger than or equal to 0. | ||
This parameter must be string represetation of an integer like "1". |
int? size = 82;
int? mfrom = 82;
UsersResponse result = await metadata.GetUsers(size, mfrom);
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Post a User
Task<MessageResponse> PostUser(Metadata user)
Parameter | Tags | Description |
---|---|---|
user | Required |
The metadata to be saved. Metadata format has its restrictions. |
var user = new Metadata();
MessageResponse result = await metadata.PostUser(user);
Error Code | Error Description |
---|---|
400 | Metadata is invalid. |
429 | Too many requests. |
500 | Unexpected internal error. |
Delete All Users
Task<MessageResponse> DeleteAllUsers()
MessageResponse result = await metadata.DeleteAllUsers();
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Get An Item
Task<Metadata> GetItem(string itemId)
Parameter | Tags | Description |
---|---|---|
itemId | Required |
The item id to delete its metadata. |
string itemId = "item_id";
Metadata result = await metadata.GetItem(itemId);
Error Code | Error Description |
---|---|
404 | Item not found. |
500 | Unexpected internal error. |
Delete An Item
Task<MessageResponse> DeleteItem(string itemId)
Parameter | Tags | Description |
---|---|---|
itemId | Required |
The item id to delete its metadata. |
string itemId = "item_id";
MessageResponse result = await metadata.DeleteItem(itemId);
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Get Items
Task<ItemsResponse> GetItems(int? size = null, int? mfrom = null)
Parameter | Tags | Description |
---|---|---|
size | Optional |
The number of the users response. |
Defaults to 10. Must be between 1 and 10.000 inclusive. | ||
This parameter must be string represetation of an integer like "1". | ||
mfrom | Optional |
The number of users to be skipped for response. |
Defaults to 0. Must be bigger than or equal to 0. | ||
This parameter must be string represetation of an integer like "1". |
int? size = 173;
int? mfrom = 173;
ItemsResponse result = await metadata.GetItems(size, mfrom);
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Post an Item
Task<MessageResponse> PostItem(Metadata item)
Parameter | Tags | Description |
---|---|---|
item | Required |
The metadata to be saved. Metadata format has its restrictions. |
var item = new Metadata();
MessageResponse result = await metadata.PostItem(item);
Error Code | Error Description |
---|---|
400 | Metadata is invalid. |
429 | Too many requests. |
500 | Unexpected internal error. |
Delete All Items
Task<MessageResponse> DeleteAllItems()
MessageResponse result = await metadata.DeleteAllItems();
Error Code | Error Description |
---|---|
429 | Too many requests. |
500 | Unexpected internal error. |
Post Bulk Users
Task<BulkPostResponse> PostBulkUsers(string users)
Parameter | Tags | Description |
---|---|---|
users | Required |
A number of user metadata objects separated with newlines. |
Each user metadata object must have its id field. | ||
Note that this is not a valid JSON data structure. | ||
The body size is limited to 10 thousand lines. |
string users = "users";
BulkPostResponse result = await metadata.PostBulkUsers(users);
Error Code | Error Description |
---|---|
400 | Body is missing. |
429 | Too many requests. |
500 | Unexpected internal error. |
Post Bulk Items
Task<BulkPostResponse> PostBulkItems(string items)
Parameter | Tags | Description |
---|---|---|
items | Required |
A number of item metadata objects separated with newlines. |
Each item metadata object must have its id field. | ||
Note that this is not a valid JSON data structure. | ||
The body size is limited to 10 thousand lines. |
string items = "items";
BulkPostResponse result = await metadata.PostBulkItems(items);
Error Code | Error Description |
---|---|
400 | Body is missing. |
429 | Too many requests. |
500 | Unexpected internal error. |
The singleton instance of the RecommendationController
class can be accessed from the API Client.
RecommendationController recommendation = client.Recommendation;
Get Recommended Users
Task<UsersResponse> GetRecommendedUsers(GetRecommendedUsersBody query)
Parameter | Tags | Description |
---|---|---|
query | Required |
The query for recommended users. |
var query = new GetRecommendedUsersBody();
UsersResponse result = await recommendation.GetRecommendedUsers(query);
Error Code | Error Description |
---|---|
400 | Request body is invalid. |
422 | Required parameters are missing. |
429 | Too many requests. |
500 | Unexpected internal error. |
Get Recommended Items
Task<ItemsResponse> GetRecommendedItems(GetRecommendedItemsBody query)
Parameter | Tags | Description |
---|---|---|
query | Required |
The query for recommended items. |
var query = new GetRecommendedItemsBody();
ItemsResponse result = await recommendation.GetRecommendedItems(query);
Error Code | Error Description |
---|---|
400 | Request body is invalid. |
422 | Required parameters are missing. |
429 | Too many requests. |
500 | Unexpected internal error. |
The singleton instance of the SimilarityController
class can be accessed from the API Client.
SimilarityController similarity = client.Similarity;
Get Similar Users
Task<UsersResponse> GetSimilarUsers(GetSimilarUsersBody query)
Parameter | Tags | Description |
---|---|---|
query | Required |
The query for similar users. |
var query = new GetSimilarUsersBody();
UsersResponse result = await similarity.GetSimilarUsers(query);
Error Code | Error Description |
---|---|
400 | Request body is invalid. |
422 | Required parameters are missing. |
429 | Too many requests. |
500 | Unexpected internal error. |
Get Similar Items
Task<ItemsResponse> GetSimilarItems(GetSimilarItemsBody query)
Parameter | Tags | Description |
---|---|---|
query | Required |
The query for similar items. |
var query = new GetSimilarItemsBody();
ItemsResponse result = await similarity.GetSimilarItems(query);
Error Code | Error Description |
---|---|
400 | Request body is invalid. |
422 | Required parameters are missing. |
429 | Too many requests. |
500 | Unexpected internal error. |