Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

New Entity Not Found Rate Topic   - - - - -

 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11363 posts

Posted 17 June 2019 - 05:10 PM #1

I'm a bit stumped by why this isn't working.

I have an addon that has a Tygh/Api/Entities directory with a file named McbProducts.php

I have the 4 methods (index, create, update and delete) defined as well as a privileges method that returns an array of true for each method (will change to the priviliges for the specific addon later but I've also tried it with the manage_* privilege info from the addon).

 

Note that the $api_user_email is a root admin and does not belong to any usergroups.

 

However, when I

$result = HTTP:/post("site.com/api/mcbproducts", $json_data, headers['basic_auth]=>$api_user_emai:$api_key, 'header' => "Content-Type: application/json");

$result always returns result:{"message":"Not Found: The Entity mcbproducts not found","status":404}

 

Without the privileges function, it returns not found but it's due to unauthorized.  So to me, that would imply that the mehod is in fact found and is returning appropriate privileges.

 

If I add code to the abstract AEntity class for isAuthorized() to log the privileges, it is never called.

 

There must be a simple answer.  The actual Entity class is below:   The api_int_log() functions are defined and never generate any output indicating that none of the methods are called.

<?php
/*
 * Copyright 2019 1st Source IT, LLC, EZ Merchant Solutions
 * All rights reserved
 * 
 * Permission to use on a single licensed domain.
 */
namespace Tygh\Api\Entities;
 
use Tygh\Api\AEntity;
use Tygh\Api\Response;
use Tygh\Registry;
 
class McbProducts extends AEntity
{
    public function index($id = '', $params = array())
    {
 api_int_log(__METHOD__.": id=$id, params:".print_r($params,true));
       return array(
            'status' => Response::STATUS_OK,
            'data' => "McbProducts: GET not supported"
 
        );
    }
 
    public function create($params)
    {
api_int_log(__METHOD__.": params:".print_r($params,true));
        return array(
            'status' => Response::STATUS_CREATED,
            'data' => "params:$params"
        );
    }
 
    public function update($id, $params)
    {
api_int_log(__METHOD__.": id=$id, params:".print_r($params,true));
        return array(
            'status' => Response::STATUS_OK,
            'data' => "McbProducts: PUT not supported"
        );
    }
 
    public function delete($id)
    {
api_int_log(__METHOD__.": id=$id");
        return array(
            'status' => Response::STATUS_NO_CONTENT,
            'data' => "McbProducts: DELETE not supported"
 
        );
    }
 
    Public function privileges() {
api_int_log(__METHOD__.": called");
     return array(
      'create' => true,
      'update' => true,
      'delete' => true,
      'index' => true
      );
    }
}
 
?>

EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19698 posts

Posted 18 June 2019 - 05:34 AM #2

Please try (use underscore in the object name)

$result = HTTP:/post("site.com/api/mcb_products", $json_data, headers['basic_auth]=>$api_user_emai:$api_key, 'header' => "Content-Type: application/json");

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.


 
  • tbirnseth
  • CS Cart Expert
  • Authorized Reseller
  • Join Date: 08-Nov 08
  • 11363 posts

Posted 18 June 2019 - 04:55 PM #3

Hmm, I had tried it with class/filename of McpProducts and Mcbproducts using 'mcbproducts' as the rest entity.  But your change seems to work for McbProducts.

 

Thanks, I knew it must be something simple.


EZ Merchant Solutions: Custom (USA based) B2B Development, Consulting, Development and Special Projects (get a quote here).
Commercial addons, payment methods and modifications to meet your business and operations needs.


 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19698 posts

Posted 19 June 2019 - 05:45 AM #4

You are welcome! )


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    CS-Cart RU                         24500 руб.
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      CS-Cart RU + UniTheme    36000 руб.