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

Send fields param to API when --fields flag is used #113

Merged
merged 2 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.0.1 (Upcoming)

- Fixed an issue where the `--fields` flag was not always requesting additional fields from the API

## 2.0.0

### Features and Enhancements
Expand Down
7 changes: 6 additions & 1 deletion src/commands/collaboration-whitelist/exemptions/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class CollaborationWhitelistGetExemptionCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(CollaborationWhitelistGetExemptionCommand);
let options = {};

let exemption = await this.client.collaborationWhitelist.getExemption(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let exemption = await this.client.collaborationWhitelist.getExemption(args.id, options);
await this.output(exemption);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/collaboration-whitelist/exemptions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class CollaborationWhitelistListExemptUserCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(CollaborationWhitelistListExemptUserCommand);
let options = {};

let exemptions = await this.client.collaborationWhitelist.getAllExemptions();
if (flags.fields) {
options.fields = flags.fields;
}

let exemptions = await this.client.collaborationWhitelist.getAllExemptions(options);
await this.output(exemptions);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/collaboration-whitelist/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class CollaborationWhitelistGetCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(CollaborationWhitelistGetCommand);
let options = {};

let whitelistEntry = await this.client.collaborationWhitelist.getWhitelistedDomain(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let whitelistEntry = await this.client.collaborationWhitelist.getWhitelistedDomain(args.id, options);
await this.output(whitelistEntry);
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/commands/collaboration-whitelist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ const BoxCommand = require('../../box-command');

class CollaborationWhitelistListCommand extends BoxCommand {
async run() {
const { flags } = this.parse(CollaborationWhitelistListCommand);
const { args } = this.parse(CollaborationWhitelistListCommand);
const { flags, args } = this.parse(CollaborationWhitelistListCommand);
let options = {};

let whitelistEntries = await this.client.collaborationWhitelist.getAllWhitelistedDomains();
if (flags.fields) {
options.fields = flags.fields;
}

let whitelistEntries = await this.client.collaborationWhitelist.getAllWhitelistedDomains(options);
await this.output(whitelistEntries);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/collections/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class CollectionsListItemsCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(CollectionsListItemsCommand);
let options = {};

let items = await this.client.collections.getItems(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let items = await this.client.collections.getItems(args.id, options);
await this.output(items);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/comments/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class CommentsGetCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(CommentsGetCommand);
let options = {};

let comment = await this.client.comments.get(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let comment = await this.client.comments.get(args.id, options);
await this.output(comment);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/files/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class CommentsListCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(CommentsListCommand);
let options = {};

let comments = await this.client.files.getComments(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let comments = await this.client.files.getComments(args.id, options);
await this.output(comments);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/files/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class FilesGetCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(FilesGetCommand);
let options = {};

let file = await this.client.files.get(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let file = await this.client.files.get(args.id, options);
await this.output(file);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/files/tasks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class FilesListTasksCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(FilesListTasksCommand);
let options = {};

let tasks = await this.client.files.getTasks(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let tasks = await this.client.files.getTasks(args.id, options);
await this.output(tasks);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/files/versions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class FilesListVersionsCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(FilesListVersionsCommand);
let options = {};

let versions = await this.client.files.getVersions(args.fileID);
if (flags.fields) {
options.fields = flags.fields;
}

let versions = await this.client.files.getVersions(args.fileID, options);
await this.output(versions);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/folders/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class FoldersGetCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(FoldersGetCommand);
let options = {};

let folder = await this.client.folders.get(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let folder = await this.client.folders.get(args.id, options);
await this.output(folder);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/commands/folders/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class FoldersListItemsCommand extends BoxCommand {
usemarker: true,
};

if (flags.fields) {
options.fields = flags.fields;
}

if (flags.direction) {
options.direction = flags.direction;
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/groups/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class GroupsGetCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(GroupsGetCommand);
let options = {};

let group = await this.client.groups.get(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let group = await this.client.groups.get(args.id, options);
await this.output(group);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/groups/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class GroupsListCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(GroupsListCommand);
let options = {};

let groups = await this.client.groups.getAll();
if (flags.fields) {
options.fields = flags.fields;
}

let groups = await this.client.groups.getAll(options);
await this.output(groups);
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/commands/groups/memberships/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ const BoxCommand = require('../../../box-command');

class GroupsGetMembershipCommand extends BoxCommand {
async run() {
const { flags } = this.parse(GroupsGetMembershipCommand);
const { args } = this.parse(GroupsGetMembershipCommand);
const { flags, args } = this.parse(GroupsGetMembershipCommand);
let options = {};

let membership = await this.client.groups.getMembership(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let membership = await this.client.groups.getMembership(args.id, options);
await this.output(membership);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/groups/memberships/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class GroupsListMembershipCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(GroupsListMembershipCommand);
let options = {};

let members = await this.client.groups.getMemberships(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let members = await this.client.groups.getMemberships(args.id, options);
await this.output(members);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/legal-hold-policies/assignments/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class LegalHoldPoliciesGetAssignmentCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(LegalHoldPoliciesGetAssignmentCommand);
let options = {};

let assignment = await this.client.legalHoldPolicies.getAssignment(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let assignment = await this.client.legalHoldPolicies.getAssignment(args.id, options);
await this.output(assignment);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/commands/legal-hold-policies/assignments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class LegalHoldPoliciesListAssignmentsCommand extends BoxCommand {
options.assign_to_id = flags['assign-to-id'];
}

if (flags.fields) {
options.fields = flags.fields;
}

let assignments = await this.client.legalHoldPolicies.getAssignments(args.id, options);
await this.output(assignments);
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/legal-hold-policies/file-version-holds/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class LegalHoldPoliciesGetVersionHoldCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(LegalHoldPoliciesGetVersionHoldCommand);
let options = {};

let fileVersionHold = await this.client.legalHoldPolicies.getFileVersionLegalHold(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let fileVersionHold = await this.client.legalHoldPolicies.getFileVersionLegalHold(args.id, options);
await this.output(fileVersionHold);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/legal-hold-policies/file-version-holds/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class LegalHoldPoliciesListVersionHoldsCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(LegalHoldPoliciesListVersionHoldsCommand);
let options = {};

let fileVersionHolds = await this.client.legalHoldPolicies.getAllFileVersionLegalHolds(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let fileVersionHolds = await this.client.legalHoldPolicies.getAllFileVersionLegalHolds(args.id, options);
await this.output(fileVersionHolds);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/legal-hold-policies/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../box-command');
class LegalHoldPoliciesGetCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(LegalHoldPoliciesGetCommand);
let options = {};

let policy = await this.client.legalHoldPolicies.get(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let policy = await this.client.legalHoldPolicies.get(args.id, options);
await this.output(policy);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/commands/legal-hold-policies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class LegalHoldPoliciesListCommand extends BoxCommand {
options.policy_name = flags['policy-name'];
}

if (flags.fields) {
options.fields = flags.fields;
}

let policies = await this.client.legalHoldPolicies.getAll(options);
await this.output(policies);
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/recent-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../box-command');
class RecentItems extends BoxCommand {
async run() {
const { flags, args } = this.parse(RecentItems);
let options = {};

let recentItems = await this.client.recentItems.get();
if (flags.fields) {
options.fields = flags.fields;
}

let recentItems = await this.client.recentItems.get(options);
await this.output(recentItems);
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/commands/retention-policies/assignments/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class RetentionPoliciesGetAssignmentCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(RetentionPoliciesGetAssignmentCommand);
let options = {};

let assignment = await this.client.retentionPolicies.getAssignment(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let assignment = await this.client.retentionPolicies.getAssignment(args.id, options);
await this.output(assignment);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/commands/retention-policies/assignments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ class RetentionPoliciesListCommand extends BoxCommand {
if (flags.type) {
options.type = flags.type;
}

if (flags.fields) {
options.fields = flags.fields;
}

let assignments = await this.client.retentionPolicies.getAssignments(args.id, options);
await this.output(assignments);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ const BoxCommand = require('../../../box-command');
class RetentionPoliciesGetVersionRetentionCommand extends BoxCommand {
async run() {
const { flags, args } = this.parse(RetentionPoliciesGetVersionRetentionCommand);
let options = {};

let retention = await this.client.retentionPolicies.getFileVersionRetention(args.id);
if (flags.fields) {
options.fields = flags.fields;
}

let retention = await this.client.retentionPolicies.getFileVersionRetention(args.id, options);
await this.output(retention);
}
}
Expand Down
Loading