Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update typespec for Cloudex.upload/2 #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/cloudex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ defmodule Cloudex do
@spec start(settings :: map) :: {:ok, pid}
defdelegate start(settings), to: Cloudex.Settings

@type upload_result ::
{:ok, Cloudex.UploadedImage.t()}
| {:error, any}
| [{:ok, Cloudex.UploadedImage.t()} | {:error, any}]
@type upload_result :: {:ok, Cloudex.UploadedImage.t()} | {:error, any}

@doc ~S"""
Uploads a (list of) image file(s) and/or url(s) to cloudinary
"""
@spec upload(list | String.t()) :: upload_result
@spec upload(list | [String.t()], map) :: upload_result
@spec upload(list | String.t(), map) :: upload_result
@spec upload(list | [String.t()], map) :: [upload_result]
def upload(list, options \\ %{}) do
sanitized_list = sanitize_list(list)
invalid_list = Enum.filter(sanitized_list, &match?({:error, _}, &1))
Expand Down