Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented a facade for PaymentMethod #402

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Facades/PaymentMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
namespace QuickBooksOnline\API\Facades;

class PaymentMethod{

public static function create(array $data, $throwException = TRUE){
if(!isset($data) || empty($data)) throw new \Exception("Passed array for creating Payment Method is Empty");
$PaymentMethodObject = FacadeHelper::reflectArrayToObject("PaymentMethod", $data, $throwException );
return $PaymentMethodObject;
}

/**
* This is an immutable function
*/
public static function update($objToUpdate, array $data){
$classOfObj = get_class($objToUpdate);
if(strcmp($classOfObj, FacadeHelper::simpleAppendClassNameSpace("PaymentMethod")) != 0){
throw new \Exception("Target object class:{" . $classOfObj . "} is not an instance of PaymentMethod.");
}
$newPaymentMethodObj = PaymentMethod::create($data);
$clonedOfObj = FacadeHelper::cloneObj($objToUpdate);
FacadeHelper::mergeObj($clonedOfObj, $newPaymentMethodObj);
return $clonedOfObj;
}

}