forked from openlabs/magento_integration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.py
89 lines (71 loc) · 2.32 KB
/
api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# -*- coding: utf-8 -*-
"""
api
Extends magento python api
:copyright: (c) 2013 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
from magento.api import API
class Core(API):
"""
This API extends the API for the custom API implementation
for the magento extension
"""
__slots__ = ()
def websites(self):
"""
Returns list of all websites
"""
return self.call('ol_websites.list', [])
def stores(self, filters=None):
"""
Returns list of all group store
:param filters: Dictionary of filters.
Format :
{<attribute>:{<operator>:<value>}}
Example :
{'website_id':{'=':'1'}}
:return: List of Dictionaries
"""
return self.call('ol_groups.list', [filters])
def store_views(self, filters=None):
"""
Returns list of all store views
:param filters: Dictionary of filters.
Format :
{<attribute>:{<operator>:<value>}}
Example :
{'website_id':{'=':'1'}}
:return: List of Dictionaries
"""
return self.call('ol_storeviews.list', [filters])
class OrderConfig(API):
'''
Getting Order Configuration from magento.
'''
def get_states(self):
"""
Get states of orders
:return: dictionary of all states.
Format :
{<state>: <state title>}
Example :
{ 'canceled': 'Canceled',
'closed': 'Closed',
'holded': 'On Hold',
'pending_payment': 'Pending Payment'
}
"""
return self.call('sales_order.get_order_states', [])
def get_shipping_methods(self):
"""
Get available shipping methods.
:return: List of dictionaries of all available shipping method.
Example :
[
{'code': 'flatrate', 'label': 'Flat Rate'},
{'code': 'tablerate', 'label': 'Best Way'},
...
]
"""
return self.call('sales_order.shipping_methods', [])