Skip to content

Commit

Permalink
named constants moved into class
Browse files Browse the repository at this point in the history
  • Loading branch information
Maple authored and Maple committed Jul 12, 2018
1 parent 702eee8 commit bf1418c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions include/bfx-api-cpp/BitfinexAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,20 @@ using CryptoPP::byte;

namespace BfxAPI
{
////////////////////////////////////////////////////////////////////////
// Global variables
////////////////////////////////////////////////////////////////////////

const auto API_URL = "https://api.bitfinex.com/v1";
const auto CURL_TIMEOUT = 30L;
const auto CURL_DEBUG_VERBOSE = 0L;
const auto WITHDRAWAL_CONF_FILE_PATH = "doc/withdraw.conf";


class BitfinexAPI
{
public:

////////////////////////////////////////////////////////////////////////
// Class constants
////////////////////////////////////////////////////////////////////////

static constexpr auto API_URL = "https://api.bitfinex.com/v1";
static constexpr auto CURL_TIMEOUT = 30L;
static constexpr auto CURL_DEBUG_VERBOSE = 0L;
static constexpr auto WITHDRAWAL_CONF_FILE_PATH = "doc/withdraw.conf";

////////////////////////////////////////////////////////////////////////
// Typedefs
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -199,7 +199,7 @@ namespace BfxAPI
const string getWDconfFilePath() const noexcept
{ return WDconfFilePath_; }

const bfxERR& getBfxApiStatusCode() const noexcept
const BfxClientErrors& getBfxApiStatusCode() const noexcept
{ return bfxApiStatusCode_; }

const CURLcode& getCurlStatusCode() const noexcept
Expand Down Expand Up @@ -454,7 +454,7 @@ namespace BfxAPI
getTonce() + "\"";

// Add params from withdraw.conf
bfxERR code(parseWDconfParams(params));
BfxClientErrors code(parseWDconfParams(params));
if (code != noError)
bfxApiStatusCode_ = code;
else
Expand Down Expand Up @@ -925,14 +925,14 @@ namespace BfxAPI
string APIurl_;
string accessKey_, secretKey_;
// dynamic and status variables
bfxERR bfxApiStatusCode_;
BfxClientErrors bfxApiStatusCode_;
string result_;

////////////////////////////////////////////////////////////////////////
// Utility private methods
////////////////////////////////////////////////////////////////////////

bfxERR parseWDconfParams(string &params)
BfxClientErrors parseWDconfParams(string &params)
{
using std::getline;
using std::ifstream;
Expand Down
2 changes: 1 addition & 1 deletion include/bfx-api-cpp/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#pragma once

enum bfxERR
enum BfxClientErrors
{
noError = 0,
curlERR, // 1
Expand Down
12 changes: 6 additions & 6 deletions include/bfx-api-cpp/jsonutils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ namespace jsonutils
cerr << "Invalid json - response:" << endl;
cerr << inputJson << endl;
cerr << "API endpoint: " << apiEndPoint << endl;
return bfxERR::responseParseError;
return BfxClientErrors::responseParseError;
}

// Create rapidjson validator and check for schema errors
Expand All @@ -210,10 +210,10 @@ namespace jsonutils
cerr << "Invalid document: " << sb.GetString() << endl;
cerr << "Invalid response: " << inputJson << endl;
cerr << "Invalid API endpoint: " << apiEndPoint << endl;
return bfxERR::responseSchemaError;
return BfxClientErrors::responseSchemaError;
}

return bfxERR::noError;
return BfxClientErrors::noError;
}

private:
Expand Down Expand Up @@ -280,7 +280,7 @@ namespace jsonutils
// Routines
////////////////////////////////////////////////////////////////////////////

bfxERR jsonStrToUset(unordered_set<string> &uSet, const string &inputJson)
BfxClientErrors jsonStrToUset(unordered_set<string> &uSet, const string &inputJson)
{
// Create schema $ref resolver
rj::Document sd;
Expand Down Expand Up @@ -322,12 +322,12 @@ namespace jsonutils
cerr << "Invalid document: " << sb.GetString() << endl;
cerr << "Invalid response: " << inputJson << endl;
}
return bfxERR::jsonStrToUSetError;
return BfxClientErrors::jsonStrToUSetError;
}
else
{
uSet.swap(handler.handlerUSet_);
return bfxERR::noError;
return BfxClientErrors::noError;
}
}
}

0 comments on commit bf1418c

Please sign in to comment.