Skip to content

hantuzun/suggestgrid-net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Getting started

How to Build

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.

  1. Open the solution (SuggestGrid.sln) file.
  2. Invoke the build process using Ctrl+Shift+B shortcut key or using the Build menu as shown below.

Building SDK using Visual Studio

How to Use

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.

1. Starting a new project

For starting a new project, right click on the current solution from the solution explorer and choose Add -> New Project.

Add a new project in the existing solution using Visual Studio

Next, choose "Console Application", provide a TestConsoleProject as the project name and click OK.

Create a new console project using Visual Studio

2. Set as startup project

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.

Set the new cosole project as the start up project

3. Add reference of the library project

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....

Open references of the TestConsoleProject

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.

Add a reference to the TestConsoleProject

4. Write sample code

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.

Add a reference to the TestConsoleProject

How to Test

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.

Initialization

Authentication and

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

Class Reference

List of Controllers

Class: TypeController

Get singleton instance

The singleton instance of the TypeController class can be accessed from the API Client.

TypeController type = client.Type;

Method: GetAllTypes

Get All Types

Task<GetTypesResponse> GetAllTypes()

Example Usage

GetTypesResponse result = await type.GetAllTypes();

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: DeleteAllTypes

Delete All Types

Task<MessageResponse> DeleteAllTypes()

Example Usage

MessageResponse result = await type.DeleteAllTypes();

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: GetType

Get Properties of a Type

Task<GetTypeResponse> GetType(string type)

Parameters

Parameter Tags Description
type Required The name of the type to get properties.

Example Usage

string type = "type";

GetTypeResponse result = await type.GetType(type);

Errors

Error Code Error Description
404 Type not found.
429 Too many requests.
500 Unexpected internal error.

Method: CreateType

Create a New Type

Task<MessageResponse> CreateType(string type, TypeRequestBody settings = null)

Parameters

Parameter Tags Description
type Required The name of the type.
settings Optional Optional settings for the rating parameter.

Example Usage

string type = "type";
var settings = new TypeRequestBody();

MessageResponse result = await type.CreateType(type, settings);

Errors

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.

Method: DeleteType

Delete a Type

Task<MessageResponse> DeleteType(string type)

Parameters

Parameter Tags Description
type Required The name of the type to be deleted.

Example Usage

string type = "type";

MessageResponse result = await type.DeleteType(type);

Errors

Error Code Error Description
404 Type does not exists.
429 Too many requests.
500 Unexpected internal error.

Back to List of Controllers

Class: ActionController

Get singleton instance

The singleton instance of the ActionController class can be accessed from the API Client.

ActionController action = client.Action;

Method: GetActions

Get Actions

Task<ActionsResponse> GetActions(
        string type = null,
        string userId = null,
        string itemId = null,
        string olderThan = null,
        int? size = null,
        int? mfrom = null)

Parameters

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".

Example Usage

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

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: PostAction

Post an Action

Task<MessageResponse> PostAction(Action action)

Parameters

Parameter Tags Description
action Required The action to be posted.

Example Usage

var action = new Action();

MessageResponse result = await action.PostAction(action);

Errors

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.

Method: DeleteActions

Delete Actions

Task<DeleteSuccessResponse> DeleteActions(
        string type = null,
        string userId = null,
        string itemId = null,
        string olderThan = null)

Parameters

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

Example Usage

string type = "type";
string userId = "user_id";
string itemId = "item_id";
string olderThan = "older_than";

DeleteSuccessResponse result = await action.DeleteActions(type, userId, itemId, olderThan);

Errors

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.

Method: PostBulkActions

Post Bulk Actions

Task<BulkPostResponse> PostBulkActions(string actions)

Parameters

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.

Example Usage

string actions = "actions";

BulkPostResponse result = await action.PostBulkActions(actions);

Errors

Error Code Error Description
400 Body is missing.
402 Action limit exceeded.
429 Too many requests.
500 Unexpected internal error.

Back to List of Controllers

Class: MetadataController

Get singleton instance

The singleton instance of the MetadataController class can be accessed from the API Client.

MetadataController metadata = client.Metadata;

Method: GetUser

Get A User

Task<Metadata> GetUser(string userId)

Parameters

Parameter Tags Description
userId Required The user id to delete its metadata.

Example Usage

string userId = "user_id";

Metadata result = await metadata.GetUser(userId);

Errors

Error Code Error Description
404 User not found.
500 Unexpected internal error.

Method: DeleteUser

Delete a User

Task<MessageResponse> DeleteUser(string userId)

Parameters

Parameter Tags Description
userId Required The user id to delete its metadata.

Example Usage

string userId = "user_id";

MessageResponse result = await metadata.DeleteUser(userId);

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: GetUsers

Get Users

Task<UsersResponse> GetUsers(int? size = null, int? mfrom = null)

Parameters

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".

Example Usage

int? size = 82;
int? mfrom = 82;

UsersResponse result = await metadata.GetUsers(size, mfrom);

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: PostUser

Post a User

Task<MessageResponse> PostUser(Metadata user)

