sharpapi-python-client 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ uMIT License
2
+
3
+ Copyright (c) 2024 SharpAPI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11
+
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.1
2
+ Name: sharpapi-python-client
3
+ Version: 1.0.0
4
+ Summary: SharpAPI.com Python SDK Client - AI-Powered Workflow Automation API.
5
+ Home-page: https://sharpapi.com
6
+ License: MIT
7
+ Author: Dawid Makowski
8
+ Author-email: contact@sharpapi.com
9
+ Requires-Python: >=3.8,<4.0
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Dist: requests (>=2.25.1)
18
+ Project-URL: Documentation, https://sharpapi.com/documentation
19
+ Project-URL: Repository, https://github.com/sharpapi/sharpapi-python-client
20
+ Description-Content-Type: text/markdown
21
+
22
+ # SharpAPI Python Client SDK
23
+
24
+ 🚀 Automate workflows with AI-powered API
25
+
26
+ ## Leverage AI API to streamline workflows in E-Commerce, Marketing, Content Management, HR Tech, Travel, and more.
27
+
28
+ [![Version](https://img.shields.io/pypi/v/sharpapi-python-client.svg)](https://pypi.org/project/sharpapi-python-client/)
29
+ [![License](https://img.shields.io/pypi/l/sharpapi-python-client.svg)](https://github.com/yourusername/sharpapi-python-client/blob/main/LICENSE)
30
+
31
+ #### Save time on repetitive content analysis and generation tasks that your app users perform daily.
32
+
33
+ See more at [SharpAPI.com Website »](https://sharpapi.com/)
34
+
35
+ ## Requirements
36
+
37
+ - Python >= 3.6
38
+
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ pip install sharpapi-python-client
44
+
45
+
46
+ ## What can it do for you?
47
+
48
+ - **E-commerce**
49
+ - Generate engaging product introductions.
50
+ - Create personalized thank-you emails.
51
+ - Streamline product categorization.
52
+ - Perform sentiment analysis on product reviews.
53
+
54
+ - **Content & Marketing Automation**
55
+ - Translate text for a global audience.
56
+ - Paraphrase and proofread any text.
57
+ - Detect spam content.
58
+ - Extract contact information.
59
+ - Summarize content and generate keywords/tags.
60
+ - Generate SEO meta tags.
61
+
62
+ - **HR Tech**
63
+ - Generate job descriptions.
64
+ - Identify related job positions and skills.
65
+ - Parse and extract information from resumes.
66
+
67
+ - **Travel, Tourism & Hospitality**
68
+ - Analyze sentiment in travel reviews.
69
+ - Categorize tours, activities, and hospitality products.
70
+
71
+ ## Usage
72
+
73
+ ### Simple Example
74
+
75
+ ```python
76
+ from sharpapi.sharp_api_service import SharpApiService
77
+
78
+ sharp_api = SharpApiService('YOUR_SHARP_API_KEY')
79
+
80
+ try:
81
+ status_url = sharp_api.product_categories(
82
+ 'Lenovo Chromebook Laptop (2023), 14" FHD Touchscreen Slim 3, 8-Core MediaTek Kompanio 520 CPU, 4GB RAM, 128GB Storage',
83
+ language='German', # optional
84
+ max_quantity=400, # optional
85
+ voice_tone='Neutral', # optional
86
+ context='Optional current e-store categories' # optional
87
+ )
88
+
89
+ result_sharp_api_job = sharp_api.fetch_results(status_url)
90
+ print(result_sharp_api_job.get_result_json())
91
+ except Exception as e:
92
+ print(e)
93
+ ```
94
+
95
+ ## Documentation
96
+ For detailed usage and API methods, please refer to the [SharpAPI Documentation](https://sharpapi.com/documentation).
97
+
98
+ ## Changelog
99
+ Please see CHANGELOG for more information on what has changed recently.
100
+
101
+ ## License
102
+ The MIT License (MIT). Please see License File for more information.
103
+
@@ -0,0 +1,81 @@
1
+ # SharpAPI Python Client SDK
2
+
3
+ 🚀 Automate workflows with AI-powered API
4
+
5
+ ## Leverage AI API to streamline workflows in E-Commerce, Marketing, Content Management, HR Tech, Travel, and more.
6
+
7
+ [![Version](https://img.shields.io/pypi/v/sharpapi-python-client.svg)](https://pypi.org/project/sharpapi-python-client/)
8
+ [![License](https://img.shields.io/pypi/l/sharpapi-python-client.svg)](https://github.com/yourusername/sharpapi-python-client/blob/main/LICENSE)
9
+
10
+ #### Save time on repetitive content analysis and generation tasks that your app users perform daily.
11
+
12
+ See more at [SharpAPI.com Website »](https://sharpapi.com/)
13
+
14
+ ## Requirements
15
+
16
+ - Python >= 3.6
17
+
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install sharpapi-python-client
23
+
24
+
25
+ ## What can it do for you?
26
+
27
+ - **E-commerce**
28
+ - Generate engaging product introductions.
29
+ - Create personalized thank-you emails.
30
+ - Streamline product categorization.
31
+ - Perform sentiment analysis on product reviews.
32
+
33
+ - **Content & Marketing Automation**
34
+ - Translate text for a global audience.
35
+ - Paraphrase and proofread any text.
36
+ - Detect spam content.
37
+ - Extract contact information.
38
+ - Summarize content and generate keywords/tags.
39
+ - Generate SEO meta tags.
40
+
41
+ - **HR Tech**
42
+ - Generate job descriptions.
43
+ - Identify related job positions and skills.
44
+ - Parse and extract information from resumes.
45
+
46
+ - **Travel, Tourism & Hospitality**
47
+ - Analyze sentiment in travel reviews.
48
+ - Categorize tours, activities, and hospitality products.
49
+
50
+ ## Usage
51
+
52
+ ### Simple Example
53
+
54
+ ```python
55
+ from sharpapi.sharp_api_service import SharpApiService
56
+
57
+ sharp_api = SharpApiService('YOUR_SHARP_API_KEY')
58
+
59
+ try:
60
+ status_url = sharp_api.product_categories(
61
+ 'Lenovo Chromebook Laptop (2023), 14" FHD Touchscreen Slim 3, 8-Core MediaTek Kompanio 520 CPU, 4GB RAM, 128GB Storage',
62
+ language='German', # optional
63
+ max_quantity=400, # optional
64
+ voice_tone='Neutral', # optional
65
+ context='Optional current e-store categories' # optional
66
+ )
67
+
68
+ result_sharp_api_job = sharp_api.fetch_results(status_url)
69
+ print(result_sharp_api_job.get_result_json())
70
+ except Exception as e:
71
+ print(e)
72
+ ```
73
+
74
+ ## Documentation
75
+ For detailed usage and API methods, please refer to the [SharpAPI Documentation](https://sharpapi.com/documentation).
76
+
77
+ ## Changelog
78
+ Please see CHANGELOG for more information on what has changed recently.
79
+
80
+ ## License
81
+ The MIT License (MIT). Please see License File for more information.
@@ -0,0 +1,25 @@
1
+ [tool.poetry]
2
+ name = "sharpapi-python-client"
3
+ version = "1.0.0"
4
+ description = "SharpAPI.com Python SDK Client - AI-Powered Workflow Automation API."
5
+ authors = ["Dawid Makowski <contact@sharpapi.com>"]
6
+ license = "MIT"
7
+ readme = "README.md"
8
+ homepage = "https://sharpapi.com"
9
+ repository = "https://github.com/sharpapi/sharpapi-python-client"
10
+ documentation = "https://sharpapi.com/documentation"
11
+
12
+ packages = [
13
+ { include = "sharpapi", from = "src" }
14
+ ]
15
+
16
+ [tool.poetry.dependencies]
17
+ python = "^3.8"
18
+ requests = ">=2.25.1"
19
+
20
+ [tool.poetry.dev-dependencies]
21
+ pytest = "^7.0"
22
+
23
+ [build-system]
24
+ requires = ["poetry-core"]
25
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,13 @@
1
+ # sharpapi/__init__.py
2
+
3
+ """
4
+ SharpAPI Python SDK Package Initialization
5
+ """
6
+
7
+ # Import the main service class for easy access
8
+ from .sharp_api_service import SharpApiService
9
+
10
+ # Import subpackages
11
+ from . import dto
12
+ from . import enums
13
+
@@ -0,0 +1,10 @@
1
+ # sharpapi/dto/__init__.py
2
+
3
+ """
4
+ Data Transfer Objects (DTO) Package Initialization
5
+ """
6
+
7
+ # Import DTO classes for easy access
8
+ from .job_description_parameters import JobDescriptionParameters
9
+ from .sharp_api_job import SharpApiJob
10
+ from .sharp_api_subscription_info import SharpApiSubscriptionInfo
@@ -0,0 +1,48 @@
1
+ class JobDescriptionParameters:
2
+ def __init__(
3
+ self,
4
+ name,
5
+ company_name=None,
6
+ minimum_work_experience=None,
7
+ minimum_education=None,
8
+ employment_type=None,
9
+ required_skills=None,
10
+ optional_skills=None,
11
+ country=None,
12
+ remote=None,
13
+ visa_sponsored=None,
14
+ voice_tone=None,
15
+ context=None,
16
+ language=None,
17
+ ):
18
+ self.name = name
19
+ self.company_name = company_name
20
+ self.minimum_work_experience = minimum_work_experience
21
+ self.minimum_education = minimum_education
22
+ self.employment_type = employment_type
23
+ self.required_skills = required_skills
24
+ self.optional_skills = optional_skills
25
+ self.country = country
26
+ self.remote = remote
27
+ self.visa_sponsored = visa_sponsored
28
+ self.voice_tone = voice_tone
29
+ self.context = context
30
+ self.language = language
31
+
32
+ def to_dict(self):
33
+ return {
34
+ 'name': self.name,
35
+ 'company_name': self.company_name,
36
+ 'minimum_work_experience': self.minimum_work_experience,
37
+ 'minimum_education': self.minimum_education,
38
+ 'employment_type': self.employment_type,
39
+ 'required_skills': self.required_skills,
40
+ 'optional_skills': self.optional_skills,
41
+ 'country': self.country,
42
+ 'remote': self.remote,
43
+ 'visa_sponsored': self.visa_sponsored,
44
+ 'voice_tone': self.voice_tone,
45
+ 'context': self.context,
46
+ 'language': self.language,
47
+ }
48
+
@@ -0,0 +1,27 @@
1
+ from ..enums.sharp_api_job_status_enum import SharpApiJobStatusEnum
2
+ from ..enums.sharp_api_job_type_enum import SharpApiJobTypeEnum
3
+ import json
4
+
5
+
6
+ class SharpApiJob:
7
+ def __init__(self, id, type, status, result):
8
+ self.id = id
9
+ self.type = type
10
+ self.status = status
11
+ self.result = result
12
+
13
+ def get_id(self):
14
+ return self.id
15
+
16
+ def get_type(self):
17
+ return self.type
18
+
19
+ def get_status(self):
20
+ return self.status
21
+
22
+ def get_result_json(self):
23
+ return json.dumps(self.result, indent=2) if self.result else None
24
+
25
+ def get_result_object(self):
26
+ return self.result
27
+
@@ -0,0 +1,15 @@
1
+ from datetime import datetime
2
+
3
+
4
+ class SharpApiSubscriptionInfo:
5
+ def __init__(self, data):
6
+ self.timestamp = datetime.fromisoformat(data['timestamp'])
7
+ self.on_trial = data['on_trial']
8
+ self.trial_ends = datetime.fromisoformat(data['trial_ends'])
9
+ self.subscribed = data['subscribed']
10
+ self.current_subscription_start = datetime.fromisoformat(data['current_subscription_start'])
11
+ self.current_subscription_end = datetime.fromisoformat(data['current_subscription_end'])
12
+ self.subscription_words_quota = data['subscription_words_quota']
13
+ self.subscription_words_used = data['subscription_words_used']
14
+ self.subscription_words_used_percentage = data['subscription_words_used_percentage']
15
+
@@ -0,0 +1,10 @@
1
+ # sharpapi/enums/__init__.py
2
+
3
+ """
4
+ Enumerations Package Initialization
5
+ """
6
+ from .sharp_api_job_status_enum import SharpApiJobStatusEnum
7
+ from .sharp_api_job_type_enum import SharpApiJobTypeEnum
8
+ from .sharp_api_languages import SharpApiLanguages
9
+ from .sharp_api_voice_tone import SharpApiVoiceTone
10
+
@@ -0,0 +1,9 @@
1
+ from enum import Enum
2
+
3
+
4
+ class SharpApiJobStatusEnum(Enum):
5
+ NEW = 'new'
6
+ PENDING = 'pending'
7
+ FAILED = 'failed'
8
+ SUCCESS = 'success'
9
+
@@ -0,0 +1,82 @@
1
+ class SharpApiJobTypeEnum:
2
+ ECOMMERCE_REVIEW_SENTIMENT = {
3
+ 'value': 'ecommerce_review_sentiment',
4
+ 'url': '/ecommerce/review_sentiment',
5
+ }
6
+ ECOMMERCE_PRODUCT_CATEGORIES = {
7
+ 'value': 'ecommerce_product_categories',
8
+ 'url': '/ecommerce/product_categories',
9
+ }
10
+ ECOMMERCE_PRODUCT_INTRO = {
11
+ 'value': 'ecommerce_product_intro',
12
+ 'url': '/ecommerce/product_intro',
13
+ }
14
+ ECOMMERCE_THANK_YOU_EMAIL = {
15
+ 'value': 'ecommerce_thank_you_email',
16
+ 'url': '/ecommerce/thank_you_email',
17
+ }
18
+ HR_PARSE_RESUME = {
19
+ 'value': 'hr_parse_resume',
20
+ 'url': '/hr/parse_resume',
21
+ }
22
+ HR_JOB_DESCRIPTION = {
23
+ 'value': 'hr_job_description',
24
+ 'url': '/hr/job_description',
25
+ }
26
+ HR_RELATED_SKILLS = {
27
+ 'value': 'hr_related_skills',
28
+ 'url': '/hr/related_skills',
29
+ }
30
+ HR_RELATED_JOB_POSITIONS = {
31
+ 'value': 'hr_related_job_positions',
32
+ 'url': '/hr/related_job_positions',
33
+ }
34
+ TTH_REVIEW_SENTIMENT = {
35
+ 'value': 'tth_review_sentiment',
36
+ 'url': '/tth/review_sentiment',
37
+ }
38
+ TTH_TA_PRODUCT_CATEGORIES = {
39
+ 'value': 'tth_ta_product_categories',
40
+ 'url': '/tth/ta_product_categories',
41
+ }
42
+ TTH_HOSPITALITY_PRODUCT_CATEGORIES = {
43
+ 'value': 'tth_hospitality_product_categories',
44
+ 'url': '/tth/hospitality_product_categories',
45
+ }
46
+ CONTENT_DETECT_PHONES = {
47
+ 'value': 'content_detect_phones',
48
+ 'url': '/content/detect_phones',
49
+ }
50
+ CONTENT_DETECT_EMAILS = {
51
+ 'value': 'content_detect_emails',
52
+ 'url': '/content/detect_emails',
53
+ }
54
+ CONTENT_DETECT_SPAM = {
55
+ 'value': 'content_detect_spam',
56
+ 'url': '/content/detect_spam',
57
+ }
58
+ CONTENT_SUMMARIZE = {
59
+ 'value': 'content_summarize',
60
+ 'url': '/content/summarize',
61
+ }
62
+ CONTENT_KEYWORDS = {
63
+ 'value': 'content_keywords',
64
+ 'url': '/content/keywords',
65
+ }
66
+ CONTENT_TRANSLATE = {
67
+ 'value': 'content_translate',
68
+ 'url': '/content/translate',
69
+ }
70
+ CONTENT_PARAPHRASE = {
71
+ 'value': 'content_paraphrase',
72
+ 'url': '/content/paraphrase',
73
+ }
74
+ CONTENT_PROOFREAD = {
75
+ 'value': 'content_proofread',
76
+ 'url': '/content/proofread',
77
+ }
78
+ SEO_GENERATE_TAGS = {
79
+ 'value': 'seo_generate_tags',
80
+ 'url': '/seo/generate_tags',
81
+ }
82
+
@@ -0,0 +1,82 @@
1
+ class SharpApiLanguages:
2
+ AFRIKAANS = 'Afrikaans'
3
+ ALBANIAN = 'Albanian'
4
+ AMHARIC = 'Amharic'
5
+ ARABIC = 'Arabic'
6
+ ARMENIAN = 'Armenian'
7
+ AZERBAIJANI = 'Azerbaijani'
8
+ BENGALI = 'Bengali'
9
+ BOSNIAN = 'Bosnian'
10
+ BULGARIAN = 'Bulgarian'
11
+ BURMESE = 'Burmese'
12
+ CATALAN = 'Catalan'
13
+ CHINESE_SIMPLIFIED = 'Chinese (Simplified)'
14
+ CHINESE_TRADITIONAL = 'Chinese (Traditional)'
15
+ CROATIAN = 'Croatian'
16
+ CZECH = 'Czech'
17
+ DANISH = 'Danish'
18
+ DARI = 'Dari'
19
+ DUTCH = 'Dutch'
20
+ ENGLISH = 'English'
21
+ ESTONIAN = 'Estonian'
22
+ FINNISH = 'Finnish'
23
+ FRENCH = 'French'
24
+ GEORGIAN = 'Georgian'
25
+ GERMAN = 'German'
26
+ GREEK = 'Greek'
27
+ GUJARATI = 'Gujarati'
28
+ HEBREW = 'Hebrew'
29
+ HINDI = 'Hindi'
30
+ HUNGARIAN = 'Hungarian'
31
+ ICELANDIC = 'Icelandic'
32
+ INDONESIAN = 'Indonesian'
33
+ ITALIAN = 'Italian'
34
+ JAPANESE = 'Japanese'
35
+ JAVANESE = 'Javanese'
36
+ KANNADA = 'Kannada'
37
+ KAZAKH = 'Kazakh'
38
+ KINYARWANDA = 'Kinyarwanda'
39
+ KOREAN = 'Korean'
40
+ KURDISH_SORANI = 'Kurdish (Sorani)'
41
+ KYRGYZ = 'Kyrgyz'
42
+ LAO = 'Lao'
43
+ LATVIAN = 'Latvian'
44
+ LITHUANIAN = 'Lithuanian'
45
+ MACEDONIAN = 'Macedonian'
46
+ MALAY = 'Malay'
47
+ MALAYALAM = 'Malayalam'
48
+ MARATHI = 'Marathi'
49
+ MONGOLIAN = 'Mongolian'
50
+ NEPALI = 'Nepali'
51
+ NORWEGIAN = 'Norwegian'
52
+ ORIYA = 'Oriya'
53
+ PASHTO = 'Pashto'
54
+ PERSIAN = 'Persian'
55
+ POLISH = 'Polish'
56
+ PORTUGUESE = 'Portuguese'
57
+ PUNJABI = 'Punjabi'
58
+ ROMANIAN = 'Romanian'
59
+ RUSSIAN = 'Russian'
60
+ SERBIAN = 'Serbian'
61
+ SESOTHO = 'Sesotho'
62
+ SINHALA = 'Sinhala'
63
+ SLOVAK = 'Slovak'
64
+ SLOVENIAN = 'Slovenian'
65
+ SOMALI = 'Somali'
66
+ SPANISH = 'Spanish'
67
+ SWAHILI = 'Swahili'
68
+ SWEDISH = 'Swedish'
69
+ TAGALOG = 'Tagalog'
70
+ TAJIK = 'Tajik'
71
+ TAMIL = 'Tamil'
72
+ TELUGU = 'Telugu'
73
+ THAI = 'Thai'
74
+ TURKISH = 'Turkish'
75
+ UKRAINIAN = 'Ukrainian'
76
+ URDU = 'Urdu'
77
+ UZBEK = 'Uzbek'
78
+ VIETNAMESE = 'Vietnamese'
79
+ XHOSA = 'Xhosa'
80
+ YORUBA = 'Yoruba'
81
+ ZULU = 'Zulu'
82
+
@@ -0,0 +1,57 @@
1
+ class SharpApiVoiceTone:
2
+ ADVENTUROUS = 'Adventurous'
3
+ ACADEMIC = 'Academic'
4
+ ARTICULATE = 'Articulate'
5
+ ASSERTIVE = 'Assertive'
6
+ AUTHORITATIVE = 'Authoritative'
7
+ CAPTIVATING = 'Captivating'
8
+ CASUAL = 'Casual'
9
+ CANDID = 'Candid'
10
+ COMPELLING = 'Compelling'
11
+ COMICAL = 'Comical'
12
+ CULTURED = 'Cultured'
13
+ ECLECTIC = 'Eclectic'
14
+ EDUCATIONAL = 'Educational'
15
+ EFFORTLESS = 'Effortless'
16
+ ELOQUENT = 'Eloquent'
17
+ EMPATHETIC = 'Empathetic'
18
+ EMPOWERING = 'Empowering'
19
+ ENCOURAGING = 'Encouraging'
20
+ ENGAGING = 'Engaging'
21
+ ENLIGHTENING = 'Enlightening'
22
+ ENTHUSIASTIC = 'Enthusiastic'
23
+ EXPRESSIVE = 'Expressive'
24
+ FORMAL = 'Formal'
25
+ FRIENDLY = 'Friendly'
26
+ FUNNY = 'Funny'
27
+ HEARTENING = 'Heartening'
28
+ HEARTFELT = 'Heartfelt'
29
+ HUMOROUS = 'Humorous'
30
+ IMPASSIONED = 'Impassioned'
31
+ INSPIRATIONAL = 'Inspirational'
32
+ INSTRUCTIONAL = 'Instructional'
33
+ INTELLECTUAL = 'Intellectual'
34
+ INFORMAL = 'Informal'
35
+ INVENTIVE = 'Inventive'
36
+ LIVELY = 'Lively'
37
+ LYRICAL = 'Lyrical'
38
+ LUXURIOUS = 'Luxurious'
39
+ MINIMALIST = 'Minimalist'
40
+ NARRATIVE = 'Narrative'
41
+ NEUTRAL = 'Neutral'
42
+ NOSTALGIC = 'Nostalgic'
43
+ OPTIMISTIC = 'Optimistic'
44
+ PERSUASIVE = 'Persuasive'
45
+ PESSIMISTIC = 'Pessimistic'
46
+ PROVOCATIVE = 'Provocative'
47
+ QUIRKY = 'Quirky'
48
+ RESPECTFUL = 'Respectful'
49
+ SERIOUS = 'Serious'
50
+ SINCERE = 'Sincere'
51
+ STORYTELLING = 'Storytelling'
52
+ SYMPATHETIC = 'Sympathetic'
53
+ TECH_SAVVY = 'Tech-Savvy'
54
+ THOUGHTFUL = 'Thoughtful'
55
+ TOUCHING = 'Touching'
56
+ WITTY = 'Witty'
57
+
@@ -0,0 +1,285 @@
1
+ import time
2
+ import requests
3
+ from urllib.parse import urlparse
4
+
5
+ from .dto.job_description_parameters import JobDescriptionParameters
6
+ from .dto.sharp_api_job import SharpApiJob
7
+ from .dto.sharp_api_subscription_info import SharpApiSubscriptionInfo
8
+ from .enums.sharp_api_job_status_enum import SharpApiJobStatusEnum
9
+ from .enums.sharp_api_job_type_enum import SharpApiJobTypeEnum
10
+
11
+
12
+ class SharpApiService:
13
+ def __init__(self, api_key, api_base_url='https://sharpapi.com/api/v1', user_agent='SharpAPIPythonClient/1.2.0'):
14
+ if not api_key:
15
+ raise ValueError('API key is required.')
16
+ self.api_key = api_key
17
+ self.api_base_url = api_base_url
18
+ self.user_agent = user_agent
19
+ self.api_job_status_polling_interval = 10 # seconds
20
+ self.use_custom_interval = False
21
+ self.api_job_status_polling_wait = 180 # seconds
22
+
23
+ def get_headers(self):
24
+ return {
25
+ 'Authorization': f'Bearer {self.api_key}',
26
+ 'Accept': 'application/json',
27
+ 'User-Agent': self.user_agent,
28
+ }
29
+
30
+ def make_request(self, method, url, data=None, file_path=None):
31
+ full_url = f'{self.api_base_url}{url}'
32
+ headers = self.get_headers()
33
+
34
+ if method == 'POST':
35
+ if file_path:
36
+ files = {'file': open(file_path, 'rb')}
37
+ response = requests.post(full_url, headers=headers, data=data, files=files)
38
+ else:
39
+ response = requests.post(full_url, headers=headers, json=data)
40
+ else:
41
+ response = requests.get(full_url, headers=headers, params=data)
42
+
43
+ response.raise_for_status()
44
+ return response.json()
45
+
46
+ def parse_status_url(self, response):
47
+ return response.get('status_url')
48
+
49
+ def fetch_results(self, status_url):
50
+ waiting_time = 0
51
+
52
+ while True:
53
+ response = requests.get(status_url, headers=self.get_headers())
54
+ response.raise_for_status()
55
+ response_data = response.json()
56
+ job_status = response_data['data']['attributes']
57
+
58
+ if job_status['status'] in [SharpApiJobStatusEnum.SUCCESS.value, SharpApiJobStatusEnum.FAILED.value]:
59
+ break
60
+
61
+ retry_after = int(response.headers.get('Retry-After', self.api_job_status_polling_interval))
62
+ if self.use_custom_interval:
63
+ retry_after = self.api_job_status_polling_interval
64
+
65
+ waiting_time += retry_after
66
+ if waiting_time >= self.api_job_status_polling_wait:
67
+ break
68
+
69
+ time.sleep(retry_after)
70
+
71
+ data = response_data['data']
72
+ url_parts = urlparse(status_url)
73
+ segments = url_parts.path.strip('/').split('/')
74
+ if len(segments) == 5:
75
+ result = data['attributes']['result']
76
+ else:
77
+ result = data['attributes']['result']
78
+
79
+ return SharpApiJob(
80
+ id=data['id'],
81
+ type=data['attributes']['type'],
82
+ status=data['attributes']['status'],
83
+ result=result or None
84
+ )
85
+
86
+ def ping(self):
87
+ response = self.make_request('GET', '/ping')
88
+ return response
89
+
90
+ def quota(self):
91
+ response = self.make_request('GET', '/quota')
92
+ if 'timestamp' not in response:
93
+ return None
94
+ return SharpApiSubscriptionInfo(response)
95
+
96
+ # Include all API methods here, following the structure:
97
+
98
+ def parse_resume(self, file_path, language=None):
99
+ data = {}
100
+ if language:
101
+ data['language'] = language
102
+ response = self.make_request('POST', SharpApiJobTypeEnum.HR_PARSE_RESUME['url'], data, file_path)
103
+ return self.parse_status_url(response)
104
+
105
+ def generate_job_description(self, job_description_parameters):
106
+ data = job_description_parameters.to_dict()
107
+ response = self.make_request('POST', SharpApiJobTypeEnum.HR_JOB_DESCRIPTION['url'], data)
108
+ return self.parse_status_url(response)
109
+
110
+ def related_skills(self, skill_name, language=None, max_quantity=None):
111
+ data = {'content': skill_name}
112
+ if language:
113
+ data['language'] = language
114
+ if max_quantity:
115
+ data['max_quantity'] = max_quantity
116
+ response = self.make_request('POST', SharpApiJobTypeEnum.HR_RELATED_SKILLS['url'], data)
117
+ return self.parse_status_url(response)
118
+
119
+ def related_job_positions(self, job_position_name, language=None, max_quantity=None):
120
+ data = {'content': job_position_name}
121
+ if language:
122
+ data['language'] = language
123
+ if max_quantity:
124
+ data['max_quantity'] = max_quantity
125
+ response = self.make_request('POST', SharpApiJobTypeEnum.HR_RELATED_JOB_POSITIONS['url'], data)
126
+ return self.parse_status_url(response)
127
+
128
+ def product_review_sentiment(self, review):
129
+ data = {'content': review}
130
+ response = self.make_request('POST', SharpApiJobTypeEnum.ECOMMERCE_REVIEW_SENTIMENT['url'], data)
131
+ return self.parse_status_url(response)
132
+
133
+ def product_categories(self, product_name, language=None, max_quantity=None, voice_tone=None, context=None):
134
+ data = {'content': product_name}
135
+ if language:
136
+ data['language'] = language
137
+ if max_quantity:
138
+ data['max_quantity'] = max_quantity
139
+ if voice_tone:
140
+ data['voice_tone'] = voice_tone
141
+ if context:
142
+ data['context'] = context
143
+ response = self.make_request('POST', SharpApiJobTypeEnum.ECOMMERCE_PRODUCT_CATEGORIES['url'], data)
144
+ return self.parse_status_url(response)
145
+
146
+ def generate_product_intro(self, product_data, language=None, max_length=None, voice_tone=None):
147
+ data = {'content': product_data}
148
+ if language:
149
+ data['language'] = language
150
+ if max_length:
151
+ data['max_length'] = max_length
152
+ if voice_tone:
153
+ data['voice_tone'] = voice_tone
154
+ response = self.make_request('POST', SharpApiJobTypeEnum.ECOMMERCE_PRODUCT_INTRO['url'], data)
155
+ return self.parse_status_url(response)
156
+
157
+ def generate_thank_you_email(self, product_name, language=None, max_length=None, voice_tone=None, context=None):
158
+ data = {'content': product_name}
159
+ if language:
160
+ data['language'] = language
161
+ if max_length:
162
+ data['max_length'] = max_length
163
+ if voice_tone:
164
+ data['voice_tone'] = voice_tone
165
+ if context:
166
+ data['context'] = context
167
+ response = self.make_request('POST', SharpApiJobTypeEnum.ECOMMERCE_THANK_YOU_EMAIL['url'], data)
168
+ return self.parse_status_url(response)
169
+
170
+ def detect_phones(self, text):
171
+ data = {'content': text}
172
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_DETECT_PHONES['url'], data)
173
+ return self.parse_status_url(response)
174
+
175
+ def detect_emails(self, text):
176
+ data = {'content': text}
177
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_DETECT_EMAILS['url'], data)
178
+ return self.parse_status_url(response)
179
+
180
+ def detect_spam(self, text):
181
+ data = {'content': text}
182
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_DETECT_SPAM['url'], data)
183
+ return self.parse_status_url(response)
184
+
185
+ def summarize_text(self, text, language=None, max_length=None, voice_tone=None, context=None):
186
+ data = {'content': text}
187
+ if language:
188
+ data['language'] = language
189
+ if max_length:
190
+ data['max_length'] = max_length
191
+ if voice_tone:
192
+ data['voice_tone'] = voice_tone
193
+ if context:
194
+ data['context'] = context
195
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_SUMMARIZE['url'], data)
196
+ return self.parse_status_url(response)
197
+
198
+ def generate_keywords(self, text, language=None, max_quantity=None, voice_tone=None, context=None):
199
+ data = {'content': text}
200
+ if language:
201
+ data['language'] = language
202
+ if max_quantity:
203
+ data['max_quantity'] = max_quantity
204
+ if voice_tone:
205
+ data['voice_tone'] = voice_tone
206
+ if context:
207
+ data['context'] = context
208
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_KEYWORDS['url'], data)
209
+ return self.parse_status_url(response)
210
+
211
+ def translate(self, text, language, voice_tone=None, context=None):
212
+ data = {'content': text, 'language': language}
213
+ if voice_tone:
214
+ data['voice_tone'] = voice_tone
215
+ if context:
216
+ data['context'] = context
217
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_TRANSLATE['url'], data)
218
+ return self.parse_status_url(response)
219
+
220
+ def paraphrase(self, text, language=None, max_length=None, voice_tone=None, context=None):
221
+ data = {'content': text}
222
+ if language:
223
+ data['language'] = language
224
+ if max_length:
225
+ data['max_length'] = max_length
226
+ if voice_tone:
227
+ data['voice_tone'] = voice_tone
228
+ if context:
229
+ data['context'] = context
230
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_PARAPHRASE['url'], data)
231
+ return self.parse_status_url(response)
232
+
233
+ def proofread(self, text):
234
+ data = {'content': text}
235
+ response = self.make_request('POST', SharpApiJobTypeEnum.CONTENT_PROOFREAD['url'], data)
236
+ return self.parse_status_url(response)
237
+
238
+ def generate_seo_tags(self, text, language=None, voice_tone=None):
239
+ data = {'content': text}
240
+ if language:
241
+ data['language'] = language
242
+ if voice_tone:
243
+ data['voice_tone'] = voice_tone
244
+ response = self.make_request('POST', SharpApiJobTypeEnum.SEO_GENERATE_TAGS['url'], data)
245
+ return self.parse_status_url(response)
246
+
247
+ def travel_review_sentiment(self, text):
248
+ data = {'content': text}
249
+ response = self.make_request('POST', SharpApiJobTypeEnum.TTH_REVIEW_SENTIMENT['url'], data)
250
+ return self.parse_status_url(response)
251
+
252
+ def tours_and_activities_product_categories(self, product_name, city=None, country=None, language=None, max_quantity=None, voice_tone=None, context=None):
253
+ data = {'content': product_name}
254
+ if city:
255
+ data['city'] = city
256
+ if country:
257
+ data['country'] = country
258
+ if language:
259
+ data['language'] = language
260
+ if max_quantity:
261
+ data['max_quantity'] = max_quantity
262
+ if voice_tone:
263
+ data['voice_tone'] = voice_tone
264
+ if context:
265
+ data['context'] = context
266
+ response = self.make_request('POST', SharpApiJobTypeEnum.TTH_TA_PRODUCT_CATEGORIES['url'], data)
267
+ return self.parse_status_url(response)
268
+
269
+ def hospitality_product_categories(self, product_name, city=None, country=None, language=None, max_quantity=None, voice_tone=None, context=None):
270
+ data = {'content': product_name}
271
+ if city:
272
+ data['city'] = city
273
+ if country:
274
+ data['country'] = country
275
+ if language:
276
+ data['language'] = language
277
+ if max_quantity:
278
+ data['max_quantity'] = max_quantity
279
+ if voice_tone:
280
+ data['voice_tone'] = voice_tone
281
+ if context:
282
+ data['context'] = context
283
+ response = self.make_request('POST', SharpApiJobTypeEnum.TTH_HOSPITALITY_PRODUCT_CATEGORIES['url'], data)
284
+ return self.parse_status_url(response)
285
+