| @@ 57-67 (lines=11) @@ | ||
| 54 | * |
|
| 55 | * @return \Acquia\LiftClient\Entity\Goal |
|
| 56 | */ |
|
| 57 | public function get($id) |
|
| 58 | { |
|
| 59 | $url = "/goals/{$id}"; |
|
| 60 | ||
| 61 | // Now make the request. |
|
| 62 | $request = new Request('GET', $url); |
|
| 63 | $data = $this->client->getResponseJson($request); |
|
| 64 | ||
| 65 | return new Goal($data); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * Add a goal. |
|
| 70 | * |
|
| @@ 79-88 (lines=10) @@ | ||
| 76 | * |
|
| 77 | * @return \Acquia\LiftClient\Entity\Goal |
|
| 78 | */ |
|
| 79 | public function add(Goal $goal) |
|
| 80 | { |
|
| 81 | $body = $goal->json(); |
|
| 82 | $url = '/goals'; |
|
| 83 | $request = new Request('POST', $url, [], $body); |
|
| 84 | $data = $this->client->getResponseJson($request); |
|
| 85 | ||
| 86 | return new Goal($data); |
|
| 87 | } |
|
| 88 | ||
| 89 | /** |
|
| 90 | * Deletes a goal by ID. |
|
| 91 | * |
|
| @@ 66-76 (lines=11) @@ | ||
| 63 | * |
|
| 64 | * @return \Acquia\LiftClient\Entity\Slot |
|
| 65 | */ |
|
| 66 | public function get($id) |
|
| 67 | { |
|
| 68 | $url = "/slots/{$id}"; |
|
| 69 | ||
| 70 | // Now make the request. |
|
| 71 | $request = new Request('GET', $url); |
|
| 72 | $data = $this->client->getResponseJson($request); |
|
| 73 | ||
| 74 | return new Slot($data); |
|
| 75 | } |
|
| 76 | ||
| 77 | /** |
|
| 78 | * Add a slot. |
|
| 79 | * |
|
| @@ 86-95 (lines=10) @@ | ||
| 83 | * |
|
| 84 | * @return \Acquia\LiftClient\Entity\Slot |
|
| 85 | */ |
|
| 86 | public function add(Slot $slot) |
|
| 87 | { |
|
| 88 | $body = $slot->json(); |
|
| 89 | $url = '/slots'; |
|
| 90 | $request = new Request('POST', $url, [], $body); |
|
| 91 | $data = $this->client->getResponseJson($request); |
|
| 92 | ||
| 93 | return new Slot($data); |
|
| 94 | } |
|
| 95 | ||
| 96 | /** |
|
| 97 | * Deletes a slot by ID. |
|
| 98 | * |
|
| @@ 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 | ||
| @@ 69-79 (lines=11) @@ | ||
| 66 | * |
|
| 67 | * @return \Acquia\LiftClient\Entity\Rule |
|
| 68 | */ |
|
| 69 | public function get($id) |
|
| 70 | { |
|
| 71 | $url = "/rules/{$id}"; |
|
| 72 | ||
| 73 | // Now make the request. |
|
| 74 | $request = new Request('GET', $url); |
|
| 75 | $data = $this->client->getResponseJson($request); |
|
| 76 | ||
| 77 | return new Rule($data); |
|
| 78 | } |
|
| 79 | ||
| 80 | /** |
|
| 81 | * Add or update a rule. |
|
| 82 | * |
|
| @@ 93-102 (lines=10) @@ | ||
| 90 | * |
|
| 91 | * @return \Acquia\LiftClient\Entity\Rule |
|
| 92 | */ |
|
| 93 | public function add(Rule $rule) |
|
| 94 | { |
|
| 95 | $body = $rule->json(); |
|
| 96 | $url = '/rules'; |
|
| 97 | $request = new Request('POST', $url, [], $body); |
|
| 98 | $data = $this->client->getResponseJson($request); |
|
| 99 | ||
| 100 | return new Rule($data); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Deletes a rule by ID. |
|
| 105 | * |
|