3lvis / Networking

Swift HTTP Networking with stubbing and caching support
MIT License
1.36k stars 112 forks source link

Expose handleJSONRequest(..)? #243

Closed markst closed 4 years ago

markst commented 5 years ago

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
markst commented 5 years ago

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

markst commented 5 years ago

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 5 years ago

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.