Skip to content

Commit c995003

Browse files
authored
[SDK-4659] Add fields to get_organizations_members (#532)
2 parents 04a184c + 7234fb9 commit c995003

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

lib/auth0/api/v2/organizations.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,8 @@ def delete_organizations_invite(organization_id, invitation_id)
214214
### Organization Member
215215

216216
# Get Members in a Organization
217+
# Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member.
218+
# To use this parameter, you must include the `read:organization_member_roles scope` in the token.
217219
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
218220
# @param organization_id [string] The Organization ID
219221
# @param options [hash] The Hash options used to define the paging of rersults
@@ -222,6 +224,8 @@ def delete_organizations_invite(organization_id, invitation_id)
222224
# * :from [string] For checkpoint pagination, the ID from which to start selection from.
223225
# * :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.
224226
# * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
227+
# * :fields [string] A comma separated list of fields to include or exclude from the result. If fields is left blank, all fields (except roles) are returned.
228+
# * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
225229
#
226230
# @return [json] Returns the members for the given organization
227231
def get_organizations_members(organization_id, options = {})
@@ -231,7 +235,9 @@ def get_organizations_members(organization_id, options = {})
231235
page: options.fetch(:page, nil),
232236
from: options.fetch(:from, nil),
233237
take: options.fetch(:take, nil),
234-
include_totals: options.fetch(:include_totals, nil)
238+
include_totals: options.fetch(:include_totals, nil),
239+
fields: options.fetch(:fields, nil),
240+
include_fields: options.fetch(:include_fields, nil)
235241
}
236242
path = "#{organizations_members_path(organization_id)}"
237243
get(path, request_params)

spec/lib/auth0/api/v2/organizations_spec.rb

+26-2
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@
451451
page: nil,
452452
from: nil,
453453
take: nil,
454-
include_totals: nil
454+
include_totals: nil,
455+
fields: nil,
456+
include_fields: nil
455457
})
456458
expect do
457459
@instance.get_organizations_members('org_id')
@@ -465,7 +467,9 @@
465467
page: 1,
466468
from: 'org_id',
467469
take: 50,
468-
include_totals: true
470+
include_totals: true,
471+
fields: nil,
472+
include_fields: nil
469473
})
470474
expect do
471475
@instance.get_organizations_members(
@@ -478,6 +482,26 @@
478482
)
479483
end.not_to raise_error
480484
end
485+
486+
it 'is expected to get /api/v2/organizations with custom fields' do
487+
expect(@instance).to receive(:get).with(
488+
'/api/v2/organizations/org_id/members', {
489+
per_page: nil,
490+
page: nil,
491+
from: nil,
492+
take: nil,
493+
include_totals: nil,
494+
fields: 'foo,bar',
495+
include_fields: false
496+
})
497+
expect do
498+
@instance.get_organizations_members(
499+
'org_id',
500+
fields: 'foo,bar',
501+
include_fields: false
502+
)
503+
end.not_to raise_error
504+
end
481505
end
482506

483507
context '.create_organizations_members' do

0 commit comments

Comments
 (0)