alphv_dart 0.0.2 copy "alphv_dart: ^0.0.2" to clipboard
alphv_dart: ^0.0.2 copied to clipboard

A gRPC apis for Alphv Payment Gateway System

example/main.dart

import 'dart:developer';

import 'package:grpc/grpc.dart';
import 'package:grpc/grpc_web.dart';
import 'package:alphv_dart/api/identity/proto/identity.pbgrpc.dart';

Future<void> main(List<String> args) async {
  String host = "";
  int port = 80;
  String email = "";
  String password = "";

  sigInWithClientChannel(host, port, email, password);
  sigInWithGrpcWeb(host, email, password);
}

Future<void> sigInWithClientChannel(
    String host, int port, String email, String password) async {
  final channel = ClientChannel(
    host,
    port: port,
    options: ChannelOptions(
      credentials: const ChannelCredentials.insecure(),
      codecRegistry:
          CodecRegistry(codecs: const [GzipCodec(), IdentityCodec()]),
    ),
  );

  final cli = IdentityClient(channel);

  try {
    final req = SignInRequest(email: email, password: password);
    final reply = await cli.signIn(req);
    log('SignInReply: $reply');
  } catch (e) {
    log('Caught error: $e');
  }

  await channel.shutdown();
}

Future<void> sigInWithGrpcWeb(String url, String email, String password) async {
  GrpcWebClientChannel channel = GrpcWebClientChannel.xhr(Uri.parse(url));
  IdentityClient cli = IdentityClient(channel);

  try {
    final req = SignInRequest(email: email, password: password);
    final reply = await cli.signIn(req,
        options: CallOptions(compression: const GzipCodec()));
    log('SignInReply: $reply');
  } catch (e) {
    log('Caught error: $e');
  }

  await channel.shutdown();
}
0
likes
130
points
32
downloads

Publisher

unverified uploader

Weekly Downloads

A gRPC apis for Alphv Payment Gateway System

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

fixnum, flutter, grpc, protobuf

More

Packages that depend on alphv_dart