name: Modules.Cloud.Likes
summary: Provides methods for accessing ArrowDB likes.
extends: Titanium.Module
excludes: { methods: [ 'addEventListener', 'applyProperties', 'fireEvent', 'removeEventListener' ] }

methods:
  - name: create
    summary: Create a like.
    description: |
        Requires user login. 
        
        See [Likes: Create a Like](https://docs.appcelerator.com/arrowdb/latest/#!/api/Likes-method-create)
        for the request parameters supported by this method.
        
        Data is returned in the `likes` property of the parameter passed to the callback.
    parameters:
      - name: parameters
        summary: Parameters to send in the request.
        type: Dictionary
        
      - name: callback
        summary: Callback function to execute when the method completes.
        type: Callback<CloudLikesResponse>
    since: 3.2.0

  - name: remove
    summary: Delete a like.
    description: |
        Requires user login.

        See [Likes: Delete a Like](https://docs.appcelerator.com/arrowdb/latest/#!/api/Likes-method-delete)
        for the request parameters supported by this method.
    parameters:
      - name: parameters
        summary: Parameters to send in the request.
        type: Dictionary

      - name: callback
        summary: Callback function to execute when the method completes.
        type: Callback<CloudLikesResponse>
    since: 3.2.0

examples:
  - title: Create a Like
    example: |
        This example creates a new like and checks the response.
        
            Cloud.Likes.create({
                user_id: someUserId
            }, function (e) {
                if (e.success) {
                    alert('Created!');
                } else {
                    alert('Error:\n' +
                        ((e.error && e.message) || JSON.stringify(e)));
                }
            });

  - title: Remove a Like
    example: |
        This example deletes a like and checks the response.
        
            Cloud.Likes.remove({
                user_id: someUserId
            }, function (e) {
                if (e.success) {
                    alert('Removed');
                } else {
                    alert('Error:\n' +
                        ((e.error && e.message) || JSON.stringify(e)));
                }
            });

---
name: CloudLikesResponse
summary: Argument passed to the callback when a request finishes successfully or erroneously.
extends: CloudResponse
properties:
  - name: likes
    summary: Set of `like` objects, if any exist.
    description: Only included if `success` is `true`.
    type: Array<Dictionary>
