From 960ac8d81eb390227414d42e3c728221db86b19d Mon Sep 17 00:00:00 2001 From: Vignesh-Kalyanasundaram Date: Fri, 11 Oct 2024 17:02:59 +0530 Subject: [PATCH 1/4] EDGPATRON-151 Adding new api contract for Post and get api of LC User registration --- ramls/edge-patron.raml | 102 ++++++++++++++ ramls/examples/staging_user.json | 28 ++++ ramls/examples/user.json | 18 +++ ramls/examples/user_error.json | 4 + ramls/schemas/user_error_400.schema | 26 ++++ ramls/schemas/user_error_404.schema | 30 ++++ ramls/staging_user.json | 100 ++++++++++++++ ramls/userdata.json | 205 ++++++++++++++++++++++++++++ 8 files changed, 513 insertions(+) create mode 100644 ramls/examples/staging_user.json create mode 100644 ramls/examples/user.json create mode 100644 ramls/examples/user_error.json create mode 100644 ramls/schemas/user_error_400.schema create mode 100644 ramls/schemas/user_error_404.schema create mode 100644 ramls/staging_user.json create mode 100644 ramls/userdata.json diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index 728959d..54f9f7d 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -18,6 +18,8 @@ types: money: !include money.json item: !include item.json external_patron: !include external_patron.json + staging_user: !!include staging_user.json + user: !!include userdata.json external_patron_collection: !include external_patron_collection.json allowedServicePoints: !include allowed-service-points-response.json hold-cancellation: !include hold-cancellation.json @@ -26,11 +28,65 @@ types: external_patron_error_get_422: !include schemas/external_patron_error_get_422.schema external_patron_error_post_422: !include schemas/external_patron_error_post_422.schema external_patron_error_put_422: !include schemas/external_patron_error_put_422.schema + user_error_400: !include schemas/user_error_400.schema + user_error_404: !include schemas/user_error_404.schema /patron: displayName: Patron Services description: | Services that allow patron empowerment from 3rd party discovery services + post: + description: | + Create a staging user or update a staging user if it exists + queryParameters: + apikey: + description: "API Key" + type: string + body: + application/json: + type: staging-user + example: !include examples/staging_user.json + responses: + 200: + description: | + staging user updated successfully + body: + application/json: + type: staging-user + example: !include examples/staging_user.json + 201: + description: | + staging user created successfully + body: + application/json: + type: staging-user + example: !include examples/staging_user.json + 400: + description: Bad request + body: + text/plain: + example: unable to process request + 401: + description: Not authorized to perform requested action + body: + text/plain: + example: unable to create request + 403: + description: Access Denied + body: + text/plain: + example: Access Denied + 422: + description: Validation error + body: + text/plain: + example: Validation error + 500: + description: | + Internal server error, e.g. due to misconfiguration + body: + text/plain: + example: internal server error, contact administrator /account: post: description: | @@ -566,4 +622,50 @@ types: body: text/plain: example: internal server error, contact administrator +/patron-registration-status/{emailId}: + uriParameters: + emailId: + description: The email ID of the patron. + type: string + required: true + get: + description: Get the patron details by email ID + queryParameters: + apikey: + description: "API Key" + type: string + responses: + 200: + description: patron information retrieved successfully + body: + application/json: + type: user + example: !include examples/user.json + 400: + description: Validation error + body: + application/json: + type: user_error_400 + example: !include examples/user_error.json + 401: + description: Not authorized to perform requested action + body: + text/plain: + example: unable to get account -- unauthorized + 403: + description: Access Denied + body: + text/plain: + example: Access Denied + 404: + description: Validation error + body: + application/json: + type: user_error_404 + example: !include examples/user_error.json + 500: + description: Internal server error, e.g. due to misconfiguration + body: + text/plain: + example: internal server error, contact administrator diff --git a/ramls/examples/staging_user.json b/ramls/examples/staging_user.json new file mode 100644 index 0000000..771b0e5 --- /dev/null +++ b/ramls/examples/staging_user.json @@ -0,0 +1,28 @@ +{ + "isEmailVerified": true, + "status": "TIER-1", + "generalInfo": { + "firstName": "John", + "preferredFirstName": "John", + "middleName": "Felix", + "lastName": "Cena" + }, + "addressInfo": { + "addressLine0": "William Morris Endeavor", + "addressLine1": "9601 Wilshire Blvd 3rd Floor", + "city": "Beverly Hills", + "province": "CA", + "zip": "12345", + "country": "USA" + }, + "contactInfo": { + "phone": "555-123456", + "mobilePhone": "55555-66666", + "email": "john_cena@test_folio.com" + }, + "preferredEmailCommunication": [ + "Support", + "Programs", + "Services" + ] +} diff --git a/ramls/examples/user.json b/ramls/examples/user.json new file mode 100644 index 0000000..a99ebcd --- /dev/null +++ b/ramls/examples/user.json @@ -0,0 +1,18 @@ +{ + "username": "jhandey", + "id": "7261ecaae3a74dc68b468e12a70b1aec", + "active": true, + "type": "patron", + "patronGroup": "4bb563d9-3f9d-4e1e-8d1d-04e75666d68f", + "meta": { + "creation_date": "2016-11-05T0723", + "last_login_date": "" + }, + "personal": { + "lastName": "Handey", + "firstName": "Jack", + "preferredFirstName": "Jackie", + "email": "jhandey@biglibrary.org", + "phone": "2125551212" + } +} diff --git a/ramls/examples/user_error.json b/ramls/examples/user_error.json new file mode 100644 index 0000000..bb7a6cb --- /dev/null +++ b/ramls/examples/user_error.json @@ -0,0 +1,4 @@ +{ + "code": 404, + "errorMessage": "USER_ACCOUNT_INACTIVE" +} diff --git a/ramls/schemas/user_error_400.schema b/ramls/schemas/user_error_400.schema new file mode 100644 index 0000000..bc4bce5 --- /dev/null +++ b/ramls/schemas/user_error_400.schema @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "external_patron_error.schema", + "description": "An external_patron user error", + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "Error code" + }, + "errorMessage": { + "type": "string", + "description": "Error message text", + "examples": [ + { + "value": "MULTIPLE_USER_EXISTS", + "description": "Multiple users found with the same email" + } + ] + } + }, + "required": [ + "code", + "errorMessage" + ] +} diff --git a/ramls/schemas/user_error_404.schema b/ramls/schemas/user_error_404.schema new file mode 100644 index 0000000..d5fcd28 --- /dev/null +++ b/ramls/schemas/user_error_404.schema @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "external_patron_error.schema", + "description": "An external_patron user error", + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "Error code" + }, + "errorMessage": { + "type": "string", + "description": "Error message text", + "examples": [ + { + "value": "USER_ACCOUNT_INACTIVE", + "description": "User is not active" + }, + { + "value": "USER_NOT_FOUND", + "description": "User does not exist" + } + ] + } + }, + "required": [ + "code", + "errorMessage" + ] +} diff --git a/ramls/staging_user.json b/ramls/staging_user.json new file mode 100644 index 0000000..b52298a --- /dev/null +++ b/ramls/staging_user.json @@ -0,0 +1,100 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "User Information Schema", + "description": "Schema for staging users", + "type": "object", + "properties": { + "isEmailVerified": { + "description": "A flag to determine if a patron is activated/email verification completed.", + "type": "boolean", + "example": true + }, + "status": { + "description": "Status of the patron, whether TIER-1 or TIER-2.", + "type": "string", + "enum": ["TIER-1", "TIER-2"], + "example": "TIER-1" + }, + "generalInfo": { + "type": "object", + "description": "General info of external patron", + "properties": { + "firstName": { + "description": "First name of the patron", + "type": "string" + }, + "preferredFirstName": { + "description": "Preferred first name of the patron", + "type": "string" + }, + "middleName": { + "description": "Middle name of the patron", + "type": "string" + }, + "lastName": { + "description": "Last name of the patron", + "type": "string" + } + } + }, + "addressInfo": { + "type": "object", + "description": "Primary address info of external patron", + "properties": { + "addressLine0": { + "description": "First line of the address", + "type": "string" + }, + "addressLine1": { + "description": "Second line of the address", + "type": "string" + }, + "city": { + "description": "City", + "type": "string" + }, + "province": { + "description": "Province/State", + "type": "string" + }, + "zip": { + "description": "Postal/Zip code", + "type": "string" + }, + "country": { + "description": "Country", + "type": "string" + } + } + }, + "contactInfo": { + "type": "object", + "description": "Contact info of external patron", + "properties": { + "phone": { + "description": "Phone number of the patron", + "type": "string" + }, + "mobilePhone": { + "description": "Mobile phone number of the patron", + "type": "string" + }, + "email": { + "description": "Email of the patron", + "type": "string" + } + } + }, + "preferredEmailCommunication": { + "type": "array", + "description": "Email communication info of external patron", + "items": { + "type": "string", + "enum": ["Support", "Programs", "Service"] + }, + "maxItems": 3, + "uniqueItems": true + } + }, + "required": ["generalInfo.firstName", "generalInfo.lastName", "contactInfo.email"] +} diff --git a/ramls/userdata.json b/ramls/userdata.json new file mode 100644 index 0000000..d0ce219 --- /dev/null +++ b/ramls/userdata.json @@ -0,0 +1,205 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "User Schema", + "description": "A user", + "javaName": "User", + "type": "object", + "properties": { + "username": { + "description": "A unique name belonging to a user. Typically used for login", + "type": "string" + }, + "id": { + "description" : "A globally unique (UUID) identifier for the user", + "type": "string" + }, + "externalSystemId": { + "description": "A unique ID that corresponds to an external authority", + "type": "string" + }, + "barcode": { + "description": "The unique library barcode for this user", + "type": "string" + }, + "active": { + "description": "A flag to determine if the user's account is effective and not expired. The tenant configuration can require the user to be active for login. Active is different from the loan patron block", + "type": "boolean" + }, + "type": { + "description": "The class of user like staff or patron; this is different from patronGroup; it can store shadow, system user and dcb types also", + "type": "string" + }, + "patronGroup": { + "description": "A UUID corresponding to the group the user belongs to, see /groups API, example groups are undergraduate and faculty; loan rules, patron blocks, fees/fines and expiration days can use the patron group", + "type": "string", + "$ref": "raml-util/schemas/uuid.schema" + }, + "departments": { + "description": "A list of UUIDs corresponding to the departments the user belongs to, see /departments API", + "type": "array", + "uniqueItems": true, + "items": { + "type": "string", + "$ref": "raml-util/schemas/uuid.schema" + } + }, + "meta": { + "description": "Deprecated", + "type": "object" + }, + "proxyFor": { + "description" : "Deprecated", + "type": "array", + "items": { + "type": "string" + } + }, + "personal": { + "description": "Personal information about the user", + "type": "object", + "properties": { + "lastName": { + "description": "The user's surname", + "type": "string" + }, + "firstName": { + "description": "The user's given name", + "type": "string" + }, + "middleName": { + "description": "The user's middle name (if any)", + "type": "string" + }, + "preferredFirstName": { + "description": "The user's preferred name", + "type": "string" + }, + "email": { + "description": "The user's email address", + "type": "string" + }, + "phone": { + "description": "The user's primary phone number", + "type": "string" + }, + "mobilePhone": { + "description": "The user's mobile phone number", + "type": "string" + }, + "dateOfBirth": { + "type": "string", + "description": "The user's birth date", + "format": "date-time" + }, + "addresses": { + "description": "Physical addresses associated with the user", + "type": "array", + "minItems": 0, + "items": { + "type": "object", + "properties": { + "id": { + "description": "A unique id for this address", + "type": "string" + }, + "countryId": { + "description": "The country code for this address", + "type": "string" + }, + "addressLine1": { + "description": "Address, Line 1", + "type": "string" + }, + "addressLine2": { + "description": "Address, Line 2", + "type": "string" + }, + "city": { + "description": "City name", + "type": "string" + }, + "region": { + "description": "Region", + "type": "string" + }, + "postalCode": { + "description": "Postal Code", + "type": "string" + }, + "addressTypeId": { + "description": "A UUID that corresponds with an address type object", + "type": "string", + "$ref": "raml-util/schemas/uuid.schema" + }, + "primaryAddress": { + "description": "Is this the user's primary address?", + "type": "boolean" + } + }, + "required":[ + "addressTypeId" + ], + "additionalProperties": false + } + }, + "preferredContactTypeId": { + "description": "Id of user's preferred contact type like Email, Mail or Text Message, see /addresstypes API", + "type": "string" + }, + "profilePictureLink": { + "description": "Link to the profile picture", + "type": "string", + "format": "uri" + } + }, + "additionalProperties": false, + "required": [ + "lastName" + ] + }, + "enrollmentDate": { + "description": "The date in which the user joined the organization", + "type": "string", + "format": "date-time" + }, + "expirationDate": { + "description": "The date for when the user becomes inactive", + "type": "string", + "format": "date-time" + }, + "createdDate": { + "description": "Deprecated", + "type": "string", + "format": "date-time" + }, + "updatedDate": { + "description": "Deprecated", + "type": "string", + "format": "date-time" + }, + "metadata": { + "type": "object", + "$ref": "raml-util/schemas/metadata.schema" + }, + "tags": { + "type": "object", + "$ref": "raml-util/schemas/tags.schema" + }, + "customFields" : { + "description": "Object that contains custom field", + "type": "object", + "additionalProperties": true + }, + "preferredEmailCommunication": { + "type": "array", + "items": { + "type": "string", + "enum": ["Support", "Programs", "Services"] + }, + "maxItems": 3, + "uniqueItems": true, + "description": "Preferred email communication types" + } + }, + "additionalProperties": false +} From 3414392609794ed38dfa0c15db284de33e7ad1f1 Mon Sep 17 00:00:00 2001 From: Vignesh-Kalyanasundaram Date: Fri, 11 Oct 2024 17:06:48 +0530 Subject: [PATCH 2/4] EDGPATRON-151 Adding new api contract for Post and get api of LC User registration --- ramls/edge-patron.raml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index 54f9f7d..592dd19 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -18,8 +18,8 @@ types: money: !include money.json item: !include item.json external_patron: !include external_patron.json - staging_user: !!include staging_user.json - user: !!include userdata.json + staging_user: !include staging_user.json + user: !include userdata.json external_patron_collection: !include external_patron_collection.json allowedServicePoints: !include allowed-service-points-response.json hold-cancellation: !include hold-cancellation.json @@ -44,7 +44,7 @@ types: type: string body: application/json: - type: staging-user + type: staging_user example: !include examples/staging_user.json responses: 200: @@ -52,14 +52,14 @@ types: staging user updated successfully body: application/json: - type: staging-user + type: staging_user example: !include examples/staging_user.json 201: description: | staging user created successfully body: application/json: - type: staging-user + type: staging_user example: !include examples/staging_user.json 400: description: Bad request From 9b1a6d7a9c15cb7758a37ec1b66cd410eb573ff6 Mon Sep 17 00:00:00 2001 From: Vignesh-Kalyanasundaram Date: Fri, 11 Oct 2024 17:13:44 +0530 Subject: [PATCH 3/4] EDGPATRON-151 Adding new api contract for Post and get api of LC User registration --- ramls/staging_user.json | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ramls/staging_user.json b/ramls/staging_user.json index b52298a..4c5669c 100644 --- a/ramls/staging_user.json +++ b/ramls/staging_user.json @@ -35,7 +35,9 @@ "description": "Last name of the patron", "type": "string" } - } + }, + "required": ["firstName", "lastName"], + "additionalProperties": false }, "addressInfo": { "type": "object", @@ -65,7 +67,8 @@ "description": "Country", "type": "string" } - } + }, + "additionalProperties": false }, "contactInfo": { "type": "object", @@ -83,14 +86,16 @@ "description": "Email of the patron", "type": "string" } - } + }, + "required": ["email"], + "additionalProperties": false }, "preferredEmailCommunication": { "type": "array", - "description": "Email communication info of external patron", + "description": "Preferred email communication types", "items": { "type": "string", - "enum": ["Support", "Programs", "Service"] + "enum": ["Support", "Programs", "Services"] }, "maxItems": 3, "uniqueItems": true From 4d616bc47de1a80fe4a74ced774d088c30bc14cd Mon Sep 17 00:00:00 2001 From: Vignesh-Kalyanasundaram Date: Fri, 11 Oct 2024 17:17:27 +0530 Subject: [PATCH 4/4] EDGPATRON-151 Adding new api contract for Post and get api of LC User registration --- ramls/staging_user.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ramls/staging_user.json b/ramls/staging_user.json index 4c5669c..c2041df 100644 --- a/ramls/staging_user.json +++ b/ramls/staging_user.json @@ -100,6 +100,5 @@ "maxItems": 3, "uniqueItems": true } - }, - "required": ["generalInfo.firstName", "generalInfo.lastName", "contactInfo.email"] + } }