Skip to content

Commit 65c9d2a

Browse files
Merge pull request #13 from Riminder/feat/asking-unfolding-apis
feat: asking, authentication, and unfolding APIs; and test suite
2 parents 2f71beb + a741f47 commit 65c9d2a

53 files changed

Lines changed: 3496 additions & 474 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,11 @@
11
HRFLOW_API_KEY="___FILL_ME___"
2-
HRFLOW_USER_EMAIL="___FILL_ME___"
2+
HRFLOW_API_KEY_READ="___FILL_ME___"
3+
HRFLOW_USER_EMAIL="___FILL_ME___"
4+
HRFLOW_ALGORITHM_KEY="___FILL_ME___"
5+
HRFLOW_BOARD_KEY="___FILL_ME___"
6+
HRFLOW_JOB_KEY="___JOB_KEY_IN_BOARD___"
7+
HRFLOW_PROFILE_KEY="___PROFILE_KEY_IN_SOURCE_QUICKSILVER_SYNC___"
8+
HRFLOW_SOURCE_KEY_HAWK_SYNC="___FILL_ME___"
9+
HRFLOW_SOURCE_KEY_QUICKSILVER_SYNC="___FILL_ME___"
10+
HRFLOW_SOURCE_KEY_QUICKSILVER_ASYNC="___FILL_ME___"
11+
HRFLOW_SOURCE_KEY_MOZART_ASYNC="___FILL_ME___"

.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
max-line-length = 88
3+
exclude = .pytest_cache, __pycache__, .env, .venv
4+
black-config = pyproject.toml
5+
per-file-ignores = __init__.py:F401
6+
ignore = E731, W503, E203

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ credentials
1212
credentials_seg
1313
test/*
1414
test_assets/*
15+
tests/assets
1516
.htpasswd
1617

1718
docker/dependencies/libs/*

Makefile

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ ARGS :=
44
clean:
55
rm -rf build dist *.egg-info
66

7+
clean_cache:
8+
find . -type d \( -name '__pycache__' -o -name '.pytest_cache' \) -exec rm -rf {} +
9+
rm -rf tests/assets
10+
711
build:
812
poetry build
913

@@ -14,4 +18,13 @@ deploy-test:
1418
poetry publish -r test-pypi --build
1519

1620
deploy:
17-
poetry publish --build
21+
poetry publish --build
22+
23+
flake8:
24+
poetry run flake8 --config=./.flake8
25+
26+
style:
27+
poetry run isort . && poetry run black --config=./pyproject.toml .
28+
29+
check:
30+
bash ./check.sh

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Install using `pip install -U hrflow` or `conda install hrflow -c conda-forge`.
5656

5757
```py
5858
from hrflow import Hrflow
59-
client = Hrflow(api_secret="YOUR_API_KEY"; api_user="YOU_USER_EMAIL")
59+
client = Hrflow(api_secret="YOUR_API_KEY", api_user="YOU_USER_EMAIL")
6060

6161
# read file from directory (in binary mode)
6262
with open("path_to_file.pdf", "rb") as f:

check.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
PYTEST_RUN="poetry run pytest"
4+
PYTEST_OPTIONS=(--verbose --tb=long --strict-markers --durations=0 --datefmt "%Y-%m-%d %H:%M:%S.%f%z")
5+
PYTEST_DIR=tests/
6+
7+
if [ "$#" -gt 0 ]; then
8+
for marker in "$@"; do
9+
$PYTEST_RUN "${PYTEST_OPTIONS[@]}" "$PYTEST_DIR" -m "$marker"
10+
done
11+
else
12+
$PYTEST_RUN "${PYTEST_OPTIONS[@]}" "$PYTEST_DIR"
13+
fi

hrflow/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1+
from .__version__ import (
2+
__author__,
3+
__author_email__,
4+
__description__,
5+
__license__,
6+
__title__,
7+
__url__,
8+
__version__,
9+
)
110
from .hrflow.hrflow import Hrflow
2-
3-
from .__version__ import __title__, __description__, __url__, __version__
4-
from .__version__ import __author__, __author_email__, __license__

hrflow/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
__version__ = importlib.metadata.version("hrflow")
77
__author__ = "HrFlow.ai"
88
__author_email__ = "contact@hrflow.ai"
9-
__license__ = "MIT"
9+
__license__ = "MIT"

hrflow/hrflow/auth/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import typing as t
2+
3+
from ..utils import validate_key, validate_response
4+
5+
API_SECRET_REGEX = r"^ask[rw]?_[0-9a-f]{32}$"
6+
7+
8+
class Auth:
9+
def __init__(self, api):
10+
self.client = api
11+
12+
def get(self) -> t.Dict[str, t.Any]:
13+
"""
14+
Try your API Keys. This endpoint allows you to learn how to add the right
15+
information to your API calls, so you can make them.
16+
17+
Args:
18+
api_user: <str>
19+
Your HrFlow.ai account's email.
20+
api_secret: <str>
21+
Your API Key.
22+
23+
Returns:
24+
`/auth` response
25+
"""
26+
27+
validate_key(
28+
"api_secret",
29+
self.client.auth_header.get("X-API-KEY"),
30+
regex=API_SECRET_REGEX,
31+
)
32+
33+
response = self.client.get("auth")
34+
35+
return validate_response(response)

hrflow/hrflow/board/__init__.py

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
1-
from ..utils import validate_key, validate_page, validate_limit, validate_value, validate_response
2-
3-
from ..utils import ORDER_BY_VALUES
1+
from ..utils import (
2+
ORDER_BY_VALUES,
3+
validate_key,
4+
validate_limit,
5+
validate_page,
6+
validate_response,
7+
validate_value,
8+
)
49

510

611
class Board(object):
7-
812
def __init__(self, client):
913
self.client = client
1014

11-
def list(self, name=None, page=1, limit=30, sort_by='date', order_by='desc'):
15+
def list(self, name=None, page=1, limit=30, sort_by="date", order_by="desc"):
1216
"""
13-
Search boards for given filters.
14-
15-
Args:
16-
name: <string>
17-
name
18-
page: <integer>
19-
page
20-
limit: <integer>
21-
limit
22-
sort_by: <string>
23-
sort_by
24-
order_by: <string>
25-
order_by
26-
27-
Returns
28-
Result of source's search
17+
Search boards for given filters.
18+
19+
Args:
20+
name: <string>
21+
name
22+
page: <integer>
23+
page
24+
limit: <integer>
25+
limit
26+
sort_by: <string>
27+
sort_by
28+
order_by: <string>
29+
order_by
30+
31+
Returns
32+
Result of source's search
2933
3034
"""
3135
query_params = {}
@@ -40,15 +44,15 @@ def list(self, name=None, page=1, limit=30, sort_by='date', order_by='desc'):
4044

4145
def get(self, key=None):
4246
"""
43-
Get source given a board key.
47+
Get source given a board key.
4448
45-
Args:
46-
key: <string>
47-
board_key
48-
Returns
49-
Board if exists
49+
Args:
50+
key: <string>
51+
board_key
52+
Returns
53+
Board if exists
5054
5155
"""
5256
query_params = {"key": validate_key("Board", key)}
53-
response = self.client.get('board', query_params)
57+
response = self.client.get("board", query_params)
5458
return validate_response(response)

0 commit comments

Comments
 (0)