Skip to content

Commit 71c6d49

Browse files
authored
Merge pull request #179 from bc-joshroe/api-fix-1
BIG-16297 - Adding some methods to the API Client
2 parents 0ec5d82 + 54815c1 commit 71c6d49

2 files changed

Lines changed: 540 additions & 18 deletions

File tree

src/Bigcommerce/Api/Client.php

Lines changed: 297 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,14 +1189,15 @@ public static function getSkus($filter = array())
11891189
}
11901190

11911191
/**
1192-
* Create sku
1192+
* Create a SKU
11931193
*
1194+
* @param $productId
11941195
* @param $object
11951196
* @return mixed
11961197
*/
1197-
public static function createSku($object)
1198+
public static function createSku($productId, $object)
11981199
{
1199-
return self::createResource('/product/skus', $object);
1200+
return self::createResource('/products/' . $productId . '/skus', $object);
12001201
}
12011202

12021203
/**
@@ -1491,18 +1492,6 @@ public static function getCurrencies($filter = array())
14911492
return self::getCollection('/currencies' . $filter->toQuery(), 'Currency');
14921493
}
14931494

1494-
/**
1495-
* Returns the total number of currencies in the collection.
1496-
*
1497-
* @param array $filter
1498-
* @return int|string number of currencies or XML string if useXml is true
1499-
*/
1500-
public static function getCurrenciesCount($filter = array())
1501-
{
1502-
$filter = Filter::create($filter);
1503-
return self::getCount('/currencies/count' . $filter->toQuery());
1504-
}
1505-
15061495
/**
15071496
* Create a new product image.
15081497
*
@@ -1607,4 +1596,297 @@ public static function deletePage($pageId)
16071596
return self::deleteResource('/pages/' . $pageId);
16081597
}
16091598

1599+
/**
1600+
* Create a Gift Certificate
1601+
*
1602+
* @param array $object
1603+
* @return mixed
1604+
*/
1605+
public static function createGiftCertificate($object)
1606+
{
1607+
return self::createResource('/gift_certificates', $object);
1608+
}
1609+
1610+
/**
1611+
* Get a Gift Certificate
1612+
*
1613+
* @param int $giftCertificateId
1614+
* @return mixed
1615+
*/
1616+
public static function getGiftCertificate($giftCertificateId)
1617+
{
1618+
return self::getResource('/gift_certificates/' . $giftCertificateId);
1619+
}
1620+
1621+
/**
1622+
* Return the collection of all gift certificates.
1623+
*
1624+
* @param array $filter
1625+
* @return mixed
1626+
*/
1627+
public static function getGiftCertificates($filter = array())
1628+
{
1629+
$filter = Filter::create($filter);
1630+
return self::getCollection('/gift_certificates' . $filter->toQuery());
1631+
}
1632+
1633+
/**
1634+
* Update a Gift Certificate
1635+
*
1636+
* @param int $giftCertificateId
1637+
* @param array $object
1638+
* @return mixed
1639+
*/
1640+
public static function updateGiftCertificate($giftCertificateId, $object)
1641+
{
1642+
return self::updateResource('/gift_certificates/' . $giftCertificateId, $object);
1643+
}
1644+
1645+
/**
1646+
* Delete a Gift Certificate
1647+
*
1648+
* @param int $giftCertificateId
1649+
* @return mixed
1650+
*/
1651+
public static function deleteGiftCertificate($giftCertificateId)
1652+
{
1653+
return self::deleteResource('/gift_certificates/' . $giftCertificateId);
1654+
}
1655+
1656+
/**
1657+
* Delete all Gift Certificates
1658+
*
1659+
* @return mixed
1660+
*/
1661+
public static function deleteAllGiftCertificates()
1662+
{
1663+
return self::deleteResource('/gift_certificates');
1664+
}
1665+
1666+
/**
1667+
* Create Product Review
1668+
*
1669+
* @param int $productId
1670+
* @param array $object
1671+
* @return mixed
1672+
*/
1673+
public static function createProductReview($productId, $object)
1674+
{
1675+
return self::createResource('/products/' . $productId . '/reviews', $object);
1676+
}
1677+
1678+
/**
1679+
* Create Product Bulk Discount rules
1680+
*
1681+
* @param string $productId
1682+
* @param array $object
1683+
* @return mixed
1684+
*/
1685+
public static function createProductBulkPricingRules($productId, $object)
1686+
{
1687+
return self::createResource('/products/' . $productId . '/discount_rules', $object);
1688+
}
1689+
1690+
/**
1691+
* Create a Marketing Banner
1692+
*
1693+
* @param array $object
1694+
* @return mixed
1695+
*/
1696+
public static function createMarketingBanner($object)
1697+
{
1698+
return self::createResource('/banners', $object);
1699+
}
1700+
1701+
/**
1702+
* Get all Marketing Banners
1703+
*
1704+
* @return mixed
1705+
*/
1706+
public static function getMarketingBanners()
1707+
{
1708+
return self::getCollection('/banners');
1709+
}
1710+
1711+
/**
1712+
* Delete all Marketing Banners
1713+
*
1714+
* @return mixed
1715+
*/
1716+
public static function deleteAllMarketingBanners()
1717+
{
1718+
return self::deleteResource('/banners');
1719+
}
1720+
1721+
/**
1722+
* Delete a specific Marketing Banner
1723+
*
1724+
* @param int $bannerID
1725+
* @return mixed
1726+
*/
1727+
public static function deleteMarketingBanner($bannerID)
1728+
{
1729+
return self::deleteResource('/banners/' . $bannerID);
1730+
}
1731+
1732+
/**
1733+
* Update an existing banner
1734+
*
1735+
* @param int $bannerID
1736+
* @param array $object
1737+
* @return mixed
1738+
*/
1739+
public static function updateMarketingBanner($bannerID, $object)
1740+
{
1741+
return self::updateResource('/banners/' . $bannerID, $object);
1742+
}
1743+
1744+
/**
1745+
* Add a address to the customer's address book.
1746+
*
1747+
* @param int $customerID
1748+
* @param array $object
1749+
* @return mixed
1750+
*/
1751+
public static function createCustomerAddress($customerID, $object)
1752+
{
1753+
return self::createResource('/customers/' . $customerID . '/addresses', $object);
1754+
}
1755+
1756+
/**
1757+
* Create a product rule
1758+
*
1759+
* @param int $productID
1760+
* @param array $object
1761+
* @return mixed
1762+
*/
1763+
public static function createProductRule($productID, $object)
1764+
{
1765+
return self::createResource('/products/' . $productID . '/rules', $object);
1766+
}
1767+
1768+
/**
1769+
* Create a customer group.
1770+
*
1771+
* @param array $object
1772+
* @return mixed
1773+
*/
1774+
public static function createCustomerGroup($object)
1775+
{
1776+
return self::createResource('/customer_groups', $object);
1777+
}
1778+
1779+
/**
1780+
* Get list of customer groups
1781+
*
1782+
* @return mixed
1783+
*/
1784+
public static function getCustomerGroups()
1785+
{
1786+
return self::getCollection('/customer_groups');
1787+
}
1788+
1789+
/**
1790+
* Delete a customer group
1791+
*
1792+
* @param int $customerGroupId
1793+
* @return mixed
1794+
*/
1795+
public static function deleteCustomerGroup($customerGroupId)
1796+
{
1797+
return self::deleteResource('/customer_groups/' . $customerGroupId);
1798+
}
1799+
1800+
/**
1801+
* Delete all customers
1802+
*
1803+
* @return mixed
1804+
*/
1805+
public static function deleteAllCustomers()
1806+
{
1807+
return self::deleteResource('/customers');
1808+
}
1809+
1810+
/**
1811+
* Delete all options
1812+
*
1813+
* @return mixed
1814+
*/
1815+
public static function deleteAllOptions()
1816+
{
1817+
return self::deleteResource('/options');
1818+
}
1819+
1820+
/**
1821+
* Return the collection of all option values for a given option.
1822+
*
1823+
* @param int $productId
1824+
* @return mixed
1825+
*/
1826+
public static function getProductOptions($productId)
1827+
{
1828+
return self::getCollection('/products/' . $productId . '/options');
1829+
}
1830+
1831+
/**
1832+
* Return the collection of all option values for a given option.
1833+
*
1834+
* @param int $productId
1835+
* @param int $productOptionId
1836+
* @return mixed
1837+
*/
1838+
public static function getProductOption($productId, $productOptionId)
1839+
{
1840+
return self::getResource('/products/' . $productId . '/options/' . $productOptionId);
1841+
}
1842+
1843+
/**
1844+
* Return the collection of all option values for a given option.
1845+
*
1846+
* @param int $productId
1847+
* @param int $productRuleId
1848+
* @return mixed
1849+
*/
1850+
public static function getProductRule($productId, $productRuleId)
1851+
{
1852+
return self::getResource('/products/' . $productId . '/rules/' . $productRuleId);
1853+
}
1854+
1855+
/**
1856+
* Return the option value object that was created.
1857+
*
1858+
* @param int $optionId
1859+
* @param array $object
1860+
* @return mixed
1861+
*/
1862+
public static function createOptionValue($optionId, $object)
1863+
{
1864+
return self::createResource('/options/' . $optionId . '/values', $object);
1865+
}
1866+
1867+
/**
1868+
* Delete all option sets that were created.
1869+
*
1870+
* @return mixed
1871+
*/
1872+
public static function deleteAllOptionSets()
1873+
{
1874+
return self::deleteResource('/optionsets');
1875+
}
1876+
1877+
/**
1878+
* Return the option value object that was updated.
1879+
*
1880+
* @param int $optionId
1881+
* @param int $optionValueId
1882+
* @param array $object
1883+
* @return mixed
1884+
*/
1885+
public static function updateOptionValue($optionId, $optionValueId, $object)
1886+
{
1887+
return self::updateResource(
1888+
'/options/' . $optionId . '/values/' . $optionValueId,
1889+
$object
1890+
);
1891+
}
16101892
}

0 commit comments

Comments
 (0)