Skip to content

Commit

Permalink
Add referral code parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgranhao committed Nov 26, 2024
1 parent 785868e commit 9e40b3a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
21 changes: 4 additions & 17 deletions crow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use graphql::perro::{ensure, permanent_failure};
use graphql::schema::list_uncompleted_topups::{topup_status_enum, ListUncompletedTopupsTopup};
use graphql::schema::{
complete_topup_setup, hide_topup, list_uncompleted_topups, register_notification_token,
register_topup, start_topup_setup, CompleteTopupSetup, HideTopup, ListUncompletedTopups,
RegisterNotificationToken, RegisterTopup, StartTopupSetup,
start_topup_setup, CompleteTopupSetup, HideTopup, ListUncompletedTopups,
RegisterNotificationToken, StartTopupSetup,
};
use graphql::{build_client, parse_from_rfc3339, post_blocking, ExchangeRate};
use honeybadger::Auth;
Expand Down Expand Up @@ -135,6 +135,7 @@ impl OfferManager {
source_iban: String,
user_currency: String,
email: Option<String>,
referral_code: Option<String>,
) -> graphql::Result<FiatTopupSetupChallenge> {
let variables = start_topup_setup::Variables {
request: StartTopupSetupRequest {
Expand All @@ -143,6 +144,7 @@ impl OfferManager {
source_iban,
user_currency,
email,
referral_code,
},
};
let access_token = self.auth.query_token()?;
Expand Down Expand Up @@ -171,21 +173,6 @@ impl OfferManager {
Ok(data.complete_topup_setup.into())
}

pub fn register_topup(&self, order_id: String, email: Option<String>) -> graphql::Result<()> {
let variables = register_topup::Variables { order_id, email };
let access_token = self.auth.query_token()?;
let client = build_client(Some(&access_token))?;
let data = post_blocking::<RegisterTopup>(&client, &self.backend_url, variables)?;
ensure!(
matches!(
data.register_topup,
Some(register_topup::RegisterTopupRegisterTopup { .. })
),
permanent_failure("Backend rejected topup registration")
);
Ok(())
}

pub fn register_notification_token(
&self,
notification_token: String,
Expand Down
1 change: 1 addition & 0 deletions graphql/schemas/schema_wallet_read.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ input StartTopupSetupRequest {
source_iban: String!
user_currency: String!
email: String
referral_code: String
}

type StartTopupSetupResponse {
Expand Down

0 comments on commit 9e40b3a

Please sign in to comment.