Compare commits
No commits in common. "45469d4ba326bf15fd56ef25c586dae5b044206a" and "bfdeef125576c576117601aa4871c5428b4597b7" have entirely different histories.
45469d4ba3
...
bfdeef1255
@ -29,7 +29,6 @@ const (
|
|||||||
CreditSendPrefix = "/api/v1/credit-send"
|
CreditSendPrefix = "/api/v1/credit-send"
|
||||||
CreditSendReverseQuotePrefix = "/api/v1/pool/reverse-quote"
|
CreditSendReverseQuotePrefix = "/api/v1/pool/reverse-quote"
|
||||||
MpesaOnrampPath = "/api/v1/trigger-onramp"
|
MpesaOnrampPath = "/api/v1/trigger-onramp"
|
||||||
MpesaOnrampRatesPath = "/api/v1/rates"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -66,7 +65,6 @@ var (
|
|||||||
CreditSendURL string
|
CreditSendURL string
|
||||||
CreditSendReverseQuoteURL string
|
CreditSendReverseQuoteURL string
|
||||||
MpesaOnrampURL string
|
MpesaOnrampURL string
|
||||||
MpresaOnrampRatesURL string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setBase() error {
|
func setBase() error {
|
||||||
@ -120,7 +118,6 @@ func LoadConfig() error {
|
|||||||
CreditSendURL, _ = url.JoinPath(dataURLBase, CreditSendPrefix)
|
CreditSendURL, _ = url.JoinPath(dataURLBase, CreditSendPrefix)
|
||||||
CreditSendReverseQuoteURL, _ = url.JoinPath(dataURLBase, CreditSendReverseQuotePrefix)
|
CreditSendReverseQuoteURL, _ = url.JoinPath(dataURLBase, CreditSendReverseQuotePrefix)
|
||||||
MpesaOnrampURL, _ = url.JoinPath(mpesaOnrampBase, MpesaOnrampPath)
|
MpesaOnrampURL, _ = url.JoinPath(mpesaOnrampBase, MpesaOnrampPath)
|
||||||
MpresaOnrampRatesURL, _ = url.JoinPath(mpesaOnrampBase, MpesaOnrampRatesPath)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -929,10 +929,3 @@ func (das *DevAccountService) MpesaTriggerOnramp(ctx context.Context, address, p
|
|||||||
TransactionCode: "ae6fb33b-4653-4f38-a3b6-85dfea7a1e99",
|
TransactionCode: "ae6fb33b-4653-4f38-a3b6-85dfea7a1e99",
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (das *DevAccountService) GetMpesaOnrampRates(ctx context.Context) (*models.MpesaOnrampRatesResponse, error) {
|
|
||||||
return &models.MpesaOnrampRatesResponse{
|
|
||||||
Buy: 128.15,
|
|
||||||
Sell: 130.06,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@ -5,8 +5,3 @@ type MpesaOnrampResponse struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
TransactionCode string `json:"transactionCode"`
|
TransactionCode string `json:"transactionCode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MpesaOnrampRatesResponse struct {
|
|
||||||
Buy float64 `json:"buy"`
|
|
||||||
Sell float64 `json:"sell"`
|
|
||||||
}
|
|
||||||
|
|||||||
@ -33,5 +33,4 @@ type AccountService interface {
|
|||||||
GetCreditSendMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.CreditSendLimitsResult, error)
|
GetCreditSendMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.CreditSendLimitsResult, error)
|
||||||
GetCreditSendReverseQuote(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount string) (*models.CreditSendReverseQouteResult, error)
|
GetCreditSendReverseQuote(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount string) (*models.CreditSendReverseQouteResult, error)
|
||||||
MpesaTriggerOnramp(ctx context.Context, address, phoneNumber, asset string, amount int) (*models.MpesaOnrampResponse, error)
|
MpesaTriggerOnramp(ctx context.Context, address, phoneNumber, asset string, amount int) (*models.MpesaOnrampResponse, error)
|
||||||
GetMpesaOnrampRates(ctx context.Context) (*models.MpesaOnrampRatesResponse, error)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -825,24 +825,6 @@ func (as *HTTPAccountService) MpesaTriggerOnramp(ctx context.Context, address, p
|
|||||||
return &r, nil
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMpesaOnrampRates calls the API to fetch the buying and selling rates for KSH.
|
|
||||||
func (as *HTTPAccountService) GetMpesaOnrampRates(ctx context.Context) (*models.MpesaOnrampRatesResponse, error) {
|
|
||||||
var r models.MpesaOnrampRatesResponse
|
|
||||||
|
|
||||||
ctx = context.WithValue(ctx, ctxKeyAuthToken, config.MpesaOnrampBearerToken)
|
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", config.MpresaOnrampRatesURL, nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := doRequest(ctx, req, &r); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &r, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove eth-custodial api dependency
|
// TODO: remove eth-custodial api dependency
|
||||||
func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
|
func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
|
||||||
var okResponse api.OKResponse
|
var okResponse api.OKResponse
|
||||||
|
|||||||
@ -135,8 +135,3 @@ func (m MockAccountService) MpesaTriggerOnramp(ctx context.Context, address, pho
|
|||||||
args := m.Called(address, phoneNumber, asset, amount)
|
args := m.Called(address, phoneNumber, asset, amount)
|
||||||
return args.Get(0).(*models.MpesaOnrampResponse), args.Error(1)
|
return args.Get(0).(*models.MpesaOnrampResponse), args.Error(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m MockAccountService) GetMpesaOnrampRates(ctx context.Context) (*models.MpesaOnrampRatesResponse, error) {
|
|
||||||
args := m.Called()
|
|
||||||
return args.Get(0).(*models.MpesaOnrampRatesResponse), args.Error(1)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -136,7 +136,3 @@ func (m TestAccountService) GetCreditSendReverseQuote(ctx context.Context, poolA
|
|||||||
func (m TestAccountService) MpesaTriggerOnramp(ctx context.Context, address, phoneNumber, asset string, amount int) (*models.MpesaOnrampResponse, error) {
|
func (m TestAccountService) MpesaTriggerOnramp(ctx context.Context, address, phoneNumber, asset string, amount int) (*models.MpesaOnrampResponse, error) {
|
||||||
return &models.MpesaOnrampResponse{}, nil
|
return &models.MpesaOnrampResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m TestAccountService) GetMpesaOnrampRates(ctx context.Context) (*models.MpesaOnrampRatesResponse, error) {
|
|
||||||
return &models.MpesaOnrampRatesResponse{}, nil
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user