Skip to content

Commit a3efb79

Browse files
committed
refactor: move last login, from date, and to date into the options object
1 parent ee923a6 commit a3efb79

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lib/provisioning/account.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,30 @@ function user(user_id, options = {}, callback) {
121121
* @param [user_ids] {string[]} - A list of up to 100 user IDs. When provided, other parameters are ignored.
122122
* @param [prefix] {string} - Returns users where the name or email address begins with the specified case-insensitive
123123
* string.
124-
* @param [sub_account_id[ {string} - Only returns users who have access to the specified account.
125-
* @param [last_login] {boolean} - Returns users based on their last login within a specified date range. true for users who logged in, false for users who haven't logged in, undefined for all users.
126-
* @param [from_date] {Date|string} - Last login start date.
127-
* @param [to_date] {Date|string} - Last login end date.
128-
* @param [options] {object} - See {@link https://cloudinary.com/documentation/cloudinary_sdks#configuration_parameters|Configuration parameters} in the SDK documentation.
124+
* @param [sub_account_id] {string} - Only returns users who have access to the specified account.
125+
* @param [options] {object} - Configuration options. Can include:
126+
* - lastLogin {boolean} - Returns users based on their last login within a specified date range. true for users who logged in, false for users who haven't logged in, undefined for all users.
127+
* - fromDate {Date|string} - Last login start date.
128+
* - toDate {Date|string} - Last login end date.
129+
* See {@link https://cloudinary.com/documentation/cloudinary_sdks#configuration_parameters|Configuration parameters} in the SDK documentation.
129130
* @param [callback] {function}
130131
*/
131-
function users(pending, user_ids, prefix, sub_account_id, last_login, from_date, to_date, options = {}, callback) {
132+
function users(pending, user_ids, prefix, sub_account_id, options = {}, callback) {
133+
// Handle optional callback argument
134+
if (typeof options === 'function') {
135+
callback = options;
136+
options = {};
137+
}
138+
132139
let uri = ['users'];
133140
let params = {
134141
ids: user_ids,
135142
pending,
136143
prefix,
137144
sub_account_id,
138-
last_login,
139-
from: from_date,
140-
to: to_date
145+
last_login: options.lastLogin,
146+
from: options.fromDate,
147+
to: options.toDate
141148
};
142149
return call_account_api('GET', uri, pickOnlyExistingValues(params, "ids", "pending", "prefix", "sub_account_id", "last_login", "from", "to"), callback, options);
143150
}

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ declare module 'cloudinary' {
14951495

14961496
function user(userId: string, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
14971497

1498-
function users(pending: boolean, userIds?: string[], prefix?: string, subAccountId?: string, lastLogin?: boolean, fromDate?: Date | string, toDate?: Date | string, options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
1498+
function users(pending: boolean, userIds?: string[], prefix?: string, subAccountId?: string, options?: ProvisioningApiOptions | { lastLogin?: boolean; fromDate?: Date | string; toDate?: Date | string }, callback?: ResponseCallback): Promise<any>;
14991499

15001500
function create_user(name: string, email: string, role: string, subAccountIds?: string[], options?: ProvisioningApiOptions, callback?: ResponseCallback): Promise<any>;
15011501

0 commit comments

Comments
 (0)