anfly0

anfly0

exBankID - A simple abstraction over the swedish BankID api

I just released a super simple client for the Swedish BankID API.
https://hex.pm/packages/exBankID

Not all that much to say about it, just hoping it can be useful to someone!

If you like it tell a friend and put a star on the github repo
If you don’t like it all feedback is more than welcome!
Thanks!

Most Liked

krstfk

krstfk

While I am not a specialist here, I have similar constraints for a project I’m working on, and I think the best path forward is to define a behaviour for the http calls and the json parsing, then it’s just a matter of implementing the callbacks for whatever library.
\Edit
You can then call functions from modules implementing the behaviour having said module declared eg in app env.
Benefits are : users can implement their own modules with libraries you didn’t think of at first and you can mock with mox.

egze

egze

Look how ExAws does it.

Behavior: ex_aws/lib/ex_aws/request/http_client.ex at main · ex-aws/ex_aws · GitHub

This is how we implement it in our project (using Mojito instead of the default client):

defmodule DB.S3.HttpClient do
  @moduledoc false
  @behaviour ExAws.Request.HttpClient
  def request(method, url, body, headers, http_opts \\ []) do
    case Mojito.request(method, url, headers, body, http_opts) do
      {:ok, response} -> {:ok, response}
      {:error, error} -> {:error, %{reason: error}}
    end
  end
end

The implementation module is passed through config. And used in ExAws like this: ex_aws/lib/ex_aws/request.ex at main · ex-aws/ex_aws · GitHub

And I think that such a config is perfectly fine for Json and HttpClient. I don’t see any usecase where you would want to have 2 different parsers in the app, right?

egze

egze

I’ve never built it myself in Elixir, but you can look at other libs for inspiration. Look how ex_aws does it with json GitHub - ex-aws/ex_aws: A flexible, easy to use set of clients AWS APIs for Elixir · GitHub

Maybe @benwilson512 could give some tips how to structure such a pluggable library. He mentioned some ideas in the ExAws thread. I would love a discussion about a a good architecture for a library :slight_smile:

Where Next?

Popular in Announcing Top

OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
gabrielpoca
Hello everyone! I want to share with you something that I’m really proud of: https://stillstatic.io/ Still is a static site builder for...
New
josevalim
Hi everyone, We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
restlessronin
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub. Docs are at OpenaiEx User Gu...
152 10380 134
New
bryanjos
Hi, I just published version 0.23.0 of Elixirscript. https://github.com/bryanjos/elixirscript/blob/master/CHANGELOG.md Most of the chan...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
oltarasenko
Dear Elixir community, After a year of development, bug fixes, and improvements, we are proudly ready to share the release of Crawly 0.1...
New
Crowdhailer
Raxx is an alternative to Plug and is inspired by projects such as Rack(Ruby) and Ring(Clojure). 1.0-rc.1 is now available. To use it re...
New
sbs
Only 650 LOC, wrote for fun :slight_smile: https://github.com/sunboshan/qrcode
New
tfwright
After working on it for a couple of months and using it in production for most of that time, today I’ve released LiveAdmin, a LiveView ba...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43657 311
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New

We're in Beta

About us Mission Statement