Skip to content

Commit 87a1032

Browse files
author
Eimantas
committed
Added composer support
2 parents 9caf825 + a65ca0f commit 87a1032

File tree

11 files changed

+273
-250
lines changed

11 files changed

+273
-250
lines changed

PHP/ML_Campaigns.php

Lines changed: 0 additions & 57 deletions
This file was deleted.

PHP/ML_Lists.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

PHP/ML_Subscribers.php

Lines changed: 0 additions & 59 deletions
This file was deleted.

PHP/base/ML_Rest.php

Lines changed: 0 additions & 61 deletions
This file was deleted.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MailerLite REST API v1
2+
3+
Official PHP wrapper for MailerLite API
4+
5+
## Installation
6+
7+
### With Composer
8+
9+
Add `mailerlite/mailerlite_rest_v1` to `composer.json`.
10+
11+
```json
12+
{
13+
"require": {
14+
"mailerlite/mailerlite_rest_v1": "1.1.*"
15+
}
16+
}
17+
```
18+
19+
## Contributors
20+
21+
https://github.com/paulschwarz/

composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "mailerlite/mailerlite_rest_v1",
3+
"type": "library",
4+
"description": "MailerLite PHP API Wrapper",
5+
"keywords": ["mailerlite"],
6+
"require": {
7+
"php": ">=5.3"
8+
},
9+
"autoload": {
10+
"psr-0": {
11+
"MailerLite": "src/"
12+
}
13+
}
14+
}

src/MailerLite/Base/Rest.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace MailerLite\Base;
4+
5+
use InvalidArgumentException;
6+
7+
class Rest extends RestBase {
8+
9+
protected
10+
$name = '',
11+
$id = null;
12+
13+
function __construct($apiKey)
14+
{
15+
parent::__construct();
16+
$this->apiKey = $apiKey;
17+
$this->path = $this->url . $this->name . '/';
18+
}
19+
20+
function setId($id)
21+
{
22+
$this->id = $id;
23+
if ($this->id)
24+
{
25+
$this->path = $this->url . $this->name . '/' . $id . '/';
26+
}
27+
else
28+
{
29+
$this->path = $this->url . $this->name . '/';
30+
}
31+
return $this;
32+
}
33+
34+
function getAll()
35+
{
36+
return $this->execute('GET');
37+
}
38+
39+
function get()
40+
{
41+
if ( ! $this->id)
42+
{
43+
throw new InvalidArgumentException('ID is not set.');
44+
}
45+
return $this->execute('GET');
46+
}
47+
48+
function add($data = null)
49+
{
50+
return $this->execute('POST', $data);
51+
}
52+
53+
function put($data = null)
54+
{
55+
return $this->execute('PUT', $data);
56+
}
57+
58+
function remove()
59+
{
60+
return $this->execute('DELETE');
61+
}
62+
63+
}

0 commit comments

Comments
 (0)