Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update enum for when_made for createListing #13

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion src/Etsy/EtsyApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions src/Etsy/EtsyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 15 additions & 3 deletions src/Etsy/RequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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.'"';
Expand Down Expand Up @@ -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.'"';
}
}
}
10 changes: 5 additions & 5 deletions src/Etsy/methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -752,7 +752,7 @@
"property_id": "int",
"value": "string",
"is_available": "boolean",
"price": "int"
"price": "float"
},
"defaults": {
"is_available": true,
Expand All @@ -771,7 +771,7 @@
"property_id": "int",
"value": "string",
"is_available": "boolean",
"price": "int"
"price": "float"
},
"defaults": {
"price": null
Expand Down Expand Up @@ -3393,4 +3393,4 @@
"visibility": "public",
"http_method": "GET"
}
}
}
2 changes: 1 addition & 1 deletion tests/Etsy/EtsyApiBuildRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to not have to change this every year, let's change this value to 2000_2009. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds Good

On Thu, Sep 1, 2016 at 12:39 PM Iñaki Abete notifications@github.com
wrote:

In tests/Etsy/EtsyApiBuildRequestTest.php
#13 (comment):

@@ -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",
    

In order to not have to change this every year, let's change this value to
2000_2009. What do you think?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/inakiabt/etsy-php/pull/13/files/b7189dc554310d15f481bb072ef40019dbca9383#r77216571,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFSc5UFi0IKpOA3kl5Kb2PR5ZfOAmDvkks5qlwnagaJpZM4Jy7Il
.

"recipient" => "men",
"occasion" => "baptism",
"style" => array('style1, style2')
Expand Down
4 changes: 2 additions & 2 deletions tests/Etsy/RequestValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -413,4 +413,4 @@ public function testDataInvalidImageFileType()
$this->assertCount(1, $result['_invalid']);
$this->assertRegExp($this->invalidTypeRegExp, $result['_invalid'][0]);
}
}
}
4 changes: 2 additions & 2 deletions tests/Etsy/methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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)",
Expand Down