Skip to content

Commit df7112e

Browse files
committed
Release 1.0.0
1 parent ce5e788 commit df7112e

File tree

5 files changed

+40
-31
lines changed

5 files changed

+40
-31
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ result = loop.run_until_complete(api.generate_invoice(invoiceData))
6868

6969
1. Here's an Example of how you can **onboard multiple EGS to ZATCA Portal** [If you are onboarding PoS devices or VAT-Group members, this comes handy].
7070

71+
2. Examples are included in the examples folder as well
72+
7173
```python
7274
import asyncio
7375
from flick.api_service import Config
74-
from flick.bills import Bills,EGSData,Devices
76+
from flick.bills import Bills,EGSData,Device
7577

7678
config = Config('sandbox', 'your-api-key')
7779

@@ -81,7 +83,7 @@ egs_data = EGSData(
8183
vat_name='Test Co.',
8284
vat_number='300000000000003',
8385
devices=[
84-
Devices(
86+
Device(
8587
device_name='TestEGS1',
8688
city='Riyadh',
8789
city_subdiv='Test Dist.',
@@ -93,7 +95,7 @@ egs_data = EGSData(
9395
branch_name='Riyad Branc h 1',
9496
branch_industry='Retail',
9597
otp='123321',
96-
), Devices(
98+
), Device(
9799
device_name='TestEGS2',
98100
city='Riyadh',
99101
city_subdiv='Test Dist.',
@@ -122,7 +124,7 @@ print(result)
122124
```python
123125
import asyncio
124126
from flick.api_service import Config
125-
from flick.bills import Bills, InvoiceData, PartyAddId, PartyDetails, AdvanceDetails, AdvanceInvoices, Invoice, LineItems
127+
from flick.bills import Bills, InvoiceData, PartyAddId, PartyDetails, AdvanceDetails, AdvanceInvoice, Invoice, LineItem
126128

127129
config = Config('sandbox', 'your-api-key')
128130

