| 227 | } |
| 228 | |
| 229 | func parseCodexDevicePollInterval(raw json.RawMessage) time.Duration { |
| 230 | defaultInterval := time.Duration(codexDeviceDefaultPollIntervalSeconds) * time.Second |
| 231 | if len(raw) == 0 { |
| 232 | return defaultInterval |
| 233 | } |
| 234 | |
| 235 | var asString string |
| 236 | if err := json.Unmarshal(raw, &asString); err == nil { |
| 237 | if seconds, convErr := strconv.Atoi(strings.TrimSpace(asString)); convErr == nil && seconds > 0 { |
| 238 | return time.Duration(seconds) * time.Second |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | var asInt int |
| 243 | if err := json.Unmarshal(raw, &asInt); err == nil && asInt > 0 { |
| 244 | return time.Duration(asInt) * time.Second |
| 245 | } |
| 246 | |
| 247 | return defaultInterval |
| 248 | } |
| 249 | |
| 250 | func codexDeviceIsSuccessStatus(code int) bool { |
| 251 | return code >= 200 && code < 300 |