Skip to content

Commit 7e5f9ce

Browse files
committed
Update
1 parent 138d814 commit 7e5f9ce

1 file changed

Lines changed: 74 additions & 75 deletions

File tree

core/services/CampaignMonitorService.php

Lines changed: 74 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -18,80 +18,6 @@ class CampaignMonitorService extends BaseService {
1818
'Craft\EmailModel'
1919
);
2020

21-
public function registerCpRoutes()
22-
{
23-
return array(
24-
'postmaster/campaignmonitor/lists' => array('action' => 'postmaster/campaignMonitor/getLists'),
25-
);
26-
}
27-
28-
public function getLists()
29-
{
30-
$client = new Client();
31-
32-
$request = $client->get($this->getApiUrl('clients/'.$this->settings->clientId.'/lists'));
33-
34-
$request->setAuth($this->settings->apiKey, '');
35-
36-
try
37-
{
38-
$response = $request->send();
39-
$response = json_decode($response->getBody());
40-
41-
return $response;
42-
}
43-
catch(\Exception $e)
44-
{
45-
throw $e;
46-
}
47-
}
48-
49-
public function subscribe(Array $data = array())
50-
{
51-
$model = new Postmaster_CampaignMonitorSubscriberModel($data);
52-
53-
try
54-
{
55-
$model->subscribe();
56-
57-
return $model;
58-
}
59-
catch(\Exception $e)
60-
{
61-
throw $e;
62-
}
63-
}
64-
65-
public function createCampaign(Array $data = array())
66-
{
67-
try
68-
{
69-
$model = new Postmaster_CampaignMonitorCampaignModel($data);
70-
$model->create();
71-
72-
return $model;
73-
}
74-
catch(\Exception $e)
75-
{
76-
throw $e;
77-
}
78-
}
79-
80-
public function createAndSendCampaign(Array $data = array())
81-
{
82-
try
83-
{
84-
$model = $this->createCampaign($data);
85-
$model->send();
86-
87-
return $model;
88-
}
89-
catch(\Exception $e)
90-
{
91-
throw $e;
92-
}
93-
}
94-
9521
public function send(Postmaster_TransportModel $model)
9622
{
9723
$response = new Postmaster_TransportResponseModel(array(
@@ -100,7 +26,6 @@ public function send(Postmaster_TransportModel $model)
10026

10127
if($this->settings->action == 'createAndSend')
10228
{
103-
10429
try
10530
{
10631
$segmentIds = array();
@@ -179,6 +104,80 @@ public function send(Postmaster_TransportModel $model)
179104
return $response;
180105
}
181106

107+
public function registerCpRoutes()
108+
{
109+
return array(
110+
'postmaster/campaignmonitor/lists' => array('action' => 'postmaster/campaignMonitor/getLists'),
111+
);
112+
}
113+
114+
public function getLists()
115+
{
116+
$client = new Client();
117+
118+
$request = $client->get($this->getApiUrl('clients/'.$this->settings->clientId.'/lists'));
119+
120+
$request->setAuth($this->settings->apiKey, '');
121+
122+
try
123+
{
124+
$response = $request->send();
125+
$response = json_decode($response->getBody());
126+
127+
return $response;
128+
}
129+
catch(\Exception $e)
130+
{
131+
throw $e;
132+
}
133+
}
134+
135+
public function subscribe(Array $data = array())
136+
{
137+
$model = new Postmaster_CampaignMonitorSubscriberModel($data);
138+
139+
try
140+
{
141+
$model->subscribe();
142+
143+
return $model;
144+
}
145+
catch(\Exception $e)
146+
{
147+
throw $e;
148+
}
149+
}
150+
151+
public function createCampaign(Array $data = array())
152+
{
153+
try
154+
{
155+
$model = new Postmaster_CampaignMonitorCampaignModel($data);
156+
$model->create();
157+
158+
return $model;
159+
}
160+
catch(\Exception $e)
161+
{
162+
throw $e;
163+
}
164+
}
165+
166+
public function createAndSendCampaign(Array $data = array())
167+
{
168+
try
169+
{
170+
$model = $this->createCampaign($data);
171+
$model->send();
172+
173+
return $model;
174+
}
175+
catch(\Exception $e)
176+
{
177+
throw $e;
178+
}
179+
}
180+
182181
public function getInputHtml(Array $data = array())
183182
{
184183
return $this->craft()->templates->render('postmaster/services/campaignmonitor/settings', $data);

0 commit comments

Comments
 (0)