-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SASS-8727: save NICs class2 answers (#120)
- Loading branch information
Showing
32 changed files
with
983 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package models.connector.api_1638 | ||
|
||
import models.connector.api_1639.SuccessResponseAPI1639 | ||
import models.frontend.nics.NICsAnswers | ||
import play.api.libs.json._ | ||
|
||
/** Represents the Swagger definition for requestSchemaAPI1638. | ||
*/ | ||
case class RequestSchemaAPI1638( | ||
taxAvoidance: Option[List[RequestSchemaAPI1638TaxAvoidanceInner]], | ||
class2Nics: Option[RequestSchemaAPI1638Class2Nics] | ||
) | ||
|
||
object RequestSchemaAPI1638 { | ||
implicit lazy val requestSchemaAPI1638JsonFormat: Format[RequestSchemaAPI1638] = Json.format[RequestSchemaAPI1638] | ||
|
||
/** Some(false) is not possible to set on class2VoluntaryContributions. We cannot send an empty object therefore if there are no other fields we | ||
* have to call DELETE. | ||
* | ||
* @return | ||
* None if the object needs to be DELETED or Some() if it needs to be updated via PUT | ||
*/ | ||
def mkRequestBody(answers: NICsAnswers, maybeExistingDisclosures: Option[SuccessResponseAPI1639]): Option[RequestSchemaAPI1638] = { | ||
val existingDisclosures = maybeExistingDisclosures.getOrElse(SuccessResponseAPI1639.empty) | ||
|
||
val bodyForPut = RequestSchemaAPI1638( | ||
taxAvoidance = existingDisclosures.taxAvoidance.map { taxAvoidance => | ||
taxAvoidance.map { taxAvoidanceInner => | ||
RequestSchemaAPI1638TaxAvoidanceInner( | ||
srn = taxAvoidanceInner.srn, | ||
taxYear = taxAvoidanceInner.taxYear | ||
) | ||
} | ||
}, | ||
class2Nics = existingDisclosures.class2Nics.map { class2Nics => | ||
RequestSchemaAPI1638Class2Nics( | ||
class2VoluntaryContributions = class2Nics.class2VoluntaryContributions | ||
) | ||
} | ||
) | ||
|
||
if (answers.class2NICs) { | ||
Some(bodyForPut.copy(class2Nics = Some(RequestSchemaAPI1638Class2Nics(Some(true))))) | ||
} else if (bodyForPut.taxAvoidance.isDefined) { | ||
Some(bodyForPut.copy(class2Nics = None)) | ||
} else { | ||
None | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/models/connector/api_1638/RequestSchemaAPI1638Class2Nics.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package models.connector.api_1638 | ||
|
||
import play.api.libs.json._ | ||
|
||
/** Voluntary contributions. | ||
*/ | ||
case class RequestSchemaAPI1638Class2Nics( | ||
class2VoluntaryContributions: Option[Boolean] | ||
) | ||
|
||
object RequestSchemaAPI1638Class2Nics { | ||
implicit lazy val requestSchemaAPI1638Class2NicsJsonFormat: Format[RequestSchemaAPI1638Class2Nics] = Json.format[RequestSchemaAPI1638Class2Nics] | ||
} |
31 changes: 31 additions & 0 deletions
31
app/models/connector/api_1638/RequestSchemaAPI1638TaxAvoidanceInner.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package models.connector.api_1638 | ||
|
||
import play.api.libs.json._ | ||
|
||
/** Represents the Swagger definition for requestSchemaAPI1638_taxAvoidance_inner. | ||
*/ | ||
case class RequestSchemaAPI1638TaxAvoidanceInner( | ||
srn: String, | ||
taxYear: String | ||
) | ||
|
||
object RequestSchemaAPI1638TaxAvoidanceInner { | ||
implicit lazy val requestSchemaAPI1638TaxAvoidanceInnerJsonFormat: Format[RequestSchemaAPI1638TaxAvoidanceInner] = | ||
Json.format[RequestSchemaAPI1638TaxAvoidanceInner] | ||
} |
32 changes: 32 additions & 0 deletions
32
app/models/connector/api_1639/SuccessResponseAPI1639.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package models.connector.api_1639 | ||
|
||
import play.api.libs.json._ | ||
|
||
/** Represents the Swagger definition for successResponseAPI1639. | ||
*/ | ||
case class SuccessResponseAPI1639( | ||
taxAvoidance: Option[List[SuccessResponseAPI1639TaxAvoidanceInner]], | ||
class2Nics: Option[SuccessResponseAPI1639Class2Nics] | ||
) | ||
|
||
object SuccessResponseAPI1639 { | ||
implicit lazy val successResponseAPI1639JsonFormat: Format[SuccessResponseAPI1639] = Json.format[SuccessResponseAPI1639] | ||
|
||
def empty: SuccessResponseAPI1639 = SuccessResponseAPI1639(None, None) | ||
} |
30 changes: 30 additions & 0 deletions
30
app/models/connector/api_1639/SuccessResponseAPI1639Class2Nics.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package models.connector.api_1639 | ||
|
||
import play.api.libs.json._ | ||
|
||
/** Voluntary contributions. | ||
*/ | ||
case class SuccessResponseAPI1639Class2Nics( | ||
class2VoluntaryContributions: Option[Boolean] | ||
) | ||
|
||
object SuccessResponseAPI1639Class2Nics { | ||
implicit lazy val successResponseAPI1639Class2NicsJsonFormat: Format[SuccessResponseAPI1639Class2Nics] = | ||
Json.format[SuccessResponseAPI1639Class2Nics] | ||
} |
31 changes: 31 additions & 0 deletions
31
app/models/connector/api_1639/SuccessResponseAPI1639TaxAvoidanceInner.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2024 HM Revenue & Customs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package models.connector.api_1639 | ||
|
||
import play.api.libs.json._ | ||
|
||
/** Represents the Swagger definition for successResponseAPI1639_taxAvoidance_inner. | ||
*/ | ||
case class SuccessResponseAPI1639TaxAvoidanceInner( | ||
srn: String, | ||
taxYear: String | ||
) | ||
|
||
object SuccessResponseAPI1639TaxAvoidanceInner { | ||
implicit lazy val successResponseAPI1639TaxAvoidanceInnerJsonFormat: Format[SuccessResponseAPI1639TaxAvoidanceInner] = | ||
Json.format[SuccessResponseAPI1639TaxAvoidanceInner] | ||
} |
Oops, something went wrong.