/api/spreadshirt.php

https://github.com/Dante2000/spreadshirt-api-php · PHP · 143 lines · 88 code · 25 blank · 30 comment · 4 complexity · 43871d266d779ab33d71f8a6d0d72051 MD5 · raw file

  1. <?php
  2. require_once("config.php");
  3. require_once("models/Address.php");
  4. require_once("models/APIFeature.php");
  5. require_once("models/APIKey.php");
  6. require_once("models/Application.php");
  7. require_once("models/Article.php");
  8. require_once("models/ArticleCategory.php");
  9. require_once("models/Basket.php");
  10. require_once("models/BasketItem.php");
  11. require_once("models/Country.php");
  12. require_once("models/Currency.php");
  13. require_once("models/Design.php");
  14. require_once("models/DesignCategory.php");
  15. require_once("models/DiscountScale.php");
  16. require_once("models/FontFamily.php");
  17. require_once("models/Language.php");
  18. require_once("models/Length.php");
  19. require_once("models/PrintType.php");
  20. require_once("models/Product.php");
  21. require_once("models/ProductType.php");
  22. require_once("models/ProductTypeDepartment.php");
  23. require_once("models/ShippingCountry.php");
  24. require_once("models/ShippingRegion.php");
  25. require_once("models/ShippingState.php");
  26. require_once("models/ShippingType.php");
  27. require_once("models/Shop.php");
  28. require_once("models/StockState.php");
  29. require_once("models/User.php");
  30. class SpreadshirtApi {
  31. /**
  32. * Retrieve Country List
  33. */
  34. public function getCountries() {
  35. $xml_countries = simplexml_load_file(SPREADSHIRT_API_URL . '/countries?fullData=true')->country;
  36. $result = array();
  37. for ($i = 0; $i < sizeof($xml_countries); $i++) {
  38. $result[$i] = new Country($xml_countries[$i]);
  39. }
  40. return $result;
  41. }
  42. /**
  43. * Retrieve Country Entity
  44. */
  45. public function getCountry($id) {
  46. $xml_country = simplexml_load_file(SPREADSHIRT_API_URL . '/countries/'.$id);
  47. return new Country($xml_country);
  48. }
  49. /**
  50. * Retrieve Currency List
  51. */
  52. public function getCurrencies() {
  53. $xml_currencies = simplexml_load_file(SPREADSHIRT_API_URL . '/currencies?fullData=true')->currency;
  54. $result = array();
  55. for ($i = 0; $i < sizeof($xml_currencies); $i++) {
  56. $result[$i] = new Currency($xml_currencies[$i]);
  57. }
  58. return $result;
  59. }
  60. /**
  61. * Retrieve Currency Entity
  62. */
  63. public function getCurrency($id) {
  64. $xml_currency = simplexml_load_file(SPREADSHIRT_API_URL . '/currencies/'.$id);
  65. return new Currency($xml_currency);
  66. }
  67. /**
  68. * Retrieve Language List
  69. */
  70. public function getLanguages() {
  71. $xml_languages = simplexml_load_file(SPREADSHIRT_API_URL . '/languages?fullData=true')->language;
  72. $result = array();
  73. for ($i = 0; $i < sizeof($xml_languages); $i++) {
  74. $result[$i] = new Language($xml_languages[$i]);
  75. }
  76. return $result;
  77. }
  78. /**
  79. * Retrieve Language Entity
  80. */
  81. public function getLanguage($id) {
  82. $xml_language = simplexml_load_file(SPREADSHIRT_API_URL . '/languages/'.$id);
  83. return new Language($xml_language);
  84. }
  85. /**
  86. * Retrieve User Entity
  87. */
  88. public function getUser($id) {
  89. $xml_user = simplexml_load_file(SPREADSHIRT_API_URL . '/users/'.$id.'?fullData=true');
  90. return new User($xml_user);
  91. }
  92. /**
  93. * Retrieve User Shop List
  94. */
  95. public function getShops($userid) {
  96. $xml_shops = simplexml_load_file(SPREADSHIRT_API_URL . '/users/'.$userid.'/shops?fullData=true')->shop;
  97. $result = array();
  98. for ($i = 0; $i < sizeof($xml_shops); $i++) {
  99. $result[$i] = new Shop($xml_shops[$i]);
  100. }
  101. return $result;
  102. }
  103. /**
  104. * Retrieve Shop Entity
  105. */
  106. public function getShop($id) {
  107. $xml_shop = simplexml_load_file(SPREADSHIRT_API_URL . '/shops/'.$id.'?fullData=true');
  108. return new Shop($xml_shop);
  109. }
  110. /**
  111. * Retrieve Shop Entity
  112. */
  113. public function getShopAddress($id) {
  114. $xml_address = simplexml_load_file(SPREADSHIRT_API_URL . '/shops/'.$id.'/address?fullData=true');
  115. return new Address($xml_address);
  116. }
  117. }
  118. ?>