public function __construct(array $jsonData)
 {
     foreach ($jsonData['Segments'] as $segment) {
         $entry = Segment::withJSON($segment);
         $this->append($entry);
     }
 }
 /**
  * Test if SegmentDetailsAction returns Segment object when onParse is called.
  * @group SegmentDetailsActionTest
  * @covers moosend\Actions\SegmentDetails\SegmentDetailsAction::onParse
  */
 public function test_Should_Return_Segment_Object_When_SegmentDetailsActionTest_Calls_onParse_With_Success()
 {
     $jsonData = json_decode(file_get_contents(__DIR__ . '/../../JsonResponses/getSegmentsJsonResponse.html'), true)['Context']['Segments'][0];
     $returnedObject = $this->_action->onParse($jsonData);
     $expectedSegmentObject = Segment::withJSON($jsonData);
     $this->assertEquals($expectedSegmentObject, $returnedObject);
 }
示例#3
0
 /**
  * Test custom "constructor" when providing valid JSON data.
  * @covers moosend\Models\Campaign::withJSON
  * @group CampaignTest
  */
 public function test_Can_Create_Campaign_Instance_When_Providing_Valid_Json_Data_To_Custom_Constructor()
 {
     $this->assertEquals('4824c0fb-c41c-4b09-a35d-03d4e6177630', $this->_campaign->getID());
     $this->assertEquals('Your Campaign Name', $this->_campaign->getName());
     $this->assertEquals('Your Campaign Subject', $this->_campaign->getSubject());
     $this->assertEquals('http://www.your-domain.com/newsletter', $this->_campaign->getWebLocation());
     $this->assertEquals('SOME HTML BODY', $this->_campaign->getHTMLContent());
     $this->assertEquals('Some plain text body', $this->_campaign->getPlainContent());
     $this->assertEquals(Sender::withJSON($this->_jsonData['Sender']), $this->_campaign->getSender());
     $this->assertEquals(null, $this->_campaign->getDeliveredOn());
     $this->assertEquals(Sender::withJSON($this->_jsonData['ReplyToEmail']), $this->_campaign->getReplyToEmail());
     $this->assertEquals('/Date(1368710321000+0300)/', $this->_campaign->getCreatedOn());
     $this->assertEquals('/Date(1368839678000+0300)/', $this->_campaign->getUpdatedOn());
     $this->assertEquals('/Date(1369017000000+0300)/', $this->_campaign->getScheduledFor());
     $this->assertEquals('GTB Standard Time', $this->_campaign->getTimezone());
     $this->assertEquals(0, $this->_campaign->getFormatType());
     $this->assertEquals(ABCampaignData::withJSON($this->_jsonData['ABCampaignData']), $this->_campaign->getABCampaignData());
     $this->assertEquals(MailingList::withJSON($this->_jsonData['MailingList']), $this->_campaign->getMailingList());
     $this->assertEquals('*****@*****.**', $this->_campaign->getConfirmationTo());
     $this->assertEquals(0, $this->_campaign->getStatus());
     $this->assertEquals(Segment::withJSON($this->_jsonData['Segment']), $this->_campaign->getSegment());
     $this->assertEquals(false, $this->_campaign->getIsTransactional());
     $this->assertInstanceOf('moosend\\Models\\Campaign', $this->_campaign);
 }
示例#4
0
 /**
  * Updates the properties of an existing segment. You may update the name and match type of the segment.
  * @link http://moosend.com/api/segments#Update
  *
  * @param string $mailingListID The ID of the mailing list where the segment belongs.
  * @param Segment $segment 
  * @throws \InvalidArgumentException
  * @return null
  */
 public function update($mailingListID, Segment $segment)
 {
     $request = new UpdateSegmentRequest($segment->getName(), $segment->getMatchType());
     $action = new UpdateSegmentAction($this->httpClient, $this->apiEndpoint, $mailingListID, $segment->getID(), $this->apiKey);
     return $action->execute($request);
 }
 public function onParse($jsonData)
 {
     return Segment::withJSON($jsonData);
 }
示例#6
0
 public function setUp()
 {
     $this->_jsonData = json_decode(file_get_contents(__DIR__ . '/../../tests/JsonResponses/getCampaignRawJsonResponse.html'), true)['Context']['Segment'];
     $this->_segment = Segment::withJSON($this->_jsonData);
 }