/**
  * sample_GetUsetDisputes::dispatchCall()
  * 
  * Dispatch the call
  *
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $req = new GetUserDisputesRequestType();
     $Pagination = new PaginationType();
     $Pagination->setPageNumber($params['PageNumber']);
     $req->setPagination($Pagination);
     $res = $this->proxy->GetUserDisputes($req);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         return true;
     } else {
         return false;
     }
 }
 /**
  * sample_GetMemberMessages::dispatchCall()
  * 
  * Dispatch the call
  *
  * @param array $params array of parameters for the eBay API call
  * 
  * @return boolean success
  */
 public function dispatchCall($params)
 {
     $req = new GetMemberMessagesRequestType();
     $req->setMailMessageType($params['MailMessageType']);
     $pagination = new PaginationType();
     $pagination->setEntriesPerPage($params['pagination']['EntriesPerPage']);
     $pagination->setPageNumber($params['pagination']['PageNumber']);
     $req->setPagination($pagination);
     $res = $this->proxy->GetMemberMessages($req);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         return true;
     } else {
         return false;
     }
 }
Example #3
0
 public function retrieveSellerSurveyList($params)
 {
     $this->session->setRequestToken($params['AuthToken']);
     $xebayuser_id = $params['xeBayUserID'];
     $bean = BeanFactory::getBean('xeBaySellerSurveys');
     $GLOBALS['db']->query("DELETE FROM xebaysellersurveys WHERE xebaysellersurveys.xebayuser_id ='{$params['xeBayUserID']}'");
     $outputSelector = array('HasMoreItems', 'ItemArray.Item.BuyItNowPrice', 'ItemArray.Item.ItemID', 'ItemArray.Item.ListingDetails.ConvertedStartPrice', 'ItemArray.Item.ListingDetails.StartTime', 'ItemArray.Item.ListingDetails.EndTime', 'ItemArray.Item.ListingDetails.ViewItemURL', 'ItemArray.Item.ListingType', 'ItemArray.Item.PictureDetails.PictureURL', 'ItemArray.Item.PrimaryCategory', 'ItemArray.Item.Quantity', 'ItemArray.Item.SellingStatus.QuantitySold', 'ItemArray.Item.StartPrice', 'ItemArray.Item.Title', 'Seller.UserID', 'ItemsPerPage', 'PageNumber', 'ReturnedItemCountActual');
     $req = new GetSellerListRequestType();
     $req->setDetailLevel('ReturnAll');
     $req->setEndTimeFrom($params['EndTimeFrom']);
     $req->setEndTimeTo($params['EndTimeTo']);
     $req->setUserID($params['UserID']);
     $req->setOutputSelector($outputSelector);
     $pagination = new PaginationType();
     $pagination->setEntriesPerPage(200);
     $pageNumber = 1;
     $returnedItemCountActual = 0;
     $hasMoreItems = false;
     do {
         $pagination->setPageNumber($pageNumber++);
         $req->setPagination($pagination);
         $res = $this->proxy->GetSellerList($req);
         if ($this->testValid($res)) {
             $hasMoreItems = $res->getHasMoreItems();
             $returnedItemCountActual += $res->getReturnedItemCountActual();
             $userID = $res->getSeller()->getUserID();
             $itemArray = $res->getItemArray();
             if (empty($itemArray)) {
                 break;
             }
             foreach ($itemArray as &$item) {
                 $bean->listing_type = $item->getListingType();
                 $listingType = $item->getListingType();
                 if ($listingType != 'FixedPriceItem' && $listingType != 'StoresFixedPrice') {
                     continue;
                 }
                 $bean->quantitysold = $item->getSellingStatus()->getQuantitySold();
                 // if ($bean->quantitysold  == 0)
                 // continue;
                 $bean->buyitnowprice = $item->getBuyItNowPrice()->getTypeValue();
                 $bean->buyitnowprice_currencyid = $item->getBuyItNowPrice()->getTypeAttribute('currencyID');
                 $bean->itemid = $item->getItemID();
                 $bean->convertedstartprice = $item->getListingDetails()->getConvertedStartPrice()->getTypeValue();
                 $bean->convertedstartprice_currencyid = $item->getListingDetails()->getConvertedStartPrice()->getTypeAttribute('currencyID');
                 $bean->starttime = $item->getListingDetails()->getStartTime();
                 $bean->endtime = $item->getListingDetails()->getEndTime();
                 $bean->viewitemurl = $item->getListingDetails()->getViewItemURL();
                 $bean->picturedetails = $this->fill_picture_details($item);
                 $bean->categoryid = $item->getPrimaryCategory()->getCategoryID();
                 $bean->categoryname = $item->getPrimaryCategory()->getCategoryName();
                 $bean->quantity = $item->getQuantity();
                 $bean->quantitysold_permonth = $bean->quantitysold * 30 / ((time() - strtotime($bean->starttime)) / (60 * 60 * 24));
                 $bean->startprice = $item->getStartPrice()->getTypeValue();
                 $bean->startprice_currencyid = $item->getStartPrice()->getTypeAttribute('currencyID');
                 $bean->name = $item->getTitle();
                 $bean->xebayuser_id = $xebayuser_id;
                 $bean->id = create_guid();
                 $bean->new_with_id = true;
                 $bean->save();
             }
         } else {
             $this->dumpObject($res);
             return false;
         }
     } while ($hasMoreItems);
     return $returnedItemCountActual;
 }
