Skip to content

Commit 2564441

Browse files
committed
added a way to get subscribers by type
phpdoc blocks
1 parent e6a3b51 commit 2564441

File tree

8 files changed

+79
-9
lines changed

8 files changed

+79
-9
lines changed

src/Api/Campaigns.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
use MailerLiteApi\Common\ApiAbstract;
66

7+
/**
8+
* Class Campaigns
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
712
class Campaigns extends ApiAbstract {
813

914
protected $endpoint = 'campaigns';
@@ -78,4 +83,4 @@ public function get($type = 'sent', $fields = ['*'])
7883

7984
return $entities;
8085
}
81-
}
86+
}

src/Api/Fields.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
use MailerLiteApi\Common\ApiAbstract;
66

7+
/**
8+
* Class Fields
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
712
class Fields extends ApiAbstract {
813

914
protected $endpoint = 'fields';
@@ -15,4 +20,4 @@ public function getAccountFields() {
1520
return $response['body'];
1621
}
1722

18-
}
23+
}

src/Api/Groups.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
use MailerLiteApi\Common\ApiAbstract;
66

7+
/**
8+
* Class Groups
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
712
class Groups extends ApiAbstract {
813

914
protected $endpoint = 'groups';
@@ -102,4 +107,4 @@ public function importSubscribers(
102107

103108
return $response['body'];
104109
}
105-
}
110+
}

src/Api/Segments.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44

55
use MailerLiteApi\Common\ApiAbstract;
66

7+
/**
8+
* Class Segments
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
712
class Segments extends ApiAbstract {
813

914
protected $endpoint = 'segments';
1015

11-
}
16+
}

src/Api/Settings.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
use MailerLiteApi\Common\ApiAbstract;
66

7+
/**
8+
* Class Settings
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
712
class Settings extends ApiAbstract {
813

914
protected $endpoint = 'settings';
@@ -33,4 +38,4 @@ public function setDoubleOptin( $status ) {
3338
return $response['body'];
3439
}
3540

36-
}
41+
}

src/Api/Stats.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
use MailerLiteApi\Common\ApiAbstract;
66

7+
/**
8+
* Class Stats
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
712
class Stats extends ApiAbstract {
813

914
protected $endpoint = 'stats';
@@ -22,4 +27,4 @@ public function getHistorical($timestamp)
2227
return $response['body'];
2328
}
2429

25-
}
30+
}

src/Api/Subscribers.php

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@
44

55
use MailerLiteApi\Common\ApiAbstract;
66

7+
/**
8+
* Class Subscribers
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
712
class Subscribers extends ApiAbstract {
813

14+
const TYPE_ACTIVE = 'active';
15+
const TYPE_UNSUBSCRIBED = 'unsubscribed';
16+
const TYPE_BOUNCED = 'bounced';
17+
const TYPE_JUNK = 'junk';
18+
const TYPE_UNCONFIRMED = 'unconfirmed';
19+
920
protected $endpoint = 'subscribers';
1021

1122
/**
@@ -66,4 +77,29 @@ public function search($query)
6677
return $response['body'];
6778
}
6879

69-
}
80+
/**
81+
* Get all subscribers
82+
*
83+
* @param string[] $fields
84+
* @param null|string $type
85+
*
86+
* @return \MailerLiteApi\Common\Collection
87+
*/
88+
public function get($fields = ['*'], $type = null)
89+
{
90+
$params = $this->prepareParams();
91+
92+
if ( ! empty($fields) && is_array($fields) && $fields != ['*']) {
93+
$params['fields'] = $fields;
94+
}
95+
96+
if ($type !== null) {
97+
$params['type'] = $type;
98+
}
99+
100+
$response = $this->restClient->get($this->endpoint, $params);
101+
102+
return $this->generateCollection($response['body']);
103+
}
104+
105+
}

src/Api/WooCommerce.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<?php
22

3-
43
namespace MailerLiteApi\Api;
54

65
use MailerLiteApi\Common\ApiAbstract;
76

7+
/**
8+
* Class WooCommerce
9+
*
10+
* @package MailerLiteApi\Api
11+
*/
812
class WooCommerce extends ApiAbstract
913
{
1014
protected $endpoint = 'woocommerce';
@@ -101,4 +105,4 @@ public function validateAccount()
101105
$endpoint = 'woocommerce/initial_account_settings';
102106
return $this->restClient->get($endpoint);
103107
}
104-
}
108+
}

0 commit comments

Comments
 (0)