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

Solved problems with php data types: #47

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8095c1a
Solved problems with php data types:
hmalicha Jan 29, 2019
91a0f92
Workaround for int array params since OAuth can't handle this normally
hmalicha Jan 31, 2019
db4e02f
now also allowing sku on property in url parameters
hmalicha Feb 14, 2019
a269346
Fixed not possible validation which made it impossible to send these …
hmalicha Mar 6, 2019
6f7aea1
Update composer.json
hmalicha Mar 11, 2019
879d48e
added necessary param
hmalicha Mar 13, 2019
5727cc1
Merge branch 'master' of https://github.com/hmalicha/etsy-php
hmalicha Mar 13, 2019
b46d610
added missing fields
hmalicha Mar 14, 2019
fecac59
fixed
hmalicha Mar 14, 2019
f96678d
possible fix
hmalicha Mar 14, 2019
bcad6db
.
hmalicha Mar 14, 2019
ef66461
added missing enum value
hmalicha Mar 14, 2019
bab4cef
.
hmalicha Mar 14, 2019
ee23562
reverted changes
hmalicha Mar 14, 2019
47f753f
Changed some entries from array to string, because the oauth lib can'…
hmalicha Mar 14, 2019
c531a50
updated enum
hmalicha Mar 28, 2019
7e2b439
added missing params
hmalicha May 6, 2019
156ee85
no message
hmalicha Jun 17, 2019
969bd0a
Update composer.json
hmalicha Jul 15, 2019
183a424
testoutput
hmalicha Jul 15, 2019
c97ba4b
Merge branch 'master' of https://github.com/hmalicha/etsy-php
hmalicha Jul 15, 2019
69c7f7f
added information for error handling
hmalicha Jul 15, 2019
c17583a
Update composer.json
hmalicha Jul 15, 2019
a0ac9ee
changed methods json to match expected params from etsy
hmalicha Jul 22, 2019
8d86d4b
Changed array(string) into string @ create and update Translation method
8bitseppel Jul 24, 2019
c171889
release 0.13.4
8bitseppel Jul 24, 2019
5847bbf
added german recipient and occasion for enum
8bitseppel Aug 14, 2019
f900a97
RELEASE 0.13.5
8bitseppel Aug 14, 2019
14ccd81
why does this work on github but not on sourcetree
8bitseppel Oct 21, 2019
742f25b
RELEASE 0.13.6
8bitseppel Oct 21, 2019
b242057
updated method json
8bitseppel Oct 21, 2019
e41940e
updated method.json
8bitseppel Oct 21, 2019
eba896a
fixed language problem for createListing
hmalicha Dec 20, 2019
0565c5d
Updated version
hmalicha Dec 20, 2019
facb4de
Update composer.json
hmalicha Dec 20, 2019
da1b8cb
added new enum values
hmalicha Jan 13, 2020
0f7e433
fixed
hmalicha Jan 5, 2022
d8c47d0
updated version
hmalicha Jan 5, 2022
14935a4
added when_made value to update listing
hmalicha Jan 13, 2022
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
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "inakiabt/etsy-php",
"version": "0.12.1",
"name": "hmalicha/etsy-php",
"version": "0.13.11",
"description": "Simple PHP wrapper for Etsy API",
"license": "MIT",
"authors": [
{
"name": "Iñaki Abete"
},
{
"name": "Henry Malicha"
}
],

