Skip to content

Commit b4d0941

Browse files
author
David Echelberger
authored
Merge pull request #38 from kaleido-io/identity
Additional methods for data and identities
2 parents 7d2b4fa + 326caaa commit b4d0941

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed

lib/firefly.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ import {
5656
FireFlyContractAPIQueryRequest,
5757
FireFlyContractInvokeRequest,
5858
FireFlyContractQueryRequest,
59+
FireFlyDataRequest,
60+
FireFlyIdentityFilter,
61+
FireFlyIdentityResponse,
62+
FireFlyIdentitiesResponse,
5963
} from './interfaces';
6064
import { FireFlyWebSocket, FireFlyWebSocketCallback } from './websocket';
6165
import HttpBase, { mapConfig } from './http';
@@ -68,23 +72,32 @@ export default class FireFly extends HttpBase {
6872
return response.data;
6973
}
7074

75+
async getIdentities(
76+
filter?: FireFlyIdentityFilter,
77+
options?: FireFlyGetOptions,
78+
): Promise<FireFlyIdentitiesResponse> {
79+
return this.getMany<FireFlyIdentitiesResponse>('/identities', filter, options);
80+
}
81+
82+
async getIdentity(
83+
nameOrId: string,
84+
options?: FireFlyGetOptions,
85+
): Promise<FireFlyIdentityResponse | undefined> {
86+
return this.getOne<FireFlyIdentityResponse>(`/identities/${nameOrId}`, options);
87+
}
88+
7189
async getOrganizations(
7290
filter?: FireFlyOrganizationFilter,
7391
options?: FireFlyGetOptions,
7492
): Promise<FireFlyOrganizationResponse[]> {
75-
return this.getMany<FireFlyOrganizationResponse[]>(
76-
'/network/organizations',
77-
filter,
78-
options,
79-
true,
80-
);
93+
return this.getMany<FireFlyOrganizationResponse[]>('/network/organizations', filter, options);
8194
}
8295

8396
async getNodes(
8497
filter?: FireFlyNodeFilter,
8598
options?: FireFlyGetOptions,
8699
): Promise<FireFlyNodeResponse[]> {
87-
return this.getMany<FireFlyNodeResponse[]>('/network/nodes', filter, options, true);
100+
return this.getMany<FireFlyNodeResponse[]>('/network/nodes', filter, options);
88101
}
89102

90103
async getVerifiers(
@@ -97,7 +110,6 @@ export default class FireFly extends HttpBase {
97110
`/namespaces/${namespace}/verifiers`,
98111
filter,
99112
options,
100-
true,
101113
);
102114
}
103115

@@ -152,6 +164,13 @@ export default class FireFly extends HttpBase {
152164
return response.data;
153165
}
154166

167+
async uploadData(
168+
data: FireFlyDataRequest,
169+
options?: FireFlyCreateOptions,
170+
): Promise<FireFlyDataResponse> {
171+
return this.createOne<FireFlyDataResponse>('/data', data, options);
172+
}
173+
155174
async uploadDataBlob(
156175
blob: string | Buffer | Readable,
157176
filename: string,

lib/interfaces.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,17 @@ export interface FireFlyWebSocketOptions {
6161

6262
// Network
6363

64+
export type FireFlyIdentityFilter = operations['getIdentities']['parameters']['query'];
6465
export type FireFlyOrganizationFilter = operations['getNetworkOrgs']['parameters']['query'];
6566
export type FireFlyNodeFilter = operations['getNetworkNodes']['parameters']['query'];
6667
export type FireFlyVerifierFilter = operations['getVerifiers']['parameters']['query'];
6768

6869
export type FireFlyIdentityResponse = Required<
6970
operations['getIdentityByID']['responses']['200']['content']['application/json']
7071
>;
72+
export type FireFlyIdentitiesResponse = Required<
73+
operations['getIdentities']['responses']['200']['content']['application/json']
74+
>;
7175
export type FireFlyOrganizationResponse = Required<
7276
operations['getNetworkOrg']['responses']['200']['content']['application/json']
7377
>;

0 commit comments

Comments
 (0)