Skip to content

Commit

Permalink
Address partial user update using POST not PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
jules2689 committed Feb 4, 2019
1 parent 3ffb4ef commit da06eab
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/oktakit/client/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ def list_users(options = {})
# @param options[:headers] [Hash] Optional. Header params for the request.
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
# @param options[:partial] [Boolean] Indicates a partial update, in which case POST will be used instead of PUT
# @param options [Hash] Optional. Body params for request.
# @return [Hash<Sawyer::Resource>] Updated User
# @see https://developer.okta.com/docs/api/resources/users#update-user
# @example
# Oktakit.update_user('id')
def update_user(id, options = {})
put("/users/#{id}", options)
if options.delete(:partial)
post("/users/#{id}", options)
else
put("/users/#{id}", options)
end
end

# Update Profile
Expand Down
62 changes: 62 additions & 0 deletions spec/cassettes/update_user_partial.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions spec/client/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@
end
end

describe '#update_user partial' do
it 'returns updated user' do
VCR.use_cassette 'update_user_partial' do
resp, = client.update_user(USERS_USER_ID,
profile: {
firstName: "Bob",
lastName: "User",
email: "[email protected]",
login: "[email protected]"
},
partial: true)
expect(resp.profile.firstName).to be == 'Bob'
end
end
end

describe '#update_profile' do
it 'returns updated user' do
VCR.use_cassette 'update_profile' do
Expand Down

0 comments on commit da06eab

Please sign in to comment.