Expand Down
5 changes: 5 additions & 0 deletions src/Etsy/EtsyApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ private function prepareParameters($params) {
$query_pairs = array();
$allowed = array("limit", "offset", "page", "sort_on", "sort_order", "include_private", "language");

//allowing additional params that are only usable in the updateInventory method, because oauth can't handle these in the data array
$allowed[] = 'price_on_property';
$allowed[] = 'quantity_on_property';
$allowed[] = 'sku_on_property';

if ($params) {
foreach($params as $key=>$value) {
if (in_array($key, $allowed)) {
Expand Down
5 changes: 4 additions & 1 deletion src/Etsy/EtsyClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ public function request($path, $params = array(), $method = OAUTH_HTTP_METHOD_GE
$data = $this->oauth->fetch($this->base_url . $this->base_path . $path, $params, $method);
$response = $this->oauth->getLastResponse();

return json_decode($response, !$json);
$response = json_decode($response, !$json);

$response['initialRequest'] = $params;
return $response;
} catch (\OAuthException $e) {
throw new EtsyRequestException($e, $this->oauth, $params);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Etsy/RequestValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public static function validateData($args, $methodInfo)
break;
}

//Changing type to float if float is expected but integer is given, since php converts floats without decimals to integers
if ($validType == 'float' && $type == 'int') {
$type = 'float';
}

if ($validType !== $type) {
if (substr($validType, 0, 4) === 'enum') {
if ($arg === 'enum' || !preg_match("@" . preg_quote($arg) . "@", $validType)) {
Expand Down
60 changes: 42 additions & 18 deletions src/Etsy/methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
"type": "ApiMethod",
"visibility": "public",
"http_method": "GET"
},
"updateVariationImages":{
"name": "updateVariationImages",
"description": "Creates variation images on a listing",
"uri": "/listings/:listing_id/variation-images",
"params": {
"listing_id": "int",
"variation_images": "array"
},
"defaults": null,
"type": null,
"visibility": "public",
"http_method": "POST"
},
"getPublicBaseline": {
"name": "getPublicBaseline",
Expand Down Expand Up @@ -383,11 +396,12 @@
"description": "Creates a new Listing. NOTE: A shipping_template_id is required when creating a listing. <strong>NOTE: All listings created on www.etsy.com must be actual items for sale. Please see our <a href='/developers/documentation/getting_started/testing'>guidelines for testing</a> with live listings.</strong>",
"uri": "/listings",
"params": {
"language": "string",
"quantity": "int",
"title": "string",
"description": "text",
"price": "float",
"materials": "array(string)",
"materials": "string",
"shipping_template_id": "int",
"shop_section_id": "int",
"image_ids": "array(int)",
Expand All @@ -399,13 +413,20 @@
"processing_max": "int",
"category_id": "int",
"taxonomy_id": "int",
"tags": "array(string)",
"tags": "string",
"who_made": "enum(i_did, collective, someone_else)",
"is_supply": "boolean",
"when_made": "enum(made_to_order, 2010_2018, 2000_2009, 1999_1999, before_1999, 1990_1998, 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, not_specified)",
"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, kwanzaa, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding)",
"style": "array(string)"
"when_made": "enum(made_to_order, 2020_2022, 2020_2020, 2010_2019, 2000_2009, before_2000, 1990s, 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, mnner, frauen, unisex_erwachsene, teenager__jungen, teenager__mdchen, jugendliche, jungs, mdchen, kinder, babys__jungen, babys__mdchen, babys, vgel, katzen, hunde, haustiere, not_specified)",
"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, kwanzaa, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding, ubilum, taufe, bar_oder_bat_mizwa, geburtstag, canada_day, chinesisches_neujahr, cinco_de_mayo, konfirmation, weihnachten, day_of_the_dead, ostern, eid, verlobung, vatertag, gute_besserung, abschluss, halloween, chanukka, hauseinweihung, kwanzaa, prom, der_4_juli, muttertag, neugeborenes, neujahr, quinceanera, ruhestand, st_patricks_day, sweet_16, anteilnahme, thanksgiving, valentinstag, hochzeit)",
"style": "string",
"should_auto_renew": "boolean",
"item_weight": "int",
"item_weight_unit": "string",
"item_height": "int",
"item_dimensions_unit": "string",
"item_length": "int",
"item_width": "int"
},
"defaults": {
"materials": null,
Expand Down Expand Up @@ -437,6 +458,7 @@
"listing_id": "array(int)"
},
"defaults": null,
"defaults": null,
"type": "Listing",
"visibility": "public",
"http_method": "GET"
Expand All @@ -452,7 +474,7 @@
"description": "text",
"price": "float",
"wholesale_price": "float",
"materials": "array(string)",
"materials": "string",
"renew": "boolean",
"shipping_template_id": "int",
"shop_section_id": "int",
Expand All @@ -468,15 +490,17 @@
"non_taxable": "boolean",
"category_id": "int",
"taxonomy_id": "int",
"tags": "array(string)",
"tags": "string",
"who_made": "enum(i_did, collective, someone_else)",
"is_supply": "boolean",
"when_made": "enum(made_to_order, 2010_2018, 2000_2009, 1999_1999, before_1999, 1990_1998, 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, not_specified)",
"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, kwanzaa, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding)",
"style": "array(string)",
"when_made": "enum(made_to_order, 2020_2022, 2020_2020, 2010_2019, 2000_2009, before_2000, 1990s, 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, mnner, frauen, unisex_erwachsene, teenager__jungen, teenager__mdchen, jugendliche, jungs, mdchen, kinder, babys__jungen, babys__mdchen, babys, vgel, katzen, hunde, haustiere, not_specified)",
"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, kwanzaa, prom, july_4th, mothers_day, new_baby, new_years, quinceanera, retirement, st_patricks_day, sweet_16, sympathy, thanksgiving, valentines, wedding, ubilum, taufe, bar_oder_bat_mizwa, geburtstag, canada_day, chinesisches_neujahr, cinco_de_mayo, konfirmation, weihnachten, day_of_the_dead, ostern, eid, verlobung, vatertag, gute_besserung, abschluss, halloween, chanukka, hauseinweihung, kwanzaa, prom, der_4_juli, muttertag, neugeborenes, neujahr, quinceanera, ruhestand, st_patricks_day, sweet_16, anteilnahme, thanksgiving, valentinstag, hochzeit)",
"style": "string",
"processing_min": "int",
"processing_max": "int",
"should_auto_renew": "boolean",
"write_missing_inventory": "boolean",
"featured_rank": "featured_rank"
},
"defaults": {
Expand Down Expand Up @@ -758,7 +782,7 @@
"uri": "/listings/:listing_id/inventory",
"params": {
"listing_id": "int",
"products": "stringJSON",
"products": "string",
"price_on_property": "array(int)",
"quantity_on_property": "array(int)",
"sku_on_property": "array(int)"
Expand Down Expand Up @@ -927,7 +951,7 @@
"language": "language",
"title": "string",
"description": "text",
"tags": "array(string)"
"tags": "string"
},
"defaults": {
"title": false,
Expand All @@ -947,7 +971,7 @@
"language": "language",
"title": "string",
"description": "text",
"tags": "array(string)"
"tags": "string"
},
"defaults": {
"title": false,
Expand Down Expand Up @@ -2605,8 +2629,8 @@
"uri": "/shops/:shop_id/receipts",
"params": {
"shop_id": "shop_id_or_name",
"min_created": "epoch",
"max_created": "epoch",
"min_created": "int",
"max_created": "int",
"min_last_modified": "int",
"max_last_modified": "int",
"limit": "int",
Expand Down Expand Up @@ -2742,7 +2766,7 @@
"description": "Retrieves a set of ShopSection objects associated to a Shop.",
"uri": "/shops/:shop_id/sections",
"params": {
"shop_id": "shop_id_or_name"
"shop_id": "int"
},
"defaults": null,
"type": "ShopSection",
Expand Down
15 changes: 14 additions & 1 deletion tests/Etsy/methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
"type": "ApiMethod",
"visibility": "public",
"http_method": "GET"
},
"updateVariationImages":{
"name": "updateVariationImages",
"description": "Creates variation images on a listing",
"uri": "/listings/:listing_id/variation-images",
"params": {
"listing_id": "int",
"variation_images": "array"
},
"defaults": null,
"type": null,
"visibility": "public",
"http_method": "POST"
},
"getPublicBaseline": {
"name": "getPublicBaseline",
Expand Down Expand Up @@ -758,7 +771,7 @@
"uri": "/listings/:listing_id/inventory",
"params": {
"listing_id": "int",
"products": "stringJSON",
"products": "string",
"price_on_property": "array(int)",
"quantity_on_property": "array(int)",
"sku_on_property": "array(int)"
Expand Down