~kf5jwc/sms-printer

ref: 88d91e19f2499a3933341a270f81e30ebc048ac3 sms-printer/sms_printer/sms/schemas/bandwidth_v1.py -rw-r--r-- 1.1 KiB
88d91e19 — Kyle Jones Refactor for adding JSON schema based parsing 2 years ago
                                                                                
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
from typing import Dict, List

from .types import sms, sms_base


class Parser(sms_base):
    messages: List[sms] = []

    def __init__(self, sms_input: Dict) -> None:
        msg = sms(
            sms_input['from'],
            sms_input['text'])
        self.messages.append(msg)


SCHEMA = """
{
   "type" : "object",
   "properties" : {
      "direction" : {
         "type" : "string"
      },
      "from" : {
         "type" : "string"
      },
      "state" : {
         "type" : "string"
      },
      "messageUri" : {
         "type" : "string"
      },
      "applicationId" : {
         "type" : "string"
      },
      "text" : {
         "type" : "string"
      },
      "time" : {
         "type" : "string"
      },
      "messageId" : {
         "type" : "string"
      },
      "to" : {
         "type" : "string"
      },
      "eventType" : {
         "type" : "string"
      }
   },
   "required" : [
      "applicationId",
      "direction",
      "eventType",
      "from",
      "messageId",
      "messageUri",
      "state",
      "text",
      "time",
      "to"
   ],
   "$schema" : "http://json-schema.org/schema#"
}
"""