From e48a3edacba891a18e641e01708e3d73fd6588ac Mon Sep 17 00:00:00 2001 From: Brandon Millman Date: Tue, 27 Feb 2018 14:06:33 -0800 Subject: Get orderHash via 0x connect --- .../sra-report/src/postman_environment_factory.ts | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'packages/sra-report/src/postman_environment_factory.ts') diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 697578a2d..b0b69ddad 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -12,38 +12,32 @@ interface EnvironmentValue { } export const postmanEnvironmentFactory = { - createGlobalEnvironment(url: string) { - const urlEnvironmentValue = { - key: 'url', - value: url, - enabled: true, - type: 'text', - }; + createGlobalEnvironment(url: string, orderHash: string) { + const urlEnvironmentValue = createEnvironmentValue('url', url); + const orderHashEnvironmentValue = createEnvironmentValue('orderHash', orderHash); const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( _.map(schemas, (schema: Schema) => { if (_.isUndefined(schema.id)) { return undefined; } else { - return { - key: convertSchemaIdToKey(schema.id), - value: JSON.stringify(schema), - enabled: true, - type: 'text', - }; + const schemaKey = convertSchemaIdToKey(schema.id); + const stringifiedSchema = JSON.stringify(schema); + const schemaEnvironmentValue = createEnvironmentValue(schemaKey, stringifiedSchema); + return schemaEnvironmentValue; } }), ); const schemaKeys = _.map(schemaEnvironmentValues, (environmentValue: EnvironmentValue) => { return environmentValue.key; }); - const schemaKeysEnvironmentValue = { - key: 'schemaKeys', - value: JSON.stringify(schemaKeys), - enabled: true, - type: 'text', - }; - const environmentValues = _.concat(schemaEnvironmentValues, urlEnvironmentValue, schemaKeysEnvironmentValue); + const schemaKeysEnvironmentValue = createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys)); + const environmentValues = _.concat( + schemaEnvironmentValues, + urlEnvironmentValue, + schemaKeysEnvironmentValue, + orderHashEnvironmentValue, + ); const environment = { values: environmentValues, }; @@ -60,7 +54,6 @@ export const postmanEnvironmentFactory = { } }, }; - function convertSchemaIdToKey(schemaId: string) { let result = schemaId; if (_.startsWith(result, '/')) { @@ -69,3 +62,11 @@ function convertSchemaIdToKey(schemaId: string) { result = `${result}Schema`; return result; } +function createEnvironmentValue(key: string, value: string) { + return { + key, + value, + enabled: true, + type: 'text', + }; +} -- cgit