@Given I add customer :customer with contact person :contactPerson to inquiry

@param string $customer
@param string $contactPerson

@throws ElementNotFoundException
323887
public function addCustomerToInquiry($customer, $contactPerson)
    {
        $selector = '#customer-1';
        $this->waitForSelector($selector);

        // Fill in auto complete customer.
        $this->iSelectFromTheHuskyAutoComplete($customer, $selector);

        // Wait until loading is finished.
        $this->spin(
            function (RawMinkContext $context) {
                // Check for a spinner.
                $spinnerElement = $context->getSession()->getPage()->find(
                    'css',
                    '#customers .spinner'
                );

                if ($spinnerElement && $spinnerElement->isVisible()) {
                    return false;
                }

                // The address should be displayed now.
                $addressElement = $context->getSession()->getPage()->find(
                    'css',
                    '#customers #address-1'
                );

                if (!$addressElement || $addressElement->getText() === '') {
                    return false;
                }

                return true;
            }
        );

        // Select contact person from list.
        $this->iFillTheHuskyField('contact-select-1', $contactPerson);
    }
1207050
protected function getCustomer($id)
    {
        $customer = $this->customerManager->findOneBy(['id' => $id]);

        if (null === $customer) {
            throw new NotFoundHttpException(sprintf('Customer (%d) not found', $id));
        }

        return $customer;
    }
393726
private function addUserRole(UserInterface $user, $userRoleData)
    {
        $alreadyContains = false;

        $role = $this->roleRepository->findRoleById($userRoleData['role']['id']);

        if (!$role) {
            throw new EntityNotFoundException($this->roleRepository->getClassName(), $userRoleData['role']['id']);
        }

        if ($user->getUserRoles()) {
            foreach ($user->getUserRoles() as $containedRole) {
                if ($containedRole->getRole()->getId() === $role->getId()) {
                    $alreadyContains = true;
                }
            }
        }

        if (false === $alreadyContains) {
            $userRole = new UserRole();
            $userRole->setUser($user);
            $userRole->setRole($role);
            $userRole->setLocale(json_encode($userRoleData['locales']));
            $this->em->persist($userRole);

            $user->addUserRole($userRole);
        }

        return true;
    }
561141
public function setCustomer(Customer $v = null)
    {
        if ($v === null) {
            $this->setCustomerId(NULL);
        } else {
            $this->setCustomerId($v->getId());
        }

        $this->aCustomer = $v;

        // Add binding for other direction of this n:n relationship.
        // If this object has already been added to the Customer object, it will not be re-added.
        if ($v !== null) {
            $v->addUserCustomerRelation($this);
        }


        return $this;
    }
851280
public function updateContactPoint(ContactPoint $contactPoint)
    {
        if (is_null($this->contactPoint) || !$this->contactPoint->sameAs($contactPoint)) {
            $this->apply(
                $this->createContactPointUpdatedEvent($contactPoint)
            );
        }
    }
793539
public Customer createCustomer(Customer customer) {
        if(getCustomer(customer.getEmail()) != null){
            return customerRepository.save(customer);
        }
        return null;
    }
122661
private function handleProviderQuirks($provider, $customer)
    {
        switch ($provider) {
            case 'Twitter':
                if ($customer->getData('lastname') === '-') {
                    $nameParts = explode(' ', $customer->getData('firstname'));
                    if (count($nameParts) > 1) {
                        $customer->setData('firstname', $nameParts[0]);
                        $lastName = implode(' ', array_slice($nameParts, 1));
                        $customer->setData('lastname', $lastName);
                    }
                }
                break;
        }
    }
370221
public function setContactData($customer)
    {
        $this->model = $customer;
        $this->setReviewCollection();
        parent::setContactData($customer);

        return $this;
    }
