| @@ 57-67 (lines=11) @@ | ||
| 54 | * |
|
| 55 | * @return \Acquia\LiftClient\Entity\Goal |
|
| 56 | */ |
|
| 57 | public function get( |
|
| 58 | $id |
|
| 59 | ) { |
|
| 60 | $url = "/goals/{$id}"; |
|
| 61 | ||
| 62 | // Now make the request. |
|
| 63 | $request = new Request('GET', $url); |
|
| 64 | $data = $this->client->getResponseJson($request); |
|
| 65 | ||
| 66 | return new Goal($data); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * Add a goal. |
|
| @@ 80-89 (lines=10) @@ | ||
| 77 | * |
|
| 78 | * @return \Acquia\LiftClient\Entity\Goal |
|
| 79 | */ |
|
| 80 | public function add( |
|
| 81 | Goal $goal |
|
| 82 | ) { |
|
| 83 | $body = $goal->json(); |
|
| 84 | $url = '/goals'; |
|
| 85 | $request = new Request('POST', $url, [], $body); |
|
| 86 | $data = $this->client->getResponseJson($request); |
|
| 87 | ||
| 88 | return new Goal($data); |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * Deletes a goal by ID. |
|
| @@ 87-96 (lines=10) @@ | ||
| 84 | * |
|
| 85 | * @return \Acquia\LiftClient\Entity\Slot |
|
| 86 | */ |
|
| 87 | public function add( |
|
| 88 | Slot $slot |
|
| 89 | ) { |
|
| 90 | $body = $slot->json(); |
|
| 91 | $url = '/slots'; |
|
| 92 | $request = new Request('POST', $url, [], $body); |
|
| 93 | $data = $this->client->getResponseJson($request); |
|
| 94 | ||
| 95 | return new Slot($data); |
|
| 96 | } |
|
| 97 | ||
| 98 | /** |
|
| 99 | * Deletes a slot by ID. |
|
| @@ 66-76 (lines=11) @@ | ||
| 63 | * |
|
| 64 | * @return \Acquia\LiftClient\Entity\Slot |
|
| 65 | */ |
|
| 66 | public function get( |
|
| 67 | $id |
|
| 68 | ) { |
|
| 69 | $url = "/slots/{$id}"; |
|
| 70 | ||
| 71 | // Now make the request. |
|
| 72 | $request = new Request('GET', $url); |
|
| 73 | $data = $this->client->getResponseJson($request); |
|
| 74 | ||
| 75 | return new Slot($data); |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * Add a slot. |
|
| @@ 70-80 (lines=11) @@ | ||
| 67 | * |
|
| 68 | * @return \Acquia\LiftClient\Entity\Rule |
|
| 69 | */ |
|
| 70 | public function get( |
|
| 71 | $id |
|
| 72 | ) { |
|
| 73 | $url = "/rules/{$id}"; |
|
| 74 | ||
| 75 | // Now make the request. |
|
| 76 | $request = new Request('GET', $url); |
|
| 77 | $data = $this->client->getResponseJson($request); |
|
| 78 | ||
| 79 | return new Rule($data); |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Add a rule. |
|
| @@ 93-102 (lines=10) @@ | ||
| 90 | * |
|
| 91 | * @return \Acquia\LiftClient\Entity\Rule |
|
| 92 | */ |
|
| 93 | public function add( |
|
| 94 | Rule $rule |
|
| 95 | ) { |
|
| 96 | $body = $rule->json(); |
|
| 97 | $url = '/rules'; |
|
| 98 | $request = new Request('POST', $url, [], $body); |
|
| 99 | $data = $this->client->getResponseJson($request); |
|
| 100 | ||
| 101 | return new Goal($data); |
|
| 102 | } |
|
| 103 | ||
| 104 | /** |
|
| 105 | * Deletes a rule by ID. |
|
| @@ 19-34 (lines=16) @@ | ||
| 16 | * |
|
| 17 | * @return \Acquia\LiftClient\Entity\Segment[] |
|
| 18 | */ |
|
| 19 | public function query() |
|
| 20 | { |
|
| 21 | $url = '/segments'; |
|
| 22 | ||
| 23 | // Now make the request. |
|
| 24 | $request = new Request('GET', $url); |
|
| 25 | $data = $this->client->getResponseJson($request); |
|
| 26 | ||
| 27 | // Get them as Segment objects |
|
| 28 | $segments = []; |
|
| 29 | foreach ($data as $dataItem) { |
|
| 30 | $segments[] = new Segment($dataItem); |
|
| 31 | } |
|
| 32 | ||
| 33 | return $segments; |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||