ApiKey = $key; $this->ApiLevel = $level; $this->Headers = $headers; } /** * Unpacks an options array into an Headers object * @param array|null $options a key => value array * * @return Headers */ public static function parse($options){ if ($options instanceof self) { return $options; } if (is_null($options)) { return new Headers(null, array()); } if (is_array($options)) { $headers = array(); $key = null; if (array_key_exists('api_key', $options) && array_key_exists('api_level', $options) ) { $key = $options['api_key']; $level = $options['api_level']; $headers['Authorization'] = 'RSA-SHA256 ' . $key; } if (array_key_exists('merchant_id', $options)) { $headers['X-Mcash-Merchant'] = $options['merchant_id']; } if (array_key_exists('user_id', $options)) { $headers['X-Mcash-User'] = $options['user_id']; } if (array_key_exists('test_token', $options)) { $headers['X-Testbed-Token'] = $options['test_token']; } return new Headers($key, $level, $headers); } } } ?>