1209897
public function updateAction(Request $request, $id)
        {

            /** @var Customer $oCustomer */
            $oCustomer = CustomerQuery::create()->findOneById($id);

            if (count($oCustomer) === 0) {
                throw $this->createNotFoundException('Unable to find Customer entity.');
            }

            $deleteForm = $this->createDeleteForm($id);
            $editForm   = $this->createEditForm($oCustomer);
            $editForm->handleRequest($request);


            if ($editForm->isValid()) {


                $sLogoPath = $this->_handleLogoUpload($request, $oCustomer);
                $oCustomer->setLogo($sLogoPath);

                $oCustomer->save();

                return $this->redirect($this->generateUrl('backend_system_customer'));
            }

            return $this->render('SlashworksAppBundle:Customer:edit.html.twig', array(
                'entity'      => $oCustomer,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
37153
public function update($customer, $attributes = [])
    {
        $params = [];

        if (isset($attributes['name'])) {
            $params['name'] = $attributes['name'];
        }

        if (isset($attributes['email'])) {
            $params['email'] = $attributes['email'];
        }

        if (isset($attributes['phone'])) {
            $params['phone'] = $attributes['phone'];
        }

        if (isset($attributes['default_card'])) {
            $params['default_payment_source_id'] = $attributes['default_card'];
        }

        return $this->gateway->commit('put', $this->gateway->buildUrlFromString("customers/{$customer}"), $params);
    }
273307
public function newCustomerAutomation($customer)
    {
        $email = $customer->getEmail();
        $websiteId = $customer->getWebsiteId();
        $customerId = $customer->getId();
        $store = $this->storeManager->getStore($customer->getStoreId());
        $storeName = $store->getName();
        try {
            //Api is enabled
            $apiEnabled = $this->helper->getWebsiteConfig(
                \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_API_ENABLED,
                $websiteId
            );

            //Automation enrolment
            $programId = $this->helper->getWebsiteConfig(
                \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER,
                $websiteId
            );

            //new contact program mapped
            if ($programId && $apiEnabled) {
                //save automation type
                $this->setEmail($email)
                    ->setAutomationType(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_CUSTOMER)
                    ->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)
                    ->setTypeId($customerId)
                    ->setWebsiteId($websiteId)
                    ->setStoreName($storeName)
                    ->setProgramId($programId);

                $this->automationResource->save($this);
            }
        } catch (\Exception $e) {
            $this->helper->debug((string)$e, []);
        }
    }
28578
private function processAdditionalSubscriptions($contact, $client, $website)
    {
        $additionalFromConfig = $this->helper->getAddressBookIdsToShow($website);

        if (!$this->helper->getCanShowAdditionalSubscriptions($website) ||
            empty($additionalFromConfig)) {
            return true;
        }

        $success = true;
        $additionalSubscriptions = $this->getRequest()->getParam('additional_subscriptions', []);

        foreach ($additionalFromConfig as $bookId) {
            if (in_array($bookId, $additionalSubscriptions)) {
                $bookResponse = $client->postAddressBookContacts(
                    $bookId,
                    $contact
                );
                if (isset($bookResponse->message)) {
                    $success = false;
                }
            }
        }
        foreach ($additionalFromConfig as $bookId) {
            if (!in_array($bookId, $additionalSubscriptions)) {
                $client->deleteAddressBookContact(
                    $bookId,
                    $contact->id
                );
            }
        }
        return $success;
    }
1018798
public function aroundSendNewAccountEmail(
        \Magento\Customer\Model\Customer $customer,
        callable $proceed,
        $type = 'registered',
        $backUrl = '',
        $storeId = '0'
    ) {
        $storeId = $customer->getStoreId();

        if (! $this->scopeConfig->getValue(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_DISABLE_CUSTOMER_SUCCESS,
            'store',
            $storeId
        )
        ) {
            return $proceed($type, $backUrl, $storeId);
        }
    }
15396
public function sendConfirmationEmail(
        $recipient,
        ApiOrderInterface $apiOrder,
        $templatePath,
        ContactInterface $customerContact = null
    ) {
        if (empty($recipient)) {
            $this->writeLog('No recipient specified.');

            return false;
        }

        $tmplData = array(
            'order' => $apiOrder,
            'contact' => $customerContact,
        );

        return $this->sendOrderMail($recipient, $templatePath, $tmplData, $apiOrder);
    }
864128
private function parseCustomer($customer)
    {
        /** @var CustomerInterface $customerItem */
        $customerItem = $this->customerFactory->create()
            ->setId($customer->getId())
            ->setBillingAddress($this->getAddressFromCustomer($customer, 'billing'))
            ->setShippingAddress($this->getAddressFromCustomer($customer, 'shipping'));

        foreach ($customer->getData() as $key => $value) {
            $customerItem->setData($key, $value);
        }

        return $customerItem;
    }
1131029
def create_customer(name, email, phone):
    
    Party = client.model('party.party')
    ContactMechanism = client.model('party.contact_mechanism')

    party, = Party.create([{'name': name}])

    # Bulk create the email and phone
    ContactMechanism.create([
        {'type': 'email', 'value': email, 'party': party},
        {'type': 'phone', 'value': phone, 'party': party},
    ])

    return party
1222250
public function addClient($client, RequestMatcher $requestMatcher): void
    {
        $this->clients[] = [
            'matcher' => $requestMatcher,
            'client' => new FlexibleHttpClient($client),
        ];
    }