Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from khanmassab/master
Browse files Browse the repository at this point in the history
Added Guage::Needle Functionalities (Show, Update)
  • Loading branch information
adminbelvedere authored Feb 26, 2024
2 parents 4603b43 + d3c9ccb commit fb1e568
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ $projects = Basecamp::projects()->index($nextPage);
- [Documents](https://github.com/coopbelvedere/laravel-basecamp-api/blob/master/docs/documents.md)
- [Events](https://github.com/coopbelvedere/laravel-basecamp-api/blob/master/docs/events.md)
- [Forwards](https://github.com/coopbelvedere/laravel-basecamp-api/blob/master/docs/forwards.md)
- [Needles](https://github.com/coopbelvedere/laravel-basecamp-api/blob/master/docs/needles.md)
- [Inboxes](https://github.com/coopbelvedere/laravel-basecamp-api/blob/master/docs/inboxes.md)
- [Message Boards](https://github.com/coopbelvedere/laravel-basecamp-api/blob/master/docs/message_boards.md)
- [Message types](https://github.com/coopbelvedere/laravel-basecamp-api/blob/master/docs/message_types.md)
Expand Down
24 changes: 24 additions & 0 deletions docs/needles.md
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);
```
1 change: 1 addition & 0 deletions docs/projects.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ $project->schedule();
$project->questionnaire();
$project->vault();
$project->inbox();
$project->needle();

// Client items
$project->clientApprovals();
Expand Down
35 changes: 35 additions & 0 deletions src/Models/Needle.php
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;
}

}
10 changes: 10 additions & 0 deletions src/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@ public function clientCorrespondences()
return Basecamp::clientCorrespondences($this->id);
}

/**
* Get the project's client needle state.
*
* @return \Illuminate\Http\Collection
*/
public function needle()
{
return Basecamp::needles($this->id);
}

/**
* Update the project.
*
Expand Down
28 changes: 28 additions & 0 deletions src/Sections/Needles.php
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));
}
}

0 comments on commit fb1e568

Please sign in to comment.