Packages

An API facade for a private biometrics service.

Current section

Files

Jump to
biometrics_facade lib biometrics_facade facial_recognitions create.ex
Raw

lib/biometrics_facade/facial_recognitions/create.ex

defmodule BiometricsFacade.FacialRecognitions.Create do
@path "/facial_recognitions"
@expected_fields ~w(facial_recognition_score)
@image_delimiter "<<<iberon-delimiter>>>"
alias BiometricsFacade.Service
def submit( image_1_bin, image_2_bin ) do
req_body = make_body_from_bin( image_1_bin, image_2_bin )
case Service.post( @path, body: req_body ) do
%HTTPotion.Response{status_code: 201} = response ->
{:ok, response}
any ->
{:error, any}
end
end
# Protected ##########
def make_body_from_bin( image_1_bin, image_2_bin ) do
image_1_bin <> @image_delimiter <> image_2_bin
end
def make_body_from_files( image_1_path, image_2_path ) do
image_1_bin = File.read!( image_1_path )
image_2_bin = File.read!( image_2_path )
make_body_from_bin( image_1_bin, image_2_bin )
end
end