public function request_daily_inventory_report() { $report_type = '_GET_MERCHANT_LISTINGS_DATA_'; $accounts = WPLA_AmazonAccount::getAll(); foreach ($accounts as $account) { $api = new WPLA_AmazonAPI($account->id); // request report - returns request list as array on success $reports = $api->requestReport($report_type); if (is_array($reports)) { // process the result WPLA_AmazonReport::processReportsRequestList($reports, $account, true); } elseif ($reports->Error->Message) { } else { } } // foreach account }
public function handleActions() { // trigger reports update if ($this->requestAction() == 'update_reports') { do_action('wpla_update_reports'); } // trigger report request if ($this->requestAction() == 'request_report') { $accounts = WPLA_AmazonAccount::getAll(); foreach ($accounts as $account) { $api = new WPLA_AmazonAPI($account->id); // request report - returns request list as array on success $reports = $api->requestReport($_REQUEST['wpla_report_type']); if (is_array($reports)) { // process the result // $this->processReportsRequestList( $reports, $account ); WPLA_AmazonReport::processReportsRequestList($reports, $account); $this->showMessage(sprintf(__('Report requested for account %s.', 'wpla'), $account->title)); } elseif ($reports->Error->Message) { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title) . '<br>Error: ' . $reports->Error->Message, 1); } else { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title), 1); } } } // handle load report action if ($this->requestAction() == 'load_report_from_amazon') { $report = new WPLA_AmazonReport($_REQUEST['amazon_report']); $report->loadFromAmazon(); // $api = new WPLA_AmazonAPI( $report->account_id ); // $api->getReport( $report->GeneratedReportId ); $this->showMessage(__('Report was downloaded from Amazon.', 'wpla')); } // handle process report action if ($this->requestAction() == 'process_amazon_report') { $this->processReportData($_REQUEST['amazon_report']); $this->showMessage(__('Report was processed.', 'wpla')); } // handle process report action if ($this->requestAction() == 'process_fba_shipment_report') { $this->processFbaShipmentReportData($_REQUEST['amazon_report']); } // handle delete_amazon_report action if ($this->requestAction() == 'delete_amazon_report') { $this->deleteReports($_REQUEST['amazon_report']); $this->showMessage(__('Selected items were removed.', 'wpla')); } // handle update_amazon_report action if ($this->requestAction() == 'update_amazon_report') { $this->updateReports($_REQUEST['amazon_report']); $this->showMessage(__('Selected items were updated.', 'wpla')); } }
public function requestNewInventoryReport($report_type = '_GET_MERCHANT_LISTINGS_DATA_') { $accounts = WPLA_AmazonAccount::getAll(); foreach ($accounts as $account) { $api = new WPLA_AmazonAPI($account->id); // request report - returns request list as array on success $reports = $api->requestReport($report_type); if (is_array($reports)) { // process the result // $this->processReportsRequestList( $reports, $account ); WPLA_AmazonReport::processReportsRequestList($reports, $account); $this->showMessage(sprintf(__('Report requested for account %s.', 'wpla'), $account->title)); } elseif ($reports->Error->Message) { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title) . '<br>Error: ' . $reports->Error->Message, 1); } else { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title), 1); } } }