From 8aaa4e3153883dab1744352bd997b2595e80f12b Mon Sep 17 00:00:00 2001 From: Mylan van Duuren Date: Mon, 5 Feb 2024 17:36:58 +0100 Subject: [PATCH 1/2] Added support for lead_products when saving a lead --- src/Client.php | 9 +++++++++ src/Resources/Lead.php | 5 +++++ src/Resources/LeadProduct.php | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 src/Resources/LeadProduct.php diff --git a/src/Client.php b/src/Client.php index fe4c710..1de8ea4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -12,6 +12,7 @@ use Eduframe\Resources\Label; use Eduframe\Resources\Lead; use Eduframe\Resources\LeadInterest; +use Eduframe\Resources\LeadProduct; use Eduframe\Resources\Location; use Eduframe\Resources\Meeting; use Eduframe\Resources\Variant; @@ -155,6 +156,14 @@ public function lead_interests($attributes = []) { return new LeadInterest($this->connection, $attributes); } + /** + * @param array $attributes + * @return \Eduframe\Resources\LeadProduct + */ + public function lead_products($attributes = []) { + return new LeadProduct($this->connection, $attributes); + } + /** * @param array $attributes * @return \Eduframe\Resources\Meeting diff --git a/src/Resources/Lead.php b/src/Resources/Lead.php index 875c4dd..db1af8a 100644 --- a/src/Resources/Lead.php +++ b/src/Resources/Lead.php @@ -34,6 +34,7 @@ class Lead extends Resource 'address', 'labels', 'courses_leads', + 'lead_products', 'updated_at', 'created_at' ]; @@ -67,5 +68,9 @@ class Lead extends Resource 'entity' => LeadInterest::class, 'type' => self::NESTING_TYPE_NESTED_OBJECTS, ], + 'lead_products' => [ + 'entity' => LeadProduct::class, + 'type' => self::NESTING_TYPE_NESTED_OBJECTS, + ], ]; } diff --git a/src/Resources/LeadProduct.php b/src/Resources/LeadProduct.php new file mode 100644 index 0000000..86529fa --- /dev/null +++ b/src/Resources/LeadProduct.php @@ -0,0 +1,32 @@ + Date: Fri, 9 Feb 2024 15:18:43 +0100 Subject: [PATCH 2/2] chore: Update example with new lead creation Update the example for creating leads with products and variants. --- example.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/example.php b/example.php index d822768..a9272b4 100644 --- a/example.php +++ b/example.php @@ -2,7 +2,7 @@ require __DIR__ . '/vendor/autoload.php'; -$access_token = 'GUFBU8ZDGRFiX5q-Xt8nzwSuO6VzXb6zBM_IVHQqQd_Y4pAnjT6PtKkU324OROqt'; # testing program builder key +$access_token = ''; # testing program builder key $connection = new Eduframe\Connection(); @@ -14,10 +14,10 @@ $data = []; // With include its possible to include nested relations. -$data['products'] = $client->catalog_products()->all(['include' => 'labels']); +$data['variants'] = $client->catalog_variants()->get(); // To get teachers pass the correct role -$data['teachers'] = $client->teachers()->all(); +$data['teachers'] = $client->teachers()->get(); // Create a new lead $lead = $client->leads(); @@ -32,9 +32,9 @@ 'city' => 'Eindhoven', 'country' => 'NL', ]); -$lead->courses_leads = [$client->lead_interests([ - "course_id" => 133, - "planned_course_id" => null +$lead->lead_products = [$client->lead_products([ + "catalog_product_id" => 123, + "catalog_variant_id" => 456, ])]; $lead->save();