Jump to content

How To Use Services->Add Function?


timnboys

Recommended Posts

How to use Services->add function?

as documented here: http://source-docs.blesta.com/class-Services.html

I am trying to add a service manually using $this->Services->add();

I am basically trying to do this inside the license_manager plugin as an additional controller file named api.php

for my reseller api I am making I got suspend,unsuspend,cancel,getinfo(gets the license data like callhome,etc to display in reseller's blesta.)

could anyone help me with that specific function?

Link to comment
Share on other sites

the class is totally clear to understand . the command should be

public function add(array $vars, array $packages = null, $notify = false)

and what you can pass as vars is explained here

	/**
	 * Adds a new service to the system
	 *
	 * @param array $vars An array of service info including:
	 * 	- parent_service_id The ID of the service this service is a child of (optional)
	 * 	- package_group_id The ID of the package group this service was added from (optional)
	 * 	- pricing_id The package pricing schedule ID for this service
	 * 	- client_id The ID of the client to add the service under
	 * 	- module_row_id The module row to add the service under (optional, default module will decide)
	 * 	- coupon_id The ID of the coupon used for this service (optional)
	 * 	- qty The quanity consumed by this service (optional, default 1)
	 * 	- override_price The price to set for this service, overriding the package pricing value for the selected term (optional, default null)
	 * 	- override_currency The currency to set for this service, overriding the package pricing value for the selected term (optional, default null)
	 *	- status The status of this service (optional, default 'pending'):
	 * 		- active
	 * 		- canceled
	 * 		- pending
	 * 		- suspended
	 * 		- in_review
	 * 	- date_added The date this service is added (default to today's date UTC)
	 * 	- date_renews The date the service renews (optional, default calculated by package term)
	 * 	- date_last_renewed The date the service last renewed (optional)
	 * 	- date_suspended The date the service was last suspended (optional)
	 * 	- date_canceled The date the service was last canceled (optional)
	 * 	- use_module Whether or not to use the module when creating the service ('true','false', default 'true', forced 'false' if status is 'pending' or 'in_review')
	 * 	- configoptions An array of key/value pairs of package options where the key is the package option ID and the value is the option value (optional)
	 * 	- * Any other service field data to pass to the module
	 * @param array $packages A numerically indexed array of packages ordered along with this service to determine if the given coupon may be applied
	 * @param boolean $notify True to notify the client by email regarding this service creation, false to not send any notification (optional, default false)
	 * @return int The ID of this service, void if error
	 */

now it left what you need to store after the call is successfully done .

 

what i recomand is to initialize the module init and call the module rather than the service add function .  a sample code is the fallowing :

$this->uses(array("ModuleManager"));
$add_services = $this->ModuleManager->moduleRpc($package->module_id, "addService", array(($package, (array)$vars, $parent_package=null, $parent_service=null, $status="pending")));

that was the module will ad the service and store the service fields to the database .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...