Skip to content

Commit 5670f09

Browse files
authored
Merge pull request #15 from Shopify/partial-user
Address partial user update using POST not PUT
2 parents 3ffb4ef + 1b5f02c commit 5670f09

File tree

4 files changed

+87
-3
lines changed

4 files changed

+87
-3
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
sudo: false
22
before_install: gem install bundler
33
rvm:
4-
- '2.2'
5-
- '2.3.1'
4+
- '2.3.8'
5+
- '2.5.3'
6+
- '2.6.0'
67

lib/oktakit/client/users.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,18 @@ def list_users(options = {})
5454
# @param options[:headers] [Hash] Optional. Header params for the request.
5555
# @param options[:accept] [String] Optional. The content type to accept. Default application/json
5656
# @param options[:content_type] [String] Optional. The content type for the request. Default application/json
57+
# @param options[:partial] [Boolean] Indicates a partial update, in which case POST will be used instead of PUT
5758
# @param options [Hash] Optional. Body params for request.
5859
# @return [Hash<Sawyer::Resource>] Updated User
5960
# @see https://developer.okta.com/docs/api/resources/users#update-user
6061
# @example
6162
# Oktakit.update_user('id')
6263
def update_user(id, options = {})
63-
put("/users/#{id}", options)
64+
if options.delete(:partial)
65+
post("/users/#{id}", options)
66+
else
67+
put("/users/#{id}", options)
68+
end
6469
end
6570

6671
# Update Profile

spec/cassettes/update_user_partial.yml

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/client/users_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@
6363
end
6464
end
6565

66+
describe '#update_user partial' do
67+
it 'returns updated user' do
68+
VCR.use_cassette 'update_user_partial' do
69+
resp, = client.update_user(USERS_USER_ID,
70+
profile: {
71+
firstName: "Bob",
72+
lastName: "User",
73+
email: "example@example.com",
74+
login: "example@example.com"
75+
},
76+
partial: true)
77+
expect(resp.profile.firstName).to be == 'Bob'
78+
end
79+
end
80+
end
81+
6682
describe '#update_profile' do
6783
it 'returns updated user' do
6884
VCR.use_cassette 'update_profile' do

0 commit comments

Comments
 (0)