This repository has been archived by the owner on Apr 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Guage::Needle Functionalities (Show, Update)
- Loading branch information
1 parent
4603b43
commit d3c9ccb
Showing
6 changed files
with
99 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Needles | ||
|
||
|
||
# Get the needle state | ||
|
||
```php | ||
$needle = Basecamp::needles()->show($project_id); | ||
``` | ||
|
||
## Update the needle state | ||
|
||
```php | ||
|
||
$data = [ | ||
"gauge_needle[position]" => 50 | ||
"gauge_needle[color]" => "green" | ||
"gauge_needle[description]" => "Hello World" | ||
]; | ||
|
||
$needle->update($data); | ||
|
||
// Or update the state with Project ID. | ||
Basecamp::needles()->update($project_id, $data); | ||
``` |
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,35 @@ | ||
<?php | ||
|
||
namespace Belvedere\Basecamp\Models; | ||
|
||
use Basecamp; | ||
|
||
class Needle extends AbstractModel | ||
{ | ||
/** | ||
* Get the Needle State. | ||
* | ||
* @param array $data | ||
* @return \Illuminate\Http\Collection | ||
*/ | ||
public function show($project_id) | ||
{ | ||
return Basecamp::needles()->show($this->project_id); | ||
} | ||
|
||
/** | ||
* Update the Needle State. | ||
* | ||
* @param array $data | ||
* @return \Illuminate\Http\Collection | ||
*/ | ||
public function update(array $data) | ||
{ | ||
$needle = Basecamp::needles()->update($this->project_id, $data); | ||
|
||
$this->setAttributes($needle); | ||
|
||
return $needle; | ||
} | ||
|
||
} |
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,28 @@ | ||
<?php | ||
|
||
namespace Belvedere\Basecamp\Sections; | ||
|
||
use Belvedere\Basecamp\Models\Needle; | ||
|
||
class Needles extends AbstractSection | ||
{ | ||
/** | ||
* Get the needle. | ||
* | ||
* @param int $id | ||
* @return \Belvedere\Basecamp\Models\Needle | ||
*/ | ||
public function show($id) | ||
{ | ||
return new Needle($this->client->get(sprintf('projects/%d/gauge/needles.json', $id))); | ||
} | ||
|
||
public function update($id, array $data) | ||
{ | ||
$needle = $this->client->post(sprintf('projects/%d/gauge/needles.json', $id), [ | ||
'json' => $data, | ||
]); | ||
|
||
return new Needle($this->response($needle)); | ||
} | ||
} |