This repository has been archived by the owner on Nov 27, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f96865d
commit c597fe7
Showing
8 changed files
with
231 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,22 @@ | ||
defmodule ArkEcosystem.Client.API.Bridgechains do | ||
@moduledoc """ | ||
Documentation for ArkEcosystem.Client.API.Bridgechains | ||
""" | ||
|
||
import ArkEcosystem.Client | ||
|
||
@spec list(Tesla.Client.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def list(client, parameters \\ []) do | ||
client |> get("bridgechains", parameters) | ||
end | ||
|
||
@spec show(Tesla.Client.t(), String.t()) :: ArkEcosystem.Client.response() | ||
def show(client, id) do | ||
client |> get("bridgechains/#{id}") | ||
end | ||
|
||
@spec search(Tesla.Client.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def search(client, parameters) do | ||
client |> post("bridgechains/search", parameters) | ||
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,27 @@ | ||
defmodule ArkEcosystem.Client.API.Businesses do | ||
@moduledoc """ | ||
Documentation for ArkEcosystem.Client.API.Businesses | ||
""" | ||
|
||
import ArkEcosystem.Client | ||
|
||
@spec list(Tesla.Client.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def list(client, parameters \\ []) do | ||
client |> get("businesses", parameters) | ||
end | ||
|
||
@spec show(Tesla.Client.t(), String.t()) :: ArkEcosystem.Client.response() | ||
def show(client, id) do | ||
client |> get("businesses/#{id}") | ||
end | ||
|
||
@spec bridgechains(Tesla.Client.t(), String.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def bridgechains(client, id, parameters \\ []) do | ||
client |> get("businesses/#{id}/bridgechains", parameters) | ||
end | ||
|
||
@spec search(Tesla.Client.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def search(client, parameters) do | ||
client |> post("businesses/search", parameters) | ||
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,27 @@ | ||
defmodule ArkEcosystem.Client.API.Locks do | ||
@moduledoc """ | ||
Documentation for ArkEcosystem.Client.API.Locks | ||
""" | ||
|
||
import ArkEcosystem.Client | ||
|
||
@spec list(Tesla.Client.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def list(client, parameters \\ []) do | ||
client |> get("locks", parameters) | ||
end | ||
|
||
@spec show(Tesla.Client.t(), String.t()) :: ArkEcosystem.Client.response() | ||
def show(client, id) do | ||
client |> get("locks/#{id}") | ||
end | ||
|
||
@spec search(Tesla.Client.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def search(client, parameters) do | ||
client |> post("locks/search", parameters) | ||
end | ||
|
||
@spec search(Tesla.Client.t(), Keyword.t()) :: ArkEcosystem.Client.response() | ||
def search(client, parameters) do | ||
client |> post("unlocked/search", parameters) | ||
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
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,42 @@ | ||
defmodule ArkEcosystem.Client.API.BridgechainsTest do | ||
use ExUnit.Case | ||
import ArkEcosystem.Client.API.Bridgechains | ||
import Tesla.Mock | ||
|
||
@client ArkEcosystem.Client.new(%{ | ||
host: "http://127.0.0.1:4003/api", | ||
nethash: "578e820911f24e039733b45e4882b73e301f813a0d2c31330dafda84534ffa23", | ||
version: "1.1.1" | ||
}) | ||
|
||
setup do | ||
mock fn | ||
%{method: :get, url: "http://127.0.0.1:4003/api/bridgechains/dummyId"} -> | ||
json(%{"success" => true, "data" => %{ id: "dummyId" }}) | ||
%{method: :get, url: "http://127.0.0.1:4003/api/bridgechains"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummyId" }]}) | ||
%{method: :post, url: "http://127.0.0.1:4003/api/bridgechains/search"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummySearch" }]}) | ||
end | ||
:ok | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Bridgechains.list" do | ||
assert {:ok, response} = list(@client) | ||
assert Enum.at(response["data"],0)["id"] == "dummyId" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Bridgechains.show" do | ||
assert {:ok, response} = show(@client, "dummyId") | ||
assert response["data"]["id"] == "dummyId" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Bridgechains.search" do | ||
assert {:ok, response} = search(@client, %{q: "searchQuery"}) | ||
assert Enum.at(response["data"], 0)["id"] == "dummySearch" | ||
assert response["success"] == true | ||
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,50 @@ | ||
defmodule ArkEcosystem.Client.API.BusinessesTest do | ||
use ExUnit.Case | ||
import ArkEcosystem.Client.API.Businesses | ||
import Tesla.Mock | ||
|
||
@client ArkEcosystem.Client.new(%{ | ||
host: "http://127.0.0.1:4003/api", | ||
nethash: "578e820911f24e039733b45e4882b73e301f813a0d2c31330dafda84534ffa23", | ||
version: "1.1.1" | ||
}) | ||
|
||
setup do | ||
mock fn | ||
%{method: :get, url: "http://127.0.0.1:4003/api/businesses/dummyId"} -> | ||
json(%{"success" => true, "data" => %{ id: "dummyId" }}) | ||
%{method: :get, url: "http://127.0.0.1:4003/api/businesses"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummyId" }]}) | ||
%{method: :get, url: "http://127.0.0.1:4003/api/businesses/dummyId/bridgechains"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummyBridgechainId" }]}) | ||
%{method: :post, url: "http://127.0.0.1:4003/api/businesses/search"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummySearch" }]}) | ||
end | ||
:ok | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Businesses.list" do | ||
assert {:ok, response} = list(@client) | ||
assert Enum.at(response["data"],0)["id"] == "dummyId" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Businesses.show" do | ||
assert {:ok, response} = show(@client, "dummyId") | ||
assert response["data"]["id"] == "dummyId" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Businesses.bridgechains" do | ||
assert {:ok, response} = bridgechains(@client, "dummyId") | ||
assert Enum.at(response["data"], 0)["id"] == "dummyBridgechainId" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Businesses.search" do | ||
assert {:ok, response} = search(@client, %{q: "searchQuery"}) | ||
assert Enum.at(response["data"], 0)["id"] == "dummySearch" | ||
assert response["success"] == true | ||
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,50 @@ | ||
defmodule ArkEcosystem.Client.API.LocksTest do | ||
use ExUnit.Case | ||
import ArkEcosystem.Client.API.Locks | ||
import Tesla.Mock | ||
|
||
@client ArkEcosystem.Client.new(%{ | ||
host: "http://127.0.0.1:4003/api", | ||
nethash: "578e820911f24e039733b45e4882b73e301f813a0d2c31330dafda84534ffa23", | ||
version: "1.1.1" | ||
}) | ||
|
||
setup do | ||
mock fn | ||
%{method: :get, url: "http://127.0.0.1:4003/api/locks/dummyId"} -> | ||
json(%{"success" => true, "data" => %{ id: "dummyId" }}) | ||
%{method: :get, url: "http://127.0.0.1:4003/api/locks"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummyId" }]}) | ||
%{method: :post, url: "http://127.0.0.1:4003/api/locks/search"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummySearch" }]}) | ||
%{method: :post, url: "http://127.0.0.1:4003/api/locks/unlocked"} -> | ||
json(%{"success" => true, "data" => [%{ id: "dummySearch" }]}) | ||
end | ||
:ok | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Locks.list" do | ||
assert {:ok, response} = list(@client) | ||
assert Enum.at(response["data"],0)["id"] == "dummyId" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Locks.show" do | ||
assert {:ok, response} = show(@client, "dummyId") | ||
assert response["data"]["id"] == "dummyId" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Locks.search" do | ||
assert {:ok, response} = search(@client, %{q: "searchQuery"}) | ||
assert Enum.at(response["data"], 0)["id"] == "dummySearch" | ||
assert response["success"] == true | ||
end | ||
|
||
test "call ArkEcosystem.Client.API.Locks.unlocked" do | ||
assert {:ok, response} = unlocked(@client, %{q: "searchQuery"}) | ||
assert Enum.at(response["data"], 0)["id"] == "dummySearch" | ||
assert response["success"] == true | ||
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