first commit

This commit is contained in:
2026-04-28 15:13:50 +02:00
commit a95acc355b
63745 changed files with 9487948 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<?php
/**
* ShipX Dispatch Points
*
* @package WooCommerce Paczkomaty InPost
*/
/**
* Can get dispatch points from API.
*/
class WPDesk_Paczkomaty_ShipX_Dispatch_Points {
/**
* @var WPDesk_Paczkomaty_ShipX
*/
private $api;
/**
* WPDesk_Paczkomaty_ShipX_Dispatch_Points constructor.
*
* @param WPDesk_Paczkomaty_ShipX $api .
*/
public function __construct( $api ) {
$this->api = $api;
}
/**
* @param string $type .
*
* @return array
* @throws Exception .
* @throws WPDesk_Paczkomaty_ShipX_Exception .
*/
public function get_dispatch_points_from_api( $type = '' ) {
$params = $this->api->add_per_page_parameter( [] );
$dispatch_points = [];
if ( $type ) {
$params['type'] = $type;
}
$get_dispatch_points = true;
while ( $get_dispatch_points ) {
$get_dispatch_points = false;
$api_dispatch_points = $this->api->get_dispatch_points( $params );
if ( isset( $api_dispatch_points->items ) && is_array( $api_dispatch_points->items ) ) {
foreach ( $api_dispatch_points->items as $item ) {
$dispatch_points[ $item->name ] = $item;
}
}
if ( isset( $api_dispatch_points->page )
&& isset( $api_dispatch_points->total_pages )
&& $api_dispatch_points->page < $api_dispatch_points->total_pages
) {
$get_dispatch_points = true;
$params['page'] = intval( $api_dispatch_points->page ) + 1;
}
}
return $dispatch_points;
}
/**
* @param object $dispatch_point .
*
* @return mixed
*/
public function get_dispatch_point_label( $dispatch_point ) {
$label = $dispatch_point->name;
return $label;
}
}