Current section
Files
Jump to
Current section
Files
lib/vtex_ws/services/app_manager.ex
defmodule VtexWs.Services.AppManager do
@moduledoc "Módulo responsável por todas as requisições entre o VtexWs e o AppManager."
alias VtexWs.Apps.App
def base_url, do: System.get_env("APP_MANAGER_URL")
@doc "Requisição para criar ou atualizar uma categoria no App Manager."
def create_or_update_category_by_app!(category, app) do
HTTPoison.post(
base_url <> "/api/categorias/produtos",
Poison.encode!(%{category: category}),
app_manager_headers(app)
)
|> elem(1)
end
defp app_manager_headers(app) do
[
{"Authorization", "Token " <> app.api_key},
{"Content-Type", "application/json"}
]
end
end