import { is, isNil, merge } from 'ramda' import { MERCHANT_API_URL } from '../../src/lib/constants' import Merchant from '../../src/models/merchant' import { MerchantAPI } from '../../src/apis/merchant' import Nock from 'nock' export class MockMerchantAPI { private _fixture: Object = null private _code: number = 200 private endpoint: string = null constructor (init: any = {}) { this.endpoint = MERCHANT_API_URL } public fixture (value: Object | string) { this._fixture = is(String, value) ? JSON.parse(value as string) : value return this } public success (code?: number): MockMerchantAPI { this._code = code ? code : 200 return this } public fail (code?: number): MockMerchantAPI { this._code = code ? code : 500 return this } public mockCheckApiKey (key: string) { Nock(this.endpoint).get(`/api_keys/${key}`).reply(this._code, this._fixture) return this } } export default MockMerchantAPI