defmodule Instruments.Card do @moduledoc false alias Customers.{AccountHolder, Customer} @derive Jason.Encoder defstruct [ :account_holder, :bin, :card_category, :card_type, :customer, :expiry_month, :expiry_year, :fingerprint, :id, :issuer, :issuer_country, :last4, :name, :product_id, :product_type, :scheme, :scheme_local, :type ] def build(body) when is_map(body) do %__MODULE__{ account_holder: AccountHolder.build(body["account_holder"]), bin: body["bin"], card_category: body["card_category"], card_type: body["card_type"], customer: Customer.build(body["customer"]), expiry_month: body["expiry_month"], expiry_year: body["expiry_year"], fingerprint: body["fingerprint"], id: body["id"], issuer: body["issuer"], issuer_country: body["issuer_country"], last4: body["last4"], name: body["name"], product_id: body["product_id"], product_type: body["product_type"], scheme: body["scheme"], scheme_local: body["scheme_local"], type: body["type"] } end end