Example #4
0
 function updateTransactions($session, $days = null, $current_page = 1)
 {
     WPLE()->logger->info('*** updateTransactions(' . $days . ') - page ' . $current_page);
     $this->initServiceProxy($session);
     // set request handler
     $this->_cs->setHandler('TransactionType', array(&$this, 'handleTransactionType'));
     // $this->_cs->setHandler( 'PaginationResultType', array( & $this, 'handlePaginationResultType' ) );
     // build request
     $req = new GetSellerTransactionsRequestType();
     $req->setIncludeContainingOrder(true);
     // check if we need to calculate lastdate
     if ($this->current_lastdate) {
         $lastdate = $this->current_lastdate;
         WPLE()->logger->info('used current_lastdate from last run: ' . $lastdate);
     } else {
         // period 30 days, which is the maximum allowed
         $now = time();
         $lastdate = $this->getDateOfLastTransaction();
         WPLE()->logger->info('getDateOfLastTransaction() returned: ' . $lastdate);
         if ($lastdate) {
             $lastdate = mysql2date('U', $lastdate);
         }
         // if last date is older than 30 days, fall back to default
         if ($lastdate < $now - 3600 * 24 * 30) {
             WPLE()->logger->info('resetting lastdate - fall back default ');
             $lastdate = false;
         }
     }
     // save lastdate for next page
     $this->current_lastdate = $lastdate;
     // parameter $days has priority
     if ($days) {
         $req->NumberOfDays = $days;
         $this->NumberOfDays = $days;
         WPLE()->logger->info('NumberOfDays: ' . $req->NumberOfDays);
         // default: transactions since last change
     } elseif ($lastdate) {
         $req->ModTimeFrom = gmdate('Y-m-d H:i:s', $lastdate);
         $req->ModTimeTo = gmdate('Y-m-d H:i:s', time());
         $this->ModTimeFrom = $req->ModTimeFrom;
         $this->ModTimeTo = $req->ModTimeTo;
         WPLE()->logger->info('lastdate: ' . $lastdate);
         WPLE()->logger->info('ModTimeFrom: ' . $req->ModTimeFrom);
         WPLE()->logger->info('ModTimeTo: ' . $req->ModTimeTo);
         // fallback: last 7 days (max allowed by ebay: 30 days)
     } else {
         $days = 7;
         $req->NumberOfDays = $days;
         $this->NumberOfDays = $days;
         WPLE()->logger->info('NumberOfDays (fallback): ' . $req->NumberOfDays);
     }
     // $req->DetailLevel = $Facet_DetailLevelCodeType->ReturnAll;
     if (!$this->is_ajax()) {
         $req->setDetailLevel('ReturnAll');
     }
     // set pagination for first page
     $items_per_page = 100;
     // should be set to 200 for production
     $this->current_page = $current_page;
     $Pagination = new PaginationType();
     $Pagination->setEntriesPerPage($items_per_page);
     $Pagination->setPageNumber($this->current_page);
     $req->setPagination($Pagination);
     // get transactions (single page)
     WPLE()->logger->info('fetching transactions - page ' . $this->current_page);
     $res = $this->_cs->GetSellerTransactions($req);
     $this->total_pages = $res->PaginationResult->TotalNumberOfPages;
     $this->total_items = $res->PaginationResult->TotalNumberOfEntries;
     // get transaction with pagination helper (doesn't work as expected)
     // EbatNs_PaginationHelper($proxy, $callName, $request, $responseElementToMerge = '__COUNT_BY_HANDLER', $maxEntries = 200, $pageSize = 200, $initialPage = 1)
     // $helper = new EbatNs_PaginationHelper( $this->_cs, 'GetSellerTransactions', $req, 'TransactionArray', 20, 10, 1);
     // $res = $helper->QueryAll();
     // handle response and check if successful
     if ($this->handleResponse($res)) {
         WPLE()->logger->info("*** Transactions updated successfully.");
         // WPLE()->logger->info( "*** PaginationResult:".print_r($res->PaginationResult,1) );
         // WPLE()->logger->info( "*** processed response:".print_r($res,1) );
         WPLE()->logger->info("*** current_page: " . $this->current_page);
         WPLE()->logger->info("*** total_pages: " . $this->total_pages);
         WPLE()->logger->info("*** total_items: " . $this->total_items);
         // fetch next page recursively - only in days mode
         if ($res->HasMoreTransactions) {
             $this->current_page++;
             $this->updateTransactions($session, $days, $this->current_page);
         }
     } else {
         WPLE()->logger->error("Error on transactions update" . print_r($res, 1));
     }
 }
Example #5
0
 public function retrieveMemberMessages($params)
 {
     $bean = BeanFactory::getBean('xeBayMessages');
     $account_id = $params['AccountID'];
     $this->session->setRequestToken($params['AuthToken']);
     $req = new GetMemberMessagesRequestType();
     $req->setMailMessageType($params['MailMessageType']);
     if (!empty($params['MessageStatus'])) {
         $req->setMessageStatus($params['MessageStatus']);
     }
     $req->setStartCreationTime($params['StartCreationTime']);
     $req->setEndCreationTime($params['EndCreationTime']);
     $pagination = new PaginationType();
     $pagination->setEntriesPerPage($params['pagination']['EntriesPerPage']);
     $pagination->setPageNumber($params['pagination']['PageNumber']);
     $req->setPagination($pagination);
     $res = $this->proxy->GetMemberMessages($req);
     $hasMoreItems = false;
     if ($this->testValid($res)) {
         $hasMoreItems = $res->getHasMoreItems();
         $memberMessages = $res->getMemberMessage();
         if (is_array($memberMessages)) {
             foreach ($memberMessages as &$memberMessage) {
                 $question = $memberMessage->getQuestion();
                 $messageID = $question->getMessageID();
                 $duplicated = $bean->retrieve_by_string_fields(array('message_id' => $messageID), true, false);
                 $bean->xebayaccount_id = $account_id;
                 $bean->name = $question->getSubject();
                 $bean->description = $question->getBody();
                 $bean->message_id = $messageID;
                 $bean->message_type = $question->getMessageType();
                 $bean->question_type = $question->getQuestionType();
                 // $bean->recipient_id = $question->getRecipientID();
                 $bean->sender_email = $question->getSenderEmail();
                 $bean->sender_id = $question->getSenderID();
                 $bean->creation_date = $memberMessage->getCreationDate();
                 $bean->message_status = $memberMessage->getMessageStatus();
                 $responses = $memberMessage->getResponse();
                 $bean->responses = $this->getResponsesXml($responses);
                 $item = $memberMessage->getItem();
                 $bean->item_id = $item->getItemID();
                 $bean->currency_id = $item->getSellingStatus()->getCurrentPrice()->getTypeAttribute('currencyID');
                 $bean->price = $item->getSellingStatus()->getCurrentPrice()->getTypeValue();
                 $bean->endtime = $item->getListingDetails()->getEndTime();
                 $bean->view_item_url = $item->getListingDetails()->getViewItemURL();
                 $bean->title = $item->getTitle();
                 if ($bean->message_status == 'Answered') {
                     $bean->replied = true;
                     $bean->read_status = true;
                 }
                 if (empty($duplicated)) {
                     if ($bean->message_status != 'Answered') {
                         $bean->replied = false;
                         $bean->read_status = false;
                     }
                     $bean->flagged = false;
                     $bean->date_sent = '';
                     $bean->id = create_guid();
                     $bean->new_with_id = true;
                 }
                 $bean->save();
             }
         }
         return true;
     } else {
         $this->dumpObject($res);
         return false;
     }
 }
