Skip to content

Commit

Permalink
[SDK-4659] Add fields to get_organizations_members (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath authored Oct 27, 2023
2 parents 04a184c + 7234fb9 commit c995003
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
8 changes: 7 additions & 1 deletion lib/auth0/api/v2/organizations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ def delete_organizations_invite(organization_id, invitation_id)
### Organization Member

# Get Members in a Organization
# Member roles are not sent by default. Use `fields=roles` to retrieve the roles assigned to each listed member.
# To use this parameter, you must include the `read:organization_member_roles scope` in the token.
# @see https://auth0.com/docs/api/management/v2/#!/Organizations/get_members
# @param organization_id [string] The Organization ID
# @param options [hash] The Hash options used to define the paging of rersults
Expand All @@ -222,6 +224,8 @@ def delete_organizations_invite(organization_id, invitation_id)
# * :from [string] For checkpoint pagination, the ID from which to start selection from.
# * :take [integer] For checkpoint pagination, the number of entries to retrieve. Default is 50.
# * :include_totals [boolean] True to include query summary in the result, false or nil otherwise.
# * :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.
# * :include_fields [boolean] True if the fields specified are to be included in the result, false otherwise.
#
# @return [json] Returns the members for the given organization
def get_organizations_members(organization_id, options = {})
Expand All @@ -231,7 +235,9 @@ def get_organizations_members(organization_id, options = {})
page: options.fetch(:page, nil),
from: options.fetch(:from, nil),
take: options.fetch(:take, nil),
include_totals: options.fetch(:include_totals, nil)
include_totals: options.fetch(:include_totals, nil),
fields: options.fetch(:fields, nil),
include_fields: options.fetch(:include_fields, nil)
}
path = "#{organizations_members_path(organization_id)}"
get(path, request_params)
Expand Down
28 changes: 26 additions & 2 deletions spec/lib/auth0/api/v2/organizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,9 @@
page: nil,
from: nil,
take: nil,
include_totals: nil
include_totals: nil,
fields: nil,
include_fields: nil
})
expect do
@instance.get_organizations_members('org_id')
Expand All @@ -465,7 +467,9 @@
page: 1,
from: 'org_id',
take: 50,
include_totals: true
include_totals: true,
fields: nil,
include_fields: nil
})
expect do
@instance.get_organizations_members(
Expand All @@ -478,6 +482,26 @@
)
end.not_to raise_error
end

it 'is expected to get /api/v2/organizations with custom fields' do
expect(@instance).to receive(:get).with(
'/api/v2/organizations/org_id/members', {
per_page: nil,
page: nil,
from: nil,
take: nil,
include_totals: nil,
fields: 'foo,bar',
include_fields: false
})
expect do
@instance.get_organizations_members(
'org_id',
fields: 'foo,bar',
include_fields: false
)
end.not_to raise_error
end
end

context '.create_organizations_members' do
Expand Down

0 comments on commit c995003

Please sign in to comment.