mwalsh2020 / lsat-cracked

1 stars 0 forks source link

LSAC/Lawhub service object #157

Closed caioertai closed 3 years ago

caioertai commented 3 years ago

Closes #132

@jamiesonreinhard this is part of the #132.

Credentials update

I updated the app credentials, which means I'll need to share with you my master.key file at some point in order for this to work for you. Let me know when you're free for a call about it.

Lawhub service module and ::Authentication

I created Lawhub as a class with some configurations that should be shared by other endpoints and Lawhub::Authentication which is essentially a class that holds the #access_token method, behind a rails' low level caching API.

Lawhub::User

Should have methods relating to particular users. Right now the only one that matters is the login ping endpoint. It could later include things like info request or subscription confirmations.

Edit:

Usage

# 1. Init anything that answers #email. More generally, user instances.
user = OpenStruct.new(email: "andrade@hey.com") 
# 2. Initialize service
service = Lawhub::User.new(user)
# 3. Call login instance method
service.login

Interface idea: add a Lawhub module for User

user =  User.find("XX")
user.lawhub.login
caioertai commented 3 years ago

@jamiesonreinhard

I updated it with the user login endpoint. It's working as intended, although SUPER slow in development since it doesn't cache the access token by default. It's NOT an issue, since I'll probably mockup their API in development to make sure we're not even talking to them.

caioertai commented 3 years ago

Usage

# 1. Init anything that answers #email. More generally, user instances.
user = OpenStruct.new(email: "andrade@hey.com") 
# 2. Initialize service
service = Lawhub::User.new(user)
# 3. Call login instance method
service.login

Interface idea: add a Lawhub module for User

user =  User.find("XX")
user.lawhub.login
caioertai commented 3 years ago

I added @jamiesonreinhard a section about usage in case you need it later.