Skip to content

Commit

Permalink
readme updates, docblocs for some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
John Hutcheson committed Jul 18, 2018
1 parent eaf8d15 commit 87f113e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
12 changes: 8 additions & 4 deletions README.md
Expand Up @@ -73,11 +73,16 @@ composer require jhut89/mailchimp3php

Alternatively you may add a require line to your projects `composer.json` for the package `jhut89/mailchimp3php`.

Then run `composer update` and add composer autoloader to your project with:
Then run `composer update` and add the composer autoloader to your project with:

```php
require "vendor/autoload.php";
```

You can then use a use statement to pull in the Mailchimp class:
```php
use MailchimpAPI\Mailchimp;
```
## Instantiation

```php
Expand All @@ -101,7 +106,7 @@ Mailchimp::getAuthUrl($client_id, $redirect_url);

From there the user will input their username and password to approve your application and will be redirected to the `redirect_uri` you set along with a `code`.

With that `code` you can now request an access token from mailchimp. You will need to call the `Mailchimp::oauthExchange()` method statically like this:
With that `code` you can now request an access token from mailchimp. For this you will need to call the `Mailchimp::oauthExchange()` method statically like this:

```php
$code = 'abc123abc123abc123abc123';
Expand Down Expand Up @@ -241,7 +246,6 @@ There are a number of getters we can use to interact with pieces our `MailchimpR

```php
$response->deserialize(); // returns a deserialized (to php object) resource returned by API
$response->getRaw(); // return the raw text response
$response->getHttpCode(); // returns an integer representation of the HTTP response code
$response->getHeaders(); // returns response headers as an array of key => value pairs
$response->getBody(); // return the raw text body of the response
Expand All @@ -259,7 +263,7 @@ $contact_email = $account
->deserialize()
->email

print $email; // outputs something like "example@domain.com"
print $contact_email; // outputs something like "example@domain.com"
```

## <a name="method-chart-heading"></a>Method Chart (\*excluding verbs)
Expand Down
35 changes: 35 additions & 0 deletions tests/UtilityTests/MailchimpConnectionTest.php
Expand Up @@ -7,20 +7,43 @@
use MailchimpAPI\Utilities\MailchimpSettings;
use MailchimpTests\MailChimpTestCase;

/**
* Class MailchimpConnectionTest
* @package MailchimpTests\UtilityTests
*/
final class MailchimpConnectionTest extends MailChimpTestCase
{
/**
* @var MailchimpSettings
*/
protected $settings;
/**
* @var MailchimpRequest
*/
protected $request;

/**
* testable header string
*/
const HEADER_STRING = "Foo: Bar";

/**
* @var array
*/
private static $post_params = [
"email_address" => "example@domain.com",
"merge_fields" => [
"FNAME" => "Jane"
]
];

/**
* MailchimpConnectionTest constructor.
* @param null $name
* @param array $data
* @param string $dataName
* @throws \MailchimpAPI\MailchimpException
*/
public function __construct($name = null, array $data = [], $dataName = '')
{
parent::__construct($name, $data, $dataName);
Expand Down Expand Up @@ -60,6 +83,9 @@ public function testGetConnection()
);
}

/**
* @throws \MailchimpAPI\MailchimpException
*/
public function testPostConnection()
{
$request = $this->request;
Expand All @@ -78,6 +104,9 @@ public function testPostConnection()
);
}

/**
* @throws \MailchimpAPI\MailchimpException
*/
public function testPatchConnection()
{
$request = $this->request;
Expand All @@ -100,6 +129,9 @@ public function testPatchConnection()
);
}

/**
* @throws \MailchimpAPI\MailchimpException
*/
public function testPutConnection()
{
$request = $this->request;
Expand All @@ -122,6 +154,9 @@ public function testPutConnection()
);
}

/**
* @throws \MailchimpAPI\MailchimpException
*/
public function testDeleteConnection()
{
$request = $this->request;
Expand Down

0 comments on commit 87f113e

Please sign in to comment.