Example #6
0
 function updateOrders($session, $days = false, $current_page = 1, $order_ids = false)
 {
     WPLE()->logger->info('*** updateOrders(' . $days . ') - page ' . $current_page);
     // this is a cron job if no number of days and no order IDs are requested
     $is_cron_job = $days == false && $order_ids == false ? true : false;
     $this->initServiceProxy($session);
     // set request handler
     $this->_cs->setHandler('OrderType', array(&$this, 'handleOrderType'));
     // $this->_cs->setHandler( 'PaginationResultType', array( & $this, 'handlePaginationResultType' ) );
     // build request
     $req = new GetOrdersRequestType();
     $req->setOrderRole('Seller');
     // $req->setIncludeContainingOrder(true);
     // check if we need to calculate lastdate
     if ($this->current_lastdate) {
         $lastdate = $this->current_lastdate;
         WPLE()->logger->info('used current_lastdate from last run: ' . $lastdate);
     } else {
         // period 30 days, which is the maximum allowed
         $now = time();
         $lastdate = $this->getDateOfLastOrder($this->account_id);
         WPLE()->logger->info("getDateOfLastOrder( {$this->account_id} ) returned: " . $lastdate);
         if ($lastdate) {
             $lastdate = mysql2date('U', $lastdate);
         }
         // if last date is older than 30 days, fall back to default
         if ($lastdate < $now - 3600 * 24 * 30) {
             WPLE()->logger->info('resetting lastdate - fall back default ');
             $lastdate = false;
         }
     }
     // save lastdate for next page
     $this->current_lastdate = $lastdate;
     // fetch orders by IDs
     if (is_array($order_ids)) {
         $OrderIDArray = new OrderIDArrayType();
         foreach ($order_ids as $id) {
             $order = $this->getItem($id);
             $OrderIDArray->addOrderID($order['order_id']);
         }
         $req->setOrderIDArray($OrderIDArray);
         // parameter $days
     } elseif ($days) {
         $req->NumberOfDays = $days;
         $this->NumberOfDays = $days;
         WPLE()->logger->info('NumberOfDays: ' . $req->NumberOfDays);
         // default: orders since last change
     } elseif ($lastdate) {
         $req->ModTimeFrom = gmdate('Y-m-d H:i:s', $lastdate);
         $req->ModTimeTo = gmdate('Y-m-d H:i:s', time());
         $this->ModTimeFrom = $req->ModTimeFrom;
         $this->ModTimeTo = $req->ModTimeTo;
         WPLE()->logger->info('lastdate: ' . $lastdate);
         WPLE()->logger->info('ModTimeFrom: ' . $req->ModTimeFrom);
         WPLE()->logger->info('ModTimeTo: ' . $req->ModTimeTo);
         // fallback: one day (max allowed by ebay: 30 days)
     } else {
         $days = 1;
         $req->NumberOfDays = $days;
         $this->NumberOfDays = $days;
         WPLE()->logger->info('NumberOfDays (fallback): ' . $req->NumberOfDays);
     }
     // $req->DetailLevel = $Facet_DetailLevelCodeType->ReturnAll;
     if (!$this->is_ajax()) {
         $req->setDetailLevel('ReturnAll');
     }
     // set pagination for first page
     $custom_page_size = get_option('wplister_fetch_orders_page_size', 50);
     $items_per_page = $is_cron_job ? $custom_page_size : 100;
     // For GetOrders, the maximum value is 100 and the default value is 25 (which is too low in some rare cases)
     $this->current_page = $current_page;
     $Pagination = new PaginationType();
     $Pagination->setEntriesPerPage($items_per_page);
     $Pagination->setPageNumber($this->current_page);
     $req->setPagination($Pagination);
     // get orders (single page)
     WPLE()->logger->info('fetching orders - page ' . $this->current_page);
     $res = $this->_cs->GetOrders($req);
     $this->total_pages = $res->PaginationResult->TotalNumberOfPages;
     $this->total_items = $res->PaginationResult->TotalNumberOfEntries;
     // get order with pagination helper (doesn't work as expected)
     // EbatNs_PaginationHelper($proxy, $callName, $request, $responseElementToMerge = '__COUNT_BY_HANDLER', $maxEntries = 200, $pageSize = 200, $initialPage = 1)
     // $helper = new EbatNs_PaginationHelper( $this->_cs, 'GetOrders', $req, 'OrderArray', 20, 10, 1);
     // $res = $helper->QueryAll();
     // handle response and check if successful
     if ($this->handleResponse($res)) {
         WPLE()->logger->info("*** Orders updated successfully.");
         // WPLE()->logger->info( "*** PaginationResult:".print_r($res->PaginationResult,1) );
         // WPLE()->logger->info( "*** processed response:".print_r($res,1) );
         WPLE()->logger->info("*** current_page : " . $this->current_page);
         WPLE()->logger->info("*** total_pages  : " . $this->total_pages);
         WPLE()->logger->info("*** total_items  : " . $this->total_items);
         WPLE()->logger->info("** count_inserted: " . $this->count_inserted);
         WPLE()->logger->info("** count_updated : " . $this->count_updated);
         WPLE()->logger->info("** count_skipped : " . $this->count_skipped);
         WPLE()->logger->info("** count_failed  : " . $this->count_failed);
         // fetch next page recursively - only in days mode, or if no new orders have been fetched yet
         if ($res->HasMoreOrders && (!$is_cron_job || $this->count_inserted == 0)) {
             $this->current_page++;
             $this->updateOrders($session, $days, $this->current_page);
         }
     } else {
         WPLE()->logger->error("Error on orders update" . print_r($res, 1));
     }
 }
