(input: CreateSessionInput)
| 169 | // -------------------------------------------------------------------------- |
| 170 | |
| 171 | async createSession(input: CreateSessionInput): Promise<SiSession> { |
| 172 | const sessionId = `si_${Date.now()}_${uuidv4().slice(0, 8)}`; |
| 173 | |
| 174 | const result = await query( |
| 175 | `INSERT INTO si_sessions ( |
| 176 | session_id, host_type, host_identifier, member_profile_id, brand_name, |
| 177 | user_slack_id, user_email, user_name, user_anonymous_id, identity_consent_granted, |
| 178 | initial_context, campaign_id, offer_id |
| 179 | ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) |
| 180 | RETURNING *`, |
| 181 | [ |
| 182 | sessionId, |
| 183 | input.host_type, |
| 184 | input.host_identifier, |
| 185 | input.member_profile_id || null, |
| 186 | input.brand_name, |
| 187 | input.user_slack_id || null, |
| 188 | input.user_email || null, |
| 189 | input.user_name || null, |
| 190 | input.user_anonymous_id || null, |
| 191 | input.identity_consent_granted || false, |
| 192 | input.initial_context || null, |
| 193 | input.campaign_id || null, |
| 194 | input.offer_id || null, |
| 195 | ] |
| 196 | ); |
| 197 | |
| 198 | return this.deserializeSession(result.rows[0]); |
| 199 | } |
| 200 | |
| 201 | async getSession(sessionId: string): Promise<SiSession | null> { |
| 202 | const result = await query( |
no test coverage detected