1 | <?php namespace Qualia\Submission; |
||
15 | class Entry |
||
16 | { |
||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $additional; |
||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $data; |
||
25 | /** |
||
26 | * @var \Qualia\Client |
||
27 | */ |
||
28 | private $client; |
||
29 | |||
30 | |||
31 | 54 | private function __construct(Client $client) { |
|
38 | |||
39 | /** |
||
40 | * Build a configuration |
||
41 | * |
||
42 | * @param \Qualia\Client $client |
||
43 | * @return \Qualia\Submission\Entry |
||
44 | */ |
||
45 | 54 | public static function build(Client $client) |
|
49 | |||
50 | /** |
||
51 | * Provide an unique identifier for an entry. It can be either string or integer e.g. incremental id from your database |
||
52 | * This ensures you are not submitting the entry twice and even if you do submit it, it will update the previous entry |
||
53 | * rather than creating a new one. |
||
54 | * |
||
55 | * @param $identifier |
||
56 | * @return $this |
||
57 | */ |
||
58 | 20 | public function uniqueId($identifier) |
|
64 | |||
65 | /** |
||
66 | * Provide a language for an entry. e.g. 'en', 'es', 'pt' |
||
67 | * |
||
68 | * @param $language |
||
69 | * @return $this |
||
70 | */ |
||
71 | 12 | public function language($language) |
|
77 | |||
78 | /** |
||
79 | * Append name question |
||
80 | * |
||
81 | * @param $id Question identifier |
||
82 | * @param $firstName First name |
||
83 | * @param null $lastName Last name |
||
84 | * @return $this |
||
85 | */ |
||
86 | 6 | public function name($id, $firstName = null, $lastName = null) { |
|
95 | |||
96 | /** |
||
97 | * Append email question |
||
98 | * |
||
99 | * @param $id Question identifier |
||
100 | * @param $address E-mail address |
||
101 | * @return $this |
||
102 | */ |
||
103 | 30 | public function email($id, $address) { |
|
108 | |||
109 | |||
110 | /** |
||
111 | * Append date question |
||
112 | * |
||
113 | * @param $id Question identifier |
||
114 | * @param $date Date in Y-m-d format |
||
115 | * @return $this |
||
116 | */ |
||
117 | 24 | public function date($id, $date) |
|
127 | |||
128 | /** |
||
129 | * Append any other type of response |
||
130 | * |
||
131 | * @param $id Question identifier |
||
132 | * @param $response Response to a question |
||
133 | * @return $this |
||
134 | */ |
||
135 | 12 | public function response($id, $response) |
|
141 | |||
142 | /** |
||
143 | * Once we have everything added, we can submit. |
||
144 | * |
||
145 | * @param bool $markComplete If you would like submit the survey and mark it as completed,please set this field to true, |
||
146 | * otherwise, survey will not be marked as completed and an email will be sent to the user |
||
147 | * asking to complete the rest of the survey. |
||
148 | * |
||
149 | * Depending on survey distribution channels this may vary: |
||
150 | * Institution may have an Enrollment form enabled where it collects some data on site, |
||
151 | * some through this API, some maybe shared in social media. If that's the case, must likely |
||
152 | * you do not need to mark it as completed. |
||
153 | * |
||
154 | * However, |
||
155 | * If all responses are collected via this API and second survey is send later, you may |
||
156 | * need to mark it as completed. |
||
157 | * @return array |
||
158 | * @throws \Qualia\Exceptions\RequestException |
||
159 | */ |
||
160 | 48 | public function send($markComplete = false) |
|
168 | |||
169 | } |