From 6ccf3ee25b05cc75d7b3b8260d55e9aa37bde182 Mon Sep 17 00:00:00 2001
From: behnamrhp <behnamrahimpour74@gmail.com>
Date: Sun, 21 May 2023 15:39:44 +0300
Subject: [PATCH] [FEAT]: add adapter of create profile in driven layer

---
 .../createProfileAdapter.ts                   | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 src/driven/adapters/create-profile-adapter/createProfileAdapter.ts

diff --git a/src/driven/adapters/create-profile-adapter/createProfileAdapter.ts b/src/driven/adapters/create-profile-adapter/createProfileAdapter.ts
new file mode 100644
index 0000000..47e3901
--- /dev/null
+++ b/src/driven/adapters/create-profile-adapter/createProfileAdapter.ts
@@ -0,0 +1,29 @@
+import { CreateProfileDtoReturnType } from '~/business-logic/core/users/create-user/create-profile/data/dto/protocols';
+import createUserPort from '~/business-logic/core/users/create-user/ports';
+import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary';
+import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols';
+import { apiUrls } from '~/driven/utils/configs/appConfig';
+
+const createProfileAdapter = (): createUserPort['httpProfileHandler'] => {
+  // make url
+  const url = apiUrls.core.createUserProfile;
+  // call http provider
+  const httpProvider = new HTTPPovider();
+
+  const httpHandler = (newAccountData: CreateProfileDtoReturnType) => {
+    // api options
+    const httpOptions: HttpOptionsType = {
+      url,
+      method: 'POST',
+      headers: {
+        'Content-Type': 'application/json',
+      },
+      data: newAccountData,
+    };
+    return httpProvider.request<string>(httpOptions);
+  };
+
+  return httpHandler;
+};
+
+export default createProfileAdapter;