Skip to content

Using Apis In Your Model

tenebrousedge edited this page Dec 26, 2012 · 1 revision

The simplest model configuration would probably look something like the following:

<?php
	class Widget extends AppModel {
		public $useDbConfig = 'myapi';
		public $useTable = 'job';
		public $actsAs = array('Copula.OAuthConsumer');
	}

$useTable should refer to a section in your path configuration, as defined in Paths.

You should be able to use find() and save() as normal. Updating records might work, and deleting records is probably going to take a lot of hacking on the part of the Copula developers, due to the way those things are implemented in CakePHP. Also, they may not even make sense in the context of a given API, so you may be on your own there. Feedback on this subject would be nice.