Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dashboard url first promoter #3989

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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