-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* release/1.8.0: Updated README and CHANGELOG for the 1.8.0 release Fix issue where a null response body in `checkStatus` would trigger a type violation on `getErrorMessage` Fix syntax issues for PHP 5.3 and 5.4 Add validation for custom field responses Add support for custom fields returned via a mailbox or conversation
- Loading branch information
Showing
19 changed files
with
557 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
namespace HelpScout; | ||
|
||
use HelpScout\model\ref\customfields\DateFieldRef; | ||
use HelpScout\model\ref\customfields\DropdownFieldRef; | ||
use HelpScout\model\ref\customfields\MultiLineFieldRef; | ||
use HelpScout\model\ref\customfields\NumberFieldRef; | ||
use HelpScout\model\ref\customfields\SingleLineFieldRef; | ||
|
||
class CustomFieldFactory | ||
{ | ||
public static function fromMailbox(array $attributes) | ||
{ | ||
$map = array( | ||
'fieldName' => 'name' | ||
); | ||
|
||
return static::createField( | ||
$attributes['fieldType'], | ||
static::mapAttributes($attributes, $map) | ||
); | ||
} | ||
|
||
public static function fromConversation(array $attributes) | ||
{ | ||
$map = array( | ||
'fieldId' => 'id' | ||
); | ||
|
||
return static::createField( | ||
$attributes['type'], | ||
static::mapAttributes($attributes, $map) | ||
); | ||
} | ||
|
||
public static function createField($type, array $attributes) | ||
{ | ||
$attributes = (object) $attributes; | ||
switch ($type) { | ||
case 'SINGLE_LINE' : | ||
return new SingleLineFieldRef($attributes); | ||
break; | ||
case 'MULTI_LINE' : | ||
return new MultiLineFieldRef($attributes); | ||
break; | ||
case 'DROPDOWN' : | ||
return new DropdownFieldRef($attributes); | ||
break; | ||
case 'DATE' : | ||
return new DateFieldRef($attributes); | ||
break; | ||
case 'NUMBER' : | ||
return new NumberFieldRef($attributes); | ||
break; | ||
} | ||
|
||
throw new \InvalidArgumentException($type . ' is not a supported Custom Field type.'); | ||
} | ||
|
||
protected static function mapAttributes(array $attributes, array $map) | ||
{ | ||
$temp = array(); | ||
|
||
foreach ($attributes as $key => $value) { | ||
if (array_key_exists($key, $map)) { | ||
$temp[$map[$key]] = $value; | ||
} else { | ||
$temp[$key] = $value; | ||
} | ||
} | ||
|
||
return $temp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
namespace HelpScout; | ||
|
||
class ValidationException extends \Exception | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.