From 87f929edc14c0c7d6556e96359bbfd7331bb8b9f Mon Sep 17 00:00:00 2001
From: "@ChristelLoftus" <christel@bob.co.za>
Date: Tue, 13 Aug 2024 14:03:05 +0200
Subject: [PATCH] Add company.php

---
 Model/Carrier/AdditionalInfo.php | 43 --------------------------------
 Model/Carrier/Company.php        | 39 +++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 43 deletions(-)
 create mode 100644 Model/Carrier/Company.php

diff --git a/Model/Carrier/AdditionalInfo.php b/Model/Carrier/AdditionalInfo.php
index fff3c92..0b002a0 100644
--- a/Model/Carrier/AdditionalInfo.php
+++ b/Model/Carrier/AdditionalInfo.php
@@ -77,47 +77,4 @@ class AdditionalInfo
         }
         return $countryName;
     }
-
-//    // Method to get the per-package price
-//    protected function _getPerpackagePrice($cost, $handlingType, $handlingFee)
-//    {
-//        if ($handlingType == AbstractCarrier::HANDLING_TYPE_PERCENT) {
-//            return $cost + $cost * $this->_numBoxes * $handlingFee / self::UNITS;
-//        }
-//        return $cost + $this->_numBoxes * $handlingFee;
-//    }
-//
-//    // Method to get the per-order price
-//    protected function _getPerorderPrice($cost, $handlingType, $handlingFee)
-//    {
-//        if ($handlingType == self::HANDLING_TYPE_PERCENT) {
-//            return $cost + $cost * $handlingFee / self::UNITS;
-//        }
-//        return $cost + $handlingFee;
-//    }
-//
-//    // Method to get configuration data of the carrier
-//    public function getCode($type, $code = '')
-//    {
-//        $codes = [
-//            'method' => [
-//                'bobGo' => __('BobGo'),
-//            ],
-//            'unit_of_measure' => [
-//                'KGS' => __('Kilograms'),
-//                'LBS' => __('Pounds'),
-//            ],
-//        ];
-//        if (!isset($codes[$type])) {
-//            return false;
-//        } elseif ('' === $code) {
-//            return $codes[$type];
-//        }
-//        if (!isset($codes[$type][$code])) {
-//            return false;
-//        } else {
-//            return $codes[$type][$code];
-//        }
-//    }
-
 }
diff --git a/Model/Carrier/Company.php b/Model/Carrier/Company.php
new file mode 100644
index 0000000..b554759
--- /dev/null
+++ b/Model/Carrier/Company.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace BobGroup\BobGo\Model\Carrier;
+
+/**
+ * Get the Company information from the request body and return it
+ */
+class Company
+{
+
+    /**
+     * @return mixed|string
+     */
+    public function getDestComp(): mixed
+    {
+        $data = json_decode(file_get_contents('php://input'), true);
+
+        if (isset($data['address']['company'])) {
+            $destComp = $data['address']['company'];
+        } else {
+            $destComp = '';
+        }
+        return $destComp;
+    }
+
+    public function getSuburb(): mixed
+    {
+
+        $data = json_decode(file_get_contents('php://input'), true);
+
+        if (isset($data['address']['custom_attributes'][0]['value'])) {
+            $destSub = $data['address']['custom_attributes'][0]['value'];
+            //print_r($destSub);
+        } else {
+            $destSub = '';
+        }
+        return $destSub;
+    }
+}
-- 
GitLab