Location: PHPKode > scripts > Jaduka API Class > jaduka-api-class/jaduka.class.php
<?php
	/* ------------------------------ BSD License Information ---------------------------------
		Copyright (c) 2006, Network Enhanced Telecom, LLP
		All rights reserved.

		Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

			* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
			* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
			* Neither the name of Jaduka or Network Enhanced Telecom, LLP nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. Contact hide@address.com, 800-880-5910.

		THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

		--------------------------------------------------------------------------------------
	*/	


	/* --------------- Jaduka PHP Class: jaduka.class.php -------------------------------------
		version: 0.8
		released: 10/25/2006
		author: Ben D. Benner, CTO, hide@address.com
		company: Jaduka, www.jaduka.com, 800.880.5910

	
		About this release:
			We wanted to get a php class file out to the developers sooner rather than later. That
			means that this release is not as feature rich as we would have liked to have made it.
			For starters this class file does not support SOAP, it utilizes only the Jaduka API's 
			HTTP support. However, we will try to get a version of the class out to the developers
			by the middle of November 2006.

			Also, this is my first time writing a class. I have written plenty of php files that 
			contained only functions, but no classes. I have used plenty of classes. Notably
			the NuSOAP class, allowing for interconnection with the old Pioneer and new Jaduka API.

			I hope that anyone using this class finds it to be useful.	
			
			Note: The methods that relate to configuring AutoRecharge (ARS) have been excluded
			from this release. They will be incorporated into the next release.


		Plans for the next release 0.9:
			-- Add AutoRecharge System (ARS) methods to the class
			-- Add methods related to setting callerId information
			-- Might rework the class to utilize the cURL class
			-- Add SOAP support
	*/



	class jaduka {
		var $username ;
		var $privateKey ;
		var $apiURL ;
		var $customer ;
		var $dnisSet ;
		var $subCustomer ;
		var $webCallAccessNumber ;
		var $webCallBackAccessNumber ;
		var $callingPartyNumber ;
		var $calledPartyNumber ;
		var $extension ;
		var $pin ;
		var $startTime ;
		var $endTime ;
		var $adjustment; 
		var $transCode; 
		var $description;
		var $accessNumber;
		var $toPhoneNumber;
		var $fromPhoneNumber;
		var $reference1;
		var $reference2;
		var $amountRemaining;
		var $callingPlan;
		var $expireTime;
		var $arsMinutes;
		var $arsAmount;
		var $arsUrl;
		var $forwardingMode;
		var $forwardingNumber;
		var $recordLimit;
		var $simCallsPerPin;
		var $playBalance;
		var $playMinutes;
		var $playCallerId;
		var $acceptPromptOn;
		var $voiceMailOn;
		var $greetingPromptName;
		var $enabled;
		var $csv;

		/* ------------------- Administrative Functions ------------------------------------------
			The functions in this section are used to set commonly used variables and parse data.
					setAPIData() - sets the API username and privateKey into the class
					setProductData() - sets the product info info the class (customer, subCustomer, etc)
					setAccountData() - sets the pin & ext into the class
					parseFaultString() - parses the fault code part of the data return
					parseHTMLtoArray() - parses the actual data returned into an array
					parseCallId() - parses the callId from the data returned
					parseCallStatus() - parses the status of a call into english terms
					cleanPhoneNumber() - removes (), - and . from a phone number (512)785-0660 = 5127850660
					
		*/

			function setAPIData($username, $privateKey) {
				/* sets the API username and privateKey into the class
				*/
				$this->username=$username;
				$this->privateKey=$privateKey;
			} // closing setAPIData() function

			function setProductData ($customer, $subCustomer, $dnisSet, $webCallAccessNumber, $webCallBackAccessNumber) {
				/* the product info info the class (customer, subCustomer, etc)
				*/

				$this->customer=$customer;
				$this->subCustomer=$subCustomer;
				$this->dnisSet=$dnisSet;
				$this->webCallAccessNumber=$webCallAccessNumber;
				$this->webCallBackAccessNumber=$webCallBackAccessNumber;
			} // closing setProductData() function

			function setAccountData($pin, $extension) {
				/* sets the pin & ext into the class
				*/
				$this->pin=$pin;
				$this->extension=$extension;
			} // closing setAccountData() function


			function parseFaultString($returnData) {
				/* parses the fault code part of the data return

				 parsing the return into a two variable array
				 [0] is the fault related info 
				 [1] will contain the data requested from the method()
				*/
				parse_str($returnData[0], $jadukaFaultCheck);

				return $jadukaFaultCheck;

			} //closing parseFaultString() function
		
			function parseHTMLtoArray($returnData) {
				/*	First we must count the number of elements in the array. This way we know
					if there is only one record returned or multiples. getCallRecords() is an example
					of a method that returns multiple records. The majority of the methods only
					return one record.
				*/

				$arrayCount = count($returnData);

				if ($arrayCount > 2) {
					$arrayCountX = 1;
					while ($arrayCountX < $arrayCount) {
						parse_str($returnData[$arrayCountX], $parsedData[$arrayCountX]);
						$arrayCountX++;
					} //closing while
				} else {
					parse_str($returnData[1], $parsedData);
				}

				return $parsedData;
			} // closing parseHTMLReturn() function


			function parseCallId($returnData) {
				/* Retrieves the callId from a return of data, presumably from startWebCall() or startWebCallBack().
					
				*/
					$parsedData = trim($returnData[1]);
					return $parsedData;
			} // closing parseCallId() function


			function parseCallStatus($returnData) {
				/* Parses the integer call status into english.
				*/
					$parsedData = trim($returnData[1]);

					switch($parsedData) {
						case 0: 
							$parsedData = "Calling party initilizing";
							break;

						case 1:
							$parsedData = "Calling Party Connected";
							break;

						case 2:
							$parsedData = "Calling Party Hearing Prompts";
							break;

						case 3:
							$parsedData = "Called Party Initilized";
							break;

						case 4:
							$parsedData = "Called Party Connected";
							break;
				} // closing switch
				return $parsedData;
			} // closing parseCallStatus() function


			function cleanPhoneNumber($returnData) {
				/*	Strips out all special characters from a phone number.
					Turns (512)785-0660 into 5127850660
					Turns 512-785-0660 into 5127850660
					Turns 512.785.0660 into 5127850660
				*/
					$cleanPhoneNumberX = preg_replace("/[\. \(\)\-]/", "", $returnData);
					return $cleanPhoneNumberX;
			} // closing cleanPhoneNumber() function


		/* ------------------- Account Functions: Financial ------------------------------------------
				The functions in this section are used to create and recharge accounts. Functions
				pertaining to the Auto Recharge System (ARS) and retrieving rates to call to specific
				phone numbers are also located in this section.

					createVFAccount() - Create Jaduka VirtualFone (VF) accounts.
					adjustPinBalance() - Add money to a pin, aka Recharge a pin.
					setPinStatus() - Turn a Pin on or off.
					setCallingPlan() - Enable a Pin for Monthly billing by setting the callingPlan
					getRateSummary() - Find out the rate to call a phone number from a USA land line.
					getWebRateSummary() - Find out the rate to call a phone number from the web.

		*/

			function createVFAccount($reference1, $reference2, $amountRemaining, $forwardingNumber) {
				/*	createVFAccount() is a replacement for the old createForwardingPin() method.
					We eliminated the need to supply excess information like retailPlan and dnis.
					
					The $reference1 & $reference2 fields that we store in our database alongside
					our account information. Typically these fields are utilized to associate
					external account information from a foreign (your) billing system.

					The $amountRemaining field is amount of starting RETAIL balance that you want 
					to the account to start with.

					And we added in the $forwardingNumber as part of this creation method. Thus, 
					avoiding the need to create the account then call another method to setup
					the forwarding number. 

					The class is automatically taking in the $username and calculating the $check 
					value. The method also requires $customer and $subCustomer, these are pulled
					from the class stored variables as well.


				*/
					$methodName = "createVFAccount" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$forwardingNumber) ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "subCustomer=".$this->subCustomer ;
					$queryString .= "&" ;
					$queryString .= "reference1=".$reference1 ;
					$queryString .= "&" ;
					$queryString .= "reference2=".$reference2 ;
					$queryString .= "&" ;
					$queryString .= "amountRemaining=".$amountRemaining ;
					$queryString .= "&" ;
					$queryString .= "forwardingNumber=".$this->cleanPhoneNumber($forwardingNumber) ;

					$queryStringRs = file($queryString);
					return $queryStringRs;
			} // closing createVFAccount() function


			function rechargePinBalance($adjustment, $description) {
				/*	rechargePinBalance() is a replacement for the old updatePinBalance() method.
					
					This method is a 'wrapper' of sorts. Due to the fact that adjustPinBalance()
					is typically utilized for recharges, I have hard coded the $transCode to
					'CCEX'.

					The rechargePinBalance() function is utilized to recharge accounts by adding
					money or stored value to the balance. 

					To add stored value to the balance the $adjustment just needs to be a 
					positive number (float). A fundamental change from the old updatePinBalance() is
					that the monetary amount taken in via the API is now in dollars rather 
					than in pennies. This means that 5.00 = $5.00 and 2.50 = $2.50.

					To remove stored value from the balance the adjustment must be a negative
					number (float).

					Please provide a brief description of the recharge, particularly if you are
					removing funds from an account. The description field is used by the 
					accounting staff when reviewing transactions.


				*/
					$methodName = "adjustPinBalance" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "adjustment=".$adjustment ;
					$queryString .= "&" ;
					$queryString .= "transCode=CCEX" ;
					$queryString .= "&" ;
					$queryString .= "description=".$description ;

					$queryStringRs = file($queryString);
					return $queryStringRs;
			} // closing rechargePinBalance() function


			function setPinStatus($pinStatus, $description) {
				/*	setPinStatus() is a replacement for the old updatePinStatus() method.
					
					The setPinStatus() method is used to deactivate a Pin. For instance
					in applications where the account is intended to be a temporary phone
					number (MyPrivateLine, ClassAdd) or a temporary button, you can 
					deactivate the account by changing the status to 'E' or Expired.

					Short list of status codes:
						'A' = Active
						'I' = Inactive, used by customer service to inactivate an account.
						'E' = Expired, used to temporarily inactivate an account.
						'T' = Terminated, used to PERMANENTLY disable an account.
						'B' = Burnt, used when an account has run out of money during a call.

					Please provide us with a $description of why you changed the status.
						Typical $descriptions:
							'Customer wanted account disabled.'
							'Customer wanted account enabled.'
							'Customer Service inactivating account.'
				*/

					$methodName = "setPinStatus" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "pinStatus=".$pinStatus ;
					$queryString .= "&" ;
					$queryString .= "description=".$description ;

					$queryStringRs = file($queryString);
					return $queryStringRs;

			} // closing setPinStatus() function	


			function setCallingPlanByPin($callingPlan, $expireTime) {
				/*	setCallingPlanByPin() is new.
					
					The new Jaduka API now supports a monthly subscription style
					of retail billing. This is done through the use of $callingPlan.

					When an account is associated to a $callingPlan and has an
					$expireTime that is valid then the account is allowed to make
					unlimited calls for an unlimited amount of minutes.

					The user is only allowed to make unlimited calls to countries 
					that are associated with that particular callingPlan. Typically
					only the continental United States of America are in a $callingPlan. 
					(No Alaska, or Hawaii)

					It is best to think of the $callingPlan logic as an override of the
					stored value billing method. If the user is trying to place a call
					to a location that is not included in the $callingPlan then the
					platform will use whatever stored value is on the account to place
					the call. Note: If the user does not have enough stored value or the 
					country has been disabled by Jaduka then no call will be placed.

					When the $expireTime has elapsed the account will again default to 
					stored value. This means that if the user had signed up for an 
					introductory offer that included one week of free calling. The 
					additional calls that are made after the $expireTime has elapsed
					will pull from whatever value they have placed on the account. 

					Also, the $expireTime is also HH:MM sensitive. This means that an 
					$expireTime set to '2006-09-23T00:11-0600' will expire at 11 minutes
					after midnight on the 23rd of September, central time. 

					The HH:MM sensitivity of the $callingPlan could be utilized to offer
					an introductory hour of free calling from the time of activation.
					
					Please contact your Jaduka Implementation Specialist to learn more
					and be assigned a $callingPlan.

				*/
				
					$methodName = "setCallingPlanByPin" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "callingPlan=".$callingPlan ;
					$queryString .= "&" ;
					$queryString .= "expireTime=".$expireTime ;

					$queryStringRs = file($queryString);
					return $queryStringRs;

			} // closing setCallingPlanByPin() function


			function getRateSummary($accessNumber, $toPhoneNumber) {
				/*	getRateSummary() is one of two methods that replace getRatesByCountryCode().
					
					We decided that no one should have to memorize all the country codes in the 
					world (or keep a database of them on hand).

					The getRateSummary() method is used to lookup the per minute cost (rate)
					of a phone call to a given phone number. This lookup assumes that the
					phone call is originating from a fixed location (MyPrivateLine). The rates 
					for this location are assigned within the platform based upon the $accessNumber. 

					You supply the $accessNumber (toll-free usually) and the $toPhoneNumber
					and we return the per minute rate, the amount of talk time available
					and additional information in an effort to make it easy for your 
					application to display rate information.

					If you are looking to display rates that relate to a phone call
					that is started from a website (Click-and-Connect) please
					use the getWebRateSummary() method.

					Note: When the $toPhoneNumber is international you must prefix the submission
					to the Jaduka API with '+'. This means that a phone number for a hotel in London
					will look like '+448704009110' while a phone number for a hotel in Austin, TX will
					look like '5124728211'.

				*/


					$methodName = "getRateSummary" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "accessNumber=".$accessNumber ;
					$queryString .= "&" ;
					$queryString .= "toPhoneNumber=".$this->cleanPhoneNumber($toPhoneNumber) ;

					$queryStringRs = file($queryString);
					return $queryStringRs;

			} // closing getRateSummary() function


			function getWebRateSummary($type, $fromPhoneNumber, $toPhoneNumber) {
				/*	getWebRateSummary() is one of two methods that replace getRatesByCountryCode().
					
					We decided that no one should have to memorize all the country codes in the 
					world (or keep a database of them on hand).

					The getWebRateSummary() method is used to lookup the per minute cost (rate)
					of a phone call that is started from the web. This lookup requires that 
					two phone numbers be provided, the $fromPhoneNumber and the $toPhoneNumber.
					
					You supply the $type, either 'webCall' or 'webCallBack', $fromPhoneNumber and
					the $toPhoneNumber 	and we return the per minute rate, the amount of talk time 
					available and additional information in an effort to make it easy for your 
					application to display rate information.

					If you are looking to display rates that relate to a phone call
					that is started from a telephone (MyPrivateLine, ClassAdd) please use
					the getRateSummary() method.

					Note: When the $fromPhoneNumber or $toPhoneNumber is international you must prefix 
					the submission to the Jaduka API with '+'. This means that a phone number for a hotel 
					in London will look like '+448704009110' while a phone number for a hotel in Austin, TX
					will look like '5124728211'.

				*/
					
					Switch ($type) {
						case "webCall":
							$accessNumber = $this->webCallAccessNumber;
							break;
	
						case "webCallBack":
							$accessNumber = $this->webCallBackAccessNumber;
							break;
					} //closing switch
				
					$methodName = "getWebRateSummary" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "accessNumber=".$accessNumber ;
					$queryString .= "&" ;
					$queryString .= "fromPhoneNumber=".$this->cleanPhoneNumber($fromPhoneNumber) ;
					$queryString .= "&" ;
					$queryString .= "toPhoneNumber=".$this->cleanPhoneNumber($toPhoneNumber) ;

//				print $queryString."<br><br>";

					$queryStringRs = file($queryString);
					return $queryStringRs;

			} // closing getWebRateSummary() function	



		/* ------------------- Account Functions: Options ------------------------------------------
				The functions in this section are used to set and view account options.

					getVFAccountSummary() - View account summary information for an account.
					setVFAccountOptions() - Enable/Disable prompts and voicemail functionality.
					setForwardingNumber() - Set the forwarding number for this account.
					setSimultaneousCallsByPin() - Enable/Disable the capability to receive simultaneous calls
		*/


			function getVFAccountSummary() {
				/*	getVFAccountSummary() is effectively a replacement for getPinDetailsExt().

					We decided that there were some common elements that should be displayed 
					on an account summary page, minutes remaining, forwarding number, voicemail
					on-off status, etc. 

					To produce and display this information required that you run at least 
					three different methods when using the Pioneer API:
									getPinDetailsExt() - Account $$ balance, account status
									getRatesByCountryCode() - to get the domestic per minute rate
									getExtensionInfo() - forwarding number, voicemail on-off status.
					
					In an effort to reduce the hassle of needing to run three methods, we 
					created the getVFAccountSummary() method to return all of this data and more.

					We also return any accessNumbers and managementNumbers that need to be dialed
					from a land line telephone. We return first and last-use information. We also
					return information pertaining to the callingPlan that the pin may be enabled
					for. 

					This should cut down on the hassle of building an account summary page inside 
					of your application. It should also speed up your application in that there
					is no longer the need to call 3 methods in succession of one another. 

					The minutes remaining are calculated against the rate associated for the
					continental United States.
					
					By providing the accessNumber and managementNumber in the data return
					we hope to eliminate the need for your applications to keep a local database 
					of this information.

				*/

					//building the query string
					$methodName = "getVFAccountSummary" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "extension=".$this->extension ;

					$queryStringRs = file($queryString);
					return $queryStringRs;
			} //closing getVFAccountSummary() function


			function setVFAccountOptions($playBalance, $playMinutes, $playCallerId, $acceptPromptOn, $voiceMailOn, $greetingPromptName) {
				/*	setVFAccountOptions() is a replacement for updateExtensionInfo().

					In converting this method we streamlined it a little and no longer
					require you to set options like the anonymousAcceptAction or
					noActionTreatment. These options logically are tied to whether or not
					voicemail is enabled. In doing so the new Jaduka API sets them for you
					based upon whether voicemail is enabled for the account.

					The anonymousAcceptAction and noActionTreatment were related to whether
					or not the platform should roll a caller over to VirtualFone voicemail or
					simply play a treatment message to the caller in the event that the 
					caller never answers or their personal voicemail answers the call but
					the anonymousAcceptMenu (now known as $accepPromptOn) is enabled.

					The following are the option names and their actions:
						$playBalance = Announces the $$ amount remaining to the account holder.
						$playMinutes = Announces the minutes remaining to the account holder.
				*new*	$playCallerId = Announces the phone number of the incoming call.
						$acceptPromptOn = "Press 1 to accept, Press 2 to send caller to voicemail."
						$voiceMailOn = Enables VirtualFone voicemail.
						$greetingPromptName = the filename for "Please wait while we connect your call."
											  Note: the filename will be without the fileExtension (no .vox)
				*/

					$methodName = "setVFAccountOptions" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "extension=".$this->extension ;
					$queryString .= "&" ;
					$queryString .= "playBalance=".$playBalance ;
					$queryString .= "&" ;
					$queryString .= "playMinutes=".$playMinutes ;
					$queryString .= "&" ;
					$queryString .= "playCallerId=".$playCallerId ;
					$queryString .= "&" ;
					$queryString .= "acceptPromptOn=".$acceptPromptOn ;
					$queryString .= "&" ;
					$queryString .= "voiceMailOn=".$voiceMailOn ;
					$queryString .= "&" ;
					$queryString .= "greetingPromptName=".$greetingPromptName ;

					$queryStringRs = file($queryString);
					return $queryStringRs;
			} // closing setVFAccountOptions() function


			function setForwardingNumber($forwardingMode, $forwardingNumber) {
				/*	setForwardingNumber() is a replacement for updatePinForwardingNumber().

					There isn't much different in this method. Except for the added
					concept of $forwardingMode. In an effort to make it easier to send
					calls to voicemail or enable an account to be in a "Do-not-Disturb"
					mode we have added this $forwardingMode parameter. Valid $forwardingMode 
					selections are as follows:
									FWD = Forward calls to the $forwardingNumber.
									DND = Callers will be informed that the subscriber is unavailable.
									VM = Callers will be sent directly to VirtualFone voicemail.
				
					When using the DND or VM $forwardingMode selections you may have the 
					$forwardingNumber be an empty string. When using the FWD selection
					the $forwardingNumber should be phone number. International numbers must start with
					011.
				
				*/
				
					$methodName = "setForwardingNumber" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "extension=".$this->extension ;
					$queryString .= "&" ;
					$queryString .= "forwardingMode=".$forwardingMode ;
					$queryString .= "&" ;
					$queryString .= "forwardingNumber=".$this->cleanPhoneNumber($forwardingNumber) ;

					$queryStringRs = file($queryString);
					return $queryStringRs;
			} // closing setForwardingNumber() function


			function setSimultaneousCallsByPin($enabled, $simCallsPerPin) {
				/*	setSimultaneousCallsByPin() is new.

					Up until recently one had to create what we simply called
					"The Work-Around" to effectively have simultaneous calls
					be possible with Click-and-Connect. 

					The Jaduka API and the Kodiak platform have native simultaneous
					call support. Meaning, that no 'work-around' is needed.

					One only has to enable an account for simultaneous calling, 
					using the setSimultaneousCallsByPin. 

					It is important to note that the platform is actively
					tracking and deducting funds from the pin for all calls
					that take place at the same time. Meaning, that if you have
					1 calls that is $0.08/minute and $8.00 on the pin, then that
					call can last 100 minutes. If you have 5 calls, each call
					can last 20 minutes. If you have 10 calls, each call can 
					last 10 minutes, etc.

					Also, meaning that ARS alerts will be triggered (if configured)
					appropriately if the adding of a 10th call pushes the time
					remaining to the configured spot. 

					We also felt it necessary to provide some control over the 
					number of simultaneous calls that the platform will connect
					for one pin/account at a time. 

					This control can be utilized in two fashions. The first, is that
					it is a little foolish to enable a pin for unlimited simultaneous 
					calls to a phone number that only have a limited number of inbound 
					phone lines from the local phone company. Simply set the 
					$simCallsPerPin to the maximum number of inbound phone lines. 

					The second fashion is to allow simultaneous calling to be sold as 
					a feature. Each additional simultaneous call allowed can be thought
					of as an up-sell feature. This provides the ability to offer a 
					simple one call at time model for no additional charge while 
					charging a small fee for 'call-waiting' model or larger fees for
					a block of 5 lines or each additional line purchased.
					
					For large call centers who are not concerned with capacity (as they
					may be adding capacity regularly) we advise that you simply
					set the $simCallsPerPin = 0. When $simCallsPerPin = 0, the platform
					will allow an unlimited number of simultaneous calls to be sent to the
					phone number.

					An account that has been enabled for a callingPlan (unlimited minutes/calls)
					and simultaneous calling is a powerful and attractive offering to any
					enterprise business.
				*/
					$methodName = "setSimultaneousCallsByPin" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "enabled=".$enabled ;
					$queryString .= "&" ;
					$queryString .= "simCallsPerPin=".$simCallsPerPin ;

					$queryStringRs = file($queryString);
					return $queryStringRs;
			} // closing setSimultaneousCallsByPin() function


		/* ------------------- Account Functions: Calls ------------------------------------------
				The functions in this section are used to start, monitor and review calls.

					startWebCall() - Start a Click-and-Connect call to the account owner's forwarding number.
					startWebCallBack() - Starts a Click-and-Connect LD call, specify two phone numbers at once.
					getWebCallStatus() - Monitor the status of a call in progress.
					getCallRecords() - Retrieve a list of call records to 
		*/

			function startWebCall($callingPartyNumber) {
				/*	startWebCall() is one of two methods that replaces the startCTCCall() method.

					To provide greater flexibility and possibly cut down on some confusion we 
					decided to split the functionality provided by startCTCCall() into two separate
					methods. 

					The startWebCall() method is to be used when your application is trying to start
					a call in much the same fasion that the Click-and-Connect email or website buttons
					are used. The method requires that you provide it with a $callingPartyNumber. 

					The $calledPartyNumber for the phone call will be retrieved from the $forwardingNumber
					that we have in the database asssociated to the $extension.

					A behavioral difference from startCTCCall() is that we no longer pass back an 
					$errorCode and a $callId. We only pass back a single integer, which is the 
					$callId, for use with the getWebCallStatus() method.

					In the event that there was an error in starting the phone call, we will pass back
					the error message in the standard 'faultCode' parameter that is returned with 
					each and every method. This negates the need to check in two places as to whether
					or not a phone call was started appropriately.

	
				*/
					$methodName = "startWebCall" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$callingPartyNumber) ;
					$queryString .= "&" ;
					$queryString .= "accessNumber=".$this->webCallAccessNumber ;
					$queryString .= "&" ;
					$queryString .= "extension=".$this->extension ;
					$queryString .= "&" ;
					$queryString .= "callingPartyNumber=".$this->cleanPhoneNumber($callingPartyNumber) ;

					$queryStringRs = file($queryString);
					return $queryStringRs;

			} // closing startWebCall() function


			function startWebCallBack($callingPartyNumber, $calledPartyNumber) {
				/*	startWebCallBack() is one of two methods that replaces the startCTCCall() method.

					To provide greater flexibility and possibly cut down on some confusion we 
					decided to split the functionality provided by startCTCCall() into two separate
					methods. 

					The startWebCallBack() method is to be used when your application is trying to start
					a call where the user (account holder) has specified both the $callingPartyNumber &
					$calledPartyNumber. This is what we have begun to refer to as a 'Web LD' call. 

					A behavioral difference from startCTCCall() is that we no longer pass back an 
					$errorCode and a $callId. We only pass back a single integer, which is the 
					$callId, for use with the getWebCallStatus() method.

					In the event that there was an error in starting the phone call, we will pass back
					the error message in the standard 'faultCode' parameter that is returned with 
					each and every method. This negates the need to check in two places as to whether
					or not a phone call was started appropriately.
	
				*/
					$methodName = "startWebCallBack" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$callingPartyNumber) ;
					$queryString .= "&" ;
					$queryString .= "accessNumber=".$this->webCallBackAccessNumber ;
					$queryString .= "&" ;
					$queryString .= "extension=".$this->extension ;
					$queryString .= "&" ;
					$queryString .= "callingPartyNumber=".$this->cleanPhoneNumber($callingPartyNumber) ;
					$queryString .= "&" ;
					$queryString .= "calledPartyNumber=".$this->cleanPhoneNumber($calledPartyNumber) ;

					$queryStringRs = file($queryString);
					return $queryStringRs;
			} // closing startWebCallBack() function

			
			function getWebCallStatus($callId) {
				/*	getWebCallStatus() replaces getCTCState().

					It requires that you pass the $callId, the integer returned by
					either startWebCall() or startWebCallBack().

					An integer will be returned to your application, this is the 
					status of the call. The codes and their meanings are as follows:
					  0 - Calling party initilizing
					  1 - Calling Party Connected
					  2 - Calling Party Hearing Prompts
					  3 - Called Party Initilized
					  4 - Called Party Connected			
				*/
					$methodName = "getWebCallStatus" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.trim($callId)) ;
					$queryString .= "&" ;
					$queryString .= "callId=".trim($callId) ;

					$queryStringRs = file($queryString);
					return $queryStringRs;

			} // closing getWebCallStatus() function


			function getCallRecords($startTime, $endTime, $recordLimit,$csv) {
				/*	getCallRecords() replaces getCallDetailsExt().

					We reduced the amount of information that we return. Much
					of the data getting returned by getCallDetailsExt() is not
					pertinent or used.
					
					We will add other call record retrieval methods to allow for
					the return of more information. However, this method will
					provide the most commonly needed information to display
					to end-users.

					The following is the data returned by getCallRecords():
						cdrId = Combination of <switchId>-<sessionId>-<cdrSessionId>
						switchId = Id number of the switch this call was placed on
						sessionId = Id number of the session this call was placed on.
						pin = Pin associated/started this call.
						customer = Customer associated with this call.
						dnisSet = DnisSet associated with this call.
						serviceCode = Service associated with this call. (43 = virtualfone, 34 = Prepaid LD)
						secondaryServiceCode = Secondary service associated. (440 = Click-and-Connect)
						callTime = Date and time of the call. YYYY-MM-DDTHH:MM:SSZ format.
						callingPartyNumber = Originating phone number. This field blank for Click-and-Connect calls.
						callingPartyCity = Originating phone number's city. This field blank for Click-and-Connect calls.
						callingPartyState = Originating phone number's state. This field blank for Click-and-Connect calls.
						calledPartyNumber = Destination phone number. 
						calledPartyCity = Destination phone number's city.
						calledPartyState = Destination phone number's state.
						talkSeconds = Number of billable seconds based upon rounding in rate plan.
						talkRate  = Rate per minute at which the talkSeconds will be billed.
						talkCharge = ((talkSeconds/60)*talkRate)
						connectCharge = Connection surcharge
						bongCharge = Additional surcharge
						payphoneCharge = FCC mandated payphone origination surcharge.
						vccCharge = Additional surcharge
						firstUseCharge = Additional surcharge
						totalCharge = Total charges for the call.
						answered = True/False, was the phone call answered. (We recieved 'offhook answer supervision')


					NOTE: This method is intended for basic display of call record information. It DOES NOT provide
					the necessary data to pair two Click-and-Connect records back up into one record. We will be 
					providing a new method for this in the near future. Thank You.

				*/
				
					$methodName = "getCallRecords" ;

					$queryString = "https://" ;
					$queryString .= "api.networkip.net/jaduka" ;
					$queryString .= "/" ;
					$queryString .= $methodName ; 
					$queryString .= "?" ;
					$queryString .= "username=".$this->username ;
					$queryString .= "&" ;
					$queryString .= "check=".md5($this->privateKey.$this->pin) ;
					$queryString .= "&" ;
					$queryString .= "pin=".$this->pin ;
					$queryString .= "&" ;
					$queryString .= "customer=".$this->customer ;
					$queryString .= "&" ;
					$queryString .= "dnisSet=".$this->dnisSet ;
					$queryString .= "&" ;
					$queryString .= "startTime=".$startTime ;
					$queryString .= "&" ;
					$queryString .= "endTime=".$endTime ;
					$queryString .= "&" ;
					$queryString .= "recordLimit=".$recordLimit ;
						if($csv == '1') {
							$queryString .= "&" ;
							$queryString .= "output=csv" ;
						} //closing if($csv == '1')

					$queryStringRs = file($queryString);
					return $queryStringRs;

			} // closing getCallRecords() function



	} //closing class

?>


Return current item: Jaduka API Class