Skip to content
Closed
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
29 changes: 29 additions & 0 deletions scripts/create_uma_invitation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,32 @@ mutation CreateUmaInvitationWithIncentives(
}

` + objects.UmaInvitationFragment

const CREATE_UMA_INVITATION_WITH_PAYMENT_MUTATION = `
mutation CreateUmaInvitationWithPayment(
$inviter_uma: String!
$payment_amount: Int!
$payment_currency_code: String!
$payment_currency_symbol: String!
$payment_currency_name: String!
$payment_currency_decimals: Int!
$expires_at: DateTime!
) {
create_uma_invitation_with_payment(input: {
inviter_uma: $inviter_uma
payment_amount: $payment_amount
payment_currency: {
code: $payment_currency_code
symbol: $payment_currency_symbol
name: $payment_currency_name
decimals: $payment_currency_decimals
}
expires_at: $expires_at
}) {
invitation {
...UmaInvitationFragment
}
}
}

` + objects.UmaInvitationFragment
53 changes: 53 additions & 0 deletions services/lightspark_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,59 @@ func (client *LightsparkClient) CreateUmaInvitationWithIncentives(
return &invitation, nil
}


// CreateUmaInvitationWithPayment creates a new uma invitation with payment.
//
// Args:
//
// inviterUma: the uma of the inviter
// paymentAmount: the amount of the payment
// paymentCurrencyCode: the code of the payment currency
// paymentCurrencySymbol: the symbol of the payment currency
// paymentCurrencyName: the name of the payment currency
// paymentCurrencyDecimals: the decimals of the payment currency
// expiresAt: the expiration time of the invitation
//
// Returns:
//
// *objects.UmaInvitation: the created invitation
func (client *LightsparkClient) CreateUmaInvitationWithPayment(
inviterUma string,
paymentAmount int,
paymentCurrencyCode string,
paymentCurrencySymbol string,
paymentCurrencyName string,
paymentCurrencyDecimals int,
expiresAt time.Time,
) (*objects.UmaInvitation, error) {
variables := map[string]interface{}{
"inviter_uma": inviterUma,
"payment_amount": paymentAmount,
"payment_currency_code": paymentCurrencyCode,
"payment_currency_symbol": paymentCurrencySymbol,
"payment_currency_name": paymentCurrencyName,
"payment_currency_decimals": paymentCurrencyDecimals,
"expires_at": expiresAt.Format(time.RFC3339),
}

response, err := client.ExecuteGraphql(scripts.CREATE_UMA_INVITATION_WITH_PAYMENT_MUTATION, variables, nil)
if err != nil {
return nil, err
}

output := response["create_uma_invitation_with_payment"].(map[string]interface{})
var invitation objects.UmaInvitation
invitationJson, err := json.Marshal(output["invitation"].(map[string]interface{}))
if err != nil {
return nil, errors.New("error parsing invitation")
}
err = json.Unmarshal(invitationJson, &invitation)
if err != nil {
return nil, err
}
return &invitation, nil
}

// ClaimUmaInvitation claims an existing uma invitation.
//
// Args:
Expand Down