/**
  * @param array<string,mixed> $couponArray
  */
 private function createCouponFromArray(array $couponArray)
 {
     $coupon = new Coupon();
     $coupon->setCouponCode($couponArray['coupon_code']);
     $coupon->setCreatedAt(JsonDate::toDateTime($couponArray['created_at']));
     foreach ($couponArray['package_discounts'] as $packageDiscountArray) {
         $coupon->addPackageDiscount($this->createPackageDiscountFromArray($packageDiscountArray));
     }
     $coupon->setEndDate(CouponDate::toDateTime($couponArray['end_date']));
     $coupon->setNumUses($couponArray['max_uses']);
     $coupon->setNote($couponArray['note']);
     $coupon->setNumUses($couponArray['num_uses']);
     $coupon->setStartDate(CouponDate::toDateTime($couponArray['start_date']));
     $coupon->setSuspended($couponArray['suspended']);
     $coupon->setUpdatedAt(JsonDate::toDateTime($couponArray['updated_at']));
     $coupon->setBookId($couponArray['book_id']);
     return $coupon;
 }
 /**
  * @param array<string,mixed> $purchaseArray
  */
 private function createPurchaseFromArray(array $purchaseArray)
 {
     $purchase = new Purchase();
     $purchase->setAuthorPaidOutAt(JsonDate::toDateTime($purchaseArray['author_paid_out_at']));
     $purchase->setAuthorRoyalties($purchaseArray['author_royalties']);
     $purchase->setAuthorRoyaltyPercentage($purchaseArray['author_royalty_percentage']);
     $purchase->setCausePaidOutAt(JsonDate::toDateTime($purchaseArray['cause_paid_out_at']));
     $purchase->setCauseRoyalties($purchaseArray['cause_royalties']);
     $purchase->setCauseRoyaltyPercentage($purchaseArray['cause_royalty_percentage']);
     $purchase->setCreatedAt(JsonDate::toDateTime($purchaseArray['created_at']));
     $purchase->setPublisherPaidOutAt(JsonDate::toDateTime($purchaseArray['publisher_paid_out_at']));
     $purchase->setPublisherRoyalties($purchaseArray['publisher_royalties']);
     $purchase->setRoyaltyDaysHold($purchaseArray['royalty_days_hold']);
     $purchase->setAuthorUsername($purchaseArray['author_username']);
     $purchase->setPublisherSlug($purchaseArray['publisher_slug']);
     $purchase->setUserEmail($purchaseArray['user_email']);
     $purchase->setPurchaseUuid($purchaseArray['purchase_uuid']);
     return $purchase;
 }