Using Square Connect PHP SDK, UpsertCatalogObject fatal error -


i using square connect php sdk, , getting following error, , haven't been able find solution. trying push few new categories have been added on app (within mysql database).

building catelogobject

foreach ($push_array $key => $cat_name) {     $category = $this->products_lib->get_category($cat_name);     $idempotency_key = uniqid('',true);     $push_obj = new stdclass();     $push_obj->type = 'category';     $push_obj->id = '#' . trim($category->name);     $push_obj->category_data = ['name'=>trim($category->name)];     $push_obj->present_at_all_locations = true;     $catelogobject = ["idempotency_key" => $idempotency_key, 'object' => $push_obj];     print_r($catelogobject);     $response = $square_connect->upsert_category($catelogobject); } 

produces

(     [idempotency_key] => 5996186208eae4.27853833     [object] => stdclass object         (             [type] => category             [id] => #drinks             [category_data] => array                 (                     [name] => drinks                 )             [present_at_all_locations] => 1         ) ) 

square_connect class

class squareconnect {     private $access_token = "***********************";     private $sandbox_access_token = "sandbox-*********************";     public function get_locations() {         squareconnect\configuration::getdefaultconfiguration()->setaccesstoken($this->access_token);         $locations_api = new \squareconnect\api\locationsapi();         echo $locations_api->listlocations();     }     public function get_categories() {         squareconnect\configuration::getdefaultconfiguration()->setaccesstoken($this->access_token);         $api = new \squareconnect\api\catalogapi();         $retobj = json_decode($api->listcatalog(null, 'category'));         // $categories = $retobj->objects;         return $retobj->objects;     }     public function upsert_category($category_object) {         squareconnect\configuration::getdefaultconfiguration()->setaccesstoken($this->access_token);         $api = new \squareconnect\api\catalogapi();         // return $apiresponse = json_decode($api->upsertcatalogobject($category_object));         print_r(json_decode($api->upsertcatalogobject($category_object))) ;     }     public function get_items() {         squareconnect\configuration::getdefaultconfiguration()->setaccesstoken($this->access_token);         $api = new \squareconnect\api\catalogapi();         echo $api->listcatalog(null, 'item');     } } 

when run code, following error :

fatal error: access undeclared static property: stdclass::$swaggertypes in /vendor/square/connect/lib/objectserializer.php on line 43

hope clear enough, , in advance assistance

edit

[debug] http request body  ~begin~  ~end~ [debug] http response body ~begin~ {"objects":[{"type":"category","id":"52ijhdsd67vaqnj3gqb5tvrx","updated_at":"2017-08-16t19:50:58.373z","version":1502913058373,"is_deleted":false,"custom_attributes":[{"name":"straight_fire_type","int_value":0}],"present_at_all_locations":true,"category_data":{"name":"candy"}},{"type":"category","id":"kfb7ddqypg532f66syayad4w","updated_at":"2017-06-13t19:45:27.653z","version":1497383127653,"is_deleted":false,"present_at_all_locations":true,"category_data":{"name":"sandwiches"}},{"type":"category","id":"sjvudrcamqbsrm7faebqatbs","updated_at":"2017-06-13t19:45:35.181z","version":1497383135181,"is_deleted":false,"present_at_all_locations":true,"category_data":{"name":"specials"}}]} ~end~ * hostname not found in dns cache *   trying 74.122.190.85... * connected connect.squareup.com (74.122.190.85) port 443 (#0) * set certificate verify locations: *   cafile: /etc/pki/tls/certs/ca-bundle.crt   capath: none * ssl connection using tlsv1.2 / ecdhe-rsa-aes128-gcm-sha256 * server certificate: *    subject: c=us; st=california; l=san francisco; o=square, inc.; cn=*.squareup.com *    start date: 2016-12-07 00:44:04 gmt *    expire date: 2017-12-16 01:14:02 gmt *    subjectaltname: connect.squareup.com matched *    issuer: c=us; o=entrust, inc.; ou=see www.entrust.net/legal-terms; ou=(c) 2012 entrust, inc. - authorized use only; cn=entrust certification authority - l1k *    ssl certificate verify ok. > /v2/catalog/list?types=category http/1.1 user-agent: square-connect-php/2.2.1 host: connect.squareup.com accept: application/json content-type: application/json authorization: bearer sq0atp-wrf2m45lezqvzcqaxsa_oa  < http/1.1 200 ok < content-type: application/json < vary: origin, accept-encoding < x-content-type-options: nosniff < x-download-options: noopen < x-frame-options: sameorigin < x-permitted-cross-domain-policies: none < x-xss-protection: 1; mode=block < date: fri, 18 aug 2017 02:29:24 gmt < keep-alive: timeout=60 < strict-transport-security: max-age=631152000 < content-length: 687 <  * connection #0 host connect.squareup.com left intact 

edit - solution: need change object property of $catelogobject array not object square connect api documentation instructs

foreach ($push_array $key => $cat_name) {     $category = $this->products_lib->get_category($cat_name);     $idempotency_key = uniqid('',true);     $push_obj = [];     $push_obj['type'] = 'category';     $push_obj['id'] = '#' . trim($category->name);     $push_obj['category_data'] = ['name'=>trim($category->name)];     $push_obj['present_at_all_locations'] = true;     $catelogobject = ["idempotency_key" => $idempotency_key, 'object' => $push_obj];     print_r($catelogobject);     $response = $square_connect->upsert_category($catelogobject); } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -