Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:bahner/ex-ipfs into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Oct 11, 2023
2 parents f3197a7 + 874d1fa commit 1277be9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/ex_ipfs/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,20 @@ defmodule ExIpfs.Utils do
_ -> data
end
end

def map_has_keys?(response, expected_keys) do
if Enum.all?(expected_keys, &Map.has_key?(response, &1)) do
response
else
raise ArgumentError, message: "Missing some of #{inspect(expected_keys)} in response from IPFS API"
end
end

def map_get_key!(response, key) do
case response do
%{^key => value} -> value
_ -> raise ArgumentError, message: "Problem extracting #{inspect(key)} from response from IPFS API"
end
end

end

0 comments on commit 1277be9

Please sign in to comment.