• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hivesolutions / budy / 1286

pending completion
1286

push

travis-ci-com

joamag
feat: new key params

3 of 3 new or added lines in 1 file covered. (100.0%)

4147 of 5856 relevant lines covered (70.82%)

6.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.24
/src/budy/controllers/api/seeplus.py
1
#!/usr/bin/python
2
# -*- coding: utf-8 -*-
3

4
# Hive Budy
5
# Copyright (c) 2008-2020 Hive Solutions Lda.
6
#
7
# This file is part of Hive Budy.
8
#
9
# Hive Budy is free software: you can redistribute it and/or modify
10
# it under the terms of the Apache License as published by the Apache
11
# Foundation, either version 2.0 of the License, or (at your option) any
12
# later version.
13
#
14
# Hive Budy is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# Apache License for more details.
18
#
19
# You should have received a copy of the Apache License along with
20
# Hive Budy. If not, see <http://www.apache.org/licenses/>.
21

22
__author__ = "João Magalhães <joamag@hive.pt>"
9✔
23
""" The author(s) of the module """
24

25
__version__ = "1.0.0"
9✔
26
""" The version of the module """
27

28
__revision__ = "$LastChangedRevision$"
9✔
29
""" The revision number of the module """
30

31
__date__ = "$LastChangedDate$"
9✔
32
""" The last change date of the module """
33

34
__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda."
9✔
35
""" The copyright for the module """
36

37
__license__ = "Apache License, Version 2.0"
9✔
38
""" The license for the module """
39

40
import time
9✔
41

42
import appier
9✔
43

44
import budy
9✔
45

46
from . import root
9✔
47

48
class SeeplusAPIController(root.RootAPIController):
9✔
49

50
    @appier.route("/api/seeplus/update", "POST", json = True)
9✔
51
    def update(self):
1✔
52
        key = self.field("token", None)
×
53
        key = self.field("key", key)
×
54
        key = self.request.get_header("X-Seeplus-Key", key)
×
55
        _key = appier.conf("SEEPLUS_KEY", None)
×
56
        if _key and not _key == key:
×
57
            raise appier.SecurityError(
×
58
                message = "Mismatch in Seeplus key",
59
                code = 401 
60
            )
61
        object = appier.get_object()
×
62
        event = object.get("event", "OrderManagement.StatusChanged")
×
63
        data = object.get("data", {})
×
64
        result = "Ignored"
×
65
        if event == "OrderManagement.StatusChanged":
×
66
            self._status_change_s(data)
×
67
            result = "Handled"
×
68
        return dict(result = result)
×
69

70
    def _status_change_s(self, data):
9✔
71
        reference = data["code"]
×
72
        status = data["status"]
×
73
        order = budy.Order.get(reference = reference)
×
74
        seeplus_timestamp = order.meta.get("seeplus_timestamp", None)
×
75
        if not seeplus_timestamp: raise appier.OperationalError(
×
76
            message = "Order not imported in Seeplus"
77
        )
78
        order.meta.update(
×
79
            seeplus_status = status,
80
            seeplus_update = time.time()
81
        )
82
        order.save()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc