The REST-API is an HTTP-based interface. The response contains a JSON object
- Using Warp as Web-server;
- Using PostgreSQL as BD;
- The response contains a JSON object;
- Supports 4 levels of logging:
- error-level(default): show only error messages;
- warning-level: show only error and warning messages;
- info-level: show info, error and warning messages;
- debug-level: show even more details than info-level;
You may clone GitHub repository
git clone https://github.com/LyuPo7/post-server.git
Project uses PostgreSQL as BD. Before use server you'll need to setup BD;
- Install PostgreSQL BD (https://www.postgresqltutorial.com/install-postgresql-linux/)
- Create PostgreSQL BD user:
- sudo su - postgres # create super user postgres;
- psql #connect the database;
- CREATE ROLE your_username WITH LOGIN CREATEDB ENCRYPTED PASSWORD 'your_password'; #create user with password (option CREATEDB enable to create dbbase);
- Create PostgreSQL BD:
- su 'your_username' # switch to user account (for which was created PostgreSQL user in previous step);
- createdb 'dbName' #connect the database;
- Using PostgreSQL BD in data/config.json:
- Use 'dbName' for field db_settings.dbName;
- Use 'your_username' for field db_settings.user;
- Use 'your_password' for field db_settings.password;
- (for example see config-json-file: 'data/config_example.json')
- "logger_settings"
- "verbocity": [Optional]-[String] level of logging - must be one of ["debug", "info", "warning", "error"] By default will be use "info" level;
- "db_settings"
- "dbName": [Required]-[String] dbname of PostgreSQL DB using for Server;
- "user": [Required]-[String] user-owner of PostgreSQL DB using for Server;
- "password": [Required]-[String] user-password of PostgreSQL DB using for Server;
- "admins": [Required]-[Array of String] List of admins;
- "server_settings"
- "host": [Required]-[String] Server host;
- "port": [Optional]-[String] Server port;
Since bot use PostgreSQL You'll need check if you have installed PostgreSQL in your system (if not - use):
- $ sudo apt-get update -y && sudo apt-get install libpq-dev postgresql -y
-
- $ stack build
-
- $ stack exec post-server-exe
- All supported requests contain in 'data/curl/'
- Every directory contains executables .sh scripts for supported requests;
- For unicode symbols in requests using .sh scripts use folowing:
- Whitespace: %20
- Left square parenthesis "[": %5B
- Right square parenthesis "[": %5D
- Supported requests:
- Account:
- login:
- Use this method to get new Token for User by login;
- Request: http://HOST:PORT/publishDraft?PARAMETERS
- Curl:
- Script location: 'data/curl/account/login.sh'
- Usage (from 'data/curl/account/'): '$ ./login.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -k User password;
- -n User login;
- Response:
- Success: JSON TextResponse object;
- Fail: JSON TextResponse object with text error;
Parameter Type Required Description password String Yes User's password login String Yes User's login
- login:
- User:
- getUsers:
- Use this method to get all User records;
- This method is available for all registered Users;
- In one request You may recieve maximum 50 records;
- For recieve more than 50 records You'll need to use several requests with different offset;
- Request: http://HOST:PORT/getUsers?PARAMETERS
- Curl:
- Script location: 'data/curl/user/getUsers.sh'
- Usage (from 'data/curl/user/'): '$ ./getUsers.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token;
- -o Offset from the first record (ordered by User's id);
- Response:
- Success: JSON UserResponse object;
- Fail: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token offset Integer Yes Offset from first User's record (ordered by User's id). Must be >=0 - createUser:
- Use this method to register new User;
- This method is available for all;
- Request: http://HOST:PORT/createUser?PARAMETERS
- Curl:
- Script location: 'data/curl/user/createUser.sh'
- Usage (from 'data/curl/user/'): '$ ./createUser.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -f User's first name;
- -l User's last name;
- -k User's password;
- -n User's login;
- Response:
- Success: JSON TextResponse object with text success;
- Fail: JSON TextResponse object with text error;
Parameter Type Required Description first_name String Yes User's first name last_name String Yes User's last name login String Yes User's login password String Yes User's password - setUserPhoto:
- Use this method to set Photo for User;
- This method is available only for User-account owner;
- Request: http://HOST:PORT/setUserPhoto?PARAMETERS
- Curl:
- Script location: 'data/curl/user/setUserPhoto.sh'
- Usage (from 'data/curl/user/'): '$ ./setUserPhoto.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token;
- -l Path to photo;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. For successful request account and token must belong to the same User path String Yes Local path to photo - removeUser:
- Use this method to remove User;
- This method is available only for admins;
- Request: http://HOST:PORT/removeUser?PARAMETERS
- Curl:
- Script location: 'data/curl/user/removeUser.sh'
- Usage (from 'data/curl/user/'): '$ ./removeUser.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i User's id (User's to remove)
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions id String Yes User's id (User's to remove)
- getUsers:
- Author:
- getAuthors:
- Use this method to get all Author records;
- This method is available only for admins;
- In one request You may recieve maximum 50 records;
- For recieve more than 50 records You'll need to use several requests with different offset;
- Request: http://HOST:PORT/getAuthors?PARAMETERS
- Curl:
- Script location: 'data/curl/author/getAuthors.sh'
- Usage (from 'data/curl/author/'): '$ ./getAuthors.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -o Offset from first Author's record (ordered by Author's id);
- Response:
- Success: JSON AuthorResponse object;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions offset Integer Yes Offset from first Author's record (ordered by Author's id). Must be >=0 - createAuthor:
- Use this method to create new Author of already existed User;
- This method is available only for admins;
- Request: http://HOST:PORT/createAuthor?PARAMETERS
- Curl:
- Script location: 'data/curl/author/createAuthor.sh'
- Usage (from 'data/curl/author/'): '$ ./createAuthor.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i User's id (for Author creation);
- -d Author's description;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions id Integer Yes User's id (for Author creation) description String Yes Author's description - editAuthor:
- Use this method to edit Author's description;
- This method is available only for admins;
- Request: http://HOST:PORT/editAuthor?PARAMETERS
- Curl:
- Script location: 'data/curl/author/editAuthor.sh'
- Usage (from 'data/curl/author/'): '$ ./editAuthor.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i User's id (corresponding to proper Author);
- -d New Author's description;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions id Integer Yes User's id (corresponding to proper Author) description String Yes New Author's description - removeAuthor:
- Use this method to remove Author. If Author has Posts it's imposible to remove his record. Firstly You'll need to remove all his Posts;
- This method is available only for admins;
- Request: http://HOST:PORT/removeAuthor?PARAMETERS
- Curl:
- Script location: 'data/curl/authors/removeAuthor.sh'
- Usage: '$ ./removeAuthor.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i User's id (corresponding to proper Author);
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions id Integer Yes User's id (corresponding to proper Author)
- getAuthors:
- Category:
- getCategories:
- Use this method to get all Category records;
- This method is available for all registered Users;
- In one request You may recieve maximum 50 records;
- For recieve more than 50 records You'll need to use several requests with different offset;
- Request: http://HOST:PORT/getCategories?PARAMETERS
- Curl:
- Script location: 'data/curl/category/getCategories.sh'
- Usage (from 'data/curl/category/'): '$ ./getCategories.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request;
- -o Offset from first Category's record (ordered by Category's id);
- Response:
- Success: JSON CategoryResponse object;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request offset Integer Yes Offset from first Category's record (ordered by Category's id). Must be >=0 - createCategory:
- Use this method to create new Category. Category's title and SubCategory's title can't be the same;
- This method is available only for admins;
- Request: http://HOST:PORT/createCategory?PARAMETERS
- Curl:
- Script location: 'data/curl/category/createCategory.sh'
- Usage (from 'data/curl/category/'): '$ ./createCategory.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -n Category's title;
- [-s] SubCategory's title (if Category expects to have one);
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions title String Yes Category's title subcategory String Optional SubCategory's title (if Category expects to have one) - editCategory:
- Use this method to edit Category's title, Category's subCategory or both. Category's title and SubCategory's title can't be the same. The SubCategory's title using for request already must exists. You can't use for Category title, title what already exists;
- This method is available only for admins;
- Request: http://HOST:PORT/editCategory?PARAMETERS
- Curl:
- Script location: 'data/curl/category/editCategory.sh'
- Usage (from 'data/curl/category/'): '$ ./editCategory.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i Category's id;
- [-s] SubCategory's title (if You want to change/set SubCategory of Category);
- [-n] New Category's title (if You want to change Category's title);
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions id Integer Yes Category's id title String Optional New Category's title (if You want to change Category's title) subcategory String Optional SubCategory's title (if You want to change/set SubCategory of Category) - removeCategory:
- Use this method to remove Category. If Category is used for Posts it's imposible to remove his record. Firstly You'll need to remove all Posts which included thic Category;
- This method is available only for admins;
- Request: http://HOST:PORT/removeCategory?PARAMETERS
- Curl:
- Script location: 'data/curl/category/removeCategory.sh'
- Usage (from 'data/curl/category/'): '$ ./removeCategory.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i Category's id;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions id Integer Yes Category's id
- getCategories:
- Tag:
- getTags:
- Use this method to get all Tag records;
- This method is available for all registered Users;
- In one request You may recieve maximum 50 records;
- For recieve more than 50 records You'll need to use several requests with different offset;
- Request: http://HOST:PORT/getTags?PARAMETERS
- Curl:
- Script location: 'data/curl/tag/getTags.sh'
- Usage (from 'data/curl/tag/'): '$ ./getTags.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request;
- -o Offset from first Tag's record (ordered by Tag's id);
- Response:
- Success: JSON TagResponse object;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request offset Integer Yes Offset from first Tag's record (ordered by Tag's id). Must be >=0 - createTag:
- Use this method to create new Tag;
- This method is available only for admins;
- Request: http://HOST:PORT/createTag?PARAMETERS
- Curl:
- Script location: 'data/curl/tag/createTag.sh'
- Usage (from 'data/curl/tag/'): '$ ./createTag.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -n Tag's title;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions title String Yes Tag's title - editTag:
- Use this method to edit Tag's title;
- This method is available only for admins;
- Request: http://HOST:PORT/editTag?PARAMETERS
- Curl:
- Script location: 'data/curl/tag/editTag.sh'
- Usage (from 'data/curl/tag/'): '$ ./editTag.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -n New Tag's title;
- -o Old Tag's title;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions new_title String Yes New Tag's title old_title String Yes Old Tag's title - removeTag:
- Use this method to remove Tag. If Tag is used for Posts it'll be remove from all Posts records;
- This method is available only for admins;
- Request: http://HOST:PORT/removeTag?PARAMETERS
- Curl:
- Script location: 'data/curl/tag/removeTag.sh'
- Usage: '$ ./removeTag.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions
- -n Tag's title;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions title String Yes Tag's title
- getTags:
- Post:
- getPosts:
- Use this method to get all Posts records. This method supports:
- Ordering by:
- Date of Post creation;
- Author of Post;
- Category's title;
- Number of photos in Post;
- Search only in Post's text;
- Search only in Post's title;
- Search in Post's title/Post's text/Author's First name and Author's Last name/Category's title Tag's title;
- Search with exact Category's id;
- Search with exact Tag's id;
- Search Posts with Tag's Id ONE of [tag_id];
- Search Posts with Tag's Id ALL in [tag_id];
- Search Posts by Author name (must contain 'first_name' and 'last_name' separated by whitespace.");
- Search Posts with exact date of creation;
- Search Posts created later than specified date;
- Search Posts created earlier than specified date;
- Ordering by:
- This method is available for all registered Users;
- In one request You may recieve maximum 50 records;
- For recieve more than 50 records You'll need to use several requests with different offset;
- Request: http://HOST:PORT/getPosts?PARAMETERS
- Curl:
- Script location: 'data/curl/posts/getPosts.sh'
- Usage (from 'data/curl/posts/'): '$ ./getPosts.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token;
- -o Offset from the first record;
- [-s] Order: key one of ['order_by_date', 'order_by_author', 'order_by_category', 'order_by_photo'] - formated like "key=true";
- [-f] Find string for search in Post's title (Sting may use wildcards - for more info see Appendix A);
- [-e] Find string for search in Post's text (Sting may use wildcards - for more info see Appendix A);
- [-a] Find string for search in (Post's title and Post's text) & (Author's First name and Author's Last name) & (Category's title) & (Tag's title) - the result is union of all searches (Sting may use wildcards - for more info see Appendix A);
- [-c] Search with exact Category's id;
- [-n] Search Posts with exact Tag's Id [tag_id] (lenght [tag_id] == 1);
- [-i] Search Posts with Tag's Id ONE of [tag_id];
- [-k] Search Posts with Tag's Id ALL in [tag_id];
- [-l] Search Posts by Author name (must contain 'first_name' and 'last_name' separated by whitespace.");
- [-q] Search Posts with exact date of creation;
- [-g] Search Posts created later than specified date;
- [-j] Search Posts created earlier than specified date;
- Response:
- Success: JSON PostResponse object;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request offset Integer Yes Offset from first Post's record corresponding to request options (ordered by Post's id). Must be >=0 order_by_date - Optional Using by default. Activate order by date of Post creation. For activate use in query string: "order_by_date=true" order_by_author - Optional Activate order by Author of Post. For activate use in query string: "order_by_author=true" (by default using 'order_by_date') order_by_category - Optional Activate order by Category's title. For activate use in query string: "order_by_category=true" (by default using 'order_by_date') order_by_photo - Optional Activate order by number of photos in Post. For activate use in query string: "order_by_photo=true" (by default using 'order_by_date') find_in_title String with wildcards Optional Find string for search in Post's title (Sting may use wildcards - for more info see Appendix A) find_in_text String with wildcards Optional Find string for search in Post's text (Sting may use wildcards - for more info see Appendix A) find String with wildcards Optional Find string for search in (Post's title and Post's text) & (Author's First name and Author's Last name) & (Category's title) & (Tag's title) - the result is union of all searches (Sting may use wildcards - for more info see Appendix A) category Integer Optional Search Posts with exact Category's id tag [Integer] Optional Search Posts with exact Tag's id. Formed like singleton [tag_id] tag__in [Integer] Optional Search Posts with Tag's Id ONE of [tag_id] tag__all [Integer] Optional Search Posts with Tag's Id ALL in [tag_id] author String with wildcards Optional Search Posts by Author name (must contain 'first_name' and 'last_name' separated by whitespace.") created_at String Optional Search Posts with exact date of creation (formated like "DD.MM.YY") created_at__gt String Optional Search Posts created later than specified date (formated like "DD.MM.YY") created_at__lt String Optional Search Posts created earlier than specified date (formated like "DD.MM.YY") - Use this method to get all Posts records. This method supports:
- createPost:
- Use this method to create new Post;
- This method is available only for Authors;
- Request: http://HOST:PORT/createTag?PARAMETERS
- Curl:
- Script location: 'data/curl/post/createPost.sh'
- Usage (from 'data/curl/post/'): '$ ./createTag.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -n Post's title;
- -b Post's text;
- -c Category's id;
- -m Tag's ids;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions title String Yes Post's title text String Yes Post's text category_id Integer Yes Category's id tag_ids [Integer] Yes Array of Tag's id - setPostMainPhoto:
- Use this method to set Main Photo for Post. If Post already has Main Photo, Main Photo will be updated;
- This method is available only for Author-Post owner;
- Request: http://HOST:PORT/setPostMainPhoto?PARAMETERS
- Curl:
- Script location: 'data/curl/post/setPostMainPhoto.sh'
- Usage (from 'data/curl/post/'): '$ ./setPostMainPhoto.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token;
- -i Post's id
- -l Path to photo
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. For successful request token must belong to User who is the Author of this Post id Integer Yes Post's id path String Yes Local path to photo - setAddMainPhoto:
- Use this method to add Additional Photo for Post;
- This method is available only for Author-Post owner;
- Request: http://HOST:PORT/setAddMainPhoto?PARAMETERS
- Curl:
- Script location: 'data/curl/post/setAddMainPhoto.sh'
- Usage (from 'data/curl/post/'): '$ ./setAddMainPhoto.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token;
- -i Post's id
- -l Path to photo
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. For successful request token must belong to User who is the Author of this Post id Integer Yes Post's id path String Yes Local path to photo - removePost:
- Use this method to remove Post;
- This method is available only for admins;
- Request: http://HOST:PORT/removePost?PARAMETERS
- Curl:
- Script location: 'data/curl/post/removePost.sh'
- Usage (from 'data/curl/post/'): '$ ./removePost.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i Post's id;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions id Integer Yes Post's id
- getPosts:
- Draft:
- getDrafts:
- Use this method to get all Draft records of Author;
- This method is available only for Author-Post owner;
- In one request You may recieve maximum 50 records;
- For recieve more than 50 records You'll need to use several requests with different offset;
- Request: http://HOST:PORT/getDrafts?PARAMETERS
- Curl:
- Script location: 'data/curl/tag/getDrafts.sh'
- Usage (from 'data/curl/tag/'): '$ ./getDrafts.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Read Author Permissions;
- -o Offset from first Draft's record (ordered by Draft's id);
- Response:
- Success: JSON DraftResponse object;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Read Author Permissions; offset Integer Yes Offset from first Draft's record (ordered by Draft's id). Must be >=0 - createDraft:
- Use this method to create Draft of Post;
- This method is available only for Author-Post owner;
- Request: http://HOST:PORT/createDraft?PARAMETERS
- Curl:
- Script location: 'data/curl/draft/createDraft.sh'
- Usage (from 'data/curl/draft/'): '$ ./createDraft.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Read Author Permissions;
- -b Draft's text;
- -i Post's id corresponding to Draft;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions post_id Integer Yes Post's id corresponding to Draft text String Yes Draft's text - editDraft:
- Use this method to edit Draft's text;
- This method is available only for Author-Post owner;
- Request: http://HOST:PORT/editDraft?PARAMETERS
- Curl:
- Script location: 'data/curl/drafts/editDraft.sh'
- Usage (from 'data/curl/drafts/'): '$ ./editDraft.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -b New Draft's text;
- -i Post's id corresponding to Draft;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions post_id Integer Yes Post's id corresponding to Draft text String Yes New Draft's text - publishDraft:
- Use this method to publish text of Draft (Change corresponding Post's text to Draft's text);
- This method is available only for Author-Post owner;
- Request: http://HOST:PORT/publishDraft?PARAMETERS
- Curl:
- Script location: 'data/curl/draft/publishDraft.sh'
- Usage (from 'data/curl/draft/'): '$ ./publishDraft.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i Post's id corresponding to Draft;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions post_id Integer Yes Post's id corresponding to Draft - removeDraft:
- Use this method to remove Draft;
- This method is available only for Author-Post owner;
- Request: http://HOST:PORT/removeDraft?PARAMETERS
- Curl:
- Script location: 'data/curl/draft/removeDraft.sh'
- Usage (from 'data/curl/draft/): '$ ./removeDraft.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -t User's token. Token of User making request. For successful request User must have Admin Permissions;
- -i Post's id corresponding to Draft;
- Response:
- Success: JSON TextResponse object with text success;
- Fail:
- If User's token includes required permissions: JSON TextResponse object with text success;
- If User's token doesn't includes required permissions: JSON TextResponse object with text error;
Parameter Type Required Description token String Yes User's token. Token of User making request. For successful request User must have Admin Permissions post_id Integer Yes Post's id corresponding to Draft
- getDrafts:
- Comment:
- createComment:
- Use this method to create Comment record to specified Post;
- This method is available for all registered Users;
- Request: http://HOST:PORT/createComment?PARAMETERS
- Curl:
- Script location: 'data/curl/comment/createComment.sh'
- Usage (from 'data/curl/comment/'): '$ ./createComment.sh [flags]'
- -h Print help message and exit;
- -y Host server name;
- -p Port server number;
- -p Port server number;
- -t User's token. Token of User making request;
- -c Comment's text;
- Response:
- Success: JSON TextResponse object;
- Fail: JSON TextResponse object;
Parameter Type Required Description token String Yes User's token. Token of User making request post_id Integer Yes Post's id corresponding to Comment text String Yes Comment's text
- createComment:
- Post
This object represents a Post record.
Field Type Description id Integer Unique identifier for this Post author Author Author of Post record title String Title of Post record text String Text of Post record created_at String Date of creation of this Post record. Formated like "DD.MM.YY" category Category Category of Post record tags [Tag] Optional. List of Tags of Post record main_photo Photo Optional. Main Photo of Post record add_photo [Photo] Optional. Additional Photos of Post record comments [Comment] Optional.Comments of Post record - User
This object represents a User record.
Field Type Description id Integer Unique identifier for this User is_admin Boolean True, if this User is a admin first_name String User's first name last_name String User's last name photo Photo User's Photo - Author
This object represents a Author record.
Field Type Description user User User corresponding to this Author description String Author's description - Category
This object represents a Category record.
Field Type Description id Integer Unique identifier for this Category title String Category's title subcategory Category Optional.SubCategory of this Category - Tag
This object represents a Tag record.
Field Type Description id Integer Unique identifier for this Tag title String Tag's title - Draft
This object represents a Draft record.
Field Type Description id Integer Unique identifier for this Draft text String Draft's text post_id Integer Post's id corresponding to Draft - Photo
This object represents a Photo record.
Field Type Description id Integer Unique identifier for this Photo link String Link to Photo - Comment
This object represents a Comment record.
Field Type Description id Integer Unique identifier for this Comment text String Comment's text - PostResponse
This object represents a Response containing Post records.
Field Type Description offset Integer Offset from first Post's record corresponding to request options (ordered by Post's id) posts [Post] List of Post's records corresponding to request options (Limit 50 records in one request) - UserResponse
This object represents a Response containing User records.
Field Type Description offset Integer Offset from first User's record (ordered by User's id) users [User] List of User's records corresponding to request options (Limit 50 records in one request) - AuthorResponse
This object represents a Response containing Author records.
Field Type Description offset Integer Offset from first Author's record (ordered by Author's id) users [Author] List of Author's records corresponding to request options (Limit 50 records in one request) - CategoryResponse
This object represents a Response containing Category records.
Field Type Description offset Integer Offset from first Category's record (ordered by Category's id) categories [Category] List of Category's records corresponding to request options (Limit 50 records in one request) - TagResponse
This object represents a Response containing Tag records.
Field Type Description offset Integer Offset from first Tag's record (ordered by Tag's id) tags [Tag] List of Tag's records corresponding to request options (Limit 50 records in one request) - DraftResponse
This object represents a Response containing Draft records.
Field Type Description offset Integer Offset from first Draft's record (ordered by Draft's id) drafts [Draft] List of Draft's records corresponding to request options (Limit 50 records in one request) - TextResponse
This object represents a message detailing success/error of processing request.
Field Type Description message String Message detailing success/error of processing request - Admin Permission
This type of permissions have only persons from admin list in data/config.json file
- Permissions to get/create/edit/remove Author's records;
- Permissions to get/remove Post's records;
- Permissions to get/remove User's records;
- Permissions to get/create/edit/remove Category's records;
- Permissions to get/create/edit/remove Tag's records;
- Permissions to create Comment's records;
- User Permission
This type of permissions have all registered Users
- Permissions to get Post's records;
- Permissions to get User's records;
- Permissions to get Category's records;
- Permissions to get Tag's records;
- Permissions to create Comment's records;
- Author Write Permission
This type of permissions have all registered Users
- Permissions to get/create Post's records;
- Permissions to get User's records;
- Permissions to get Category's records;
- Permissions to get Tag's records;
- Permissions to create Comment's records;
- Author Write Permission
This type of permissions have all registered Users
- Permissions to get/create Post's records;
- Permissions to get User's records;
- Permissions to get/edit/publish/remove Draft's records of Post's belonging to this Author;
- Permissions to get Category's records;
- Permissions to get Tag's records;
- Permissions to create Comment's records;
- For unicode symbols in requests (using .sh scripts) use folowing:
- Instead of whitespace: %20
- Instead of left square parenthesis "[": %5B
- Instead of right square parenthesis "[": %5D
- Supporting wildcard symbols:
- _ denotes any single character (is comparable to . in POSIX regular expressions);
- % denotes any string (is comparable to .* in POSIX regular expressions);
- | denotes alternation (either of two alternatives);
- * denotes repetition of the previous item zero or more times;
- + denotes repetition of the previous item one or more times;
- ? denotes repetition of the previous item zero or one time;
- {m} denotes repetition of the previous item exactly m times;
- {m,} denotes repetition of the previous item m or more times;
- {m,n} denotes repetition of the previous item at least m and not more than n times;
- Parentheses () can be used to group items into a single logical item;
- A bracket expression [...] specifies a character class, just as in POSIX regular expressions;