Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

Commit

Permalink
Change response on all requests, with seconds for response time.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothymarois committed Nov 20, 2019
1 parent 6138083 commit d2f5932
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Account/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(\Alpaca\Alpaca $alpaca)
*/
public function get($type, $options=[])
{
return $this->alpaca->request('activity',array_merge(['type'=>$type],$options))->contents();
return $this->alpaca->request('activity',array_merge(['type'=>$type],$options))->results();
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Account/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(\Alpaca\Alpaca $alpaca)
*/
public function get($id)
{
return $this->alpaca->request('order',['id'=>$id],'GET')->contents();
return $this->alpaca->request('order',['id'=>$id],'GET')->results();
}

/**
Expand All @@ -36,7 +36,7 @@ public function get($id)
*/
public function create($options = [])
{
return $this->alpaca->request('orders',$options,'POST')->contents();
return $this->alpaca->request('orders',$options,'POST')->results();
}

/**
Expand All @@ -46,7 +46,7 @@ public function create($options = [])
*/
public function replace($id, $options = [])
{
return $this->alpaca->request('order',array_merge(['id'=>$id],$options),'PATCH')->contents();
return $this->alpaca->request('order',array_merge(['id'=>$id],$options),'PATCH')->results();
}

/**
Expand All @@ -62,7 +62,7 @@ public function getAll($status = 'open', $limit = 50, $from = null, $to = null,
'after' => $from,
'until' => $to,
'direction' => $dir
])->contents();
])->results();
}

/**
Expand All @@ -72,7 +72,7 @@ public function getAll($status = 'open', $limit = 50, $from = null, $to = null,
*/
public function cancel($id)
{
return $this->alpaca->request('order',['id'=>$id],'DELETE')->contents();
return $this->alpaca->request('order',['id'=>$id],'DELETE')->results();
}

/**
Expand All @@ -82,6 +82,6 @@ public function cancel($id)
*/
public function cancelAll()
{
return $this->alpaca->request('orders',[],'DELETE')->contents();
return $this->alpaca->request('orders',[],'DELETE')->results();
}
}
14 changes: 14 additions & 0 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@ public function seconds()
{
return $this->seconds;
}

/**
* results()
*
* get the results and time of response
*
*/
public function results()
{
return [
'response' => $this->contents(),
'seconds' => $this->seconds()
];
}
}

0 comments on commit d2f5932

Please sign in to comment.