public function register(YousticeShopRegistration $registration) { $referenceString = uniqid(); $request_data = array('orgName' => $registration->getCompanyName(), 'orgUrl' => $registration->getShopUrl(), 'orgLogo' => $registration->getShopLogo(), 'admin' => array('email' => $registration->getEmail(), 'firstName' => $registration->getFirstName(), 'lastName' => $registration->getLastName(), 'password' => $registration->getPassword(), 'primaryLang' => $registration->getAdminLang()), 'country' => $registration->getDefaultCountry(), 'subscription' => $registration->getSubscription(), 'acceptsTC' => true, 'acceptsPP' => true, 'couponCode' => $registration->getCouponCode(), 'shops' => array(array('ref' => $referenceString, 'name' => $registration->getShopName(), 'url' => $registration->getShopUrl(), 'sector' => 'RETAIL', 'currency' => $registration->getShopCurrency(), 'primaryLang' => $registration->getShopLang(), 'logo' => $registration->getShopLogo(), 'integrationInfo' => array('platform' => $this->shop_software_type, 'version' => $this->shop_software_version, 'pluginVersion' => $this->plugin_software_version)))); $url = $this->api_production_url . 'organizations/retailers/registration'; try { $this->post($url, $request_data); } catch (YousticeFailedRemoteConnectionException $e) { //shop was already registered if ($e->getCode() == 409) { throw new YousticeShopRegistrationShopAlreadyRegistered(); } throw $e; } $response = $this->responseToArray(); $shop_data = $response['shops'][0]; if ($shop_data['ref'] != $referenceString) { throw new YousticeFailedRemoteConnectionException('Post Request failed: ' . $url, -1); } return $shop_data['apiKey']; }