olp-cpp-sdk  1.21.0
Public Types | Public Member Functions | List of all members
olp::client::ApiResponse< Result, Error, Payload > Class Template Reference

Represents a request outcome. More...

#include <ApiResponse.h>

Inheritance diagram for olp::client::ApiResponse< Result, Error, Payload >:
Inheritance graph
[legend]
Collaboration diagram for olp::client::ApiResponse< Result, Error, Payload >:
Collaboration graph
[legend]

Public Types

using ResultType = Result
 The type of result.
 
using ErrorType = Error
 The type of error.
 
using PayloadType = Payload
 The type of additional payload.
 

Public Member Functions

template<typename P = Payload, typename R = Result, typename = typename std::enable_if<!std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_copy_constructible<R>::value>::type>
 ApiResponse (const ApiResponse< R, Error, void > &other)
 Creates the ApiResponse instance from a similar response type without payload. The payload is default initialized. More...
 
template<typename P = Payload, typename R = Result, typename = typename std::enable_if<!std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_move_constructible<R>::value>::type>
 ApiResponse (ApiResponse< R, Error, void > &&other)
 Creates the ApiResponse instance from a similar response type without payload. The payload is default initialized. More...
 
template<typename P = Payload, typename = typename std::enable_if< !std::is_same<P, void>::value>::type>
 ApiResponse (const ApiResponse< Result, Error, void > &other, P payload)
 Creates the ApiResponse instance from a similar response type without payload, and a separate payload. More...
 
template<typename U , typename P = Payload, typename R = Result, typename = typename std::enable_if<std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_copy_constructible<R>::value>::type>
 ApiResponse (const ApiResponse< R, Error, U > &other)
 Creates the ApiResponse instance from a similar request with a payload. More...
 
template<typename U , typename P = Payload, typename R = Result, typename = typename std::enable_if<std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_move_constructible<R>::value>::type>
 ApiResponse (ApiResponse< R, Error, U > &&other)
 Creates the ApiResponse instance from a similar request with a payload. More...
 
 ApiResponse (ResultType result)
 Creates the ApiResponse instance. More...
 
template<typename P = Payload, typename = typename std::enable_if< !std::is_same<P, void>::value>::type>
 ApiResponse (ResultType result, P payload)
 Creates the ApiResponse instance with payload. More...
 
 ApiResponse (const ErrorType &error)
 Creates the ApiResponse instance if the request is not successful. More...
 
template<typename P = Payload, typename = typename std::enable_if< !std::is_same<P, void>::value>::type>
 ApiResponse (const ErrorType &error, P payload)
 Creates the ApiResponse instance if the request is not successful. More...
 
bool IsSuccessful () const
 Checks the status of the request attempt. More...
 
const ResultTypeGetResult () const
 Gets the result of the successfully executed request. More...
 
ResultType && MoveResult ()
 Moves the result of the successfully executed request. More...
 
const ErrorTypeGetError () const
 Gets the error of the unsuccessful request attempt. More...
 
 operator bool () const
 Operator to check the status of the request attempt. More...
 

Detailed Description

template<typename Result, typename Error, typename Payload = void>
class olp::client::ApiResponse< Result, Error, Payload >

Represents a request outcome.

Contains a successful result or failure error. Before you try to access the error result, check the request outcome.

Template Parameters
ResultThe result type.
ErrorThe error type.

Constructor & Destructor Documentation

◆ ApiResponse() [1/9]

template<typename Result , typename Error , typename Payload = void>
template<typename P = Payload, typename R = Result, typename = typename std::enable_if<!std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_copy_constructible<R>::value>::type>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( const ApiResponse< R, Error, void > &  other)
inline

Creates the ApiResponse instance from a similar response type without payload. The payload is default initialized.

Note
Enabled only for the use cases when the input response type has no payload.

Used for moving the successfully executed request.

Parameters
otherThe ApiResponse instance.

◆ ApiResponse() [2/9]

template<typename Result , typename Error , typename Payload = void>
template<typename P = Payload, typename R = Result, typename = typename std::enable_if<!std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_move_constructible<R>::value>::type>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( ApiResponse< R, Error, void > &&  other)
inline

Creates the ApiResponse instance from a similar response type without payload. The payload is default initialized.

Note
Enabled only for the use cases when the input response type has no payload.

Used for moving the successfully executed request.

Parameters
otherThe ApiResponse instance.

◆ ApiResponse() [3/9]

template<typename Result , typename Error , typename Payload = void>
template<typename P = Payload, typename = typename std::enable_if< !std::is_same<P, void>::value>::type>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( const ApiResponse< Result, Error, void > &  other,
payload 
)
inline

Creates the ApiResponse instance from a similar response type without payload, and a separate payload.

Note
Enabled only for the use cases when the input response type has no payload.

Used for moving the successfully executed request.

Parameters
otherThe ApiResponse instance.
payloadThe Payload value.

◆ ApiResponse() [4/9]

template<typename Result , typename Error , typename Payload = void>
template<typename U , typename P = Payload, typename R = Result, typename = typename std::enable_if<std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_copy_constructible<R>::value>::type>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( const ApiResponse< R, Error, U > &  other)
inline

Creates the ApiResponse instance from a similar request with a payload.

Note
Enabled only for the use cases when the input with a payload is sliced to the response without payload.

Used for moving the successfully executed request.

Parameters
otherThe ApiResponse instance.

◆ ApiResponse() [5/9]

template<typename Result , typename Error , typename Payload = void>
template<typename U , typename P = Payload, typename R = Result, typename = typename std::enable_if<std::is_same<P, void>::value>::type, typename = typename std::enable_if<std::is_move_constructible<R>::value>::type>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( ApiResponse< R, Error, U > &&  other)
inline

Creates the ApiResponse instance from a similar request with a payload.

Note
Enabled only for the use cases when the input with a payload is sliced to the response without payload.

Used for moving the successfully executed request.

Parameters
otherThe ApiResponse instance.

◆ ApiResponse() [6/9]

template<typename Result , typename Error , typename Payload = void>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( ResultType  result)
inline

Creates the ApiResponse instance.

Used for moving the successfully executed request.

Parameters
resultThe ResultType instance.

◆ ApiResponse() [7/9]

template<typename Result , typename Error , typename Payload = void>
template<typename P = Payload, typename = typename std::enable_if< !std::is_same<P, void>::value>::type>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( ResultType  result,
payload 
)
inline

Creates the ApiResponse instance with payload.

Used for moving the successfully executed request.

Parameters
resultThe ResultType instance.
payloadThe payload.

◆ ApiResponse() [8/9]

template<typename Result , typename Error , typename Payload = void>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( const ErrorType error)
inline

Creates the ApiResponse instance if the request is not successful.

Parameters
errorThe ErrorType instance.

◆ ApiResponse() [9/9]

template<typename Result , typename Error , typename Payload = void>
template<typename P = Payload, typename = typename std::enable_if< !std::is_same<P, void>::value>::type>
olp::client::ApiResponse< Result, Error, Payload >::ApiResponse ( const ErrorType error,
payload 
)
inline

Creates the ApiResponse instance if the request is not successful.

Parameters
errorThe ErrorType instance.

Member Function Documentation

◆ GetError()

template<typename Result , typename Error , typename Payload = void>
const ErrorType& olp::client::ApiResponse< Result, Error, Payload >::GetError ( ) const
inline

Gets the error of the unsuccessful request attempt.

Returns
The result instance.

◆ GetResult()

template<typename Result , typename Error , typename Payload = void>
const ResultType& olp::client::ApiResponse< Result, Error, Payload >::GetResult ( ) const
inline

Gets the result of the successfully executed request.

Returns
The result instance.

◆ IsSuccessful()

template<typename Result , typename Error , typename Payload = void>
bool olp::client::ApiResponse< Result, Error, Payload >::IsSuccessful ( ) const
inline

Checks the status of the request attempt.

Returns
True if the request is successfully completed; false otherwise.

◆ MoveResult()

template<typename Result , typename Error , typename Payload = void>
ResultType&& olp::client::ApiResponse< Result, Error, Payload >::MoveResult ( )
inline

Moves the result of the successfully executed request.

Returns
The forwarding reference to the result instance.

◆ operator bool()

template<typename Result , typename Error , typename Payload = void>
olp::client::ApiResponse< Result, Error, Payload >::operator bool ( ) const
inlineexplicit

Operator to check the status of the request attempt.

Returns
True if the request is successfully completed; false otherwise.

The documentation for this class was generated from the following file: