Skip to content

Commit a8fc2ce

Browse files
committed
add mnp lookup
1 parent 4939c97 commit a8fc2ce

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

actions/lookup_mnp.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 Sms77SendVoiceAction(Action):
8+
def __init__(self, config=None, action_service=None):
9+
super(Sms77SendVoiceAction, self).__init__(config, action_service)
10+
self.client = Sms77api(self.config['api_key'])
11+
12+
def run(self, number, json=False):
13+
def on_error(ex):
14+
err = ('Failed looking up MNP 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.MNP, number, json)
20+
21+
except Exception as e:
22+
on_error(e)

actions/lookup_mnp.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
description: This looks up mobile number portability information using sms77.
3+
enabled: true
4+
entry_point: lookup_mnp.py
5+
name: lookup_mnp
6+
parameters:
7+
json:
8+
description: Return a detailed JSON response?
9+
position: 1
10+
type: boolean
11+
number:
12+
description: The phone number to look up.
13+
position: 0
14+
required: true
15+
type: string
16+
runner_type: python-script

0 commit comments

Comments
 (0)