-
Notifications
You must be signed in to change notification settings - Fork 6
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 support for GraphQL API, starting with createEtchPacket #16
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
55ad5b2
init. basic getCurrentUser works
newhouse 69c16a3
Adding support for GraphQL createEtchPacket
newhouse 036c615
added graphql folders. wrapping all request/responses in throttle and…
newhouse 3b567a9
touch ups
newhouse f3baae7
tidying up
newhouse bf1c999
added example base for create-etch-packet
newhouse b7574f1
ignore scratch directory
newhouse b0fb5f5
updated docs
newhouse ae0372e
touch up
newhouse 3d6b099
touched up README
newhouse e5ccbd4
added abort signal
newhouse d79f1ca
just The Way
newhouse e948a8c
updated docs
newhouse cfc596e
removed stuff don't want them to see
newhouse 1e0f926
Fix connections to signature fields
benogle 5e9f52d
tests fixed.
newhouse 49d14b2
added bdd and other paterns we follow in web app
newhouse 690bcd9
added tests
newhouse 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 |
---|---|---|
|
@@ -5,3 +5,5 @@ node_modules | |
package-lock.json | ||
example/script/*.pdf | ||
example/script/*.json | ||
|
||
scratch/ |
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
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,165 @@ | ||
const path = require('path') | ||
const Anvil = require('../../src/index') | ||
const argv = require('yargs') | ||
.usage('Usage: $0 apiKey orgEid castEid, fileName') | ||
.demandCommand(4).argv | ||
|
||
const [apiKey, orgEid, castEid, fileName] = argv._ | ||
const pathToFile = path.resolve(__dirname, fileName) | ||
|
||
async function main () { | ||
const clientOptions = { | ||
apiKey, | ||
} | ||
|
||
const client = new Anvil(clientOptions) | ||
|
||
// Example where pathToFile will be used to create a new Stream. Can also | ||
// pass an existing Stream or Buffer | ||
const streamFile = Anvil.prepareGraphQLFile(pathToFile) | ||
|
||
const variables = { | ||
organizationEid: orgEid, | ||
send: false, | ||
isTest: true, | ||
signatureEmailSubject: 'Test Create Packet', | ||
signers: [ | ||
{ | ||
id: 'signerOne', | ||
name: 'Sally Signer', | ||
email: 'sally@example.com', | ||
fields: [ | ||
{ | ||
fileId: 'fileUpload', | ||
fieldId: 'aDateField', | ||
}, | ||
{ | ||
fileId: 'fileUpload', | ||
fieldId: 'aSignatureField', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'signerTwo', | ||
name: 'Scotty Signer', | ||
email: 'scotty@example.com', | ||
fields: [ | ||
{ | ||
fileId: 'fileUpload', | ||
fieldId: 'anotherSignatureField', | ||
}, | ||
{ | ||
fileId: 'preExistingCastReference', | ||
fieldId: 'signature1', | ||
}, | ||
{ | ||
fileId: 'preExistingCastReference', | ||
fieldId: 'signatureDate1', | ||
}, | ||
], | ||
}, | ||
], | ||
fillPayload: { | ||
payloads: { | ||
fileUpload: { | ||
textColor: '#CC0000', | ||
data: { | ||
myShortText: 'Something Filled', | ||
}, | ||
}, | ||
preExistingCastReference: { | ||
textColor: '#00CC00', | ||
data: { | ||
name: { | ||
firstName: 'Robin', | ||
lastName: 'Smith', | ||
}, | ||
dateOfBirth: '2020-09-01', | ||
socialSecurityNumber: '456454567', | ||
primaryPhone: { | ||
num: '5554443333', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
files: [ | ||
{ | ||
id: 'fileUpload', | ||
title: 'Important PDF One', | ||
file: streamFile, | ||
fields: [ | ||
{ | ||
id: 'myShortText', | ||
type: 'shortText', | ||
pageNum: 0, | ||
rect: { | ||
x: 20, | ||
y: 100, | ||
width: 100, | ||
height: 30, | ||
}, | ||
}, | ||
{ | ||
id: 'aDateField', | ||
type: 'signatureDate', | ||
pageNum: 1, | ||
name: 'Some Date', | ||
rect: { | ||
x: 200, | ||
y: 170, | ||
width: 100, | ||
height: 30, | ||
}, | ||
}, | ||
{ | ||
id: 'aSignatureField', | ||
type: 'signature', | ||
name: 'Some Sig', | ||
pageNum: 1, | ||
rect: { | ||
x: 200, | ||
y: 120, | ||
width: 100, | ||
height: 30, | ||
}, | ||
}, | ||
{ | ||
id: 'anotherSignatureField', | ||
type: 'signature', | ||
name: 'Another Sig', | ||
pageNum: 1, | ||
rect: { | ||
x: 200, | ||
y: 400, | ||
width: 100, | ||
height: 30, | ||
}, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'preExistingCastReference', | ||
castEid: castEid, | ||
}, | ||
], | ||
} | ||
|
||
const { statusCode, data, errors } = await client.createEtchPacket({ variables }) | ||
console.log( | ||
JSON.stringify({ | ||
statusCode, | ||
data, | ||
errors, | ||
}), | ||
) | ||
} | ||
|
||
main() | ||
.then(() => { | ||
process.exit(0) | ||
}) | ||
.catch((err) => { | ||
console.log(err.stack || err.message) | ||
process.exit(1) | ||
}) |
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
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,5 @@ | ||
const mutations = require('./mutations') | ||
|
||
module.exports = { | ||
mutations, | ||
} |
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,46 @@ | ||
|
||
const defaultResponseQuery = `{ | ||
newhouse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
id | ||
eid | ||
name | ||
documentGroup { | ||
id | ||
eid | ||
files | ||
signers { | ||
id | ||
eid | ||
name | ||
} | ||
} | ||
}` | ||
|
||
module.exports = { | ||
getMutation: (responseQuery = defaultResponseQuery) => ` | ||
mutation CreateEtchPacket ( | ||
$name: String, | ||
$organizationEid: String!, | ||
$files: [EtchFile!], | ||
$send: Boolean, | ||
$isTest: Boolean, | ||
$signatureEmailSubject: String, | ||
$signatureEmailBody: String, | ||
$signaturePageOptions: JSON, | ||
$signers: [JSON!], | ||
$fillPayload: JSON, | ||
) { | ||
createEtchPacket ( | ||
name: $name, | ||
organizationEid: $organizationEid, | ||
files: $files, | ||
send: $send, | ||
isTest: $isTest, | ||
signatureEmailSubject: $signatureEmailSubject, | ||
signatureEmailBody: $signatureEmailBody, | ||
signaturePageOptions: $signaturePageOptions, | ||
signers: $signers, | ||
fillPayload: $fillPayload | ||
) ${responseQuery} | ||
}`, | ||
} |
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,11 @@ | ||
const fs = require('fs') | ||
|
||
const IGNORE_FILES = ['index.js'] | ||
|
||
module.exports = fs.readdirSync(__dirname) | ||
.filter((fileName) => (fileName.endsWith('.js') && !fileName.startsWith('.') && !IGNORE_FILES.includes(fileName))) | ||
.reduce((acc, fileName) => { | ||
const mutationName = fileName.slice(0, fileName.length - 3) | ||
acc[mutationName] = require(`./${mutationName}`) | ||
return acc | ||
}, {}) |
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.
This module is currently on
v9.0.0
but have to drop to6.0.0
to get it to work onNode 8