Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
fix send notices
Browse files Browse the repository at this point in the history
  • Loading branch information
mltbnz committed Mar 28, 2023
1 parent 0ad77c0 commit 7638090
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
8 changes: 3 additions & 5 deletions WegliKit/Sources/ApiClient/Services/APIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extension APIService: DependencyKey {
let noticePutRequestBody = NoticePutRequestBody(notice: input)
let body = try noticePutRequestBody.encoded(encoder: .noticeEncoder)

let data = try await apiClient.send(.createNotice(body: body))
let data = try await apiClient.send(.post(.notices, body: body))

return try data.decoded(decoder: .noticeDecoder)
},
Expand All @@ -66,10 +66,8 @@ extension APIService: DependencyKey {
return try responseData.decoded(decoder: .noticeDecoder)
},
submitNotice: { notice in
let noticePutRequestBody = NoticePutRequestBody(notice: notice)
let body = try noticePutRequestBody.encoded(encoder: .noticeEncoder)

let data = try await apiClient.send(.post(.submitNotices, body: body))
let body = try notice.encoded(encoder: .noticeEncoder)
let data = try await apiClient.send(.patch(.submitNotices, body: body))

return try data.decoded(decoder: .noticeDecoder)
},
Expand Down
2 changes: 1 addition & 1 deletion WegliKit/Sources/ReportFeature/ReportDomain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ public extension SharedModels.NoticeInput {
registration: reportState.description.licensePlateNumber,
brand: reportState.description.carBrandSelection.selectedBrand?.title ?? "",
color: DescriptionDomain.colors[reportState.description.selectedColor].key,
charge: reportState.description.chargeSelection.selectedCharge?.text ?? "",
tbnr: reportState.description.chargeSelection.selectedCharge?.id ?? "",
date: reportState.date,
duration: Int64(reportState.description.selectedDuration),
severity: nil,
Expand Down
6 changes: 3 additions & 3 deletions WegliKit/Sources/SharedModels/Notice/NoticeInput.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public struct NoticeInput: Codable, Equatable, Identifiable, Sendable {
public let registration: String
public let brand: String
public let color: String
public let charge: String
public let tbnr: String
public let date: Date
public let duration: Int64
public let severity: String?
Expand All @@ -39,7 +39,7 @@ public struct NoticeInput: Codable, Equatable, Identifiable, Sendable {
registration: String,
brand: String,
color: String,
charge: String,
tbnr: String,
date: Date,
duration: Int64,
severity: String?,
Expand All @@ -64,7 +64,7 @@ public struct NoticeInput: Codable, Equatable, Identifiable, Sendable {
self.registration = registration
self.brand = brand
self.color = color
self.charge = charge
self.tbnr = tbnr
self.date = date
self.duration = duration
self.severity = severity
Expand Down

0 comments on commit 7638090

Please sign in to comment.