Add snippets

This commit is contained in:
Roei Erez
2023-12-14 09:46:58 +02:00
parent 31483fb54e
commit 05f18fe1df
10 changed files with 259 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ public class ServiceStatusSnippets
try
{
var healthCheck = sdk.ServiceHealthCheck();
Console.WriteLine($"Current service status is: {healthCheck.status}");
Console.WriteLine($"Current service status is: {healthCheck.status}");
}
catch (Exception)
{

View File

@@ -0,0 +1,32 @@
using Breez.Sdk;
public class ServiceStatusSnippets
{
public void Webhook(BlockingBreezServices sdk)
{
// ANCHOR: register-webook
try
{
sdk.RegisterWebhook("https://yourapplication.com");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: register-webook
}
public void PaymentWebhook(BlockingBreezServices sdk)
{
// ANCHOR: register-payment-webook
try
{
sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
}
catch (Exception)
{
// Handle error
}
// ANCHOR_END: register-payment-webook
}
}

View File

@@ -0,0 +1,14 @@
import 'package:breez_sdk/breez_sdk.dart';
import 'package:breez_sdk/bridge_generated.dart';
Future<void> webhook() async {
// ANCHOR: register-webook
await BreezSDK().registerWebhook("https://yourapplication.com");
// ANCHOR_END: register-webook
}
Future<void> paymentWebhook({required String paymentHash}) async {
// ANCHOR: register-payment-webook
await BreezSDK().registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>");
// ANCHOR_END: register-payment-webook
}

21
snippets/go/webhook.go Normal file
View File

@@ -0,0 +1,21 @@
package example
import (
"log"
)
func Webhook() {
// ANCHOR: register-webook
if err := sdk.RegisterWebhook("https://yourapplication.com"); err != nil {
log.Printf("Webhook registration failed: %v", err)
}
// ANCHOR_END: register-webook
}
func PaymentWebhook() {
// ANCHOR: register-payment-webook
if err := sdk.RegisterWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>"); err != nil {
log.Printf("Webhook registration failed: %v", err)
}
// ANCHOR_END: register-payment-webook
}

View File

@@ -0,0 +1,24 @@
package com.example.kotlinmpplib
import breez_sdk.*
class ServiceStatus {
fun Webhook(sdk: BlockingBreezServices) {
// ANCHOR: register-webook
try {
sdk.registerWebhook("https://yourapplication.com")
} catch (e: Exception) {
// Handle error
}
// ANCHOR_END: register-webook
}
fun paymentWebhook(sdk: BlockingBreezServices) {
// ANCHOR: register-payment-webook
try {
sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
} catch (e: Exception) {
// Handle error
}
// ANCHOR_END: register-payment-webook
}
}

View File

@@ -0,0 +1,19 @@
import breez_sdk
def webhook(sdk_services):
try:
# ANCHOR: register-webook
sdk_services.registerWebhook("https://yourapplication.com")
# ANCHOR_END: register-webook
except Exception as error:
print(error)
raise
def paymentWebhook(sdk_services):
try:
# ANCHOR: register-payment-webook
sdk_services.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>")
# ANCHOR_END: register-payment-webook
except Exception as error:
print(error)
raise

View File

@@ -0,0 +1,13 @@
import { registerWebhook } from '@breeztech/react-native-breez-sdk'
const webhook = async () => {
// ANCHOR: register-webook
await registerWebhook("https://yourapplication.com")
// ANCHOR_END: register-webook
}
const paymentWebhook = async () => {
// ANCHOR: register-payment-webook
await registerWebhook('https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>')
// ANCHOR_END: register-payment-webook
}

View File

@@ -6,7 +6,7 @@ use breez_sdk_core::*;
async fn webhook(sdk: Arc<BreezServices>) -> Result<()> {
// ANCHOR: register-webook
sdk.register_webhook("https://yourapplication.com").await?
sdk.register_webhook("https://yourapplication.com").await?
// ANCHOR_END: register-webook
Ok(())

View File

@@ -0,0 +1,20 @@
//
// ServiceStatus.swift
//
//
//
import Foundation
import BreezSDK
func webhook(sdk: BlockingBreezServices) throws {
// ANCHOR: register-webook
sdk.registerWebhook("https://yourapplication.com")
// ANCHOR_END: register-webook
}
func paymentWebhook(sdk: BlockingBreezServices) {
// ANCHOR: register-payment-webook
sdk.registerWebhook("https://your-nds-service.com/notify?platform=ios&token=<PUSH_TOKEN>").await?
// ANCHOR_END: register-payment-webook
}