Posts
Usage
List posts, groups, and comments:
import asyncio
import factorialhr
async def main():
auth = factorialhr.AccessTokenAuth("your_access_token")
async with factorialhr.ApiClient(auth=auth) as api:
posts = factorialhr.PostsEndpoint(api)
response = await posts.get(params={"page": 1})
for p in response.data():
print(p.title, p.group_id)
groups = factorialhr.GroupsEndpoint(api)
for g in (await groups.all()).data():
print(g.name)
asyncio.run(main())
- class factorialhr.Comment(*, id: int, post_id: int, author_id: int, text: str, created_at: datetime)[source]
Model for posts_comment.
- author_id: int
Author identifier refers to the employee access, you can get the employee from the employee endpoint
- created_at: datetime
Date of the comment
- id: int
Identifier of the comment
- post_id: int
Identifier of the post
- text: str
Text of the comment
- class factorialhr.CommentsEndpoint(api: ApiClient)[source]
Endpoint for posts/comments operations.
- async all(**kwargs) ListApiResponse[Comment][source]
Get all comments records.
Official documentation: posts/comments
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing the list of records.
- Return type:
- async create(data: Mapping[str, Any], **kwargs) Comment[source]
Create a new comment.
Official documentation: posts/comments
- Parameters:
data (Mapping[str, Any]) – Payload for the new record (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The created record.
- Return type:
- async delete(comment_id: int | str, **kwargs) Comment[source]
Delete a comment.
Official documentation: posts/comments
- Parameters:
comment_id (int | str) – The unique identifier of the record to delete.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The deleted record.
- Return type:
- async get(**kwargs) MetaApiResponse[Comment][source]
Get comments with pagination metadata.
Official documentation: posts/comments
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing records and pagination metadata.
- Return type:
- async get_by_id(comment_id: int | str, **kwargs) Comment[source]
Get a specific comment by ID.
Official documentation: posts/comments
- Parameters:
comment_id (int | str) – The unique identifier.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The record.
- Return type:
- async update(comment_id: int | str, data: Mapping[str, Any], **kwargs) Comment[source]
Update a comment.
Official documentation: posts/comments
- Parameters:
comment_id (int | str) – The unique identifier of the record to update.
data (Mapping[str, Any]) – Payload with fields to update (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The updated record.
- Return type:
- class factorialhr.Group(*, id: int, title: str, description: str, company_id: int, archived: bool | None = None, created_at: datetime | None = None, updated_at: datetime | None = None)[source]
Model for posts_group.
- archived: bool | None
Whether the group is archived
- company_id: int
Identifier of the company
- created_at: datetime | None
Date when the group was created
- description: str
Description of the group
- id: int
Identifier of the group
- title: str
Title of the group
- updated_at: datetime | None
Date when the group was updated
- class factorialhr.GroupsEndpoint(api: ApiClient)[source]
Endpoint for posts/groups operations.
- async all(**kwargs) ListApiResponse[Group][source]
Get all groups records.
Official documentation: posts/groups
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing the list of records.
- Return type:
- async archive(data: Mapping[str, Any], **kwargs) Group[source]
Archive a group.
Official documentation: posts/groups
- Parameters:
data (Mapping[str, Any]) – Payload for the new record (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Result.
- Return type:
- async create(data: Mapping[str, Any], **kwargs) Group[source]
Create a new group.
Official documentation: posts/groups
- Parameters:
data (Mapping[str, Any]) – Payload for the new record (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The created record.
- Return type:
- async delete(group_id: int | str, **kwargs) Group[source]
Delete a group.
Official documentation: posts/groups
- Parameters:
group_id (int | str) – The unique identifier of the record to delete.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The deleted record.
- Return type:
- async get(**kwargs) MetaApiResponse[Group][source]
Get groups with pagination metadata.
Official documentation: posts/groups
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing records and pagination metadata.
- Return type:
- async get_by_id(group_id: int | str, **kwargs) Group[source]
Get a specific group by ID.
Official documentation: posts/groups
- Parameters:
group_id (int | str) – The unique identifier.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The record.
- Return type:
- async update(group_id: int | str, data: Mapping[str, Any], **kwargs) Group[source]
Update a group.
Official documentation: posts/groups
- Parameters:
group_id (int | str) – The unique identifier of the record to update.
data (Mapping[str, Any]) – Payload with fields to update (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The updated record.
- Return type:
- class factorialhr.Post(*, id: int, title: str, description: str, post_group_id: int, allow_comments_and_reactions: bool | None = None, published_at: datetime | None = None, created_at: datetime, updated_at: datetime, visits_count: int | None = None, cover_image_url: str | None = None, comments_count: int | None = None, author_id: int | None = None)[source]
Model for posts_post.
- allow_comments_and_reactions: bool | None
Allow comments and reactions on the post
- author_id: int | None
Author identifier of the post
- comments_count: int | None
Number of comments on the post
- cover_image_url: str | None
URL of the cover image
- created_at: datetime
Date when the post was created
- description: str
Description of the post
- id: int
Identifier of the post
- post_group_id: int
Group identifier of the post
- published_at: datetime | None
Date when the post was published
- title: str
Title of the post
- updated_at: datetime
Date when the post was updated
- visits_count: int | None
Number of visits of the post
- class factorialhr.PostsEndpoint(api: ApiClient)[source]
Endpoint for posts/posts operations.
- async all(**kwargs) ListApiResponse[Post][source]
Get all posts records.
Official documentation: posts/posts
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing the list of records.
- Return type:
- async create(data: Mapping[str, Any], **kwargs) Post[source]
Create a new post.
Official documentation: posts/posts
- Parameters:
data (Mapping[str, Any]) – Payload for the new record (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The created record.
- Return type:
- async delete(post_id: int | str, **kwargs) Post[source]
Delete a post.
Official documentation: posts/posts
- Parameters:
post_id (int | str) – The unique identifier of the record to delete.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The deleted record.
- Return type:
- async get(**kwargs) MetaApiResponse[Post][source]
Get posts with pagination metadata.
Official documentation: posts/posts
- Parameters:
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
Response containing records and pagination metadata.
- Return type:
- async get_by_id(post_id: int | str, **kwargs) Post[source]
Get a specific post by ID.
Official documentation: posts/posts
- Parameters:
post_id (int | str) – The unique identifier.
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The record.
- Return type:
- async update(post_id: int | str, data: Mapping[str, Any], **kwargs) Post[source]
Update a post.
Official documentation: posts/posts
- Parameters:
post_id (int | str) – The unique identifier of the record to update.
data (Mapping[str, Any]) – Payload with fields to update (key-value mapping).
kwargs (optional) – Optional keyword arguments (e.g.
paramsfor query string) forwarded to the HTTP request.
- Raises:
httpx.HTTPStatusError – When the API returns an error status code.
- Returns:
The updated record.
- Return type: