-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add imanage action functions and change directory structure #5
base: main
Are you sure you want to change the base?
Conversation
const AUTHURL = "https://cloudimanage.com/auth/oauth2/token" | ||
|
||
const imanageLogin = async ({email, password, client_id, client_secret}) => { | ||
const formData = new urlSearchParams({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
formData naming seems a bit off. formData is a actually a different class used is some requests: https://developer.mozilla.org/en-US/docs/Web/API/FormData
} | ||
}, | ||
getAllFolderChildren: { | ||
url: "https://cloudimanage.com/work/api/v2/customers/{customerId}/libraries/{libraryName}/folders/{folderId}/children", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe good to split the host and common part in the path into a seperate var and reuse this when setting the url
@@ -0,0 +1,32 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file
@@ -0,0 +1,13 @@ | |||
import join from 'lodash/join'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
} | ||
} | ||
|
||
if (url === "https://cloudimanage.com/work/api/v2/customers/0000/documents") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split common part of the url with dynamic part and reuse the common part so var = common + dynamic
@@ -0,0 +1,4 @@ | |||
test('sayHello 1.0', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove file please
token: tokens.access_token | ||
} | ||
} | ||
throw Error(`${JSON.stringify(response)}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to throw an error or use console.error() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is both logging and throwing Error alright?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can test, if this also logs items :)
allDocuments: { | ||
url: `${BASEURL}/{customerId}/documents`, | ||
method: "GET", | ||
processResponse: (respose) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
define the functios for processResponse() and returnFormat() and reuse them. Then the object will be something like;
url: ${BASEURL}/{customerId}/workspaces
,
method: "GET",
processResponse,
returnFormat,
}
You could also using object spreading which would be even cleaner
const BASEURL = "https://cloudimanage.com/work/api/v2/customers" | ||
|
||
const responseResultFormatterNestedResult = { | ||
processResponse: (respose) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: response
} | ||
|
||
const responseResultFormatterNoNestedResult = { | ||
processResponse: (respose) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
|
||
const responseResultFormatterNoNestedResult = { | ||
processResponse: (respose) => { | ||
return respose.data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arrow function does not need a return in this case, if you remove the brackets and make it into 1 line
No description provided.