'use strict';

const genericResource = require('bin/generic');

const resource = {
    name: 'organisation',
    defaultQuery: '[].{id:id, name:name, billing:billing.company, state:state, tags:join(\',\',keys(tag || `{}`) ) }',
    url: () => 'organisation',
    plugins: [
        require('bin/_plugins/loginRequired'),
        require('bin/_plugins/outputFormat'),
        require('bin/_plugins/api'),
    ],
    title: 'Organisation',
    commands: ['show', 'history', 'access/user', 'list', 'rename', 'tag', 'payment', 'delete'],
};

const category = genericResource(resource);

const childDefaults = Object.assign({}, resource, {
    options: {
        organisation: {
            description: 'Organisation ID or name',
            type: 'string',
            required: true,
        },
    },
    url: args => `${resource.url(args)}/${args.organisation}`,
});

category.addChild(require('./transfer')(childDefaults));
module.exports = category;
