This repository has been archived by the owner on Jan 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from jonyw4/2.0.0
2.0.0
- Loading branch information
Showing
15 changed files
with
935 additions
and
5,901 deletions.
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,25 @@ | ||
{ | ||
"name": "Vendure WebmaniaBR Plugin", | ||
"dockerComposeFile": [ | ||
"../docker-compose.yml" | ||
], | ||
"service": "dev", | ||
"workspaceFolder": "/workspace", | ||
"settings": { | ||
"terminal.integrated.shell.linux": "/bin/bash" | ||
}, | ||
"extensions": [ | ||
"christian-kohler.path-intellisense", | ||
"christian-kohler.npm-intellisense", | ||
"mhutchie.git-graph", | ||
"dbaeumer.vscode-eslint", | ||
"joelday.docthis", | ||
"esbenp.prettier-vscode", | ||
"mikehanson.auto-barrel", | ||
"streetsidesoftware.code-spell-checker", | ||
"steoates.autoimport" | ||
], | ||
"forwardPorts": [3000, 3306], | ||
"postCreateCommand": "yarn install", | ||
// "remoteUser": "node" | ||
} |
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,12 @@ | ||
version: "3" | ||
services: | ||
dev: | ||
image: mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12 | ||
command: /bin/sh -c "while sleep 1000; do :; done" | ||
ports: | ||
- "3000:3000" | ||
volumes: | ||
- .:/workspace:cached | ||
- node_modules:/workspace/node_modules | ||
volumes: | ||
node_modules: |
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,37 @@ | ||
import WebmaniaBR from 'webmaniabr-js'; | ||
import { CustomFulfillmentProcess, FulfillmentState } from '@vendure/core'; | ||
import { WebmaniaBRPluginOptions } from './types'; | ||
|
||
export function createCustomFulfillmentProcess<T extends FulfillmentState>( | ||
options: WebmaniaBRPluginOptions<T> | ||
): CustomFulfillmentProcess<T> { | ||
const { createNfe } = options; | ||
const webmaniaClient = new WebmaniaBR( | ||
options.consumerKey, | ||
options.consumerSecret, | ||
options.accessToken, | ||
options.accessTokenSecret, | ||
options.timeout | ||
); | ||
|
||
return { | ||
init: async (injector) => { | ||
if (typeof options.init === 'function') { | ||
await options.init(injector); | ||
} | ||
}, | ||
destroy: async () => { | ||
if (typeof options.destroy === 'function') { | ||
await options.destroy(); | ||
} | ||
}, | ||
onTransitionStart: async (fromState, toState, data) => { | ||
if (fromState === createNfe.fromState || toState === createNfe.toState) { | ||
return createNfe.save( | ||
data, | ||
await webmaniaClient.createNotaFiscal(createNfe.map(data)) | ||
); | ||
} | ||
} | ||
}; | ||
} |
Oops, something went wrong.