Skip to content

Commit

Permalink
fix(users): orderby can't be used with filter
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed May 28, 2024
1 parent a923f55 commit db32089
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: office365
version: 1.25.1
version: 1.25.2

crystal: ">= 0.36.1"

Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module SpecHelper
end

def mock_list_users
WebMock.stub(:get, "https://graph.microsoft.com/v1.0/users?$select=id,userPrincipalName,surname,preferredLanguage,officeLocation,mobilePhone,mail,jobTitle,givenName,displayName,businessPhones,accountEnabled,mailNickname&$orderby=displayName&$filter=accountEnabled eq true")
WebMock.stub(:get, "https://graph.microsoft.com/v1.0/users?$select=id,userPrincipalName,surname,preferredLanguage,officeLocation,mobilePhone,mail,jobTitle,givenName,displayName,businessPhones,accountEnabled,mailNickname&$filter=accountEnabled eq true")
.to_return(mock_user_query.to_json)
end

Expand Down
9 changes: 5 additions & 4 deletions src/users.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ module Office365::Users
end

query_params = URI::Params.new({
"$select" => fields.join(","),
"$orderby" => "displayName",
"$filter" => filter_param,
"$top" => limit,
"$select" => fields.join(","),
# can't use order if there is a filter
# "$orderby" => "displayName",
"$filter" => filter_param,
"$top" => limit,
}.compact.transform_values { |val| [val] })

graph_http_request("GET", "#{USERS_BASE}", query: query_params)
Expand Down

0 comments on commit db32089

Please sign in to comment.