Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
Merge branch 'release/v0.5.7'
Browse files Browse the repository at this point in the history
* release/v0.5.7:
  Bump version to v0.5.7
  Added support for additional attachment properties
  • Loading branch information
mcrumm committed Oct 8, 2015
2 parents c9cfbe5 + 87cc3a4 commit 02d456c
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,10 @@
Changelog
=========

### `v0.5.7` (2015-10-08)

* Adds support for additional Attachment properties: `author_name`, `author_link`, `author_icon`, `title`, `title_link`, `image_url`, `thumb_url`, `mrkdwn_in` (Courtesy @errodr)

### `v0.5.6` (2015-08-14)

* Add support for sending direct messages to a user. (Courtesy @atomasevic)
Expand Down
2 changes: 1 addition & 1 deletion bin/phlackbot
Expand Up @@ -2,7 +2,7 @@
<?php

define('PHLACKBOT_NAME', 'phlackbot');
define('PHLACKBOT_VERSION', '0.5.6-PREVIEW');
define('PHLACKBOT_VERSION', '0.5.7-PREVIEW');

if (is_dir($vendor = getcwd() . '/vendor')) {
require $vendor . '/autoload.php';
Expand Down
8 changes: 8 additions & 0 deletions spec/Crummy/Phlack/Builder/AttachmentBuilderSpec.php
Expand Up @@ -25,6 +25,14 @@ function it_provides_a_fluent_interface()
$this->setText('text')->shouldReturn($this);
$this->setPretext('pretext')->shouldReturn($this);
$this->setColor('danger')->shouldReturn($this);
$this->setAuthorName('author name')->shouldReturn($this);
$this->setAuthorLink('author link')->shouldReturn($this);
$this->setAuthorIcon('http://domain.com/icon.png')->shouldReturn($this);
$this->setTitle('title')->shouldReturn($this);
$this->setTitleLink('http://www.title-link.com/')->shouldReturn($this);
$this->setImageUrl('http://domain.com/image.png')->shouldReturn($this);
$this->setThumbUrl('http://domain.com/thumb.png')->shouldReturn($this);
$this->setMrkdwnIn(['text', 'pretext'])->shouldReturn($this);
}

function it_fails_on_empty_fallback()
Expand Down
8 changes: 8 additions & 0 deletions spec/Crummy/Phlack/Message/AttachmentSpec.php
Expand Up @@ -30,6 +30,14 @@ function it_provides_a_fluent_interface()
$this->setText('text')->shouldReturn($this);
$this->setPretext('pretext')->shouldReturn($this);
$this->setColor('danger')->shouldReturn($this);
$this->setAuthorName('author name')->shouldReturn($this);
$this->setAuthorLink('author link')->shouldReturn($this);
$this->setAuthorIcon('http://domain.com/icon.png')->shouldReturn($this);
$this->setTitle('title')->shouldReturn($this);
$this->setTitleLink('http://www.title-link.com/')->shouldReturn($this);
$this->setImageUrl('http://domain.com/image.png')->shouldReturn($this);
$this->setThumbUrl('http://domain.com/thumb.png')->shouldReturn($this);
$this->setMrkdwnIn(['text', 'pretext'])->shouldReturn($this);
}

function it_contains_a_field_collection()
Expand Down
72 changes: 72 additions & 0 deletions src/Crummy/Phlack/Builder/AttachmentBuilder.php
Expand Up @@ -69,6 +69,78 @@ public function setColor($color)
return $this->setParameter('color', $color);
}

/**
* @param $author_name
* @return $this
*/
public function setAuthorName($author_name)
{
return $this->setParameter('author_name', $author_name);
}

/**
* @param $author_link
* @return $this
*/
public function setAuthorLink($author_link)
{
return $this->setParameter('author_link', $author_link);
}

/**
* @param $author_icon
* @return $this
*/
public function setAuthorIcon($author_icon)
{
return $this->setParameter('author_icon', $author_icon);
}

/**
* @param $title
* @return $this
*/
public function setTitle($title)
{
return $this->setParameter('title', $title);
}

/**
* @param $title_link
* @return $this
*/
public function setTitleLink($title_link)
{
return $this->setParameter('title_link', $title_link);
}

/**
* @param $image_url
* @return $this
*/
public function setImageUrl($image_url)
{
return $this->setParameter('image_url', $image_url);
}

/**
* @param $thumb_url
* @return $this
*/
public function setThumbUrl($thumb_url)
{
return $this->setParameter('thumb_url', $thumb_url);
}

/**
* @param $mrkdwn_in
* @return $this
*/
public function setMrkdwnIn($mrkdwn_in)
{
return $this->setParameter('mrkdwn_in', $mrkdwn_in);
}

/**
* Sets values on non-empty parameters.
* Set $value to null to remove the custom value.
Expand Down
82 changes: 81 additions & 1 deletion src/Crummy/Phlack/Message/Attachment.php
Expand Up @@ -8,7 +8,7 @@
class Attachment extends Partial implements AttachmentInterface
{
protected $required = [ 'fallback' ];
protected $optional = [ 'text', 'pretext', 'color', 'fields' ];
protected $optional = [ 'text', 'pretext', 'color', 'fields', 'author_name', 'author_link', 'author_icon', 'title', 'title_link', 'image_url', 'thumb_url', 'mrkdwn_in' ];

/**
* {@inheritDoc}
Expand Down Expand Up @@ -106,4 +106,84 @@ public function getFields()
{
return $this['fields'];
}

/**
* @param $author_name
* @return $this
*/
public function setAuthorName($author_name)
{
$this['author_name'] = (string)$author_name;
return $this;
}

/**
* @param $author_link
* @return $this
*/
public function setAuthorLink($author_link)
{
$this['author_link'] = (string)$author_link;
return $this;
}

/**
* @param $author_icon
* @return $this
*/
public function setAuthorIcon($author_icon)
{
$this['author_icon'] = (string)$author_icon;
return $this;
}

/**
* @param $title
* @return $this
*/
public function setTitle($title)
{
$this['title'] = (string)$title;
return $this;
}

/**
* @param $title_link
* @return $this
*/
public function setTitleLink($title_link)
{
$this['title_link'] = (string)$title_link;
return $this;
}

/**
* @param $image_url
* @return $this
*/
public function setImageUrl($image_url)
{
$this['image_url'] = (string)$image_url;
return $this;
}

/**
* @param $thumb_url
* @return $this
*/
public function setThumbUrl($thumb_url)
{
$this['thumb_url'] = (string)$thumb_url;
return $this;
}

/**
* @param $mrkdwn_in
* @return $this
*/
public function setMrkdwnIn($mrkdwn_in)
{
$this['mrkdwn_in'] = $mrkdwn_in;
return $this;
}
}

0 comments on commit 02d456c

Please sign in to comment.