Jump to content

Adding new ressource to Webservice


ossedkk

Recommended Posts

Hello, 

 

We are trying to add a new webservice resource from a module.

 

We can add it as a resource in the backend, so it's visible. But we can't reach it on the url: 

 

http://example.com/api/quickpay/

 

We get 500 internal error.

 

We can access all the default webservice resources of course.

 

Here is the code for the module:

 

<?php
class QuickpayAPICore extends ObjectModel {


    public $exec_id;
    public $id_cart;
    public $trans_id;
    public $order_id;
    public static $definition = array(
        'table' => 'quickpay_execution',
        'primary' => 'exec_id',
        'fields' => array(
            'exec_id' => array('type' => self::TYPE_INT, 'required' => true),
            'id_cart' => array('type' => self::TYPE_INT, 'required' => true),
            'trans_id' => array('type' => self::TYPE_INT),
            'order_id' => array('type' => self::TYPE_STRING)
        )
    );
    protected $webserviceParameters = array();


}
?>

Placed: /modules/quickpay/override/classes

 

Filename: QuickpayAPI.php

 

The webservice:

 

<?php
class WebserviceRequest extends WebserviceRequestCore {
    public static function getResources(){
        $resources = parent::getResources();
        $resources['quickpay'] = array('description' => 'Quikpay Details', 'class' => 'QuickpayAPI');
        ksort($resources);
        return $resources;
    }


}
?>

Placed: /modules/quickpay/override/classes/webservice

 

Filename: WebserviceRequest.php

 

So why can't we reach the resource. We have added it to the API account.

 

What are we missing here to be able to access these resouces via webservice?

 

 

Link to comment
Share on other sites

  • 1 year later...

I have the same issue.

Which names i have to add to class of object model ?

class CategoryEcommerceCore but class file without "Core" ? 

and add resource with:  $resources['categoryecommerce'] = array('description' => 'o jacie marcin', 'class' => 'CategoryEcommerceCore');

 

class CategoryEcommerceCore extends ObjectModel {
    
    public $category_id;
    public $category_core_id;
    
    public static $definition = array(
        'table' => "category_ecommerce",
        'primary' => 'category_id',
        'fields' => array(
            'category_core_id' => array('type' => self::TYPE_INT),
        )
    );
      
    protected $webserviceParameters = array();

}

 

class WebserviceRequest extends WebserviceRequestCore {
    /*
    * module: EcommerceServaq
    * date: 2017-10-31 13:30:46
    * version: 1.0.0
    */
    public static function getResources(){
        $resources = parent::getResources();
        
        $resources['test'] = array('description' => 'Manage My API', 'specific_management' => true);
        
        $resources['categoryecommerce'] = array('description' => 'o jacie marcin', 'class' => 'CategoryEcommerceCore');
        
        $mp_resource = Hook::exec('addMobikulResources', array('resources' => $resources), null, true, false);
        if (is_array($mp_resource) && count($mp_resource)) {
            foreach ($mp_resource as $new_resources) {
                if (is_array($new_resources) && count($new_resources)) {
                    $resources = array_merge($resources, $new_resources);
                }
            }
        }
        
        ksort($resources);
        return $resources;
    }
}

Please answer

Regards

Martin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...