Parameters

Parameter Tags Description
user Required The metadata to be saved. Metadata format has its restrictions.

Example Usage

var user = new Metadata();

MessageResponse result = await metadata.PostUser(user);

Errors

Error Code Error Description
400 Metadata is invalid.
429 Too many requests.
500 Unexpected internal error.

Method: DeleteAllUsers

Delete All Users

Task<MessageResponse> DeleteAllUsers()

Example Usage

MessageResponse result = await metadata.DeleteAllUsers();

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: GetItem

Get An Item

Task<Metadata> GetItem(string itemId)

Parameters

Parameter Tags Description
itemId Required The item id to delete its metadata.

Example Usage

string itemId = "item_id";

Metadata result = await metadata.GetItem(itemId);

Errors

Error Code Error Description
404 Item not found.
500 Unexpected internal error.

Method: DeleteItem

Delete An Item

Task<MessageResponse> DeleteItem(string itemId)

Parameters

Parameter Tags Description
itemId Required The item id to delete its metadata.

Example Usage

string itemId = "item_id";

MessageResponse result = await metadata.DeleteItem(itemId);

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: GetItems

Get Items

Task<ItemsResponse> GetItems(int? size = null, int? mfrom = null)

Parameters

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".

Example Usage

int? size = 173;
int? mfrom = 173;

ItemsResponse result = await metadata.GetItems(size, mfrom);

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: PostItem

Post an Item

Task<MessageResponse> PostItem(Metadata item)

Parameters

Parameter Tags Description
item Required The metadata to be saved. Metadata format has its restrictions.

Example Usage

var item = new Metadata();

MessageResponse result = await metadata.PostItem(item);

Errors

Error Code Error Description
400 Metadata is invalid.
429 Too many requests.
500 Unexpected internal error.

Method: DeleteAllItems

Delete All Items

Task<MessageResponse> DeleteAllItems()

Example Usage

MessageResponse result = await metadata.DeleteAllItems();

Errors

Error Code Error Description
429 Too many requests.
500 Unexpected internal error.

Method: PostBulkUsers

Post Bulk Users

Task<BulkPostResponse> PostBulkUsers(string users)

Parameters

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.

Example Usage

string users = "users";

BulkPostResponse result = await metadata.PostBulkUsers(users);

Errors

Error Code Error Description
400 Body is missing.
429 Too many requests.
500 Unexpected internal error.

Method: PostBulkItems

Post Bulk Items

Task<BulkPostResponse> PostBulkItems(string items)

Parameters

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.

Example Usage

string items = "items";

BulkPostResponse result = await metadata.PostBulkItems(items);

Errors

Error Code Error Description
400 Body is missing.
429 Too many requests.
500 Unexpected internal error.

Back to List of Controllers

Class: RecommendationController

Get singleton instance

The singleton instance of the RecommendationController class can be accessed from the API Client.

RecommendationController recommendation = client.Recommendation;

Method: GetRecommendedUsers

Get Recommended Users

Task<UsersResponse> GetRecommendedUsers(GetRecommendedUsersBody query)

Parameters

Parameter Tags Description
query Required The query for recommended users.

Example Usage

var query = new GetRecommendedUsersBody();

UsersResponse result = await recommendation.GetRecommendedUsers(query);

Errors

Error Code Error Description
400 Request body is invalid.
422 Required parameters are missing.
429 Too many requests.
500 Unexpected internal error.

Method: GetRecommendedItems

Get Recommended Items

Task<ItemsResponse> GetRecommendedItems(GetRecommendedItemsBody query)

Parameters

Parameter Tags Description
query Required The query for recommended items.

Example Usage

var query = new GetRecommendedItemsBody();

ItemsResponse result = await recommendation.GetRecommendedItems(query);

Errors

Error Code Error Description
400 Request body is invalid.
422 Required parameters are missing.
429 Too many requests.
500 Unexpected internal error.

Back to List of Controllers

Class: SimilarityController

Get singleton instance

The singleton instance of the SimilarityController class can be accessed from the API Client.

SimilarityController similarity = client.Similarity;

Method: GetSimilarUsers

Get Similar Users

Task<UsersResponse> GetSimilarUsers(GetSimilarUsersBody query)

Parameters

Parameter Tags Description
query Required The query for similar users.

Example Usage

var query = new GetSimilarUsersBody();

UsersResponse result = await similarity.GetSimilarUsers(query);

Errors

Error Code Error Description
400 Request body is invalid.
422 Required parameters are missing.
429 Too many requests.
500 Unexpected internal error.

Method: GetSimilarItems

Get Similar Items

Task<ItemsResponse> GetSimilarItems(GetSimilarItemsBody query)

Parameters

Parameter Tags Description
query Required The query for similar items.

Example Usage

var query = new GetSimilarItemsBody();

ItemsResponse result = await similarity.GetSimilarItems(query);

Errors

Error Code Error Description
400 Request body is invalid.
422 Required parameters are missing.
429 Too many requests.
500 Unexpected internal error.

Back to List of Controllers

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages