Jestor SDK for .NET (Beta)
.NET SDK documentation.
Default Settings
To use Jestor SDK you need to pass your org (account name) and API token.
In the constructor you should pass the class of the table you want to work with. It is possible to use dynamic or object, but you may consider creating class types based on each table you're going to be working with.
Create Record
To create a record use the tables method using the table name as a parameter, then the insert method using an object as a parameter. Example:
var jestor = new Jestor<MyTable>(org, token);
var record = new MyTable{
field1 ="value1",
field2 = 1,
field3 = "value3"
};
var result = jestor.Tables("table_name").Insert(record);
Console.WriteLine(result.id_table_name); //result will be an object in your table
Edit Record
To edit a record use the tables method using the table name as a parameter, then the update method using the id of the record that will be changed and a Dictionary as a parameter. Example:
var jestor = new Jestor<MyTable>(org, token);
int recordId = 1;
var dictionary = new Dictionary<string, dynamic>();
dictionary.Add("field1", "value 123");
dictionary.Add("field_date", new DateTime(2022,12,25));
var result = jestor.Tables('table_name').Update(recordId, dictionary);
Console.WriteLine(result.field1); //result will be an object in your table
Delete Record
To delete a record use the tables method using the table name as a parameter, then the delete method using the record id as a parameter. Example:
var jestor = new Jestor<MyTable>(org, token);
int recordId = 1;
bool isOK = jestor.Tables('table_name').Delete(recordId);
Console.WriteLine(isOK == true? "Successfully deleted.": "Error when deleting.");
List Records
To list records use the tables method using the table name as a parameter, then the get method.
- filters: List of Filter = null,
- limit: int = 100,
- page: int = 1,
- sort: string = null
Example:
var jestor = new Jestor<MyTable>(org, token);
var list = jestor.Tables('table_name').Get();
Console.WriteLine(list.Count); //list will be a list of objects
// To apply filters use the Filter object:
var filters = new List<Filter>();
filters.Add(new Filter("field_name", "field_value", "string", Operators.like));
var list = jestor.Tables('table_name').Get(filters)
Console.WriteLine(list.Count); //list will be list of objects filtered by filters
The Filter object receives the following parameters:
- field_name: string (field name).
- value: string (field value).
- type: string (field type).
- operator: Enumerable.
Create User
To create a user use the user() method, then the createUser() method passing a list as a parameter. This list must contain the following fields in order: [email, password, profile_id, name]. Example:
var jestor = new Jestor<MyTable>(org, token);
var newUser = jestor.User().CreateUser("email", "password", 999, "name", true, Seats.member);
Console.WriteLine(newUser.name); //newUser will be list a User object
List of fields:
- email: string (user e-mail).
- password: string (user password, if you don't want to set a default password just pass an empty string).
- profileId: int (users roles).
- name: string (user first name).
- sendEmailToValidation: bool (By default is set to false, if you want the user to confirm whether the e-mail is real set this to true. If you set it to true, you don't need to pass a password).
- Seats: Enumerable (By default new users will be created as member, but you can set other types).
List Users
To list users use the user() method, then the get method. The get method accepts the following parameters:
- filters: List of Filter = null,
- limit: int = 100,
- page: int = 1,
- sort: string = null
Example:
var jestor = new Jestor<MyTable>(org, token);
var list = jestor.User().Get();
Console.WriteLine(list.Count); //list will be a list of users
// To apply filters use the Filter object:
var filters = new List<Filter>();
filters.Add(new Filter("email", "email", "string", Operators.like));
var list = jestor.User().Get(filters);
Console.WriteLine(list.Count);
Updated almost 2 years ago