WaifuVault (waifu_vault v0.0.3)

This API wrapper is meant to conform to the WaifuVault Swagger docs.

To include in your project:

  # In your mix.exs deps/0 function
  {:waifu_vault, "~> 0.0.3"}

To Use:

  # In your_file.ex
  require WaifuVault

Summary

Albums

The associate_file/2 function connects one or more files to an album.

The create_album/2 function creates an album within the specified bucket.

The delete_album/2 function removes the specified album.

The disassociate_file/2 function dis-connects one or more files from an album.

The get_album/1 function returns album info, given the private token.

The revoke_album/2 function disables public sharing. Note that future calls to share_album/2 will give it a new public token and new public URL.

The share_album/2 function takes the album's private token and returns the public URL. Calling share_album/2 on an already-shared album will just return its token.

Buckets

Buckets are virtual collections that are linked to your IP and a token. When you create a bucket, you will receive a bucket token that you can use in Get Bucket to get all the files in that bucket. Later calls to create_bucket/0 will return the same token as long as your IP address doesn't change.

Deleting a bucket will delete the bucket and all the files it contains.

The get_bucket/1 function returns the list of files and albums contained in a bucket. The bucket has a dateCreated value that can be converted with DateTime.from_unix( dateCreated, :millisecond)

Files

The file_info/2 function retrieves file metadata for the specified file token.

The get_file/2 function retrieves the specified file. The password is ignored unless the file is password-protected.

Resources

The get_file_stats/0 function returns server limits for the current IP address.

The get_restrictions/0 function returns restrictions for the current IP address.

Albums

associate_file(album_token, file_tokens)

The associate_file/2 function connects one or more files to an album.

  iex> {:ok, album_response} = WaifuVault.associate_file("some-valid-album-token", ["valid-file1". "valid-file2"])
  {:ok, Map}

create_album(bucket_token, album_name)

The create_album/2 function creates an album within the specified bucket.

  iex> {:ok, album} = WaifuVault.create_album("some-bucket-token", "album-name")
  {:ok, Map}

delete_album(album_token, delete_files \\ false)

The delete_album/2 function removes the specified album.

  # First deletion attempt
  iex> WaifuVault.delete_album("album-token")
  {:ok, %{"description" => "album deleted", "success" => true}}

  # Attempt a second deletion
  iex> WaifuVault.delete_album("album-token")
  {:error,
  "Error 400 (BAD_REQUEST): Album with token album-token not found"}

disassociate_file(album_token, file_tokens)

The disassociate_file/2 function dis-connects one or more files from an album.

  iex> {:ok, album_response} = WaifuVault.disassociate_file("some-valid-album-token", ["valid-file1". "valid-file2"])
  {:ok, Map}

get_album(token)

The get_album/1 function returns album info, given the private token.

  iex> {:ok, album_response} = WaifuVault.get_album("some-valid-album-token")
  {:ok, Map}

revoke_album(album_token)

The revoke_album/2 function disables public sharing. Note that future calls to share_album/2 will give it a new public token and new public URL.

  iex> {:ok, album_response} = WaifuVault.revoke_album("some-valid-album-token")
  {:ok, "album unshared"}

share_album(album_token)

The share_album/2 function takes the album's private token and returns the public URL. Calling share_album/2 on an already-shared album will just return its token.

  iex> {:ok, url} = WaifuVault.share_album("some-valid-album-token")
  {:ok, "https://waifuvault.moe/public-token"}
  iex> {:ok, token} = WaifuVault.share_album("some-valid-album-token")
  {:ok, "public-token"}

Buckets

create_bucket()

Buckets are virtual collections that are linked to your IP and a token. When you create a bucket, you will receive a bucket token that you can use in Get Bucket to get all the files in that bucket. Later calls to create_bucket/0 will return the same token as long as your IP address doesn't change.

  iex> {:ok, bucket} = WaifuVault.create_bucket()
  {:ok, "some-uuid-type-value"}

delete_bucket(token)

Deleting a bucket will delete the bucket and all the files it contains.

IMPORTANT: All contained files will be DELETED along with the Bucket!

  iex> {:ok, boolean} = WaifuVault.delete_bucket("some-valid-uuid-token")
  {:ok, true}

get_bucket(token)

The get_bucket/1 function returns the list of files and albums contained in a bucket. The bucket has a dateCreated value that can be converted with DateTime.from_unix( dateCreated, :millisecond)

Individual files have a retentionPeriod which is the UNIX timestamp in milliseconds for when the file will expire. It can be converted with DateTime.from_unix( retentionPeriod, :millisecond)

  iex> {:ok, boolean} = WaifuVault.get_bucket("some-valid-uuid-token")
  {:ok, Map}

Files

file_info(token, formatted \\ false)

The file_info/2 function retrieves file metadata for the specified file token.

  iex> {:ok, map} = WaifuVault.file_info("some-valid-file-token")
  {:ok, %{...}}

get_file(album_response, password \\ nil)

The get_file/2 function retrieves the specified file. The password is ignored unless the file is password-protected.

  iex> {:ok, bitstring} = WaifuVault.get_file("some-valid-album-token", "some-password")
  {:ok, <<many bytes>>}

Resources

get_file_stats()

The get_file_stats/0 function returns server limits for the current IP address.

  iex> WaifuVault.get_file_stats
  {:ok, %{"recordCount" => 1420, "recordSize" => "1.92 GiB"}}

get_restrictions()

The get_restrictions/0 function returns restrictions for the current IP address.

  iex> {:ok, restrictions} = WaifuVault.get_restrictions()
  {:ok,
    [
      %{type: "MAX_FILE_SIZE", value: 104857600},
      %{
        type: "BANNED_MIME_TYPE",
        value: "application/x-dosexec,application/x-executable,application/x-hdf5,application/x-java-archive,application/vnd.rar"
      }
    ]
  }