Skip to content

Commit e696e1a

Browse files
committed
Updated responses and endpoints
1 parent 41e8ffc commit e696e1a

File tree

2 files changed

+28
-34
lines changed

2 files changed

+28
-34
lines changed

src/Client.php

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ public function importLeadsCsv($args)
118118
}
119119

120120
return $this->getResult('importLeadsCsv', $args);
121+
return json_decode($this->post('leads.json', $args)->getBody());
122+
121123
}
122124

123125
/**
@@ -135,7 +137,7 @@ public function getBulkUploadStatus($batchId)
135137
throw new \Exception('Invalid $batchId provided in ' . __METHOD__);
136138
}
137139

138-
return $this->get(sprintf('leads/batch/%d.json', $batchId));
140+
return json_decode($this->get(sprintf('leads/batch/%d.json', $batchId))->getBody());
139141
}
140142

141143
/**
@@ -153,7 +155,7 @@ public function getBulkUploadFailures($batchId)
153155
throw new \Exception('Invalid $batchId provided in ' . __METHOD__);
154156
}
155157

156-
return $this->get(sprintf('leads/batch/%d/failures.json', $batchId));
158+
return json_decode($this->get(sprintf('leads/batch/%d/failures.json', $batchId))->getBody());
157159
}
158160

159161
/**
@@ -171,7 +173,7 @@ public function getBulkUploadWarnings($batchId)
171173
throw new \Exception('Invalid $batchId provided in ' . __METHOD__);
172174
}
173175

174-
return $this->get(sprintf('leads/batch/%d/warnings.json', $batchId));
176+
return json_decode($this->get(sprintf('leads/batch/%d/warnings.json', $batchId))->getBody());
175177
}
176178

177179
/**
@@ -201,7 +203,7 @@ private function createOrUpdateLeadsCommand($action, $leads, $lookupField, $args
201203
}
202204

203205
return new CreateOrUpdateLeadsResponse(
204-
$this->get('leads.json', $args)
206+
json_decode($this->get('leads.json', $args)->getBody())
205207
);
206208
}
207209

@@ -290,7 +292,7 @@ public function getLists($ids = null, $args = array())
290292
}
291293

292294
return new GetListsResponse(
293-
$this->get('lists.json', $args)
295+
json_decode($this->get('lists.json', $args)->getBody())
294296
);
295297
}
296298

@@ -309,7 +311,7 @@ public function getList($id, $args = array())
309311
$args['id'] = $id;
310312

311313
return new GetListResponse(
312-
$this->get(sprintf('lists/%d.json', $id), $args)
314+
json_decode($this->get(sprintf('lists/%d.json', $id), $args)->getBody())
313315
);
314316
}
315317

@@ -338,7 +340,7 @@ public function getLeadsByFilterType($filterType, $filterValues, $fields = array
338340
}
339341

340342
return new GetLeadsResponse(
341-
$this->get('leads.json', $args)
343+
json_decode($this->get('leads.json', $args)->getBody())
342344
);
343345
}
344346

@@ -366,7 +368,7 @@ public function getLeadByFilterType($filterType, $filterValue, $fields = array()
366368
}
367369

368370
return new GetLeadResponse(
369-
$this->get('leads.json', $args)
371+
json_decode($this->get('leads.json', $args)->getBody())
370372
);
371373
}
372374

@@ -380,7 +382,7 @@ public function getLeadByFilterType($filterType, $filterValue, $fields = array()
380382
public function getLeadPartitions($args = array())
381383
{
382384
return new GetLeadPartitionsResponse(
383-
$this->get('leads/partitions.json', $args)
385+
json_decode($this->get('leads/partitions.json', $args)->getBody())
384386
);
385387
}
386388

@@ -399,7 +401,7 @@ public function getLeadsByList($listId, $args = array())
399401
$args['listId'] = $listId;
400402

401403
return new GetLeadsResponse(
402-
$this->get(sprintf('list/%d/leads.json', $listId), $args)
404+
json_decode($this->get(sprintf('list/%d/leads.json', $listId), $args)->getBody())
403405
);
404406
}
405407

@@ -423,7 +425,7 @@ public function getLead($id, $fields = null, $args = array())
423425
}
424426

425427
return new GetLeadResponse(
426-
$this->get(sprintf('lead/%d.json', $id), $args)
428+
json_decode($this->get(sprintf('lead/%d.json', $id), $args)->getBody())
427429
);
428430
}
429431

@@ -444,7 +446,7 @@ public function isMemberOfList($listId, $id, $args = array(), $returnRaw = false
444446
$args['id'] = $id;
445447

446448
return new IsMemberOfListResponse(
447-
$this->get(sprintf('lists/%d/leads/ismember.json', $listId), $args)
449+
json_decode($this->get(sprintf('lists/%d/leads/ismember.json', $listId), $args)->getBody())
448450
);
449451
}
450452

@@ -463,7 +465,7 @@ public function getCampaign($id, $args = array())
463465
$args['id'] = $id;
464466

465467
return new GetCampaignResponse(
466-
$this->get(sprintf('campaigns/%d.json', $id), $args)
468+
json_decode($this->get(sprintf('campaigns/%d.json', $id), $args)->getBody())
467469
);
468470
}
469471

@@ -484,7 +486,7 @@ public function getCampaigns($ids = null, $args = array())
484486
}
485487

486488
return new GetCampaignsResponse(
487-
$this->get('campaigns.json', $args)
489+
json_decode($this->get('campaigns.json', $args)->getBody())
488490
);
489491
}
490492

@@ -505,7 +507,7 @@ public function addLeadsToList($listId, $leads, $args = array(), $returnRaw = fa
505507
$args['id'] = (array) $leads;
506508

507509
return new AddOrRemoveLeadsToListResponse(
508-
$this->get(sprintf('lists/%d/leads.json', $listId), $args)
510+
json_decode($this->get(sprintf('lists/%d/leads.json', $listId), $args)->getBody())
509511
);
510512
}
511513

@@ -526,7 +528,7 @@ public function removeLeadsFromList($listId, $leads, $args = array(), $returnRaw
526528
$args['id'] = (array) $leads;
527529

528530
return new AddOrRemoveLeadsToListResponse(
529-
$this->delete(sprintf('lists/%d/leads.json', $listId), $args)
531+
json_decode($this->delete(sprintf('lists/%d/leads.json', $listId), $args)->getBody())
530532
);
531533
}
532534

@@ -545,7 +547,7 @@ public function deleteLead($leads, $args = array(), $returnRaw = false)
545547
$args['id'] = (array) $leads;
546548

547549
return new DeleteLeadResponse(
548-
$this->delete('leads.json', $args)
550+
json_decode($this->delete('leads.json', $args)->getBody())
549551
);
550552
}
551553

@@ -574,7 +576,7 @@ public function requestCampaign($id, $leads, $tokens = array(), $args = array(),
574576
}
575577

576578
return new RequestCampaignResponse(
577-
$this->post(sprintf('campaigns/%d/trigger.json', $id), $args)
579+
json_decode($this->post(sprintf('campaigns/%d/trigger.json', $id), $args)->getBody())
578580
);
579581
}
580582

@@ -603,7 +605,7 @@ public function scheduleCampaign($id, \DateTime $runAt = NULL, $tokens = array()
603605
}
604606

605607
return new ScheduleCampaignResponse(
606-
$this->post(sprintf('campaigns/%d/schedule.json', $id), $args)
608+
json_decode($this->post(sprintf('campaigns/%d/schedule.json', $id), $args)->getBody())
607609
);
608610
}
609611

@@ -627,7 +629,7 @@ public function associateLead($id, $cookie = null, $args = array(), $returnRaw =
627629
}
628630

629631
return new AssociateLeadResponse(
630-
$this->post(sprintf('leads/%d/associate.json', $id), $args)
632+
json_decode($this->post(sprintf('leads/%d/associate.json', $id), $args)->getBody())
631633
);
632634
}
633635

@@ -647,7 +649,7 @@ public function getPagingToken($sinceDatetime, $args = array(), $returnRaw = fal
647649
$args['sinceDatetime'] = $sinceDatetime;
648650

649651
return new AssociateLeadResponse(
650-
$this->post('activities/pagingtoken.json', $args)
652+
json_decode($this->post('activities/pagingtoken.json', $args)->getBody())
651653
);
652654
}
653655

@@ -674,7 +676,7 @@ public function getLeadChanges($nextPageToken, $fields, $args = array(), $return
674676
}
675677

676678
return new GetLeadChanges(
677-
$this->post('activities/leadchanges.json', $args)
679+
json_decode($this->post('activities/leadchanges.json', $args)->getBody())
678680
);
679681
}
680682

@@ -694,7 +696,7 @@ public function updateEmailContent($emailId, $args = array(), $returnRaw = false
694696
$args['id'] = $emailId;
695697

696698
return new Response(
697-
$this->post(sprintf('rest/asset/v1/email/%d/content.json', $emailId), $args)
699+
json_decode($this->post(sprintf('rest/asset/v1/email/%d/content.json', $emailId), $args)->getBody())
698700
);
699701
}
700702

@@ -715,7 +717,7 @@ public function updateEmailContentInEditableSection($emailId, $htmlId, $args = a
715717
$args['htmlId'] = $htmlId;
716718

717719
return new UpdateEmailContentInEditableSectionResponse(
718-
$this->post(sprintf('rest/asset/v1/email/%d/content/{htmlId}.json', $emailId), $args)
720+
json_decode($this->post(sprintf('rest/asset/v1/email/%d/content/{htmlId}.json', $emailId), $args)->getBody())
719721
);
720722
}
721723

@@ -735,7 +737,7 @@ public function approveEmail($emailId, $args = array(), $returnRaw = false)
735737
$args['id'] = $emailId;
736738

737739
return new ApproveEmailResponse(
738-
$this->post(sprintf('rest/asset/v1/email/%d/approveDraft.json', $emailId), $args)
740+
json_decode($this->post(sprintf('rest/asset/v1/email/%d/approveDraft.json', $emailId), $args)->getBody())
739741
);
740742
}
741743
}

src/Response.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @author Daniel Chesterton <[email protected]>
2020
*/
21-
class Response implements ResponseClassInterface
21+
class Response
2222
{
2323
/**
2424
* @var array
@@ -76,12 +76,4 @@ public function getError()
7676

7777
return null;
7878
}
79-
80-
/**
81-
* {@inheritdoc}
82-
*/
83-
public static function fromCommand(OperationCommand $command)
84-
{
85-
return new static($command->getResponse()->json());
86-
}
8779
}

0 commit comments

Comments
 (0)