NewtailElixir simplifies the integration with the Newtail Retail Media APIs, currently supporting the synchronization of products and inventories.
Include the library in your mix.exs file under the deps function. This ensures the library is fetched from the specified GitHub repository.
def deps do
[
{:newtail_elixir, github: "petlove/newtail_elixir"}
]
endRun mix deps.get in your terminal to fetch the dependency.
Set the base_url configuration in your application. This is required for the library to communicate with the Newtail Retail Media APIs. The values for app_id and api_key are required to be sent over in the opts when calling the library (see Usage for more information), but setting their values in environment variables and definind them here alongside the base url is a good practice:
config :newtail_elixir,
app_id: System.fetch_env!("NEWTAIL_APP_ID"),
api_key: System.fetch_env!("NEWTAIL_API_KEY"),
base_url: System.fetch_env!("NEWTAIL_BASE_URL")NewtailElixir.sync(params, type, opts)The type argument is an atom that has to be either :products or :inventories.
The params argument will vary depending on the type. All accepted (required/optional) fields can be found here for products and here for inventories.
The opts argument is a list that must contain both api_key and app_id.