Skip to content

Refactor module to use type-safe classes for state management#10

Closed
Claude wants to merge 2 commits intomainfrom
claude/refactor-type-safe-classes
Closed

Refactor module to use type-safe classes for state management#10
Claude wants to merge 2 commits intomainfrom
claude/refactor-type-safe-classes

Conversation

@Claude
Copy link
Copy Markdown
Contributor

@Claude Claude AI commented Mar 31, 2026

Adding Type-Safe Data Object Classes

Extending the type-safe class approach to data objects returned from Snipe-IT API.

Plan:

  • Design data object class architecture (base class + specific classes like Asset)
  • Create base SnipeITDataObject class for common functionality
  • Create SnipeITAsset class with properties and factory method from PSCustomObject
  • Update Get-SnipeITAsset to optionally return typed objects
  • Add tests for Asset class functionality
  • Run all tests to verify backward compatibility
  • Document the new class-based approach

Design Goals:

  • Maintain backward compatibility (PSCustomObject by default)
  • Provide opt-in typed classes with intellisense support
  • Support nested objects (model, status_label, etc.)
  • Easy conversion from API responses

- Created SnipeITConnection class to encapsulate URL and token with validation
- Created SnipeITThrottleConfig class to encapsulate all throttle logic
- Created SnipeITSession class to manage module state
- Created helper classes: SnipeITQueryParameters, SnipeITRequestBody, SnipeITImageUpload
- Refactored Connect-SnipeIT to use factory methods for different auth modes
- Refactored Disconnect-SnipeIT to use session disconnect method
- Refactored Invoke-SnipeITAPI to use session class for auth and throttling
- All 365 tests pass successfully

Agent-Logs-Url: https://github.com/djeborn/snipe-it-ps/sessions/b1b988a4-d600-4119-9dd3-f637bba13f28

Co-authored-by: djeborn <116414068+djeborn@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Refactor code to be type-safe using classes Refactor module to use type-safe classes for state management Mar 31, 2026
@Claude Claude AI requested a review from djeborn March 31, 2026 18:40
Copilot stopped work on behalf of djeborn due to an error March 31, 2026 19:41
@djeborn djeborn closed this Mar 31, 2026
@djeborn djeborn deleted the claude/refactor-type-safe-classes branch March 31, 2026 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants