Jump to content

pepijn

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by pepijn

  1. yes, the api directly calls the models, so you can use the model directly http://docs.blesta.com/display/dev/API#API-WithintheBlestaenvironment // from somewhere in your controller... $this->uses(array("Transactions")); // Now invoke it $this->Transactions->getTotalCredit(1, "USD");
  2. /** * Searches packages that contain the given meta field * * @param string $key They service field key to search * @param string $value The service field value to search * @param string $subkey The key to look for in serialised meta * @return array An array of stdClass objects, each containing a service */ public function searchPackageMeta($key, $value, $subkey=null) { $this->Record = $this->getPackages(); $qry = $this->Record->innerJoin("package_meta", "package_meta.package_id", "=", "packages.id", false)-> where("package_meta.key", "=", $key)-> where("package_meta.value", "=", $value); if($subkey) { return $qry->orLike("package_meta.value", sprintf('%%s:%d:"%s";s:%d:"%s";%%', strlen($subkey), $subkey, strlen($value), $value))->fetchAll(); } else { return $qry->orLike("package_meta.value", sprintf('%%:%%:%%;s:%d:"%s";%%', strlen($value), $value))->fetchAll(); } } Ok, fixed that. I think this is a really usefull thing to have, so if you'd be willing to include it in Blesta, I'm happy to give you all the permissions and copyrights and whatnot to do so.
  3. Ok thanks. I modified the Namecheap module, but managed to break it in a subtle way so that no module_row_id was given.
  4. I added this method to Packages, so you can look for a package based on meta fields. It even includes some hackery to look up values in serialized data. /** * Searches packages that contain the given meta field * * @param string $key They service field key to search * @param string $value The service field value to search * @param string $subkey The key to look for in serialised meta * @return array An array of stdClass objects, each containing a service */ public function searchPackageMeta($key, $value, $subkey=null) { $module_id=1; $this->Record = $this->getPackages(); $qry = $this->Record->innerJoin("package_meta", "package_meta.package_id", "=", "packages.id", false)-> group("packages.id")-> where("package_meta.key", "=", $key)-> where("package_meta.value", "=", $value); if($subkey) { return $qry->orLike("package_meta.value", sprintf('%%s:%d:"%s";s:%d:"%s";%%', strlen($subkey), $subkey, strlen($value), $value))->fetchAll(); } else { return $qry->orLike("package_meta.value", sprintf('%%:%%:%%;s:%d:"%s";%%', strlen($value), $value))->fetchAll(); } } Example usage: find packages that include .com NameCheap domains. blesta.api('packages/searchPackageMeta', {'key': 'tlds', 'value': '.com'}) Find all SSL certificates blesta.api('packages/searchPackageMeta', {'key': 'type', 'value': 'ssl'}) Get all 33" washing machines blesta.api('packages/searchPackageMeta', {'key': 'dimensions', 'value': '33', 'subkey': 'diameter'})
  5. So i have this service blesta.command('services/get', {'service_id': 12}) {'response': {'client_id': '2', 'coupon_id': None, 'date_added': '2013-09-16 12:09:11', 'date_canceled': None, 'date_last_renewed': None, 'date_renews': '2013-10-16 12:09:11', 'date_suspended': None, 'fields': [{'encrypted': '0', 'key': 'DomainName', 'serialized': '0', 'value': 'fu.ga'}], 'id': '12', 'id_code': '12', 'id_format': '{num}', 'id_value': '12', 'module_row_id': None, 'name': 'fu.ga', 'package': {'company_id': '1', 'description': '', 'description_html': '', 'id': '1', 'id_format': '{num}', 'id_value': '1', 'module_group': None, 'module_id': '1', 'module_row': '0', 'name': 'Free domains', 'qty': '87', 'status': 'active', 'taxable': '0'}, 'package_group_id': None, 'package_pricing': {'cancel_fee': '0.0000', 'currency': 'USD', 'id': '1', 'package_id': '1', 'period': 'month', 'price': '0.0000', 'setup_fee': '0.0000', 'term': '1'}, 'parent_service_id': None, 'pricing_id': '1', 'qty': '1', 'status': 'active'}} But I'm trying to look it up by the DomainName blesta.command('services/searchServiceFields', {'module_id': 1, 'key': 'DomainName', 'value': 'fu.ga'}) [] The above code is using a Python wrapper for the API.
  6. $ curl -u user:key -X POST -v "http://blestadomain.tk/blesta/index.php/api/services/add.json" -d "pricing_id=1&client_id=2&status=active&DomainName=fu.ga&use_module=false" {"message":"An unexpected error occured.","response":"Internal error: Failed to retrieve the default value"} I tried adding a service using the Namecheap module, but I get this error. [edit] ok, I had to use a nested array like vars[password]. Am I correct that use_module decides if the domain is provisioned or not?
  7. Thanks, but I'm using the API, not the order form. I saw the box in the order form.
  8. So I figured Accounts are for credit card info, Users has an auth method for verification and I can add Contacts to Clients. So I'm getting there. Now I tried to auth a user, but it's not working $ php index.php api/users/auth.json -u apiuser -k key -m GET -p "username=user&password=password&type=any" {"message":"An unexpected error occured.","response":"Internal error: Failed to retrieve the default value"} [edit] ok, I had to use a nested array like vars[password]. Contacts also don't seem to support custom fields and I still don't get the relation between clients and users.
  9. So the Service.add API doesn't mention if it will provison the service or not. Sometimes I want this and sometimes I don't because I'm adding a service for an already provisioned service. If that API call does not provision the service, how do I do that?
  10. So I'm looking at the API to create and verify users/clients/contacts/accounts, and I'm at a loss which model/endpoint to use. There are a few things I need to do. For the purpose of this list, a client is someone who can log in and buy stuff, a contact is just a name and address attached to this client. I'm not sure how this maps to the 4 concepts found in hte API. Given a username and password, verify it is an existing client Add contacts to a client Add custom fields to this contact
×
×
  • Create New...