wix-catalyst-platformized-http-client
v1.0.11
Published
HTTP Client that helps building clients for platformized Wix apis
Downloads
43
Maintainers
Keywords
Readme
Field Masks
There is helper that converts any JS object to field mask based on keys in it: convertObjectToFieldMask({field: 1})
Http Client
import {wix} from './proto-generated';
import * as protoModule from './proto-generated';
import {HttpClient, ClientOptions} from 'wix-catalyst-platformized-http-client';
export class AppSettingsServiceClient {
private httpClient: HttpClient;
constructor(options: ClientOptions) {
this.httpClient = HttpClient.fromClientOptions(options);
}
updateAppSettings(req: wix.filesharing.api.v1.settings.UpdateAppSettingsRequest): Promise<wix.filesharing.api.v1.settings.UpdateAppSettingsResponse> {
return this.httpClient.patch('/api/v1/file-sharing/settings', this.settings('UpdateAppSettingsRequest'), this.settings('UpdateAppSettingsResponse'), req);
}
getAppSettings(req: wix.filesharing.api.v1.settings.GetAppSettingsRequest): Promise<wix.filesharing.api.v1.settings.GetAppSettingsResponse> {
return this.httpClient.get('/api/v1/file-sharing/settings', this.settings('GetAppSettingsRequest'), this.settings('GetAppSettingsResponse'), req);
}
private settings(clazz: string): string {
return `wix.filesharing.api.v1.settings.${clazz}`;
}
}
const clientOptions: ClientOptions = {
authorization: 'platformized-authorization',
protoModule,
serverUrl: 'http://my-cool-server.com/api',
fetch: window.fetch
};
new AppSettingsServiceClient(clientOptions).getAppSettings({})