Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import Client from './client'
  2. // import method from './method'
  3. import Resource from './resource'
  4. export enum AuthenticationTypes {
  5. BasicAuth = 'basic',
  6. TokenAuth = 'token',
  7. KeyAuth = 'key',
  8. BearerAuth = 'bearer',
  9. }
  10. export type Seconds = number
  11. export type BaseUrl = string | URL
  12. export interface Headers {}
  13. export interface Authentication {
  14. type: AuthenticationTypes,
  15. }
  16. export interface Config {
  17. baseUrl: BaseUrl,
  18. headers?: Headers,
  19. authentication?: Authentication,
  20. retries?: number,
  21. timeout?: Seconds,
  22. }
  23. export interface Portal {
  24. // route: method, // TODO: function taking some spec
  25. // resource: Resource, // TODO: function taking some spec
  26. _client: Client,
  27. }
  28. export interface Response {
  29. status: {
  30. code: number,
  31. word: string,
  32. },
  33. body: Object | undefined,
  34. headers: Headers,
  35. _rawResponse: string, // raw string response
  36. }
  37. export function createBaseClient (config: Config): Portal {
  38. const client = new Client()
  39. const portal: Portal = {
  40. _client: client,
  41. }
  42. return portal
  43. }
  44. export { Client } from './client'
  45. export { MethodSpec } from './method'
  46. export default createBaseClient