Skip to content

Commit

Permalink
Merge pull request #3 from netinternet/feature/customer-change
Browse files Browse the repository at this point in the history
Domain moving between accounts added.
  • Loading branch information
hakanersu authored Jan 23, 2018
2 parents f442163 + 9bf742d commit 0542f71
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ logicboxes()->customer()->get('app@yourdomain.com')
logicboxes()->customer()->get(17939294)
// Changing customers password
logicboxes()->customer()->get('app@yourdomain.com','myNew8CharPassword')
// Change customer
logicboxes()->customer()->moveProduct("app@yourdomain.com", 'old-customer-id', 'new-customer-id, 'old-contact');
```

## Test Configuration
Expand Down
13 changes: 12 additions & 1 deletion src/Api/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,18 @@ public function delete($customer)
'customer-id' => $customer
]);
}

public function moveProduct($domain, $customerId, $newCustomerId, $contact = false)
{
$query = [
'domain-name' => $domain,
'existing-customer-id' => $customerId,
'new-customer-id' => $newCustomerId
];
if ($contact) {
$query['default-contact'] = $contact;
}
return $this->request('products/move.json', $query, 'POST');
}
/**
* Get customers id
*
Expand Down
21 changes: 21 additions & 0 deletions tests/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,25 @@ public function logicboxes_package_can_delete_a_customer()
$this->assertTrue($response['status']);
$this->assertTrue($response['response']);
}

/** @test */
public function logicboxes_change_customer()
{
$customer = $this->createCustomer();
$contact = $this->createContact(['customer-id' => $customer['customer-id']]);
$customer = $customer['customer-id'];
$contact = $contact['contact-id'];

$domain = strtolower(str_random(8));
logicboxes()->domain("{$domain}.com")
->register($this->prepareDomainData($customer, $contact));
// create 2. Customer
$customer2 = $this->createCustomer();
$customer2Id = $customer2['customer-id'];

$response = logicboxes()->customer()->moveProduct("{$domain}.com", $customer, $customer2Id, $contact);

$this->assertTrue($response['status']);
$this->assertEquals($response['message'], 'success');
}
}

0 comments on commit 0542f71

Please sign in to comment.