4.0.0 • Published 3 years ago

medisot-hyperledger-client v4.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

npm.io JIMI A lightweight library that helps establish connection with the chaincode How to use To run the application:

  1. Install the library using:

    npm install --save medisot-hyperledger-client
  2. Register the connection dependency that's required by medisot-hyperledger-client to connect with BCN:

    container.bind<any>(HyperledgerClientTypes.Connection).toConstantValue(Connection);
  3. Register the medisot-hyperledger-client dependency in the application container:

    import { HyperledgerClient, TYPES as HyperledgerClientTypes } from "medisot-hyperledger-client";
    
    container.bind<HyperledgerClient>(TYPES.HyperledgerClient).to(HyperledgerClient);
  4. Inject this dependency wherever required and use it's apis:

    export default class AppointmentService {
       constructor(@inject(TYPES.HyperledgerClient) private hyperledgerClient: HyperledgerClient) {}
    
       public async getAppointment(appointmentId: string, loggedInUser: string) {
           return this.hyperledgerClient.InvokeHandler("getAppointmentById", appointmentId, loggedInUser, null, true).then((appointmentResponse: any) => {
               if (appointmentResponse.success) {
                   return AppUtils.createGenericServiceResponseObj(appointmentResponse, SERVICE_RESPONSE_STATUS.SUCCESS, null);
               } else {
                   return AppUtils.createGenericServiceResponseObj(null, SERVICE_RESPONSE_STATUS.FAILED, appointmentResponse);
               }
           }).catch((err: any) => {
               return AppUtils.createGenericServiceResponseObj(null, SERVICE_RESPONSE_STATUS.FAILED, err);
           })
       }
    
       public async createAppointment(appointmentObj: any, username: string) {
           return this.hyperledgerClient.InvokeHandler("bookAppointment", JSON.stringify(appointmentObj), username, null, false).then((bookAppointmentResponse: any) => {
               if (bookAppointmentResponse.success) {
                   return AppUtils.createGenericServiceResponseObj(bookAppointmentResponse, SERVICE_RESPONSE_STATUS.SUCCESS, null);
               } else {
                   return AppUtils.createGenericServiceResponseObj(null, SERVICE_RESPONSE_STATUS.FAILED, bookAppointmentResponse);
               }
           }).catch((err: any) => {
               return AppUtils.createGenericServiceResponseObj(null, SERVICE_RESPONSE_STATUS.FAILED, err);
           })
       }
    }
4.0.0

3 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.5.0

4 years ago

2.4.3

4 years ago

2.5.1

4 years ago

2.4.1

4 years ago

2.4.2

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago