# TODO

- [x] Run codebase analysis: bugs, code reuse opportunities, unit test gaps, other issues
- [x] Branch `fix/service-bugs-and-test-coverage` created off master
- [x] Fix bugs found during analysis:
  - [x] Unclosed `CloseableHttpResponse` leak in every service call (BaseService/Oauth/Rate/Tracking/Address)
  - [x] `KNOWN_CODES` vs `HttpStatusCode` mismatch (429/422 now reconciled into KNOWN_CODES)
  - [x] Copy-pasted `"Tracking Error"` label in AddressService -> `"Validation Error"`
  - [x] `BaseService.parse` swallowed JsonProcessingException cause -> now chained
  - [x] `ValidationRequest.AddressToValidate` non-static inner class broke JSON deserialization -> made static
  - [x] `RequestedShipment` / `Commodity` missing no-args constructor (Lombok @Builder without @NoArgsConstructor) broke RateRequest deserialization -> added constructors
  - [x] `trackingResponse.json` fixture had `alerts` as a string instead of array -> fixed fixture
  - [x] Added OAuth token caching in FedexApi (was fetching a new token on every call)
- [x] Refactored RateService/TrackingService/AddressService duplication into BaseService.post() + ApiResponse<T> interface
- [x] Added tests: HttpStatusCodeTest, BaseServiceTest, OauthServiceTest, RateServiceTest, TrackingServiceTest,
  AddressServiceTest, FedexApiTest, RateRequestTest, TrackingResponseTest, ValidationRequestTest, ValidationResponseTest;
  strengthened OauthResponseTest error-path assertions; added TrackingFactory boundary tests
  - [x] Full test suite green: 47/47 passing, `mvn package` clean
  - [ ] --> Awaiting user review/commit decision (no commit made yet, working tree has uncommitted changes on the new branch)

## Notes
- Project: io.ljunggren.fedex.api — FedEx API client library (Maven/Lombok)
- Structure: small set of service classes (BaseService, OauthService, RateService, TrackingService, AddressService),
  one factory (TrackingFactory), one util (ServiceTypeUtils), and a large set of model/DTO classes for
  rate/tracking/address request & response payloads.
- Existing tests: OauthResponseTest, TrackingFactoryTest, TrackingRequestTest, RateResponseTest — coverage looks thin
  relative to the number of model/service classes.
