Skip to main content

lib/pomelo_ex/cards/credits/credit_lines/update_credit_line.ex

defmodule PomeloEx.Cards.Credits.CreditLines.UpdateCreditLine do
  @moduledoc false

  alias PomeloEx.Types.Cards.Credits.CreditLines.UpdateCreditLineType

  def execute(%UpdateCreditLineType{token: token, id: id} = payload) do
    headers = build_headers(token)

    body = payload.body |> Jason.encode!()

    PomeloEx.Client.request(:patch, "/lending/v1/credit-lines/#{id}", body, headers)
  end

  defp build_headers(token) do
    [
      {"Content-Type", "application/json"},
      {"Authorization", "Bearer #{token}"}
    ]
  end
end