Skip to content

Commit 8526518

Browse files
committed
add format lookup
1 parent 223aec4 commit 8526518

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# 1.3.0
2+
3+
- Add CNAM lookup
4+
- Add FORMAT lookup
5+
- Add HLR lookup
6+
- Add MNP lookup
7+
18
# 1.2.0
29

310
- Add more SMS options

actions/lookup_format.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from sms77api.Sms77api import Sms77api
2+
from sms77api.classes.Lookup import LookupType
3+
4+
from st2common.runners.base_action import Action
5+
6+
7+
class Sms77LookupFormatAction(Action):
8+
def __init__(self, config=None, action_service=None):
9+
super(Sms77LookupFormatAction, self).__init__(config, action_service)
10+
self.client = Sms77api(self.config['api_key'])
11+
12+
def run(self, number):
13+
def on_error(ex):
14+
err = ('Failed looking up formatting for: %s, exception: %s\n'
15+
% (number, str(ex)))
16+
self.logger.error(err)
17+
raise Exception(err)
18+
19+
try:
20+
return self.client.lookup(LookupType.FORMAT, number)
21+
22+
except Exception as e:
23+
on_error(e)

actions/lookup_format.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
description: This retrieves number formatting information using sms77.
3+
enabled: true
4+
entry_point: lookup_format.py
5+
name: lookup_format
6+
parameters:
7+
number:
8+
description: The phone number to look up.
9+
position: 0
10+
required: true
11+
type: string
12+
runner_type: python-script

pack.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ name: sms77
66
ref: sms77
77
python_versions:
88
- "3"
9-
version: 1.2.0
9+
version: 1.3.0

0 commit comments

Comments
 (0)