Example #1
0
 /**
  * Send http request to api and return response.
  *
  * @param string $operation the operation type to perform
  * @param array $args
  *
  * @return Response
  */
 public function send($operation_type, array $args)
 {
     $fields = array_merge($this->authParams(), $args, compact('operation_type'));
     $response = new Response($this->client->post($this->apiUrl, ['body' => Xml::arrayToXml($fields)]));
     $response->offsetSet('original_args', $args);
     return $response;
 }
 /**
  * Sets attributes from response xml.
  *
  * @param ResponseInterface $response
  * @param array $attributes
  */
 public function __construct(ResponseInterface $response, array $attributes = null)
 {
     $this->response = $response;
     if (is_null($attributes)) {
         $attributes = Xml::elementsToArray($response->xml()->xpath('/RESPONSE/FIELDS/*'));
     }
     parent::__construct($attributes);
 }
Example #3
0
 /** @test */
 public function key_attribute_should_override_element_name()
 {
     $elements = [new SimpleXMLElement('<field KEY="bar"></field>')];
     $this->assertArrayHasKey('bar', Xml::elementsToArray($elements));
 }