added support for db_num when using the redis token store
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# AVT Fresh!
|
||||
|
||||
This is a wrapper of [the roly-poly, not 100% ergonomic Freshbooks web API](https://www.freshbooks.com/api/start). It is far from comprehensive: It was created for the specific client- and invoice-related needs of [Averbach Transcription](https://avtranscription.com).
|
||||
This is a wrapper of [the Freshbooks web API](https://www.freshbooks.com/api/start). It is far from comprehensive: It was created for the specific client- and invoice-related needs of [Averbach Transcription](https://avtranscription.com).
|
||||
|
||||
There are "band-aids" here to work around some of the API's shortcomings. For example, you don't have to deal with pagination at all. 🎉
|
||||
|
||||
@@ -14,12 +14,13 @@ pip install avt-fresh
|
||||
Instantiate the avt_fresh `Client` like so, and you're off to the races:
|
||||
|
||||
```python
|
||||
client = Client(client_secret="...", client_id="...", redirect_uri="https://...", account_id="...")
|
||||
from avt_fresh import ApiClient
|
||||
|
||||
client = ApiClient(client_secret="...", client_id="...", redirect_uri="https://...", account_id="...")
|
||||
monster_invoices = client.get_all_invoices_for_org_name("Monsters Inc")
|
||||
```
|
||||
|
||||
You can get and set the required arguments to `Client` [here](https://my.freshbooks.com/#/developer). Well, all of them except `FRESHBOOKS_ACCOUNT_ID`, which you can see (there's got to be another way??) by clicking on one of your invoices and grabbing the substring here: `https://my.freshbooks.com/#/invoice/<THIS THING>-1234567`.
|
||||
You can get and set the required arguments to `ApiClient` [here](https://my.freshbooks.com/#/developer). Well, all of them except `FRESHBOOKS_ACCOUNT_ID`, which you can see (there's got to be another way??) by clicking on one of your invoices and grabbing the substring here: `https://my.freshbooks.com/#/invoice/<THIS THING>-1234567`.
|
||||
|
||||
Don't tell anyone but `redirect_uri` can be pretty much anything! See `Initializing` below 👇.
|
||||
|
||||
@@ -145,7 +146,7 @@ client = Client(
|
||||
redirect_uri="https://...",
|
||||
account_id="...",
|
||||
token_store=avt_fresh.token.TokenStoreOnRedis,
|
||||
connection_string="redis://..." ,
|
||||
connection_string="rediss://..." ,
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
@@ -56,8 +56,8 @@ class TokenStoreOnDisk(TokenStore):
|
||||
|
||||
|
||||
class TokenStoreOnRedis(TokenStore):
|
||||
def __init__(self, redis_url):
|
||||
self.redis_client = redis.from_url(redis_url)
|
||||
def __init__(self, redis_url, redis_db_num: int = 0):
|
||||
self.redis_client = redis.from_url(redis_url, db=redis_db_num)
|
||||
|
||||
def get(self) -> TokenTup:
|
||||
result = self.redis_client.get(TOKEN_KEY)
|
||||
|
||||
Reference in New Issue
Block a user