Skip to content

Commit

Permalink
Add delete method to unmanaged_access_codes + test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-balitskyi committed Oct 25, 2023
1 parent c0a68ae commit 52d6b4b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/seam/clients/unmanaged_access_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ def convert_to_managed(access_code_id, allow_external_modification: nil)
action_attempt.wait_until_finished
action_attempt
end

def delete(access_code_id)
action_attempt = request_seam_object(
:post,
"/access_codes/unmanaged/delete",
Seam::ActionAttempt,
"action_attempt",
body: {
access_code_id: access_code_id
}
)
action_attempt.wait_until_finished
action_attempt
end
end
end
end
29 changes: 29 additions & 0 deletions spec/clients/unmanaged_access_codes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,33 @@
expect(result).to be_a(Seam::ActionAttempt)
end
end

describe "#convert_to_managed" do
let(:access_code_id) { "access_code_1234" }
let(:action_attempt_hash) { {action_attempt_id: "1234", status: "pending"} }

before do
stub_seam_request(
:post, "/access_codes/unmanaged/delete", {action_attempt: action_attempt_hash}
).with do |req|
req.body.source == {access_code_id: access_code_id}.to_json
end

stub_seam_request(
:get,
"/action_attempts/get",
{
action_attempt: {
status: "success"
}
}
).with(query: {action_attempt_id: action_attempt_hash[:action_attempt_id]})
end

let(:result) { client.unmanaged_access_codes.delete(access_code_id) }

it "returns an Action Attempt" do
expect(result).to be_a(Seam::ActionAttempt)
end
end
end

0 comments on commit 52d6b4b

Please sign in to comment.