Documentation ¶
Index ¶
Constants ¶
const (
// Name is the name of the provider.
Name = "static-mock-provider"
)
Variables ¶
This section is empty.
Functions ¶
func NewAPIHandler ¶
func NewAPIHandler() types.PriceAPIDataHandler
NewAPIHandler returns a new MockAPIHandler. This constructs a new static mock provider from the config. Notice this method expects the market configuration map to the offchain ticker to the desired price.
Types ¶
type MetaData ¶
type MetaData struct {
Price float64 `json:"price"`
}
MetaData is the per-ticker specific metadata that is used to configure the static provider.
func (*MetaData) MustToJSON ¶
MustToJSON marshals the MetaData struct into a JSON string.
type MockAPIHandler ¶
type MockAPIHandler struct{}
MockAPIHandler implements a mock API handler that returns static data.
func (*MockAPIHandler) CreateURL ¶
func (s *MockAPIHandler) CreateURL(_ []types.ProviderTicker) (string, error)
CreateURL is a no-op.
func (*MockAPIHandler) ParseResponse ¶
func (s *MockAPIHandler) ParseResponse( tickers []types.ProviderTicker, _ *http.Response, ) types.PriceResponse
ParseResponse is a no-op. This simply returns the price of the tickers configured, timestamped with the current time.
type MockClient ¶
type MockClient struct{}
MockClient is meant to be paired with the MockAPIHandler. It should only be used for testing.
func NewStaticMockClient ¶
func NewStaticMockClient() *MockClient
func (*MockClient) Type ¶
func (s *MockClient) Type() string
Type returns the HTTP method used to send requests.