Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Grimcrow
Copy link
Collaborator

No description provided.

const AUTHURL = "https://cloudimanage.com/auth/oauth2/token"

const imanageLogin = async ({email, password, client_id, client_secret}) => {
const formData = new urlSearchParams({
Copy link
Collaborator

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",
Copy link
Collaborator

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 @@
{
Copy link
Collaborator

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';
Copy link
Collaborator

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") {
Copy link
Collaborator

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 () => {
Copy link
Collaborator

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)}`)
Copy link
Collaborator

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() ?

Copy link
Collaborator Author

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?

Copy link
Collaborator

@jwielinga jwielinga Oct 26, 2022

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) => {
Copy link
Collaborator

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) => {
Copy link
Collaborator

@jwielinga jwielinga Oct 26, 2022

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) => {
Copy link
Collaborator

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
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants