1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include "sakeRequestInternal.h"
#include "sakeRequest.h"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Rate Record
static SAKEStartRequestResult SAKE_CALL sakeiRateRecordValidateInput(SAKERequest request)
{
SAKERateRecordInput *input = (SAKERateRecordInput *)request->mInput;
// check the tableid
if(!input->mTableId)
return SAKEStartRequestResult_BAD_TABLEID;
return SAKEStartRequestResult_SUCCESS;
}
static SAKEStartRequestResult SAKE_CALL sakeiRateRecordFillSoapRequest(SAKERequest request)
{
SAKERateRecordInput *input = (SAKERateRecordInput *)request->mInput;
// write the table id
gsXmlWriteStringElement(request->mSoapRequest, GSI_SAKE_SERVICE_NAMESPACE, "tableid", input->mTableId);
// write the recordid
gsXmlWriteIntElement(request->mSoapRequest, GSI_SAKE_SERVICE_NAMESPACE, "recordid", (gsi_u32)input->mRecordId);
// write the rating
gsXmlWriteIntElement(request->mSoapRequest, GSI_SAKE_SERVICE_NAMESPACE, "rating", (gsi_u32)input->mRating);
return SAKEStartRequestResult_SUCCESS;
}
static SAKERequestResult sakeiRateRecordProcessSoapResponse(SAKERequest request)
{
SAKERateRecordOutput *output = (SAKERateRecordOutput *)request->mOutput;
if(gsi_is_false(gsXmlReadChildAsInt(request->mSoapResponse, "numRatings", &output->mNumRatings)) ||
gsi_is_false(gsXmlReadChildAsFloat(request->mSoapResponse, "averageRating", &output->mAverageRating)))
{
return SAKERequestResult_MALFORMED_RESPONSE;
}
return SAKERequestResult_SUCCESS;
}
SAKEStartRequestResult SAKE_CALL sakeiStartRateRecordRequest(SAKERequest request)
{
static SAKEIRequestInfo info =
{
sizeof(SAKERateRecordOutput),
SAKEI_FUNC_NAME_STRINGS("RateRecord"),
sakeiRateRecordValidateInput,
sakeiRateRecordFillSoapRequest,
sakeiRateRecordProcessSoapResponse
};
return sakeiStartRequest(request, &info);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Get Record Limit
static SAKEStartRequestResult SAKE_CALL sakeiGetRecordLimitValidateInput(SAKERequest request)
{
SAKEGetRecordLimitInput *input = (SAKEGetRecordLimitInput *)request->mInput;
// check the tableid
if(!input->mTableId)
return SAKEStartRequestResult_BAD_TABLEID;
return SAKEStartRequestResult_SUCCESS;
}
static SAKEStartRequestResult SAKE_CALL sakeiGetRecordLimitFillSoapRequest(SAKERequest request)
{
SAKEGetRecordLimitInput *input = (SAKEGetRecordLimitInput *)request->mInput;
// write the table id
gsXmlWriteStringElement(request->mSoapRequest, GSI_SAKE_SERVICE_NAMESPACE, "tableid", input->mTableId);
return SAKEStartRequestResult_SUCCESS;
}
static SAKERequestResult sakeiGetRecordLimitProcessSoapResponse(SAKERequest request)
{
SAKEGetRecordLimitOutput *output = (SAKEGetRecordLimitOutput *)request->mOutput;
if(gsi_is_false(gsXmlReadChildAsInt(request->mSoapResponse, "limitPerOwner", &output->mLimitPerOwner)) ||
gsi_is_false(gsXmlReadChildAsInt(request->mSoapResponse, "numOwned", &output->mNumOwned)))
{
return SAKERequestResult_MALFORMED_RESPONSE;
}
return SAKERequestResult_SUCCESS;
}
SAKEStartRequestResult SAKE_CALL sakeiStartGetRecordLimitRequest(SAKERequest request)
{
static SAKEIRequestInfo info =
{
sizeof(SAKEGetRecordLimitOutput),
SAKEI_FUNC_NAME_STRINGS("GetRecordLimit"),
sakeiGetRecordLimitValidateInput,
sakeiGetRecordLimitFillSoapRequest,
sakeiGetRecordLimitProcessSoapResponse
};
return sakeiStartRequest(request, &info);
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Get Record Count
static SAKEStartRequestResult SAKE_CALL sakeiGetRecordCountValidateInput(SAKERequest request)
{
SAKEGetRecordCountInput *input = (SAKEGetRecordCountInput *)request->mInput;
// check the tableid
if(!input->mTableId)
return SAKEStartRequestResult_BAD_TABLEID;
return SAKEStartRequestResult_SUCCESS;
}
static SAKEStartRequestResult SAKE_CALL sakeiGetRecordCountFillSoapRequest(SAKERequest request)
{
SAKEGetRecordCountInput *input = (SAKEGetRecordCountInput *)request->mInput;
// write the table id
gsXmlWriteStringElement(request->mSoapRequest, GSI_SAKE_SERVICE_NAMESPACE, "tableid", input->mTableId);
// write the filter
if(input->mFilter != NULL)
gsXmlWriteTStringElement(request->mSoapRequest, GSI_SAKE_SERVICE_NAMESPACE, "filter", input->mFilter);
// write the cache flag
gsXmlWriteIntElement(request->mSoapRequest, GSI_SAKE_SERVICE_NAMESPACE, "cacheFlag", (gsi_u32)input->mCacheFlag);
return SAKEStartRequestResult_SUCCESS;
}
static SAKERequestResult sakeiGetRecordCountProcessSoapResponse(SAKERequest request)
{
SAKEGetRecordCountOutput *output = (SAKEGetRecordCountOutput *)request->mOutput;
if(gsi_is_false(gsXmlReadChildAsInt(request->mSoapResponse, "count", &output->mCount)))
{
return SAKERequestResult_MALFORMED_RESPONSE;
}
return SAKERequestResult_SUCCESS;
}
SAKEStartRequestResult SAKE_CALL sakeiStartGetRecordCountRequest(SAKERequest request)
{
static SAKEIRequestInfo info =
{
sizeof(SAKEGetRandomRecordOutput),
SAKEI_FUNC_NAME_STRINGS("GetRecordCount"),
sakeiGetRecordCountValidateInput,
sakeiGetRecordCountFillSoapRequest,
sakeiGetRecordCountProcessSoapResponse
};
return sakeiStartRequest(request, &info);
}
|