Example #7
0
 public function retrieveOrders($params)
 {
     global $sugar_config;
     $shipping_service = $sugar_config['ebay_shipping_service'];
     $result = true;
     $account_id = $params['AccountID'];
     $this->session->setRequestToken($params['AuthToken']);
     $bean = BeanFactory::getBean('xeBayOrders');
     $req = new GetOrdersRequestType();
     if ($params['NumberOfDays'] != 90) {
         $req->setNumberOfDays($params['NumberOfDays']);
     } else {
         $req->setCreateTimeFrom(date('Y-m-dTH:i:s', strtotime('now - 88 days')));
     }
     $req->setOrderStatus($params['OrderStatus']);
     $pagination = new PaginationType();
     $pagination->setEntriesPerPage(50);
     $pageNumber = 1;
     $hasMoreOrders = false;
     do {
         $pagination->setPageNumber($pageNumber++);
         $req->setPagination($pagination);
         $res = $this->proxy->GetOrders($req);
         if ($this->testValid($res)) {
             $hasMoreOrders = $res->getHasMoreOrders();
             $ordersPerPage = $res->getOrdersPerPage();
             $orderArray = $res->getOrderArray();
             if (empty($orderArray)) {
                 break;
             }
             foreach ($orderArray as &$order) {
                 $eBayPaymentStatus = $order->getCheckoutStatus()->getEBayPaymentStatus();
                 if ($eBayPaymentStatus != "NoPaymentFailure") {
                     continue;
                 }
                 $completeStatus = $order->getCheckoutStatus()->getStatus();
                 if ($completeStatus != "Complete") {
                     continue;
                 }
                 $orderId = $order->getOrderID();
                 $duplicated = $bean->retrieve_by_string_fields(array('order_id' => $orderId));
                 if (empty($duplicated)) {
                     $bean->shipping_service = $shipping_service;
                     $bean->populateDefaultValues(true);
                 }
                 $bean->source_type = 'ebay';
                 $bean->xebayaccount_id = $account_id;
                 $bean->buyer_checkout_message = $order->getBuyerCheckoutMessage();
                 $bean->order_id = $order->getOrderID();
                 $bean->order_status = $order->getOrderStatus();
                 $bean->buyer_user_id = $order->getBuyerUserID();
                 $bean->subtotal_currency_id = $order->getSubtotal()->getTypeAttribute('currencyID');
                 $bean->subtotal_value = $order->getSubtotal()->getTypeValue();
                 $bean->total_currency_id = $order->getTotal()->getTypeAttribute('currencyID');
                 $bean->total_value = $order->getTotal()->getTypeValue();
                 $bean->date_entered = $order->getCreatedTime();
                 $bean->paid_time = $order->getPaidTime();
                 $bean->shipped_time = $order->getShippedTime();
                 if (!empty($bean->shipped_time)) {
                     $bean->handled_status = 'handled';
                 } else {
                     if (empty($duplicated)) {
                         $bean->handled_status = 'unhandled';
                     } else {
                         // do not change handled status
                     }
                 }
                 $bean->sales_record_number = $order->getShippingDetails()->getSellingManagerSalesRecordNumber();
                 $bean->eias_token = $order->getEIASToken();
                 $bean->payment_hold_status = $order->getPaymentHoldStatus();
                 $shippingAddress = $order->getShippingAddress();
                 $bean->name = $shippingAddress->getName();
                 $bean->street1 = $shippingAddress->getStreet1();
                 $bean->street2 = $shippingAddress->getStreet2();
                 $bean->city_name = $shippingAddress->getCityName();
                 $bean->state_or_province = $shippingAddress->getStateOrProvince();
                 $bean->country = $shippingAddress->getCountry();
                 $bean->country_name = $shippingAddress->getCountryName();
                 $bean->phone = $shippingAddress->getPhone();
                 $bean->postal_code = $shippingAddress->getPostalCode();
                 $bean->address_id = $shippingAddress->getAddressID();
                 $bean->address_owner = $shippingAddress->getAddressOwner();
                 $bean->external_address_id = $shippingAddress->getExternalAddressID();
                 if (empty($duplicated)) {
                     $bean->checkout_status_last_modified_time = $order->getCheckoutStatus()->getLastModifiedTime();
                     $bean->id = create_guid();
                     $bean->new_with_id = true;
                     $this->add_transactions($order->getTransactionArray(), $bean);
                     $bean->save();
                 } else {
                     $checkoutStatusLastModifiedTime = $order->getCheckoutStatus()->getLastModifiedTime();
                     if ($bean->checkout_status_last_modified_time != $checkoutStatusLastModifiedTime) {
                         $bean->checkout_status_last_modified_time = $checkoutStatusLastModifiedTime;
                         $bean->save();
                     }
                 }
             }
         } else {
             $this->dumpObject($res);
             $result = false;
             break;
         }
     } while ($hasMoreOrders);
     return $result;
 }
Example #8
0
 function updateMessages($session, $days = null, $current_page = 1, $message_ids = false)
 {
     WPLE()->logger->info('*** updateMessages(' . $days . ') - page ' . $current_page);
     $this->initServiceProxy($session);
     // set request handler
     $this->_cs->setHandler('MyMessagesMessageType', array(&$this, 'handleMyMessagesMessageType'));
     // $this->_cs->setHandler( 'PaginationResultType', array( & $this, 'handlePaginationResultType' ) );
     // build request
     $req = new GetMyMessagesRequestType();
     $req->setDetailLevel('ReturnHeaders');
     // default, unless message_ids provided
     // check if we need to calculate lastdate
     if ($this->current_lastdate) {
         $lastdate = $this->current_lastdate;
         WPLE()->logger->info('used current_lastdate from last run: ' . $lastdate);
     } else {
         // period 30 days, which is the maximum allowed
         $now = time();
         // $lastdate = $this->getDateOfLastMessage();
         // WPLE()->logger->info('getDateOfLastMessage() returned: '.$lastdate);
         $lastdate = null;
         if ($lastdate) {
             $lastdate = mysql2date('U', $lastdate);
         }
         // if last date is older than 30 days, fall back to default
         if ($lastdate < $now - 3600 * 24 * 30) {
             WPLE()->logger->info('resetting lastdate - fall back default ');
             $lastdate = false;
         }
     }
     // save lastdate for next page
     $this->current_lastdate = $lastdate;
     if (is_array($message_ids)) {
         $MyMessagesMessageIDArray = new MyMessagesMessageIDArrayType();
         foreach ($message_ids as $id) {
             $message = $this->getItem($id);
             $MyMessagesMessageIDArray->addMessageID($message['message_id']);
         }
         $req->setMessageIDs($MyMessagesMessageIDArray);
         $req->setDetailLevel('ReturnMessages');
     } elseif ($lastdate) {
         $req->StartTime = gmdate('Y-m-d H:i:s', $lastdate);
         $this->StartTime = $req->StartTime;
         WPLE()->logger->info('lastdate: ' . $lastdate);
         WPLE()->logger->info('StartTime: ' . $req->StartTime);
     }
     /*
     // fetch messages by IDs
     if ( is_array( $message_ids ) ) {
     	$MyMessagesMessageIDArray = new MyMessagesMessageIDArrayType();
     	foreach ( $message_ids as $id ) {
     		$message = $this->getItem( $id );
     		$MyMessagesMessageIDArray->addMessageID( $message['message_id'] );
     	}
     	$req->setMyMessagesMessageIDArray( $MyMessagesMessageIDArray );
     // parameter $days
     } elseif ( $days ) {
     	$req->NumberOfDays  = $days;
     	$this->NumberOfDays = $days;
     	WPLE()->logger->info('NumberOfDays: '.$req->NumberOfDays);
     
     // default: messages since last change
     } elseif ( $lastdate ) {
     	$req->StartTime  = gmdate( 'Y-m-d H:i:s', $lastdate );
     	$this->StartTime = $req->StartTime;
     	WPLE()->logger->info('lastdate: '.$lastdate);
     	WPLE()->logger->info('StartTime: '.$req->StartTime);
     
     // fallback: one day (max allowed by ebay: 30 days)
     } else {
     	$days = 1;
     	$req->NumberOfDays  = $days;
     	$this->NumberOfDays = $days;
     	WPLE()->logger->info('NumberOfDays (fallback): '.$req->NumberOfDays);
     }
     */
     // $req->DetailLevel = $Facet_DetailLevelCodeType->ReturnMessages;
     // if ( ! $this->is_ajax() ) $req->setDetailLevel('ReturnSummary');
     // $req->setFolderID( 0 ); // Inbox (FolderID = 0) and Sent (FolderID = 1)
     // $req->setDetailLevel( 'ReturnSummary' );
     // $req->setDetailLevel( 'ReturnMessages' );
     // $req->setDetailLevel( 'ReturnHeaders' );
     // set pagination for first page
     $items_per_page = 100;
     // should be set to 200 for production
     $this->current_page = $current_page;
     $Pagination = new PaginationType();
     $Pagination->setEntriesPerPage($items_per_page);
     $Pagination->setPageNumber($this->current_page);
     $req->setPagination($Pagination);
     // get messages (single page)
     WPLE()->logger->info('fetching messages - page ' . $this->current_page);
     $res = $this->_cs->GetMyMessages($req);
     $this->total_pages = $res->PaginationResult->TotalNumberOfPages;
     $this->total_items = $res->PaginationResult->TotalNumberOfEntries;
     // get message with pagination helper (doesn't work as expected)
     // EbatNs_PaginationHelper($proxy, $callName, $request, $responseElementToMerge = '__COUNT_BY_HANDLER', $maxEntries = 200, $pageSize = 200, $initialPage = 1)
     // $helper = new EbatNs_PaginationHelper( $this->_cs, 'GetMyMessages', $req, 'MessageArray', 20, 10, 1);
     // $res = $helper->QueryAll();
     // handle response and check if successful
     if ($this->handleResponse($res)) {
         WPLE()->logger->info("*** Messages updated successfully.");
         // WPLE()->logger->info( "*** PaginationResult:".print_r($res->PaginationResult,1) );
         // WPLE()->logger->info( "*** processed response:".print_r($res,1) );
         WPLE()->logger->info("*** current_page: " . $this->current_page);
         WPLE()->logger->info("*** total_pages: " . $this->total_pages);
         WPLE()->logger->info("*** total_items: " . $this->total_items);
         // fetch next page recursively - only in days mode
         /*
         if ( $res->HasMoreMessages ) {
         	$this->current_page++;
         	$this->updateMessages( $session, $days, $this->current_page );
         }
         */
     } else {
         WPLE()->logger->error("Error on messages update" . print_r($res, 1));
     }
 }
Example #9
0
 public function dumpUserFeedback($params)
 {
     $this->session->setRequestToken($params['AuthToken']);
     $result = true;
     $req = new GetFeedbackRequestType();
     $req->setUserID($params['UserID']);
     // $req->setDetailLevel('ReturnAll');
     $pagination = new PaginationType();
     $pagination->setEntriesPerPage(25);
     $pageNumber = 1;
     $pagination->setPageNumber($pageNumber++);
     $req->setPagination($pagination);
     $res = $this->proxy->GetFeedback($req);
     if ($this->testValid($res)) {
         $this->dumpObject($res);
         $result = true;
     } else {
         $this->dumpObject($res);
         $result = false;
     }
     return $result;
 }