Gidah.com Wiki

Token Status

Modified: 2009/01/15 07:46 by daryl - Categorized as: Token Framework API
All API methods return a status code. This status code is universal; it has the same meaning everywhere it is used.

The status code comes back as a long int, but is really a three-part bit mask. The status code also comes back as a text string indicating the three parts of the bit mask. Either one is reliable to use for the purposes of determining the result of a request.

Response
The first part you should check as a developer is the validity of the response. If, for example, you are executing a Lock if the lock was successful you'll get a Response_Valid response. If the lock was not successful (for whatever reason) you'll get a Response_Invalid response.

Token Status
With token operations you'll get a report of the token's status also. The token's status can be one of many possibilities, including Status_Open, Status_Locked, Status_Redeemed, and more.

Result
Finally you'll also get a report back about whether the Token Service received any unexpected errors processing your request. This is unlikely, however it is possible. Normally you'll see a Result_Expected, but a Result_Unexpected is possible.

In many cases there will also be an error message included in any failures. This varies by method.

The recommended way to process status codes is by using the bit mask values. These are listed below:

  Status_Active     = 1,
  Status_Pending    = 2,
  Status_Inactive   = 4,
  Status_Open       = 8,
  Status_Locked     = 16,
  Status_Redeemed   = 32,
  Status_Expired    = 64,
  Status_Deleted    = 128,
  Status_NSF        = 256,
  Status_Assigned   = 512,
  Status_Complete   = 1024,

  Response_Valid    = 131072,
  Response_Invalid  = 262144,

  Result_Expected   = 524288,
  Result_Unexpected = 1048576

In C# you could test for one of these statuses with the following code:


  Status status;
  ... 
  if(Status.Status_Open == (Status.Status_Open & status))
  {
     // status contains the open flag
  }
  else
  {
     // status does not contain the open flag
  }

Gidah.com uses ScrewTurn Wiki version 2.0.36. Some of the icons created by FamFamFam. Support Open Source.