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

Should we parse the output of the API? #65

Closed
dave-irvine opened this issue Dec 27, 2014 · 3 comments
Closed

Should we parse the output of the API? #65

dave-irvine opened this issue Dec 27, 2014 · 3 comments
Labels

Comments

@dave-irvine
Copy link
Contributor

At the moment we complete callbacks with the raw JSON output of the API... what about parsing the output?

This lets us call functions on the created objects:

This:

gitlab.projects.all (projects) ->
   for project in projects
      project.members.all (members) ->
         console.log members

rather than:

gitlab.projects.all (projects) ->
   for project in projects
      gitlab.projects.members.list project.id, (members) ->
         console.log members

Not the best example, but it seems simpler?

@moul
Copy link
Owner

moul commented Dec 27, 2014

👍 +1 for me

@moul moul added the question label Dec 27, 2014
@mdsb100
Copy link
Contributor

mdsb100 commented Feb 12, 2015

+1.
In cli-gitlab

stringifyFormat = (data) ->
  console.log(stringify(data, {space: 2})) if data?

As u say, "data" will be a object, and "data" need a function "toJSON".

But sometimes "data" is "true".

So this:

str = ""
if data.toJSON?
  str = stringify(data.toJSON(), {space: 2})
else
  str = stringify(data, {space: 2})

@mdsb100
Copy link
Contributor

mdsb100 commented Feb 12, 2015

CLI
this:

gitlab membersWithProject --filter "project.owner.id==9"

rather than:

gitlab projects --filter "item.owner.id==9"
[
{
    .......
    "id": 29,
    ......
    "owner": {
      "avatar_url": "http://gitlab.baidao.com//uploads/user/avatar/9/764b89699bcc946e4239b04f28002ce9.jpeg",
      "id": 9,
      "name": "Cao Jun",
      "state": "active",
      "username": "mdsb100"
    },
    .......
  }
]

get project id 29

gitlab members 29

@moul moul closed this as completed Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants