Current section

4 Versions

Jump to

Compare versions

5 files changed
+103 additions
-8 deletions
  @@ -10,7 +10,7 @@ by adding `ex_uphold` to your list of dependencies in `mix.exs`:
10 10 ```elixir
11 11 def deps do
12 12 [
13 - {:ex_uphold, "~> 0.0.2"}
13 + {:ex_uphold, "~> 0.0.4"}
14 14 ]
15 15 end
16 16 ```
  @@ -20,6 +20,9 @@ end
20 20 - **UPHOLD_ACCESS_TOKEN**: Uphold API token (obtained in Uphold settings)
21 21 - **UPHOLD_ENV**: Uphold API environment (production, sandbox)
22 22
23 + ## Tests
24 + - For tests you can use [ExUphold.FakeApi](lib/ex_uphold/fake_api.ex)
25 +
23 26 ## TODO:
24 27
25 28 - [ ] Add support for more API requests (cards, transactions, etc.)
  @@ -4,8 +4,8 @@
4 4 {<<"elixir">>,<<"~> 1.8">>}.
5 5 {<<"files">>,
6 6 [<<"lib">>,<<"lib/ex_uphold.ex">>,<<"lib/ex_uphold">>,
7 - <<"lib/ex_uphold/api.ex">>,<<".formatter.exs">>,<<"mix.exs">>,
8 - <<"README.md">>,<<"LICENSE.md">>]}.
7 + <<"lib/ex_uphold/fake_api.ex">>,<<"lib/ex_uphold/api.ex">>,
8 + <<".formatter.exs">>,<<"mix.exs">>,<<"README.md">>,<<"LICENSE.md">>]}.
9 9 {<<"licenses">>,[<<"MIT">>]}.
10 10 {<<"links">>,[{<<"GitHub">>,<<"https://github.com/utrustdev/ex_uphold">>}]}.
11 11 {<<"name">>,<<"ex_uphold">>}.
  @@ -25,4 +25,4 @@
25 25 {<<"optional">>,false},
26 26 {<<"repository">>,<<"hexpm">>},
27 27 {<<"requirement">>,<<"~> 1.15">>}]]}.
28 - {<<"version">>,<<"0.0.3">>}.
28 + {<<"version">>,<<"0.0.4">>}.
  @@ -37,8 +37,7 @@ defmodule ExUphold.Api do
37 37 do: [
38 38 {Tesla.Middleware.BaseUrl, base_url(os_env!("UPHOLD_ENV"))},
39 39 {Tesla.Middleware.JSON, []},
40 - {Tesla.Middleware.Headers,
41 - [{"Authorization", "Bearer #{os_env!("UPHOLD_ACCESS_TOKEN")}"}]}
40 + {Tesla.Middleware.Headers, [{"Authorization", "Bearer #{os_env!("UPHOLD_ACCESS_TOKEN")}"}]}
42 41 ]
43 42
44 43 defp base_url("production"), do: "https://api.uphold.com"
  @@ -0,0 +1,93 @@
1 + defmodule ExUphold.FakeApi do
2 + @fake_card %{
3 + "address" => %{
4 + "bitcoin" => "msbLNpBxiyyfFfPPnRAbnoNqFD9qNLSzmn",
5 + "wire" => "UH263F859C"
6 + },
7 + "available" => "0.00",
8 + "balance" => "0.00",
9 + "currency" => "EUR",
10 + "id" => "12121ed6-4d1f-4fce-good-302a303bd234",
11 + "label" => "uphold_api_unit_test_btc_address",
12 + "lastTransactionAt" => nil,
13 + "normalized" => [
14 + %{"available" => "0.00", "balance" => "0.00", "currency" => "CHF"}
15 + ],
16 + "settings" => %{"position" => 13, "protected" => false, "starred" => false},
17 + "wire" => [
18 + %{
19 + "accountName" => "Uphold Europe Limited",
20 + "address" => %{
21 + "line1" => "Tartu mnt 2",
22 + "line2" => "100000 Tallinn, Estonia"
23 + },
24 + "bic" => "ABCBEE22",
25 + "currency" => "EUR",
26 + "iban" => "BB12 7722 7711 0170 0110",
27 + "name" => "AS LHV Pank"
28 + },
29 + %{
30 + "accountName" => "Uphold HQ, Inc.",
31 + "accountNumber" => "0333224341",
32 + "address" => %{
33 + "line1" => "9959 Broadway",
34 + "line2" => "New York, NY 10012"
35 + },
36 + "bic" => "ABCDUS33",
37 + "currency" => "USD",
38 + "name" => "Metropolitan Bank",
39 + "routingNumber" => "026013312"
40 + }
41 + ]
42 + }
43 + @fake_transaction %{
44 + "application" => nil,
45 + "createdAt" => "2020-06-04T12:17:33.894Z",
46 + "denomination" => %{"amount" => "0.000066", "currency" => "ETH"},
47 + "destination" => %{
48 + "amount" => "0.000066",
49 + "base" => "0.000066",
50 + "commission" => "0.00",
51 + "currency" => "ETH",
52 + "fee" => "0.00",
53 + "rate" => "1.00"
54 + },
55 + "fees" => [],
56 + "id" => "8feaa2c0-4897-4df6-9177-2f6bcfbfa23c",
57 + "origin" => %{
58 + "amount" => "0.000066",
59 + "base" => "0.000066",
60 + "commission" => "0.00",
61 + "currency" => "ETH",
62 + "fee" => "0.00",
63 + "rate" => "1.00",
64 + "sources" => []
65 + },
66 + "params" => %{
67 + "currency" => "ETH",
68 + "margin" => "0.00",
69 + "pair" => "ETHETH",
70 + "rate" => "1.00",
71 + "txid" => "0x0cc8xe6b04ee56d010d09e91c0b5439ffb45f327196f4fe6ffaf2e29cd357a8d"
72 + },
73 + "priority" => "normal",
74 + "status" => "completed",
75 + "type" => "deposit"
76 + }
77 + @type result_t :: {:ok, any} | {:error, Tesla.Env.t()}
78 +
79 + @spec get_card_details(binary()) :: result_t
80 + def get_card_details(card_id) do
81 + {:ok, @fake_card}
82 + end
83 +
84 + @spec get_transaction_details(binary()) :: result_t
85 + def get_transaction_details(transaction_id) do
86 + {:ok, @fake_transaction}
87 + end
88 +
89 + @spec list_card_transactions(binary()) :: result_t
90 + def list_card_transactions(card_id) do
91 + {:ok, [@fake_transaction]}
92 + end
93 + end
  @@ -4,9 +4,9 @@ defmodule ExUphold.MixProject do
4 4 def project do
5 5 [
6 6 app: :ex_uphold,
7 - version: "0.0.3",
7 + version: "0.0.4",
8 8 elixir: "~> 1.8",
9 - build_embedded: Mix.env == :prod,
9 + build_embedded: Mix.env() == :prod,
10 10 start_permanent: Mix.env() == :prod,
11 11 deps: deps(),
12 12 description: description(),