-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Onfleet node #2593
Closed
Closed
Onfleet node #2593
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
be60920
feat: added Onfleet nodes
6d111c5
style: fixed typos, arrays uniformity, unnecesary files
4c36754
refactor: changed add to create in comments and labels
1c4a6ab
Merge pull request #1 from YokySantiago/master
jamesliupenn 56d6e77
feat: added name field to onfleet trigger node
34f3b33
Merge pull request #2 from YokySantiago/master
jamesliupenn 19d90e9
feat: added team endpoints to onfleet node
49a8e03
style: remove dots in descriptions and fixed some typos
2fb2be6
Merge pull request #3 from YokySantiago/master
jamesliupenn 9e597ec
feat: added fixes according to comments made on the n8n PR
19c67e1
fix: fixed recipient and destination cretion
a95f4a6
docs: added docstrings for format some functions
addba39
style: formatting the code according to n8n nodelinter
4424dc8
Merge branch 'n8n-io:master' into master
jamesliupenn 78842f8
fix: typos and better descriptions
7d14e43
Merge pull request #4 from YokySantiago/master
jamesliupenn 007ed0b
[INT-510] n8n: Address additional problems from n8n code review (#5)
YokySantiago File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
ICredentialType, | ||
NodePropertyTypes, | ||
} from 'n8n-workflow'; | ||
|
||
export class OnfleetApi implements ICredentialType { | ||
name = 'onfleetApi'; | ||
displayName = 'Onfleet API'; | ||
documentationUrl = 'onfleet'; | ||
properties = [ | ||
{ | ||
displayName: 'API Key', | ||
name: 'apiKey', | ||
type: 'string' as NodePropertyTypes, | ||
default: '', | ||
}, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
IDataObject, | ||
JsonObject, | ||
NodeApiError | ||
} from 'n8n-workflow'; | ||
import { | ||
IExecuteFunctions, | ||
IHookFunctions, | ||
ILoadOptionsFunctions, | ||
IWebhookFunctions, | ||
} from 'n8n-core'; | ||
|
||
import { | ||
OptionsWithUri, | ||
} from 'request'; | ||
|
||
export async function onfleetApiRequest( | ||
this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, | ||
method: string, | ||
apikey: string, | ||
resource: string, | ||
body: any = {}, // tslint:disable-line:no-any | ||
qs?: any, // tslint:disable-line:no-any | ||
uri?: string, | ||
headers: IDataObject = {}, | ||
option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any | ||
const options: OptionsWithUri = { | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Authorization': `Basic ${apikey}`, | ||
'User-Agent': 'n8n-onfleet', | ||
}, | ||
method, | ||
body, | ||
qs, | ||
uri: uri || `https://onfleet.com/api/v2/${resource}`, | ||
json: true, | ||
}; | ||
try { | ||
//@ts-ignore | ||
return await this.helpers.request(options); | ||
} catch (error) { | ||
const apiError = error as IDataObject; | ||
const { message: messageError } = apiError.error as IDataObject; | ||
if (messageError) { | ||
const { message = '', cause = '' } = messageError as IDataObject; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't you simply pass the error object to the NodeApiError? |
||
if (message && cause) { | ||
apiError.message = `${message}: ${cause}`; | ||
} else { | ||
apiError.message = message; | ||
} | ||
throw new NodeApiError(this.getNode(), apiError as JsonObject); | ||
} | ||
throw new NodeApiError(this.getNode(), apiError as JsonObject); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Header is a parameter but it's never used in the function?