diff --git a/README.md b/README.md index 36dc9b7..86d2a6b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Add the following to your `composer.json` file: ```json { "require": { - "inakiabt/etsy-php": "dev-master" + "inakiabt/etsy-php": ">=0.9.0" } } ``` diff --git a/composer.json b/composer.json index cd5a63a..c925da9 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "inakiabt/etsy-php", - "version": "0.9.0", + "version": "0.9.1", "description": "Simple PHP wrapper for Etsy API", "license": "MIT", "authors": [ diff --git a/src/Etsy/EtsyApi.php b/src/Etsy/EtsyApi.php index a498109..a185235 100644 --- a/src/Etsy/EtsyApi.php +++ b/src/Etsy/EtsyApi.php @@ -94,7 +94,7 @@ protected function validateResponse($request_args, $response) private function prepareParameters($params) { $query_pairs = array(); - $allowed = array("limit", "offset", "page", "sort_on", "sort_order", "include_private"); + $allowed = array("limit", "offset", "page", "sort_on", "sort_order", "include_private", "language"); if ($params) { foreach($params as $key=>$value) { diff --git a/src/Etsy/EtsyClient.php b/src/Etsy/EtsyClient.php index cd99ea6..9495170 100644 --- a/src/Etsy/EtsyClient.php +++ b/src/Etsy/EtsyClient.php @@ -102,6 +102,10 @@ public function getConsumerSecret() return $this->consumer_secret; } + public function getLastResponseHeaders(){ + return $this->oauth->getLastResponseHeaders(); + } + public function setDebug($debug) { $this->debug = $debug; diff --git a/src/Etsy/RequestValidator.php b/src/Etsy/RequestValidator.php index 8846f23..c4b06fb 100644 --- a/src/Etsy/RequestValidator.php +++ b/src/Etsy/RequestValidator.php @@ -52,7 +52,9 @@ public static function validateData($args, $methodInfo) $result['_invalid'][] = 'Method not found'; return $result; } + $methodsParams = $methodInfo['params']; + foreach ($args as $name => $arg) { if (isset($methodsParams[$name])) @@ -85,16 +87,26 @@ public static function validateData($args, $methodInfo) case 'double': $item_type = 'float'; break; - } + } $type = 'array('.$item_type.')'; } } break; } + if ($validType !== $type) { - if (substr($validType, 0, 4) === 'enum') + if( $validType === "boolean" && $type === "string" ) { + if( $arg === "false" || $arg === "true" || $arg === "0" || $arg === "1") + { + $result['_valid'][$name] = $arg; + } + else + { + $result['_invalid'][] = RequestValidator::invalidParam($name, $arg, gettype($arg)); + } + } elseif (substr($validType, 0, 4) === 'enum') { if ($arg === 'enum' || !preg_match("@".preg_quote($arg)."@", $validType)) { $result['_invalid'][] = 'Invalid enum data param "'.$name.'" value ('.$arg.'): valid values "'.$validType.'"'; @@ -128,4 +140,4 @@ public static function invalidParamType($name, $value, $type, $validType) { return 'Invalid data param type "'.$name.'" ('.(is_array($value) ? implode(', ', $value) : $value).': '.$type.'): required type "'.$validType.'"'; } -} \ No newline at end of file +} diff --git a/src/Etsy/methods.json b/src/Etsy/methods.json index 221a90e..b793590 100644 --- a/src/Etsy/methods.json +++ b/src/Etsy/methods.json @@ -367,7 +367,7 @@ "tags": "array(string)", "who_made": "enum(i_did, collective, someone_else)", "is_supply": "boolean", - "when_made": "enum(made_to_order, 2010_2015, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", + "when_made": "enum(made_to_order, 2010_2016, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", "recipient": "enum(men, women, unisex_adults, teen_boys, teen_girls, teens, boys, girls, children, baby_boys, baby_girls, babies, birds, cats, dogs, pets)", "occasion": "enum(anniversary, baptism, bar_or_bat_mitzvah, birthday, canada_day, chinese_new_year, cinco_de_mayo, confirmation, christmas, day_of_the_dead, easter, eid, engagement, fathers_day, get_well, graduation, halloween, hanukkah, housewarming, kwanza, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding)", "style": "array(string)" @@ -425,7 +425,7 @@ "tags": "array(string)", "who_made": "enum(i_did, collective, someone_else)", "is_supply": "boolean", - "when_made": "enum(made_to_order, 2010_2015, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", + "when_made": "enum(made_to_order, 2010_2016, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", "recipient": "enum(men, women, unisex_adults, teen_boys, teen_girls, teens, boys, girls, children, baby_boys, baby_girls, babies, birds, cats, dogs, pets)", "occasion": "enum(anniversary, baptism, bar_or_bat_mitzvah, birthday, canada_day, chinese_new_year, cinco_de_mayo, confirmation, christmas, day_of_the_dead, easter, eid, engagement, fathers_day, get_well, graduation, halloween, hanukkah, housewarming, kwanza, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding)", "style": "array(string)", @@ -752,7 +752,7 @@ "property_id": "int", "value": "string", "is_available": "boolean", - "price": "int" + "price": "float" }, "defaults": { "is_available": true, @@ -771,7 +771,7 @@ "property_id": "int", "value": "string", "is_available": "boolean", - "price": "int" + "price": "float" }, "defaults": { "price": null @@ -3393,4 +3393,4 @@ "visibility": "public", "http_method": "GET" } -} \ No newline at end of file +} diff --git a/tests/Etsy/EtsyApiBuildRequestTest.php b/tests/Etsy/EtsyApiBuildRequestTest.php index c504159..97b5126 100644 --- a/tests/Etsy/EtsyApiBuildRequestTest.php +++ b/tests/Etsy/EtsyApiBuildRequestTest.php @@ -76,7 +76,7 @@ public function testValidData() "tags" => array('fashion, othertag'), "who_made" => "collective", "is_supply" => true, - "when_made" => "2010_2015", + "when_made" => "2010_2016", "recipient" => "men", "occasion" => "baptism", "style" => array('style1, style2') diff --git a/tests/Etsy/RequestValidatorTest.php b/tests/Etsy/RequestValidatorTest.php index 621c05a..fa3fdae 100644 --- a/tests/Etsy/RequestValidatorTest.php +++ b/tests/Etsy/RequestValidatorTest.php @@ -134,7 +134,7 @@ public function testDataEmpty() "tags": "array(string)", "who_made": "enum(i_did, collective, someone_else)", "is_supply": "boolean", - "when_made": "enum(made_to_order, 2010_2015, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", + "when_made": "enum(made_to_order, 2010_2016, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", "recipient": "enum(men, women, unisex_adults, teen_boys, teen_girls, teens, boys, girls, children, baby_boys, baby_girls, babies, birds, cats, dogs, pets)", "occasion": "enum(anniversary, baptism, bar_or_bat_mitzvah, birthday, canada_day, chinese_new_year, cinco_de_mayo, confirmation, christmas, day_of_the_dead, easter, eid, engagement, fathers_day, get_well, graduation, halloween, hanukkah, housewarming, kwanza, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding)", "style": "array(string)" @@ -413,4 +413,4 @@ public function testDataInvalidImageFileType() $this->assertCount(1, $result['_invalid']); $this->assertRegExp($this->invalidTypeRegExp, $result['_invalid'][0]); } -} \ No newline at end of file +} diff --git a/tests/Etsy/methods.json b/tests/Etsy/methods.json index a643a49..e9b88f3 100644 --- a/tests/Etsy/methods.json +++ b/tests/Etsy/methods.json @@ -366,7 +366,7 @@ "tags": "array(string)", "who_made": "enum(i_did, collective, someone_else)", "is_supply": "boolean", - "when_made": "enum(made_to_order, 2010_2015, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", + "when_made": "enum(made_to_order, 2010_2016, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", "recipient": "enum(men, women, unisex_adults, teen_boys, teen_girls, teens, boys, girls, children, baby_boys, baby_girls, babies, birds, cats, dogs, pets)", "occasion": "enum(anniversary, baptism, bar_or_bat_mitzvah, birthday, canada_day, chinese_new_year, cinco_de_mayo, confirmation, christmas, day_of_the_dead, easter, eid, engagement, fathers_day, get_well, graduation, halloween, hanukkah, housewarming, kwanza, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding)", "style": "array(string)" @@ -423,7 +423,7 @@ "tags": "array(string)", "who_made": "enum(i_did, collective, someone_else)", "is_supply": "boolean", - "when_made": "enum(made_to_order, 2010_2015, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", + "when_made": "enum(made_to_order, 2010_2016, 2000_2009, 1994_1999, before_1994, 1990_1993, 1980s, 1970s, 1960s, 1950s, 1940s, 1930s, 1920s, 1910s, 1900s, 1800s, 1700s, before_1700)", "recipient": "enum(men, women, unisex_adults, teen_boys, teen_girls, teens, boys, girls, children, baby_boys, baby_girls, babies, birds, cats, dogs, pets)", "occasion": "enum(anniversary, baptism, bar_or_bat_mitzvah, birthday, canada_day, chinese_new_year, cinco_de_mayo, confirmation, christmas, day_of_the_dead, easter, eid, engagement, fathers_day, get_well, graduation, halloween, hanukkah, housewarming, kwanza, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding)", "style": "array(string)",