Skip to content

Commit

Permalink
Merge pull request Shopify#47 from Tetra-Insights/reactivate-delete
Browse files Browse the repository at this point in the history
Add Reactivate-Delete
  • Loading branch information
ltk authored Jan 10, 2022
2 parents 91dd415 + 92cdc36 commit 83eb94d
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lib/oktakit/client/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,24 @@ def activate_user(id, options = {})
post("/users/#{id}/lifecycle/activate", options)
end

# Reactivate User
#
# @params id [string] User ID
# @param options[:query] [Hash] Optional. Query params for request
# @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 [Hash] Optional. Body params for request.
# @return [Hash<Sawyer::Resource>].
# @note The user must be in a PROVISIONED status
# @see https://developer.okta.com/docs/reference/api/users/#reactivate-user
# @example
# Oktakit.reactivate_user('id')

def reactivate_user(id, options = {})
post("/users/#{id}/lifecycle/reactivate", options)
end

# Deactivate User
#
# @params id [string] User ID
Expand All @@ -147,6 +165,24 @@ def deactivate_user(id, options = {})
post("/users/#{id}/lifecycle/deactivate", options)
end

# Delete User
#
# @params id [string] User ID
# @param options[:query] [Hash] Optional. Query params for request
# @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 [Hash] Optional. Body params for the request.
# @return 204 'No Content'
# @note Deletes a user permanently. This operation can only be performed on users that have a DEPROVISIONED status. This action cannot be recovered!
# This operation on a user that hasn't been deactivated causes that user to be deactivated. A second delete operation is required to delete the user.
# @see https://developer.okta.com/docs/reference/api/users/#delete-user
# @example
# Oktakit.delete_user('id')
def delete_user(id, options = {})
delete("/users/#{id}", options)
end

# Suspend User
#
# @params id [string] User ID
Expand Down
65 changes: 65 additions & 0 deletions spec/cassettes/delete_user.yml

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

71 changes: 71 additions & 0 deletions spec/cassettes/reactivate_user.yml

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

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

describe '#reactivate_user' do
it 'returns activation token by default.' do
VCR.use_cassette('reactivate_user') do
resp, status = client.reactivate_user(USERS_USER_ID)
expect(status).to(be == 200)
expect(resp[:activationToken]).to(be == '-9OhPWRjr7_S8t2iV5_w')
end
end
end

describe '#deactivate_user' do
it 'returns an empty object.' do
VCR.use_cassette('deactivate_user') do
Expand All @@ -130,6 +140,16 @@
end
end

describe '#delete_user' do
it 'returns an empty object.' do
VCR.use_cassette('delete_user') do
resp, status = client.delete_user(USERS_USER_ID)
expect(resp).to(be_empty)
expect(status).to(be == 204)
end
end
end

describe '#suspend_user' do
it 'returns an empty object.' do
VCR.use_cassette('suspend_user') do
Expand Down

0 comments on commit 83eb94d

Please sign in to comment.