Skip to content

Commit 9f40b1e

Browse files
committed
Add number recycling
1 parent 7d481b6 commit 9f40b1e

File tree

2 files changed

+362
-0
lines changed

2 files changed

+362
-0
lines changed

.github/workflows/rdme-guides-openapi.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,8 @@ jobs:
122122
uses: readmeio/rdme@v10
123123
with:
124124
rdme: openapi --file=./v0/catalog/knowyourcustomer/kyc_tenure_openapi.yaml --key=${{ secrets.README_API_KEY }} --id=6874e6f254f6aa3161e0c45b
125+
126+
- name: Run `openapi` command 🚀
127+
uses: readmeio/rdme@v10
128+
with:
129+
rdme: openapi --file=./v0/catalog/numberrecycling/numberrecycling_openapi.yaml --key=${{ secrets.README_API_KEY }} --slug=v0catalognumberrecyclingnumberrecycling_openapi.yaml --branch=0
Lines changed: 357 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,357 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Number Recycling
4+
description: |
5+
The API can be used to check whether the subscriber of the phone number has changed.
6+
A common scenario is when Application service provider (ASP) wants to check whether there has been a change in the user associated with the phone number after the specified date. This allows the ASP to ensure that a phone number is correctly linked to an user and prevent the mis-delivery of SMS messages.
7+
8+
For example, below is a potential scenarios:
9+
* Scenario 1
10+
* Pre-conditions
11+
* User A signed a contract with MNO A for the phone number '+123456789' on October 9, 2023, and is still using it.
12+
* User A also signed contracts with ASP A on December 22, 2023 for its services.
13+
* ASP A holds the contract date (2023-12-22) and the phone number (+123456789) for User A.
14+
* Currently, on November 2, 2024, ASP A wishes to send a SMS message to User A.
15+
* Potential operations
16+
* ASP A sends a request with specified date (2023-12-22) and phone number (+123456789) to the Number Recycling API.
17+
* The API response sets to 'false', indicating that there has not been a change in the user associated with the phone number.
18+
* Post-conditions
19+
* ASP A decides to send the SMS message to User A.
20+
* By following these steps, ASP A ensures that a phone number is linked to User A.
21+
22+
<img width="4000" alt="Number_Recycling_scenario_1" src="https://raw.githubusercontent.com/camaraproject/NumberRecycling/r1.1/documentation/API_documentation/assets/Number_Recycling_scenario_1.png">
23+
24+
Note:
25+
* When API receives a request with specified date on which a user signed a contract with MNO, the API respond sets to 'false'(e.g., 2023-10-09 in the Scenario 1 of the figure above).
26+
27+
* Scenario 2
28+
* Pre-conditions
29+
* User A signed a contract with MNO A for the phone number '+123456789' on October 9, 2023, and canceled it on February 25, 2024. Subsequently, User B signed a contract with MNO A for the same phone number on September 21, 2024, and is still using it.
30+
* User A also signed contracts with ASP A on December 22, 2023 for its services.
31+
* ASP A holds the contract date (2023-12-22) and the phone number (+123456789) for User A.
32+
* Currently, on November 2, 2024, ASP A wishes to send a SMS message to User A.
33+
* Potential operations
34+
* ASP A sends a request with specified date (2023-12-22) and phone number (+123456789) to the Number Recycling API.
35+
* The API response sets to 'true', indicating that there has been a change in the user associated with the phone number.
36+
* Post-conditions
37+
* ASP A decides to stop sending the SMS message to User A and contacts User A by mail.
38+
* By following these steps, ASP A ensures that a phone number is not linked to User A and prevents the mis-delivery of the SMS message.
39+
40+
<img width="4000" alt="Number_Recycling_scenario_2" src="https://raw.githubusercontent.com/camaraproject/NumberRecycling/r1.1/documentation/API_documentation/assets/Number_Recycling_scenario_2.png">
41+
42+
Note:
43+
* When the API receives a request with specified date during which there is no contract with MNO for the phone number, the API respond sets to 'true'(e.g., the period between 2024-02-25 and 2024-09-20 in the Scenario 2 of the figure above).
44+
45+
# Authorization and authentication
46+
47+
The "Camara Security and Interoperability Profile" provides details of how an API consumer requests an access token. Please refer to Identity and Consent Management (https://github.com/camaraproject/IdentityAndConsentManagement/) for the released version of the profile.
48+
49+
The specific authorization flows to be used will be agreed upon during the onboarding process, happening between the API consumer and the API provider, taking into account the declared purpose for accessing the API, whilst also being subject to the prevailing legal framework dictated by local legislation.
50+
51+
In cases where personal data is processed by the API and users can exercise their rights through mechanisms such as opt-in and/or opt-out, the use of three-legged access tokens is mandatory. This ensures that the API remains in compliance with privacy regulations, upholding the principles of transparency and user-centric privacy-by-design.
52+
53+
# Identifying the phone number from the access token
54+
55+
This API requires the API consumer to identify a phone number as the subject of the API as follows:
56+
- When the API is invoked using a two-legged access token, the subject will be identified from the optional `phoneNumber` field, which therefore MUST be provided.
57+
- When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token.
58+
59+
This approach simplifies API usage for API consumers using a three-legged access token to invoke the API by relying on the information that is associated with the access token and was identified during the authentication process.
60+
61+
## Error handling:
62+
63+
- If the subject cannot be identified from the access token and the optional `phoneNumber` field is not included in the request, then the server will return an error with the `422 MISSING_IDENTIFIER` error code.
64+
- If the subject can be identified from the access token and the optional `phoneNumber` field is also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same phone number is identified by these two methods, as the server is unable to make this comparison.
65+
66+
version: "0.1"
67+
termsOfService: http://example.com/terms/
68+
contact:
69+
name: Telefónica Open Gateway DevRel
70+
url: https://opengateway.telefonica.com/en/developer-hub
71+
email: devrel@telefonica.com
72+
license:
73+
name: Apache 2.0
74+
url: https://www.apache.org/licenses/LICENSE-2.0.html
75+
76+
servers:
77+
- url: '{host}/number-recycling/v0'
78+
variables:
79+
host:
80+
default: sandbox.opengateway.telefonica.com/apigateway
81+
description: gateway URL
82+
83+
tags:
84+
- name: Check for phone number subscriber change
85+
description: Check whether the subscriber of the phone number has changed.
86+
87+
paths:
88+
/check:
89+
post:
90+
summary: Check number recycling v0.1
91+
security:
92+
- three_legged:
93+
- number-recycling:check
94+
tags:
95+
- Check for phone number subscriber change
96+
description: Check whether the subscriber of the phone number has changed.
97+
operationId: checkNumberRecycling
98+
parameters:
99+
- $ref: '#/components/parameters/x-correlator'
100+
requestBody:
101+
description: |
102+
Check whether the subscriber of the phone number has changed.
103+
content:
104+
application/json:
105+
schema:
106+
$ref: '#/components/schemas/CreateCheckNumRecycling'
107+
required: true
108+
responses:
109+
'200':
110+
$ref: '#/components/responses/Generic200'
111+
'400':
112+
$ref: '#/components/responses/Generic400'
113+
'401':
114+
$ref: '#/components/responses/Generic401'
115+
'403':
116+
$ref: '#/components/responses/Generic403'
117+
'404':
118+
$ref: '#/components/responses/Generic404'
119+
'422':
120+
$ref: '#/components/responses/Generic422'
121+
components:
122+
securitySchemes:
123+
three_legged:
124+
type: oauth2
125+
flows:
126+
authorizationCode:
127+
authorizationUrl: https://{host}/authorize
128+
tokenUrl: https://{host}/token
129+
scopes:
130+
"number-recycling:check": checkNumberRecycling operation
131+
parameters:
132+
x-correlator:
133+
name: x-correlator
134+
in: header
135+
description: Correlation id for the different services
136+
schema:
137+
type: string
138+
pattern: "^[a-zA-Z0-9-]{0,55}$"
139+
example: "b4333c46-49c0-4f62-80d7-f0ef930f1c46"
140+
headers:
141+
x-correlator:
142+
description: Correlation id for the different services
143+
schema:
144+
type: string
145+
pattern: "^[a-zA-Z0-9-]{0,55}$"
146+
example: "b4333c46-49c0-4f62-80d7-f0ef930f1c46"
147+
schemas:
148+
CreateCheckNumRecycling:
149+
type: object
150+
required:
151+
- specifiedDate
152+
properties:
153+
phoneNumber:
154+
$ref: '#/components/schemas/PhoneNumber'
155+
specifiedDate:
156+
type: string
157+
format: date
158+
description: Specified date to check whether there has been a change in the subscriber associated with the specific phone number, in RFC 3339 calendar date format (YYYY-MM-DD).
159+
example: "2024-10-31"
160+
PhoneNumber:
161+
description: A public identifier addressing a telephone subscription. In mobile networks it corresponds to the MSISDN (Mobile Station International Subscriber Directory Number). In order to be globally unique it has to be formatted in international format, according to E.164 standard, prefixed with '+'.
162+
type: string
163+
pattern: '^\+[1-9][0-9]{4,14}$'
164+
example: "+123456789"
165+
CheckNumRecyclingInfo:
166+
type: object
167+
required:
168+
- phoneNumberRecycled
169+
properties:
170+
phoneNumberRecycled:
171+
type: boolean
172+
description: |
173+
Set to true (Boolean, not string) when there has been a change in the subscriber associated with the specific phone number after “specifiedDate”.
174+
ErrorInfo:
175+
type: object
176+
required:
177+
- status
178+
- code
179+
- message
180+
properties:
181+
status:
182+
type: integer
183+
description: HTTP response status code
184+
code:
185+
type: string
186+
description: Code given to this error
187+
message:
188+
type: string
189+
description: A human readable description of what the event represent
190+
responses:
191+
Generic200:
192+
description: OK
193+
headers:
194+
x-correlator:
195+
$ref: '#/components/headers/x-correlator'
196+
content:
197+
application/json:
198+
schema:
199+
$ref: '#/components/schemas/CheckNumRecyclingInfo'
200+
201+
Generic400:
202+
description: Problem with the client request
203+
headers:
204+
x-correlator:
205+
$ref: '#/components/headers/x-correlator'
206+
content:
207+
application/json:
208+
schema:
209+
allOf:
210+
- $ref: "#/components/schemas/ErrorInfo"
211+
- type: object
212+
properties:
213+
status:
214+
enum:
215+
- 400
216+
code:
217+
enum:
218+
- INVALID_ARGUMENT
219+
- OUT_OF_RANGE
220+
examples:
221+
InvalidArgument:
222+
description: Invalid Argument. Generic Syntax Exception
223+
value:
224+
status: 400
225+
code: INVALID_ARGUMENT
226+
message: Client specified an invalid argument, request body or query param.
227+
OutOfRange:
228+
description: Out of Range. Specific Syntax Exception used when a given field has a pre-defined range or a invalid filter criteria combination is requested
229+
value:
230+
status: 400
231+
code: OUT_OF_RANGE
232+
message: Client specified an invalid range.
233+
234+
Generic401:
235+
description: Authentication problem with the client request
236+
headers:
237+
x-correlator:
238+
$ref: '#/components/headers/x-correlator'
239+
content:
240+
application/json:
241+
schema:
242+
allOf:
243+
- $ref: "#/components/schemas/ErrorInfo"
244+
- type: object
245+
properties:
246+
status:
247+
enum:
248+
- 401
249+
code:
250+
enum:
251+
- UNAUTHENTICATED
252+
- AUTHENTICATION_REQUIRED
253+
examples:
254+
Unauthenticated:
255+
description: Request cannot be authenticated
256+
value:
257+
status: 401
258+
code: UNAUTHENTICATED
259+
message: Request not authenticated due to missing, invalid, or expired credentials.
260+
Authentication Required:
261+
description: New authentication is needed, authentication is no longer valid
262+
value:
263+
status: 401
264+
code: AUTHENTICATION_REQUIRED
265+
message: New authentication is required.
266+
267+
Generic403:
268+
description: Client does not have sufficient permission
269+
headers:
270+
x-correlator:
271+
$ref: '#/components/headers/x-correlator'
272+
content:
273+
application/json:
274+
schema:
275+
allOf:
276+
- $ref: "#/components/schemas/ErrorInfo"
277+
- type: object
278+
properties:
279+
status:
280+
enum:
281+
- 403
282+
code:
283+
enum:
284+
- PERMISSION_DENIED
285+
examples:
286+
Permission Denied:
287+
description: Permission denied. OAuth2 token access not have the required scope or when the user fails operational security
288+
value:
289+
status: 403
290+
code: PERMISSION_DENIED
291+
message: Client does not have sufficient permissions to perform this action
292+
293+
Generic404:
294+
description: Resource Not Found
295+
headers:
296+
x-correlator:
297+
$ref: '#/components/headers/x-correlator'
298+
content:
299+
application/json:
300+
schema:
301+
allOf:
302+
- $ref: "#/components/schemas/ErrorInfo"
303+
- type: object
304+
properties:
305+
status:
306+
enum:
307+
- 404
308+
code:
309+
enum:
310+
- IDENTIFIER_NOT_FOUND
311+
examples:
312+
Phone Number Used By Different Network Operator:
313+
description: Provided phone number is used by a different network operator
314+
value:
315+
status: 404
316+
code: IDENTIFIER_NOT_FOUND
317+
message: Phone number not found.
318+
319+
Generic422:
320+
description: Unprocessable Content
321+
headers:
322+
x-correlator:
323+
$ref: '#/components/headers/x-correlator'
324+
content:
325+
application/json:
326+
schema:
327+
allOf:
328+
- $ref: "#/components/schemas/ErrorInfo"
329+
- type: object
330+
properties:
331+
status:
332+
enum:
333+
- 422
334+
code:
335+
enum:
336+
- SERVICE_NOT_APPLICABLE
337+
- MISSING_IDENTIFIER
338+
- UNNECESSARY_IDENTIFIER
339+
examples:
340+
Device Not Applicable:
341+
description: Service not applicable for the provided phone number
342+
value:
343+
status: 422
344+
code: SERVICE_NOT_APPLICABLE
345+
message: The service is not available for the provided phone number
346+
Unnecessary Identifier:
347+
description: An explicit identifier is provided when a phone number has already been identified from the access token
348+
value:
349+
status: 422
350+
code: UNNECESSARY_IDENTIFIER
351+
message: The phone number is already identified by the access token
352+
Missing Identifier:
353+
description: An identifier is not included in the request and the phone number identification cannot be derived from the 3-legged access token
354+
value:
355+
status: 422
356+
code: MISSING_IDENTIFIER
357+
message: The phone number cannot be identified

0 commit comments

Comments
 (0)