Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor improvements: silent option for app requests + fix external_id … #181

Merged
merged 1 commit into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions models/PodioApp.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ public static function get_for_space($space_id, $attributes = array()) {
/**
* @see https://developers.podio.com/doc/applications/add-new-app-22351
*/
public static function create($attributes = array()) {
return self::member(Podio::post("/app/", $attributes));
public static function create($attributes = array(), $silent = false) {
return self::member(Podio::post(Podio::url_with_options("/app/", array('silent' => $silent)), $attributes));
}

/**
* @see https://developers.podio.com/doc/applications/update-app-22352
*/
public static function update($app_id, $attributes = array()) {
return Podio::put("/app/{$app_id}", $attributes);
public static function update($app_id, $attributes = array(), $silent = false) {
return Podio::put(Podio::url_with_options("/app/{$app_id}", array('silent' => $silent)), $attributes);
}

/**
* @see https://developers.podio.com/doc/applications/delete-app-43693
*/
public static function delete($app_id) {
return Podio::delete("/app/{$app_id}");
public static function delete($app_id, $silent = false) {
return Podio::delete(Podio::url_with_options("/app/{$app_id}", array('silent' => $silent)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion models/PodioComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public function __construct($attributes = array()) {
$this->property('comment_id', 'integer', array('id' => true));
$this->property('value', 'string');
$this->property('rich_value', 'string');
$this->property('external_id', 'integer');
$this->property('external_id', 'string');
$this->property('space_id', 'integer');
$this->property('created_on', 'datetime');
$this->property('like_count', 'integer');
Expand Down
12 changes: 11 additions & 1 deletion models/field/PodioTagItemField.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,17 @@ class PodioTagItemField extends PodioItemField

public function api_friendly_values()
{
return $this->values !== null ? $this->values : null;
return $this->values ? $this->values : array();
}

public function humanized_value()
{
if (!$this->values) {
return '';
}
return join(';', array_map(function ($value) {
return $value['value'];
}, $this->values));
}

}
23 changes: 23 additions & 0 deletions tests/PodioCalculationItemFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,31 @@ public function setup() {
));
$this->empty_values = new PodioCalculationItemField(array('field_id' => 1));
$this->zero_value = new PodioCalculationItemField(array('__api_values' => true, 'field_id' => 2, 'values' => array(array('value' => '0'))));
$this->date_value = new PodioCalculationItemField(array(
'__api_values' => true,
'field_id' => 3,
'values' => array(array(
'start' => '2016-11-11 00:00:00',
'start_date_utc' => '2016-11-11',
'start_time_utc' => '00:00:00',
'start_time' => '00:00:00',
'start_utc' => '2016-11-11 00:00:00',
'start_date' => '2016-11-11'
))));
}

public function test_can_provide_value() {
$this->assertNull($this->empty_values->values);
$this->assertEquals('1234.5600', $this->object->values);
$this->assertEquals('0', $this->zero_value->values);
$this->assertEquals(array(
'start' => '2016-11-11 00:00:00',
'start_date_utc' => '2016-11-11',
'start_time_utc' => '00:00:00',
'start_time' => '00:00:00',
'start_utc' => '2016-11-11 00:00:00',
'start_date' => '2016-11-11'
), $this->date_value->values);
}

public function test_cannot_modify_value() {
Expand All @@ -28,12 +47,16 @@ public function test_can_humanize_value() {
$this->assertEquals('', $this->empty_values->humanized_value());
$this->assertEquals('1234.56', $this->object->humanized_value());
$this->assertEquals('0', $this->zero_value->humanized_value());
// cannot humanize value for date ($this->date_value)
}

public function test_can_convert_to_api_friendly_json() {
$this->assertEquals('null', $this->empty_values->as_json());
$this->assertEquals('"1234.5600"', $this->object->as_json());
$this->assertEquals('"0"', $this->zero_value->as_json());
$date_value_json = '{"start":"2016-11-11 00:00:00","start_date_utc":"2016-11-11","start_time_utc":"00:00:00",' .
'"start_time":"00:00:00","start_utc":"2016-11-11 00:00:00","start_date":"2016-11-11"}';
$this->assertEquals('' . $date_value_json . '', $this->date_value->as_json());
}

}