@@ -155,7 +157,7 @@ invoice_data = InvoiceData(
155157
advance_amount=575,
156158
total_amount=2875,
157159
advance_invoices=[
158-
AdvanceInvoices(
160+
AdvanceInvoice(
159161
tax_category='S',
160162
tax_percentage=0.15,
161163
taxable_amount=500,
@@ -171,14 +173,14 @@ invoice_data = InvoiceData(
171173
],
172174
),
173175
lineitems=[
174-
LineItems(
176+
LineItem(
175177
name_ar='متحرك',
176178
quantity=1,
177179
tax_category='S',
178180
tax_exclusive_price=750,
179181
tax_percentage=0.15,
180182
),
181-
LineItems(
183+
LineItem(
182184
name_ar='حاسوب محمول',
183185
quantity=1,
184186
tax_category='S',

examples/generate_invoice.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from flick.api_service import Config
3-
from flick.bills import Bills, InvoiceData, PartyAddId, PartyDetails, AdvanceDetails, AdvanceInvoices, Invoice, LineItems
3+
from flick.bills import Bills, InvoiceData, PartyAddId, PartyDetails, AdvanceDetails, AdvanceInvoice, Invoice, LineItem
44

55
config = Config('sandbox', 'your-api-key')
66

@@ -33,7 +33,7 @@
3333
advance_amount=575,
3434
total_amount=2875,
3535
advance_invoices=[
36-
AdvanceInvoices(
36+
AdvanceInvoice(
3737
tax_category='S',
3838
tax_percentage=0.15,
3939
taxable_amount=500,
@@ -49,14 +49,14 @@
4949
],
5050
),
5151
lineitems=[
52-
LineItems(
52+
LineItem(
5353
name_ar='متحرك',
5454
quantity=1,
5555
tax_category='S',
5656
tax_exclusive_price=750,
5757
tax_percentage=0.15,
5858
),
59-
LineItems(
59+
LineItem(
6060
name_ar='حاسوب محمول',
6161
quantity=1,
6262
tax_category='S',

examples/onboard_egs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from flick.api_service import Config
3-
from flick.bills import Bills,EGSData,Devices
3+
from flick.bills import Bills,EGSData,Device
44

55
config = Config('sandbox', 'your-api-key')
66

@@ -10,7 +10,7 @@
1010
vat_name='Test Co.',
1111
vat_number='300000000000003',
1212
devices=[
13-
Devices(
13+
Device(
1414
device_name='TestEGS1',
1515
city='Riyadh',
1616
city_subdiv='Test Dist.',
@@ -22,7 +22,7 @@
2222
branch_name='Riyad Branc h 1',
2323
branch_industry='Retail',
2424
otp='123321',
25-
), Devices(
25+
), Device(
2626
device_name='TestEGS2',
2727
city='Riyadh',
2828
city_subdiv='Test Dist.',

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
setup(
66
name = "flick-python-sdk",
7-
version = "0.0.14",
7+
version = "1.0.0",
88
author = "Sivadas Rajan",
99
author_email = "sivadasrajan@gmail.com",
1010
description = "A Python wrapper for interacting with APIs from Flick.",
1111
long_description = long_description,
1212
long_description_content_type = "text/markdown",
1313
install_requires=["aiohttp>=3.5.0"],
1414
url = "https://pypi.org/project/flick-python-sdk/",
15+
maintainer="Sivadas Rajan",
16+
maintainer_email="sivadasrajan@gmail.com",
1517
project_urls = {
1618
"Bug Tracker": "https://github.com/flick-network/flick-python-sdk/issues",
1719
},

src/flick/bills.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from .api_service import FlickAPI, Config
44

55

6-
class Devices():
6+
class Device():
77
""" The Devices class. """
88

99
def __init__(self, device_name: str, city: str, city_subdiv: str, street: str, plot: str, building: str, postal: str, branch_name: str, branch_industry: str, otp: str):
@@ -23,7 +23,7 @@ def __init__(self, device_name: str, city: str, city_subdiv: str, street: str, p
2323
class EGSData:
2424
""" The EGSData class. """
2525

26-
def __init__(self, vat_name: str, vat_number: str, devices: List[Devices]):
26+
def __init__(self, vat_name: str, vat_number: str, devices: List[Device]):
2727
"""
2828
Initializes an instance of EGSData.
2929
@@ -36,7 +36,8 @@ def __init__(self, vat_name: str, vat_number: str, devices: List[Devices]):
3636
self.vat_number = vat_number
3737
self.devices = devices
3838

39-
def to_json(self):
39+
def to_dict(self):
40+
""" function to convert class to dictionary """
4041

4142
out = {
4243
"vat_name": self.vat_name,
@@ -89,7 +90,8 @@ def __init__(self,
8990
self.building = building
9091
self.postal_zone = postal_zone
9192

92-
def to_json(self):
93+
def to_dict(self):
94+
""" function to convert class to dictionary """
9395

9496
out = {
9597
"party_name_ar": self.party_name_ar,
@@ -121,7 +123,7 @@ def __init__(self, invoice_id: str, issue_date: str, issue_time: str):
121123
self.issue_time = issue_time
122124

123125

124-
class LineItems:
126+
class LineItem:
125127
""" The LineItems class. """
126128

127129
def __init__(self,
@@ -140,7 +142,7 @@ def __init__(self,
140142
self.tax_percentage = tax_percentage
141143

142144

143-
class AdvanceInvoices:
145+
class AdvanceInvoice:
144146
""" The AdvanceInvoices class. """
145147

146148
def __init__(self,
@@ -155,7 +157,8 @@ def __init__(self,
155157
self.tax_amount = tax_amount
156158
self.invoices = invoices
157159

158-
def to_json(self):
160+
def to_dict(self):
161+
""" function to convert class to dictionary """
159162

160163
out = {
161164
"tax_category": self.tax_category,
@@ -177,21 +180,22 @@ class AdvanceDetails:
177180
def __init__(self,
178181
advance_amount: float,
179182
total_amount: float,
180-
advance_invoices: AdvanceInvoices
183+
advance_invoices: AdvanceInvoice
181184
):
182185
self.advance_amount = advance_amount
183186
self.total_amount = total_amount
184187
self.advance_invoices = advance_invoices
185188

186-
def to_json(self):
189+
def to_dict(self):
190+
""" function to convert class to dictionary """
187191

188192
out = {
189193
"advance_amount": self.advance_amount,
190194
"total_amount": self.total_amount,
191195
}
192196
advance_invoices = []
193197
for advance_invoice in self.advance_invoices:
194-
advance_invoices.append(advance_invoice.to_json())
198+
advance_invoices.append(advance_invoice.to_dict())
195199
out["advance_invoices"] = advance_invoices
196200

197201
return out
@@ -208,7 +212,7 @@ def __init__(self,
208212
doc_type: str,
209213
inv_type: str,
210214
payment_method: int,
211-
lineitems: LineItems,
215+
lineitems: LineItem,
212216
party_details: PartyDetails,
213217
advance_details: AdvanceDetails = None,
214218
has_advance: bool = None,
@@ -228,7 +232,8 @@ def __init__(self,
228232
self.total_tax = total_tax
229233
self.lineitems = lineitems
230234

231-
def to_json(self):
235+
def to_dict(self):
236+
""" function to convert class to dictionary """
232237

233238
out = {
234239
"egs_uuid": self.egs_uuid,
@@ -242,12 +247,12 @@ def to_json(self):
242247
"currency": self.currency,
243248
"total_tax": self.total_tax,
244249
}
245-
out["party_details"] = self.party_details.to_json()
250+
out["party_details"] = self.party_details.to_dict()
246251
lineitems = []
247252
for lineitem in self.lineitems:
248253
lineitems.append(lineitem.__dict__)
249254
out["lineitems"] = lineitems
250-
out["advance_details"] = self.advance_details.to_json()
255+
out["advance_details"] = self.advance_details.to_dict()
251256

252257
return out
253258

@@ -305,7 +310,7 @@ async def onboard_egs(self, egs_data: EGSData):
305310

306311
try:
307312
async with FlickAPI(config=self.config) as session:
308-
async with session.request('POST', '/egs/onboard', data=json.dumps(egs_data.to_json())) as response:
313+
async with session.request('POST', '/egs/onboard', data=json.dumps(egs_data.to_dict())) as response:
309314
if response.status == 200:
310315
response_text = await response.text()
311316
# Process the response data here
@@ -360,7 +365,7 @@ async def generate_invoice(self, invoice_data: InvoiceData):
360365
"""
361366
try:
362367
async with FlickAPI(config=self.config) as session:
363-
async with session.request('POST', '/invoice/generate', data=json.dumps(invoice_data.to_json())) as response:
368+
async with session.request('POST', '/invoice/generate', data=json.dumps(invoice_data.to_dict())) as response:
364369
if response.status == 200:
365370
response_text = await response.text()
366371
# Process the response data here

0 commit comments

Comments
 (0)