sul-dlss / folio_client

Interface for interacting with the Folio ILS API.
Other
0 stars 0 forks source link

Add method for looking up a source storage MARC record by HRID. #4

Closed lwrubel closed 1 year ago

lwrubel commented 1 year ago

To get a MARC source record (as JSON) from FOLIO, a method needs to be added to the folio_client gem to look up a record when passed an HRID. This will get used when refreshing descriptive metadata.

From Naomi: This ticket includes testing that the marc json is parseable by the ruby-marc gem; perhaps as a spec?? (It does not USE the ruby-marc gem, but it might make a good test? If so, include ruby-marc gem as a testing dependency only) _discussed this pairing after standup, was decided we'll revisit if we see a need for validation in folioclient, as it's just passing along the json it gets back

GET /source-storage/source-records?instanceHrid={HRID}

For example: /source-storage/source-records?instanceHrid=a5617360

Docs on AWS

The MARC JSON is in sourceRecords['parsedRecord']['content']['fields'].

{'sourceRecords': [{'recordId': '992460aa-bfe6-50ff-93f6-65c6aa786a43',
   'snapshotId': '5ae00995-bcb3-4fdc-8519-75c1357c44c4',
   'recordType': 'MARC_BIB',
   'parsedRecord': {'id': '992460aa-bfe6-50ff-93f6-65c6aa786a43',
    'content': {'fields': [{'001': 'a666'},
      {'003': 'SIRSI'},
      {'005': '19900820141050.0'},
      {'008': '750409s1961||||enk           ||| | eng  '},
      {'010': {'ind1': ' ',
        'ind2': ' ',
        'subfields': [{'a': '   62039356\\\\72b2'}]}},
      {'040': {'ind1': ' ', 'ind2': ' ', 'subfields': [{'d': 'OrLoB'}]}},
      {'050': {'ind1': ' ',
        'ind2': ' ',
        'subfields': [{'a': 'M231.B66 Bb maj. 1961'}]}},
      {'100': {'ind1': '1',
        'ind2': ' ',
        'subfields': [{'a': 'Boccherini, Luigi,'}, {'d': '1743-1805.'}]}},
      {'240': {'ind1': '1',
        'ind2': '0',
        'subfields': [{'a': 'Sonatas,'},
         {'m': 'cello, continuo,'},
         {'r': 'B♭ major'}]}},
      {'245': {'ind1': ' ',
        'ind2': '0',
        'subfields': [{'a': 'Sonata no. 7, in B flat, for violoncello and piano.'},
         {'c': 'Edited with realization of the basso continuo by Fritz Spiegl and Walter Bergamnn. Violoncello part edited by Joan Dickson.'}]}},
      {'260': {'ind1': ' ',
        'ind2': ' ',
        'subfields': [{'a': 'London, Schott; New York, Associated Music Publishers'},
         {'c': '[c1961]'}]}},
      {'300': {'ind1': ' ',
        'ind2': ' ',
        'subfields': [{'a': 'score (20 p.) & part.'}, {'c': '29cm.'}]}},
      {'490': {'ind1': '1',
        'ind2': ' ',
        'subfields': [{'a': 'Edition [Schott]  10731'}]}},
      {'500': {'ind1': ' ',
        'ind2': ' ',
        'subfields': [{'a': "Edited from a recently discovered ms. Closely parallels Gruetzmacher's free arrangement of the Violoncello concerto, G. 482."}]}},
      {'596': {'ind1': ' ', 'ind2': ' ', 'subfields': [{'a': '31'}]}},
      {'650': {'ind1': ' ',
        'ind2': '0',
        'subfields': [{'a': 'Sonatas (Cello and harpsichord)'}]}},
      {'700': {'ind1': '1',
        'ind2': '2',
        'subfields': [{'a': 'Boccherini, Luigi,'},
         {'d': '1743-1805.'},
         {'t': 'Concertos,'},
         {'m': 'cello, orchestra,'},
         {'n': 'G. 482,'},
         {'r': 'B♭ major'},
         {'o': 'arranged.'}]}},
      {'830': {'ind1': ' ',
        'ind2': '0',
        'subfields': [{'a': 'Edition Schott'}, {'v': '10731'}]}},
      {'998': {'ind1': ' ', 'ind2': ' ', 'subfields': [{'a': 'SCORE'}]}},
      {'035': {'ind1': ' ',
        'ind2': ' ',
        'subfields': [{'a': '(OCoLC-M)17708345'}]}},
      {'035': {'ind1': ' ',
        'ind2': ' ',
        'subfields': [{'a': '(OCoLC-I)268876650'}]}},
      {'918': {'ind1': ' ', 'ind2': ' ', 'subfields': [{'a': '666'}]}},
      {'035': {'ind1': ' ', 'ind2': ' ', 'subfields': [{'a': 'AAA0675'}]}},
      {'999': {'ind1': 'f',
        'ind2': 'f',
        'subfields': [{'i': '696ef04d-1902-5a70-aebf-98d287bce1a1'},
         {'s': '992460aa-bfe6-50ff-93f6-65c6aa786a43'}]}}],
     'leader': '01185ccm a2200301   4500'}},
   'deleted': False,
   'externalIdsHolder': {'instanceId': '696ef04d-1902-5a70-aebf-98d287bce1a1',
    'instanceHrid': 'a666'},
   'additionalInfo': {'suppressDiscovery': False},
   'metadata': {'createdDate': '2023-02-11T03:54:43.938+00:00',
    'createdByUserId': '3e2ed889-52f2-45ce-8a30-8767266f07d2',
    'updatedDate': '2023-02-11T03:54:44.574+00:00',
    'updatedByUserId': '3e2ed889-52f2-45ce-8a30-8767266f07d2'}}],
 'totalRecords': 1}
lwrubel commented 1 year ago

Question: Should folio_client's method return marcxml or should the consumer convert the JSON to marcxml? Either way that would be via the ruby-marc gem.

ndushay commented 1 year ago

We can return the marc.json for now; it will be read by the ruby-marc gem by the user of the client method.