diff --git a/v0/swagger.json b/v0/swagger.json index a82f645..0840142 100644 --- a/v0/swagger.json +++ b/v0/swagger.json @@ -257,6 +257,474 @@ } } } + }, + "/logo/add/": { + "post": { + "tags": ["Logo"], + "summary": "Add a new logo", + "requestBody": { + "description": "Logo data", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Company id" + }, + "logo": { + "type": "string", + "description": "URL or identifier of the logo" + } + }, + "required": ["id", "logo"] + } + } + } + } + }, + "responses": { + "200": { + "description": "Logo added successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "Success message" + } + } + } + } + } + }, + "400": { + "description": "Bad Request. Invalid input parameter.", + "content": {} + }, + "500": { + "description": "Internal Server Error. Something went wrong on the server side.", + "content": {} + } + } + } + }, + "/logo/delete/": { + "post": { + "tags": ["Logo"], + "summary": "Delete a logo", + "requestBody": { + "description": "Company name to delete logo", + "required": true, + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "company": { + "type": "string", + "description": "Company name whose logo is to be deleted" + } + }, + "required": ["company"] + } + } + } + }, + "responses": { + "200": { + "description": "Logo deleted successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "Success message" + } + } + } + } + } + }, + "400": { + "description": "Bad Request. Invalid input parameter.", + "content": {} + }, + "500": { + "description": "Internal Server Error. Something went wrong on the server side.", + "content": {} + } + } + } + }, + "/search/": { + "get": { + "tags": ["Search"], + "summary": "Search jobs", + "description": "Search for jobs using Solr", + "parameters": [ + { + "name": "q", + "in": "query", + "required": true, + "description": "The search query", + "schema": { + "type": "string" + } + }, + { + "name": "start", + "in": "query", + "required": false, + "description": "Pagination start index", + "schema": { + "type": "integer" + } + }, + { + "name": "rows", + "in": "query", + "required": false, + "description": "Number of results to return", + "schema": { + "type": "integer" + } + }, + { + "name": "sort", + "in": "query", + "required": false, + "description": "Sort order", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Search results", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "400": { + "description": "Bad Request. Invalid input parameter.", + "content": {} + }, + "500": { + "description": "Internal Server Error. Something went wrong on the server side.", + "content": {} + } + } + } + }, + "/total/": { + "get": { + "tags": ["General"], + "summary": "Get total job count", + "responses": { + "200": { + "description": "Total job count", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "total": { + "type": "integer", + "description": "Total number of jobs" + } + } + } + } + } + } + } + } + }, + "/update/": { + "post": { + "tags": ["Jobs"], + "summary": "Update jobs", + "description": "Update jobs using Solr", + "requestBody": { + "description": "Jobs data to be updated", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "job_title": { + "type": "string", + "description": "Job title" + }, + "city": { + "type": "string", + "description": "City" + }, + "job_link": { + "type": "string", + "description": "Job link" + }, + "company": { + "type": "string", + "description": "Company name" + } + }, + "required": ["job_title", "city", "job_link", "company"] + } + } + } + } + }, + "responses": { + "200": { + "description": "Jobs updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "Success message" + } + } + } + } + } + }, + "400": { + "description": "Bad Request. Invalid input parameter.", + "content": {} + }, + "500": { + "description": "Internal Server Error. Something went wrong on the server side.", + "content": {} + } + } + } + }, + "/updateuser/": { + "post": { + "tags": ["User"], + "summary": "Update user", + "description": "Update user details in Solr", + "requestBody": { + "description": "User data to be updated", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "User ID" + }, + "url": { + "type": "string", + "description": "User URL" + }, + "company": { + "type": "string", + "description": "Company name" + }, + "logo": { + "type": "string", + "description": "Logo URL" + }, + "apikey": { + "type": "string", + "description": "API key" + } + }, + "required": ["id"] + } + } + } + } + }, + "responses": { + "200": { + "description": "User updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "Success message" + } + } + } + } + } + }, + "400": { + "description": "Bad Request. Invalid input parameter.", + "content": {} + }, + "500": { + "description": "Internal Server Error. Something went wrong on the server side.", + "content": {} + } + } + } + }, + "/updateusr/": { + "put": { + "tags": ["User"], + "summary": "Update user", + "description": "Update user details in Solr", + "requestBody": { + "description": "User data to be updated", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "User ID" + }, + "url": { + "type": "string", + "description": "User URL" + }, + "company": { + "type": "string", + "description": "Company name" + }, + "logo": { + "type": "string", + "description": "Logo URL" + }, + "apikey": { + "type": "string", + "description": "API key" + } + }, + "required": ["id"] + } + } + } + } + }, + "responses": { + "200": { + "description": "User updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "Success message" + } + } + } + } + } + }, + "400": { + "description": "Bad Request. Invalid input parameter.", + "content": {} + }, + "500": { + "description": "Internal Server Error. Something went wrong on the server side.", + "content": {} + } + } + } + }, + "/updatejobs/": { + "put": { + "tags": ["Jobs"], + "summary": "Update jobs", + "description": "Update jobs using Solr", + "requestBody": { + "description": "Jobs data to be updated", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "job_title": { + "type": "string", + "description": "Job title" + }, + "city": { + "type": "string", + "description": "City" + }, + "job_link": { + "type": "string", + "description": "Job link" + }, + "company": { + "type": "string", + "description": "Company name" + } + }, + "required": ["job_title", "city", "job_link", "company"] + } + } + } + } + }, + "responses": { + "200": { + "description": "Jobs updated successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "Success message" + } + } + } + } + } + }, + "400": { + "description": "Bad Request. Invalid input parameter.", + "content": {} + }, + "500": { + "description": "Internal Server Error. Something went wrong on the server side.", + "content": {} + } + } + } } } } diff --git a/v0/updatejobs/index.php b/v0/updatejobs/index.php new file mode 100644 index 0000000..314a03d --- /dev/null +++ b/v0/updatejobs/index.php @@ -0,0 +1,85 @@ + array( + 'header' => "Content-type: application/json\r\n", + 'method' => 'POST', + 'content' => $data + ) + ); + + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); + + if ($result === FALSE) { /* Handle error */ } +} + +$method = 'PUT'; + +require_once '../config.php'; + +$core = 'jobs'; +$command ='/update'; + +$qs = '?'; +$qs = $qs . '_=1617366504771'; +$qs = $qs . '&'; +$qs = $qs . 'commitWithin=1000'; +$qs = $qs . '&'; +$qs = $qs . 'overwrite=true'; +$qs = $qs . '&'; +$qs = $qs . 'wt=json'; + +$url = 'http://' . $server . '/solr/' . $core . $command . $qs; + +$data = file_get_contents('php://input'); + +$json = json_decode($data); +print_r($data); + +foreach ($json as $item) { + $item->job_title=html_entity_decode($item->job_title); + $item->city = city_fix($item->city); + $item->id = md5($item->job_link).""; + $company= $item->company; +} + +$data = json_encode($json); + +$options = array( + 'http' => array( + 'header' => "Content-type: application/json\r\n", + 'method' => 'PUT', + 'content' => $data + ) +); + +discord_webhook($company); +$context = stream_context_create($options); +$result = file_get_contents($url, false, $context); + +if ($result === FALSE) { /* Handle error */ } + +?>