Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments to entity #18

Open
luisherranz opened this issue Jul 5, 2018 · 0 comments
Open

Add comments to entity #18

luisherranz opened this issue Jul 5, 2018 · 0 comments

Comments

@luisherranz
Copy link
Contributor

luisherranz commented Jul 5, 2018

Comments appear in the replies array of the _embed property:

screen shot 2018-07-05 at 11 44 49

We should return an array of comments:

connection.entity('post', 60).comments // => array of comments

We need a new Comment model. Comments in the REST API have the following schema:

{
  "id": 49719,
  "post": 117741,
  "parent": 49714,
  "author": 0,
  "author_name": "M.A.",
  "author_url": "",
  "date": "2018-08-13T23:09:00",
  "date_gmt": "2018-08-13T21:09:00",
  "content": {
    "rendered": "<p>Toda la razón.<br />\nPero si el tiempo ha demostrado algo es que por mucho que cambies, unos están arriba y otros abajo. Y casi siempre son los mismos&#8230;.</p>\n"
  },
  "link": "https://www.diariomotor.com/competicion/noticia/zak-brown-no-es-ideal-tener-a-dos-pilotos-jovenes-en-mclaren/#comment-49719",
  "status": "approved",
  "type": "comment",
  "author_avatar_urls": {
    "24": "https://secure.gravatar.com/avatar/09371c7b05ce82b1f692a19cd164a60e?s=24&d=mm&r=g",
    "48": "https://secure.gravatar.com/avatar/09371c7b05ce82b1f692a19cd164a60e?s=48&d=mm&r=g",
    "96": "https://secure.gravatar.com/avatar/09371c7b05ce82b1f692a19cd164a60e?s=96&d=mm&r=g"
  },
  "meta": [],
  "_links": {
    "self": [
      {
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/comments/49719"
      }
    ],
    "collection": [
      {
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/comments"
      }
    ],
    "up": [
      {
        "embeddable": true,
        "post_type": "noticia",
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/noticias/117741"
      }
    ],
    "in-reply-to": [
      {
        "embeddable": true,
        "href": "https://www.diariomotor.com/competicion/wp-json/wp/v2/comments/49714"
      }
    ]
  }
}

We need to decide what fields to expose directly (the other ones can be got from .raw)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant