3lvis/Networking

Expose handleJSONRequest(..)?

markst opened this issue · 3 comments

Would exposing handleJSONRequest() every be considered?

I'd like to be able to perform requests conditional on an objects primary key & have control over the caching level.

i.e:

let primaryKey = resource.value(forKey: resource.entity.sync_remotePrimaryKey())
self.handleJSONRequest(primaryKey != nil ? .post : .put,
                       path: path,
                       cacheName: nil,
                       parameterType: .json,
                       parameters: values,
                       responseType: .json,
                       cachingLevel: .none) { (result) in

I suppose this would also involve exposing RequestType & ResponseType enums.

Current workaround:

        let primaryKey = resource.value(forKey: resource.entity.sync_localPrimaryKey())
        if primaryKey == nil {
            self.post(path,
                      parameterType: .json,
                      parameters: values,
                      completion: completion)
        } else {
            self.put(path,
                     parameterType: .json,
                     parameters: values,
                     completion: completion)
        }
3lvis commented

Hi! I don't think the workaround might make it worthwhile to exposing those endpoints. It looks pretty clean the way you've resolve it.