Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API logic for placing a SMS notifications order #328

Closed
15 tasks done
Tracked by #201
SandGrainOne opened this issue Dec 6, 2023 · 2 comments
Closed
15 tasks done
Tracked by #201

API logic for placing a SMS notifications order #328

SandGrainOne opened this issue Dec 6, 2023 · 2 comments
Assignees
Labels
kind/user-story Used for issues that describes functionality for our users.

Comments

@SandGrainOne
Copy link
Member

SandGrainOne commented Dec 6, 2023

Description

Create a new endpoint for placing an order for an SMS notification.

Controller name SMSNotificationOrderController
Endpoint: POST notfications/api/v1/orders/sms

Considerations

  • Assume norwegian number if missing country code? Copy validation rules from Altinn 2
  • Are there any numbers we should deny? Copy rules from Altinn 2?
  • Text length validation, max length? Splitting of messages on our side?

Fått fra Altinn 2:

<add key="KofuviValidCountryCode" value="(^\+([0-9]{1,3}))" />
<add key="KofuviValidMobileNumber" value="(^[0-9]+$)" />
Samt to lister over lovlige landkoder og telefonnummer for hvert land bare Norge har liste over lovlige serier:
<add key="ValidPhoneNumberCountryCodes" value="1,1242,1246,1264,1268,1284,1340,1345,1441,1473,1649,1664,1670,1671,1684,1721,1758,1767,1784,1787,1809,1829,1849,1868,1869,1876,1939,20,210,211,212,EH,213,214,215,216,217,218,219.6.0,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,YT,TF,263,264,265,266,267,268,269,27,28,290,TA,291,292,293,294,295,296,297,298,299,30,31,32,33,34,350,351,352,353,354,355,356,357,358,AX,359,36,370,371,372,373,374,QN,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,39,VA,40,41,420,421,422,423,424,425,426,427,428,429,43,44,GG,IM,JE,45,46,47,SJ,BV,48,49,500,GS,501,502,503,504,505,506,507,508,509,51,52,53,54,55,56,57,58,590,BL,MF,591,592,593,594,595,596,597,598,599,CW,60,61,CX,CC,62,63,64,PN,65,66,670,671,672,AQ,HM,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,7,KZ,73,74,76,77,78,79,800,801,802,803,804,805,806,807,808,809,81,82,83,84,850,851,852,853,854,855,856,857,858,859,86,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,89,90,CT,91,92,93,94,95,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,98,990,991,992,993,994,995,996,997,998,999" />
<add key="ValidPhoneNumberRangesPerCountry" value="47:40000000-49999999,90000000-99999999" />

Vi har også denne sjekken: ^(([0-9]{5})|([0-9]{8})|(00[0-9]{3,})|(+[0-9]{3,}))$
Den godkjenner

5 siffer
8 siffer
00 fulgt av minst tre siffer

  • fulgt av minst tre siffer

Den ligger også i altinn.config: ValidMobileNumber
Det er denne som brukes ved Varslingsadresse validering

Tasks

  • Implement a new controller with a POST endpoint taking an external SMS notification order
  • Implement mapping between internal and external model
  • Documentation
  • Review/QA
  • Update swagger in APIM
  • Update swagger in docs
  • Manual testing @SandGrainOne

Acceptance Criteria

  • A mobile number must start with 00 or + to be valid.
  • A mobile number not starting with 00 or + should result in the SmsNotificationOrderRequestValidator failing
  • Input (mobile number) from end user should not be modified before persisting in database
  • Application Owner with correct scope can place an order for an SMS Notification
  • An app with a valid AccessToken can place an order for an SMS Notification
@acn-sbuad acn-sbuad changed the title Endpoint for ordering an SMS notification Controller logic for placing a SMS notifications order Dec 8, 2023
@acn-sbuad acn-sbuad changed the title Controller logic for placing a SMS notifications order API logic for placing a SMS notifications order Dec 8, 2023
@acn-sbuad acn-sbuad added the kind/user-story Used for issues that describes functionality for our users. label Dec 11, 2023
@khanrn khanrn self-assigned this Jan 17, 2024
@acn-sbuad
Copy link
Contributor

For documentation we should also document which mobile numbers we accept and not. @codemascot maybe you can create a PR covering this part of the documentation. Unchecking the documentation until this has been completed

khanrn added a commit that referenced this issue Jan 30, 2024
#384)

* RecipientExt Phone number property added

* SMS notification order request data model added

* SMS notification orders controller added

* SMS phone number validation initiated

* Phone number validation added to singleton

* Changed PhoneNumber to MobileNumber

* With rebase phone changed to mobile

* Change of phone to mobile

* Attribute for SMS address point added

* Mobile number validation rules regex fix

* Validator test initiated for SMS notifiaction order request

* Validatee recipient provided for SMS return true added

* Validatee recipient provided for SMS return false added

* Validate SMS recipient not defined return false added

* Validate send time has local timezone return true added

* Validate send time has UTC Now timezone return true added

* Validate send time has unspecified timezone return false added

* Validate Send Numbwer missing returns false

* Type added to the validationResult variable

* Test for valid SMS number added

* Explicit type added to the variable

* Explicit type added to the variable

* Type definition for recipients variable fixed

* Sender Number removed from must rule

* Order mapper helper function added for getting mobile number

* Norwegian phone number strict validation added

* Tests adapted for Norwegian phone numbet validation

* Test refactored for readability purpose

* Typo fixed

* Both MapToRecipientExt tests merged into one

* SMS order mapper moved to OrderMapper class

* SMS order mapper tests added

* Fixed merge conflicts with main

* Integration tests added for the SMS notificaitons API

* Sender number changed to Altinn for integration tests

* PostTests API base path fixed for integration tests

* Revert:Removed the k6 tests added with integration tests

* Ternary to if-else to remove code smell

* Removed 5 digit pass as LinkMobility need 9 digits

* Validation logic changed for SMS mobile numbers

* RegEx removed from validation logic

* Invalid mobile number error message updated

Co-authored-by: Stephanie Buadu <[email protected]>

* Arguments fixed for the tests

* Tests messgae update

---------

Co-authored-by: Stephanie Buadu <[email protected]>
@SandGrainOne SandGrainOne self-assigned this Feb 1, 2024
@SandGrainOne
Copy link
Member Author

Manual testing completed.

@SandGrainOne SandGrainOne removed their assignment Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/user-story Used for issues that describes functionality for our users.
Projects
None yet
Development

No branches or pull requests

3 participants