Skip to content

Commit

Permalink
Merge 903f356 into 7875604
Browse files Browse the repository at this point in the history
  • Loading branch information
liampauling committed May 12, 2020
2 parents 7875604 + 903f356 commit 11af08a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
8 changes: 8 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Release History
---------------

2.3.1 (2020-05-12)
+++++++++++++++++++

**Improvements**

- LRUCache added to strip datetime
- NemID docs added

2.3.0 (2020-04-06)
+++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion betfairlightweight/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = "betfairlightweight"
__description__ = "Lightweight python wrapper for Betfair API-NG"
__url__ = "https://github.com/liampauling/betfair"
__version__ = "2.3.0"
__version__ = "2.3.1"
__author__ = "Liam Pauling"
__license__ = "MIT"
2 changes: 2 additions & 0 deletions betfairlightweight/resources/baseresource.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import datetime
from typing import Union, Optional

Expand All @@ -20,6 +21,7 @@ def json(self) -> str:
return json.dumps(self._data)

@staticmethod
@functools.lru_cache()
def strip_datetime(value: Union[str, int]) -> Optional[datetime.datetime]:
"""
Converts value to datetime if string or int.
Expand Down
36 changes: 36 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,35 @@ Betfair uses slightly different endpoints depending on your country of residence
- sweden
- australia

### NEMID Login

Danish residents are restricted in how they login due to NemID requirements, this can be handled by replicating the login flow:

```python
import re
import betfairlightweight

trading = betfairlightweight.APIClient("username", "password", app_key="app_key")

resp = trading.session.post(
url=trading.login_interactive.url,
data={
"username": trading.username,
"password": trading.password,
"redirectMethod": "POST",
"product": trading.app_key,
"url": "https://www.betfair.com",
"submitForm": True,
}
)
session_token = re.findall(
"ssoid=(.*?);", resp.headers["Set-Cookie"]
)
trading.set_session_token(session_token[0])

print(trading.betting.list_event_types())
```

### Session

The client assumes requests is used for the http requests but other clients can be used if required, a session object can be passed to the client:
Expand Down Expand Up @@ -83,6 +112,13 @@ Elapsed, created and updated time:
2020-01-27 09:56:32.984387
```

Raw requests response object:

```python
>>> response[0]._response
<Response [200]>
```

### Lightweight

In order to return the raw json you can select lightweight on client initialization:
Expand Down

0 comments on commit 11af08a

Please sign in to comment.