Skip to content

Commit 223aec4

Browse files
committed
add cnam lookup
1 parent a8fc2ce commit 223aec4

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

actions/lookup_cnam.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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 Sms77LookupCnamAction(Action):
8+
def __init__(self, config=None, action_service=None):
9+
super(Sms77LookupCnamAction, 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 CNAM for: %s, exception: %s\n' % (number, str(ex)))
15+
self.logger.error(err)
16+
raise Exception(err)
17+
18+
try:
19+
return self.client.lookup(LookupType.CNAM, number)
20+
21+
except Exception as e:
22+
on_error(e)

actions/lookup_cnam.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
description: This looks up caller name information using sms77.
3+
enabled: true
4+
entry_point: lookup_cnam.py
5+
name: lookup_cnam
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

actions/lookup_hlr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from st2common.runners.base_action import Action
55

66

7-
class Sms77SendVoiceAction(Action):
7+
class Sms77LookupHlrAction(Action):
88
def __init__(self, config=None, action_service=None):
9-
super(Sms77SendVoiceAction, self).__init__(config, action_service)
9+
super(Sms77LookupHlrAction, self).__init__(config, action_service)
1010
self.client = Sms77api(self.config['api_key'])
1111

1212
def run(self, number):

actions/lookup_mnp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from st2common.runners.base_action import Action
55

66

7-
class Sms77SendVoiceAction(Action):
7+
class Sms77LookupMnpAction(Action):
88
def __init__(self, config=None, action_service=None):
9-
super(Sms77SendVoiceAction, self).__init__(config, action_service)
9+
super(Sms77LookupMnpAction, self).__init__(config, action_service)
1010
self.client = Sms77api(self.config['api_key'])
1111

1212
def run(self, number, json=False):

0 commit comments

Comments
 (0)