-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a1dd8c
commit a104bfe
Showing
7 changed files
with
170 additions
and
30 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,42 @@ | ||
import { toXML } from 'jstoxml' | ||
|
||
import alephFetch from '../util/aleph-fetch' | ||
import { borrowerInfo } from './borrower-info' | ||
|
||
export async function updateBorrowerEmail(borId: string, newEmailAddress: string) { | ||
if (!borId.match(/^PWD\d+$/)) { | ||
const borInfo = await borrowerInfo(borId, false, false) | ||
borId = borInfo.z303['z303-id'] | ||
} | ||
|
||
const requestData = { | ||
'p-file-20': { | ||
'patron-record': { | ||
z303: { | ||
'match-id-type': '00', | ||
'match-id': borId, | ||
'record-action': 'X', | ||
}, | ||
z304: { | ||
'record-action': 'U', | ||
'z304-email-address': newEmailAddress, | ||
'z304-address-type': '01', | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
const params = { | ||
update_flag: 'Y', | ||
xml_full_req: toXML(requestData), | ||
} | ||
|
||
const result = await alephFetch('update-bor', params, undefined, true, 'POST') | ||
if (result.error) { | ||
const error = typeof result.error === 'string' ? result.error : result.error[0] | ||
|
||
if (error && error !== `Succeeded to REWRITE table z304. cur-id ${borId}.`) { | ||
throw new Error(error) | ||
} | ||
} | ||
} |
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
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
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