Skip to content

Commit

Permalink
Merge pull request #3989 from santiment/add-dashboard-url-promoter
Browse files Browse the repository at this point in the history
Add dashboard url first promoter
  • Loading branch information
tspenov authored Nov 21, 2023
2 parents 3d908ce + d3a14f8 commit 030106c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/sanbase_web/graphql/resolvers/promoter_resolver.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ defmodule SanbaseWeb.Graphql.Resolvers.PromoterResolver do

# Note: Adding new field to extract should be also reflected by adding it in promoter_types.ex
defp extract_and_atomize_needed_fields({:ok, promoter}) do
auth_token = promoter["auth_token"]

promoter =
promoter
|> Map.take([
Expand Down Expand Up @@ -47,6 +49,13 @@ defmodule SanbaseWeb.Graphql.Resolvers.PromoterResolver do
end)
|> Sanbase.MapUtils.atomize_keys()

promoter =
promoter
|> Map.put(
:dashboard_url,
"https://santiment.firstpromoter.com/view_dashboard_as?at=#{auth_token}"
)

{:ok, promoter}
end
end
1 change: 1 addition & 0 deletions lib/sanbase_web/graphql/schema/types/promoter_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule SanbaseWeb.Graphql.Schema.PromoterTypes do
field(:current_balance, :integer)
field(:paid_balance, :integer)
field(:promotions, list_of(:promotion))
field(:dashboard_url, :string)
end

object :promotion do
Expand Down
6 changes: 6 additions & 0 deletions test/sanbase_web/graphql/promoter/promoter_api_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ defmodule SanbaseWeb.Graphql.PromoterApiTest do
promotion = promoter["promotions"] |> hd

assert promoter["email"] == resp["email"]

assert promoter["dashboardUrl"] ==
"https://santiment.firstpromoter.com/view_dashboard_as?at=#{resp["auth_token"]}"

assert promotion["visitorsCount"] == resp["promotions"] |> hd |> Map.get("visitors_count")
end)
end
Expand Down Expand Up @@ -86,6 +90,7 @@ defmodule SanbaseWeb.Graphql.PromoterApiTest do
currentBalance
earningsBalance
paidBalance
dashboardUrl
promotions {
refId
referralLink
Expand All @@ -112,6 +117,7 @@ defmodule SanbaseWeb.Graphql.PromoterApiTest do
currentBalance
earningsBalance
paidBalance
dashboardUrl
promotions {
refId
referralLink
Expand Down

0 comments on commit 030106c

Please sign in to comment.