Set up APIService and expose first public methods#3
Conversation
|
Also open to general structure and organization feedback from @slifty and @jasonaowen as well! |
93e0591 to
60b98b6
Compare
|
I don't see any new tests for this new public method. Can you add some? Edit: JK, wasn't looking hard enough. I'm going to pass this review along to someone else. LGTM. |
|
I'd also like to see the functionality added here documented in the README before merging. |
|
Great point! Can definitely update the README. |
|
@andrewatwood some of the commits in this PR were made without a committer email address, which we should fix. The rest use your personal email address; is that what you intended? Make sure to set your email address in git, and then I'd be happy to pair on rebasing to fix these commits! |
jasonaowen
left a comment
There was a problem hiding this comment.
Looking good!
I'll test this tomorrow, but first some feedback just from reading the code.
|
@jasonaowen hmm was confused for a minute trying to figure that out, but realized those email-less were edits from the GitHub UI I made on 'main' to set up some Actions and other repo housekeeping stuff, and synced back in to this branch for the PR. Didn't realize it didn't have an email on the commits, seems bizarre for a default behavior...Still open to fixing that if you'd like! |
Install axios for HTTP requests. axios is async/await compatible out of the box and allows for easy mocking, along with axios-mock-adapter and ts-sinon for mocking during testing. Sets up the API service to make standardized API requests, and sets up the first public methods on the client via AuthResource, which contains a method isSessionValid Issue #2 - Method to validate session
b8c4f18 to
17c51c8
Compare
|
Thanks for pairing with me on rebasing, @andrewatwood! I'll work on testing this now. |
jasonaowen
left a comment
There was a problem hiding this comment.
Awesome work, @andrewatwood ! This looks good to me.
I tested it by building, then running in the REPL:
$ npm run build
$ nodejs
> // omitted: assign secrets to variables
> const permsdk = require('./build/main/');
> const perm = new permsdk.Permanent({sessionToken: permSession, mfaToken: permMFA, archiveId: 0, apiKey});
> perm.auth.isSessionValid().then((result) => console.log('Is session valid? ' + result));
Promise { <pending> }
Is session valid? trueThere's a small UX issue below. Your call on if you want to add it to this PR, follow up in a separate PR, or not do it at all!
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Feature
What is the current behavior? (You can also link to an open issue here)
No public methods exposed on the SDK client instance.
What is the new behavior (if this is a feature change)?
Sets up the API service to make standardized API requests, and sets up the first public methods on the client via
AuthResource, which contains a methodisSessionValidTesting
permSessionandpermMFAcookies, and the API key from the request body on anypermanent.org/apiconst perm = new Permanent()and test thatperm.auth.isSessionValid()resolves totrue