Alternc  latest
Alternc logiel libre pour l'h├ębergement
 All Classes Namespaces Files Functions Variables Pages
Alternc_Api_Request Class Reference

Standard Request object for the AlternC API. More...

Public Member Functions

 __construct ($options)
 

Public Attributes

 $token
 
 $token_hash
 
 $object
 
 $action
 
 $options
 
 $metadata
 
const ERR_MISSING_PARAMETER = 111801
 

Detailed Description

Standard Request object for the AlternC API.

Helps streamlining the calls by checking parameters

Definition at line 8 of file Request.php.

Constructor & Destructor Documentation

Alternc_Api_Request::__construct (   $options)

Definition at line 53 of file Request.php.

References $options.

53  {
54 
55 
56  // Attempts to retrieve object
57  if (isset($options["object"]) && is_string($options["object"])) {
58  $this->object = $options["object"];
59  } else {
60  throw new \Exception("Missing parameter object", self::ERR_MISSING_PARAMETER);
61  }
62 
63  // Attempts to retrieve action
64  if (isset($options["action"]) && is_string($options["action"])) {
65  $this->action = $options["action"];
66  } else {
67  throw new \Exception("Missing parameter action", self::ERR_MISSING_PARAMETER);
68  }
69 
70  // Attempts to retrieve options
71  if (isset($options["options"])) {
72  if (is_array($options)) {
73  $this->options = $options["options"];
74  } else {
75  throw new \Exception("Missing parameter options", self::ERR_MISSING_PARAMETER);
76  }
77  } else {
78  $this->options = array();
79  }
80 
81  // Attempts to retrieve token
82  if (isset($options["token"])) {
83  if (is_a($options["token"], Alternc_Api_Token)) {
84  $this->token = $options["token"];
85  } else {
86  throw new \Exception("Bad parameter token", self::ERR_MISSING_PARAMETER);
87  }
88  } else {
89  // Attempts to retrieve token_hash then
90  if (isset($options["token_hash"]) && is_string($options["token_hash"])) {
91  $this->token_hash = $options["token_hash"];
92  } else {
93  throw new \Exception("Missing parameter token OR token_hash", self::ERR_MISSING_PARAMETER);
94  }
95  }
96 
97  // Attempts to retrieve metadata (eg: API version)
98  if (isset($options["metadata"])) {
99  $this->metadata = $options["metadata"];
100  }
101  }
Standard Token object for the AlternC API.
Definition: Token.php:7

Member Data Documentation

Alternc_Api_Request::$action

Definition at line 34 of file Request.php.

Alternc_Api_Request::$metadata

Definition at line 49 of file Request.php.

Alternc_Api_Request::$object

Definition at line 27 of file Request.php.

Alternc_Api_Request::$options

Definition at line 41 of file Request.php.

Referenced by __construct().

Alternc_Api_Request::$token

Definition at line 14 of file Request.php.

Alternc_Api_Request::$token_hash

Definition at line 20 of file Request.php.

const Alternc_Api_Request::ERR_MISSING_PARAMETER = 111801

Definition at line 51 of file Request.php.


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