public function cmd_pair() { \System\Init::full(); $token = \System\Settings::get('bank', 'token'); $from = \System\Settings::get('bank', 'from'); $to = date('Y-m-d'); $url = str_replace('{token}', $token, self::URL_TRANSACTIONS); $url = str_replace('{from}', $from, $url); $url = str_replace('{to}', $to, $url); $res = \Helper\Offcom\Request::get($url); if (!$res->ok()) { if ($res->status == 409) { \Helper\Cli::out('Please wait 30 seconds and try again.'); exit(4); } else { \Helper\Cli::out('Unknown error during transaction scrape.'); exit(5); } } $feed = \System\Json::decode($res->content); \Workshop\Payment::pair_with_feed($feed); }
/** Fetch file from remote URL * @param string $url URL of file * @param string $dir Directory to save file * @return self * @throws System\Error\File * @throws System\Error\Connection */ static function fetch($url) { $u = explode('/', $url); $name = end($u); $data = \Helper\Offcom\Request::get($url); if ($data->ok()) { $f = new self(array("name" => $name)); $f->set_content($data->content); $f->size = $data->size; $f->mime = $data->mime; return $f; } else { throw new \System\Error\Connection('Couldn\'t fetch file', sprintf('HTTP error %s ', $data->status)); } }