Skip to content

Commit

Permalink
Merge pull request #83 from appwrite/dev
Browse files Browse the repository at this point in the history
Fix msg91 params
  • Loading branch information
christyjacob4 authored Mar 24, 2024
2 parents 920b493 + 56d1dbc commit 35c17ae
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite Python SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-python.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.0-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down
4 changes: 2 additions & 2 deletions appwrite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def __init__(self):
self._endpoint = 'https://cloud.appwrite.io/v1'
self._global_headers = {
'content-type': '',
'user-agent' : 'AppwritePythonSDK/5.0.1 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
'user-agent' : 'AppwritePythonSDK/5.0.2 (${os.uname().sysname}; ${os.uname().version}; ${os.uname().machine})',
'x-sdk-name': 'Python',
'x-sdk-platform': 'server',
'x-sdk-language': 'python',
'x-sdk-version': '5.0.1',
'x-sdk-version': '5.0.2',
'X-Appwrite-Response-Format' : '1.5.0',
}

Expand Down
22 changes: 20 additions & 2 deletions appwrite/id.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
from datetime import datetime
import math
import os

class ID:
# Generate an hex ID based on timestamp
# Recreated from https://www.php.net/manual/en/function.uniqid.php
@staticmethod
def __hex_timestamp():
now = datetime.now()
sec = int(now.timestamp())
usec = (now.microsecond % 1000)
hex_timestamp = f'{sec:08x}{usec:05x}'
return hex_timestamp

@staticmethod
def custom(id):
return id

# Generate a unique ID with padding to have a longer ID
@staticmethod
def unique():
return 'unique()'
def unique(padding = 7):
base_id = ID.__hex_timestamp()
random_bytes = os.urandom(math.ceil(padding / 2))
random_padding = random_bytes.hex()[:padding]
return base_id + random_padding
8 changes: 4 additions & 4 deletions appwrite/services/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def update_mailgun_provider(self, provider_id, name = None, api_key = None, doma
'content-type': 'application/json',
}, api_params)

def create_msg91_provider(self, provider_id, name, xfrom = None, sender_id = None, auth_key = None, enabled = None):
def create_msg91_provider(self, provider_id, name, template_id = None, sender_id = None, auth_key = None, enabled = None):
"""Create Msg91 provider"""


Expand All @@ -432,7 +432,7 @@ def create_msg91_provider(self, provider_id, name, xfrom = None, sender_id = Non

api_params['providerId'] = provider_id
api_params['name'] = name
api_params['from'] = xfrom
api_params['templateId'] = template_id
api_params['senderId'] = sender_id
api_params['authKey'] = auth_key
api_params['enabled'] = enabled
Expand All @@ -441,7 +441,7 @@ def create_msg91_provider(self, provider_id, name, xfrom = None, sender_id = Non
'content-type': 'application/json',
}, api_params)

def update_msg91_provider(self, provider_id, name = None, enabled = None, sender_id = None, auth_key = None, xfrom = None):
def update_msg91_provider(self, provider_id, name = None, enabled = None, template_id = None, sender_id = None, auth_key = None):
"""Update Msg91 provider"""


Expand All @@ -454,9 +454,9 @@ def update_msg91_provider(self, provider_id, name = None, enabled = None, sender

api_params['name'] = name
api_params['enabled'] = enabled
api_params['templateId'] = template_id
api_params['senderId'] = sender_id
api_params['authKey'] = auth_key
api_params['from'] = xfrom

return self.client.call('patch', api_path, {
'content-type': 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/messaging/create-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ messaging = Messaging(client)
result = messaging.create_msg91_provider(
provider_id = '<PROVIDER_ID>',
name = '<NAME>',
from = '+12065550100', # optional
template_id = '<TEMPLATE_ID>', # optional
sender_id = '<SENDER_ID>', # optional
auth_key = '<AUTH_KEY>', # optional
enabled = False # optional
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/messaging/update-msg91provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ result = messaging.update_msg91_provider(
provider_id = '<PROVIDER_ID>',
name = '<NAME>', # optional
enabled = False, # optional
template_id = '<TEMPLATE_ID>', # optional
sender_id = '<SENDER_ID>', # optional
auth_key = '<AUTH_KEY>', # optional
from = '<FROM>' # optional
auth_key = '<AUTH_KEY>' # optional
)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'appwrite/encoders',
'appwrite/enums',
],
version = '5.0.1',
version = '5.0.2',
license='BSD-3-Clause',
description = 'Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API',
long_description = long_description,
Expand All @@ -23,7 +23,7 @@
maintainer = 'Appwrite Team',
maintainer_email = 'team@appwrite.io',
url = 'https://appwrite.io/support',
download_url='https://github.com/appwrite/sdk-for-python/archive/5.0.1.tar.gz',
download_url='https://github.com/appwrite/sdk-for-python/archive/5.0.2.tar.gz',
install_requires=[
'requests',
],
Expand Down

0 comments on commit 35c17ae

Please sign in to comment.