Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Mysterious Endpoint #309

Open
tengpeng opened this issue Sep 16, 2016 · 3 comments
Open

Mysterious Endpoint #309

tengpeng opened this issue Sep 16, 2016 · 3 comments

Comments

@tengpeng
Copy link

I am trying to add a double-tap-to-like function. However, I failed to update the database. One thing I notice is that the mysterious endpoints. How do you choose the right one?

extension BluemixDataManager{
    /**
     Method updates like
    id: Image ID
     */

    func updateLike(id:String) {
        let requestURL = getBluemixBaseRequestURL() + "/" + kImagesEndPoint + "/" + id // I tried but failed
        let request = Request(url: requestURL, method: HttpMethod.PUT)

        request.timeout = kDefaultTimeOut
        let imageDataArray = BluemixDataManager.SharedInstance.images
        for image in imageDataArray{
            if image.id == id {
                print("\(id)") // I can find out which image is being tapped
                let imageDictionary = ["_id": image.id, "_rev": image._rev, "fileName": image.fileName, "caption" : image.caption, "width" : image.width, "height" : image.height, "location" : ["name" : image.location.name, "latitude" : image.location.latitude, "longitude" : image.location.longitude], "like" : image.like + 1]


                do {
                    let jsonData = try NSJSONSerialization.dataWithJSONObject(imageDictionary, options: .PrettyPrinted)

                    request.sendData(jsonData, completionHandler: { (response, error) -> Void in
                        if let error = error {
                            print(NSLocalizedString("Update Like Fail:", comment: "") + " \(error.localizedDescription)") // this one called 
                        }
                    })

                } catch {
                    print(NSLocalizedString("Update Like Fail", comment: ""))
                }
            }
        }
    }
}
@tfrank64
Copy link
Member

I don't think I know what you mean by mysterious endpoint? I think the functionality you are trying to use does not exist on BluePic-Server. I believe this would involve adding a new endpoint for adding likes to an image, in Routes.swift.

@tengpeng
Copy link
Author

Thanks for replying. Forgive me. I tried but failed to find related documents (create an endpoint on server side)

@rolivieri
Copy link
Collaborator

Hello, we are in the middle of migrating the code to Swift 3.0 and also addressing some technical debt and issues/defects. We hope to be done with this pretty soon. It would be better to incorporate any new functionality after we complete these tasks. We will get back to you and let you know once we are done so we can continue the discussion. Thanks so much for your interest in BluePic!

@rolivieri rolivieri reopened this Sep 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants