---
`_processRequest` is unecessary indirection. People expect methods to get called, not pass in as parameters.
If we want to factor out `parseJson`, we should make a patched version of the request methods that automatically parse json, that way we reduce duplication without introducing a confusing method call.
---
These tests don't do anything. Not only are they broken because even though they are asynchronous, the done()
parameter isn't being used, but even when I get them working, I can delete most of the method body and still get the tests to pass.
A lot of these endpoints, such as list
and search
take in a params endpoint. What are valid parameters? Is this just a pass-through to the assets api?
The Param
classes that were created are worse than having long parameter lists. Now you have a bunch of tiny "data classes" with duplicated fields that provide no helpful abstraction. It's the equivalent of sweeping a problem under the rug rather than fixing it.
Here are a few refactorings that could improve the design of these methods and reduce the parameter list.
itemGuid
andcontentType
do seem to be related. Those could be grouped into anItem
class (bad name, but you get the idea).accessKey
is duplicated across calls, why not instantiate the client with theaccessKey
instead of passing in to every method?- You could take this a step further and initialize the client with the folder guid as well, to have folder specific clients.
The resulting code would look like this:
var folderClient = new NewscredAssets.FolderClient(accesskey, folderGuid);
var item = new NewscredAssets.Item(itemGuid, contentType);
var folderClient.addItem(item);
The softDelete
parameter is a flag argument and should be avoided. Better to have two separate methods.