// Generated by protoc-gen-twirp_typescript. DO NOT EDIT
import {code} from './infrastructure.pb';
import {createTwirpAdapter} from 'pbjs-twirp';
import Axios from 'axios';

const getServiceMethodName = (fn: any): string => {
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.allowAccountsPublish) {
		return 'AllowAccountsPublish';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.allowIAMRolePublish) {
		return 'AllowIAMRolePublish';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.registerEventDefinitions) {
		return 'RegisterEventDefinitions';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.createAuthorizedFieldSubscriberGrant) {
		return 'CreateAuthorizedFieldSubscriberGrant';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.createAuthorizedFieldPublisherGrant) {
		return 'CreateAuthorizedFieldPublisherGrant';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.revokeAuthorizedFieldGrant) {
		return 'RevokeAuthorizedFieldGrant';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.deletePublication) {
		return 'DeletePublication';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.deleteIAMRolePublication) {
		return 'DeleteIAMRolePublication';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.listPublicationsByEventStream) {
		return 'ListPublicationsByEventStream';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.deleteAuthorizedFieldGrant) {
		return 'DeleteAuthorizedFieldGrant';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.deleteAuthorizedFieldSubscriberGrant) {
		return 'DeleteAuthorizedFieldSubscriberGrant';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.deleteEventType) {
		return 'DeleteEventType';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.deleteEventStreamsForEventType) {
		return 'DeleteEventStreamsForEventType';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.deleteAuthorizedField) {
		return 'DeleteAuthorizedField';
    }
	if (fn === code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.prototype.listAuthorizedFieldSubscriberGrantsByAuthorizedField) {
		return 'ListAuthorizedFieldSubscriberGrantsByAuthorizedField';
    }

    throw new Error('Unknown Method');
};


export const InfrastructurePathPrefix = '/twirp/code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure/';

export const createInfrastructure = (baseURL: string, options = {}): code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure => {
    const defaultOpts = {
        baseURL: baseURL + InfrastructurePathPrefix,
        headers: {
          Accept: 'application/protobuf'
        }
    };
    const axiosOpts = { ...defaultOpts, ...options };
    
    const axios = Axios.create(axiosOpts);

    return code.justin.tv.eventbus.controlplane.infrastructure.Infrastructure.create(createTwirpAdapter(axios, getServiceMethodName));
};
