CreateControlProgram creates a control program that is tied to the Account and stores it in the database.
(ctx context.Context, accountID string, change bool, expiresAt time.Time)
| 272 | // CreateControlProgram creates a control program |
| 273 | // that is tied to the Account and stores it in the database. |
| 274 | func (m *Manager) CreateControlProgram(ctx context.Context, accountID string, change bool, expiresAt time.Time) ([]byte, error) { |
| 275 | cp, err := m.createControlProgram(ctx, accountID, change, expiresAt) |
| 276 | if err != nil { |
| 277 | return nil, err |
| 278 | } |
| 279 | err = m.insertAccountControlProgram(ctx, cp) |
| 280 | if err != nil { |
| 281 | return nil, err |
| 282 | } |
| 283 | return cp.controlProgram, nil |
| 284 | } |
| 285 | |
| 286 | func (m *Manager) insertAccountControlProgram(ctx context.Context, progs ...*controlProgram) error { |
| 287 | const q = ` |