forked from snowcap/Emarsys
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add export handling endpoint FA-4095 * update get data endpoint to handle CSV response FA-4095 * make special send method more explicit FA-4095 --------- Co-authored-by: Enrico Wolf <[email protected]>
- Loading branch information
1 parent
32ae258
commit 550577a
Showing
6 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -303,6 +303,50 @@ public function testUpdateRds() | |
$this->assertSame('Rows updated: 2', $response->getReplyText()); | ||
} | ||
|
||
public function testItTriggersExport() | ||
{ | ||
$expectedResponse = $this->createExpectedResponse('postExport'); | ||
$client = $this->getGuzzleMock(200, $expectedResponse); | ||
|
||
$data = [ | ||
'filter' => 12345, | ||
'language' => 'de', | ||
'delimiter' => ';', | ||
'distribution_method' => 'local', | ||
'add_field_names_header' => 1, | ||
'contact_fields' => [ | ||
1, | ||
2, | ||
], | ||
]; | ||
$response = $client->triggerExport($data); | ||
|
||
$this->assertInstanceOf('\Emarsys\Response', $response); | ||
} | ||
|
||
public function testItReturnsExportStatus() | ||
{ | ||
$expectedResponse = $this->createExpectedResponse('getExportStatus'); | ||
$client = $this->getGuzzleMock(200, $expectedResponse); | ||
|
||
$response = $client->getExportStatus(12345); | ||
|
||
$this->assertInstanceOf('\Emarsys\Response', $response); | ||
} | ||
|
||
public function testItReturnsDataOfExport() | ||
{ | ||
$expectedResponse = $this->createExpectedResponse('getExportData'); | ||
$client = $this->getGuzzleMock(200, $expectedResponse); | ||
|
||
$response = $client->getExportData(12345, ';'); | ||
|
||
$this->assertSame( | ||
'user_id;E-Mail' . PHP_EOL . '12345;[email protected]' . PHP_EOL . '67890;[email protected]', | ||
$response | ||
); | ||
} | ||
|
||
/** | ||
* Get a json test data and decode it | ||
* | ||
|
@@ -317,6 +361,20 @@ private function createExpectedResponse($fileName) | |
return $fileContent; | ||
} | ||
|
||
/** | ||
* Get a json test data and decode it | ||
* | ||
* @param string $fileName | ||
* | ||
* @return mixed | ||
*/ | ||
private function createExpectedCSVResponse($fileName) | ||
{ | ||
$fileContent = file_get_contents(__DIR__ . '/TestData/' . $fileName . '.csv'); | ||
|
||
return $fileContent; | ||
} | ||
|
||
/** | ||
* returns a emarsys client with mocked handler | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
user_id;E-Mail | ||
12345;[email protected] | ||
67890;[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"replyCode":0, | ||
"replyText":"OK", | ||
"data": { | ||
"id":"12345" | ||
}, | ||
"created":"2023-11-06 15:58:12", | ||
"status":"done", | ||
"type":"contactlist", | ||
"distribution_method":"local", | ||
"file_name":"export_12345_6_de-7a8b9c.csv" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"replyCode": 0, | ||
"replyText": "OK", | ||
"data": { | ||
"id": 2140 | ||
} | ||
} |