Skip to content

Commit 10fe111

Browse files
createContactList using only post params
AUT-4110 Co-authored-by: Bence Kadar <bence.kadar@emarsys.com>
1 parent e0e2ecc commit 10fe111

3 files changed

Lines changed: 11 additions & 27 deletions

File tree

src/Suite/Api/ContactList.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ public function createContactList(
3939
$data['external_ids'] = $contactIds;
4040
}
4141

42+
if($businessAreaId) {
43+
$data['business_area_id'] = $businessAreaId;
44+
}
45+
4246
try {
4347
return $this->apiClient->post(
44-
$this->endPoints->createContactList($customerId, $businessAreaId), $data)['data']['id'];
48+
$this->endPoints->createContactList($customerId), $data)['data']['id'];
4549
} catch (Error $error) {
4650
throw new RequestFailed('Could not create contact list: ' . $error->getMessage(), $error->getCode(), $error);
4751
}

src/Suite/Api/ContactListEndPoints.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,14 @@ private function baseUrl(int $customerId)
1919
return "{$this->apiBaseUrl}/{$customerId}/contactlist";
2020
}
2121

22-
public function createContactList(int $customerId, string $businessAreaId = null)
22+
public function createContactList(int $customerId)
2323
{
24-
return $this->baseUrl($customerId)
25-
. ($businessAreaId ? "/?business_area_id=$businessAreaId" : '');
24+
return $this->baseUrl($customerId);
2625
}
2726

28-
public function contactLists(int $customerId, string $businessAreaId = null)
27+
public function contactLists(int $customerId)
2928
{
30-
return $this->baseUrl($customerId)
31-
. ($businessAreaId ? "/?business_area_id=$businessAreaId" : '');
29+
return $this->baseUrl($customerId);
3230
}
3331

3432
public function addToContactList(int $customerId, int $contactListId)

test/unit/Suite/Api/ContactListTest.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ public function createContactList_CalledWithBusinessAreaId_PassesBusinessAreaId(
5252
->expects($this->once())
5353
->method('post')
5454
->with(
55-
"api_base_url/$this->customerId/contactlist/?business_area_id=$businessAreaId",
55+
"api_base_url/$this->customerId/contactlist",
5656
[
5757
'name' => $this->listName,
5858
'key_id' => 'id',
5959
'external_ids' => $contactIds,
60+
'business_area_id' => $businessAreaId
6061
]
6162
)
6263
->willReturn($this->apiSuccess(['id' => $this->contactListId]));
@@ -122,25 +123,6 @@ public function getContactLists_Perfect_Perfect(): void
122123
$this->assertEquals($contactLists, $returnedContactLists);
123124
}
124125

125-
/**
126-
* @test
127-
*/
128-
public function getContactLists_CalledWithBusinessAreaId_PassesBusinessAreaId(): void
129-
{
130-
$businessAreaId = 'HU';
131-
$contactLists = [
132-
$this->contactListData('id', 'contact list'),
133-
];
134-
135-
$this->apiClient
136-
->expects($this->once())
137-
->method('get')
138-
->with("api_base_url/$this->customerId/contactlist/?business_area_id=$businessAreaId")
139-
->willReturn($this->apiSuccess($contactLists));
140-
141-
$this->listService->getContactLists($this->customerId, $businessAreaId);
142-
}
143-
144126
/**
145127
* @test
146128
*/

0 commit comments

Comments
 (0)