-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Missing Methods for Blueprints
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
defmodule Novu.Blueprints do | ||
@moduledoc """ | ||
Provide access to the Novu Blueprints API | ||
""" | ||
|
||
alias Novu.Http | ||
|
||
@doc """ | ||
Retrieve the current environment | ||
[API Documentation](https://docs.novu.co/api-reference/get-v1blueprints) | ||
""" | ||
@spec get_blueprints(transaction_id :: String.t()) :: Http.response() | ||
def get_blueprints(transaction_id) do | ||
Http.get("/v1/blueprints/#{URI.encode(transaction_id)}") | ||
end | ||
|
||
@doc """ | ||
Returns a list of API keys | ||
[API Documentation](https://docs.novu.co/api-reference/get-v1blueprintsgroup-by-category) | ||
""" | ||
@spec get_group_by_category :: Http.response() | ||
def get_group_by_category do | ||
Http.get("/v1/blueprints/group-by-category") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
defmodule Novu.BlueprintsTest do | ||
use ExUnit.Case | ||
|
||
import Novu.ApiTestHelpers | ||
|
||
alias Novu.Blueprints | ||
|
||
@test_api_key "test-api-key" | ||
|
||
setup do | ||
bypass = Bypass.open() | ||
|
||
current_domain = Application.get_env(:novu, :domain) | ||
|
||
Application.put_env(:novu, :domain, "http://localhost:#{bypass.port}") | ||
Application.put_env(:novu, :api_key, @test_api_key) | ||
|
||
on_exit(fn -> | ||
Application.put_env(:novu, :domain, current_domain) | ||
end) | ||
|
||
{:ok, bypass: bypass} | ||
end | ||
|
||
describe "get_subscribers/1" do | ||
test "creates a GET to /v1/blueprints", %{bypass: bypass} do | ||
template_id = "template_id" | ||
|
||
Bypass.expect(bypass, "GET", "/v1/blueprints//#{URI.encode(subscriber_id)}", fn conn -> | ||
Check warning on line 29 in test/novu/blueprints_test.exs GitHub Actions / Test (Elixir 1.12 OTP 24)
Check failure on line 29 in test/novu/blueprints_test.exs GitHub Actions / Test (Elixir 1.12 OTP 24)
Check warning on line 29 in test/novu/blueprints_test.exs GitHub Actions / Test (Elixir 1.13 OTP 25)
Check failure on line 29 in test/novu/blueprints_test.exs GitHub Actions / Test (Elixir 1.13 OTP 25)
Check warning on line 29 in test/novu/blueprints_test.exs GitHub Actions / Test (Elixir 1.14 OTP 25)
Check failure on line 29 in test/novu/blueprints_test.exs GitHub Actions / Test (Elixir 1.14 OTP 25)
|
||
novu_response(conn, 200, %{data: %{templateId: template_id}}) | ||
end) | ||
|
||
assert {:ok, _body} = Blueprints.get_blueprints(template_id) | ||
end | ||
end | ||
|
||
describe "get_group_by_category" do | ||
test "creates a GET to /v1/blueprints/group-by-category", %{bypass: bypass} do | ||
Bypass.expect(bypass, "GET", "/v1/blueprints/group-by-category", fn conn -> | ||
novu_response(conn, 201, %{data: []}) | ||
end) | ||
|
||
assert {:ok, _body} = Blueprints.get_group_by_category() | ||
end | ||
end | ||
end |