Completed
Pull Request — master (#349)
by Tomaz
07:18 queued 04:45
created

YammerAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %
Metric Value
dl 0
loc 16
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A authenticate() 0 3 1
A __init__() 0 11 1
1
try:
2
    import yampy
3
except ImportError:
4
    message = ('Missing "yampy", please install it using pip:\n'
5
               'pip install yampy')
6
    raise ImportError(message)
7
8
from st2actions.runners.pythonrunner import Action
9
10
__all__ = [
11
    'YammerAction',
12
]
13
14
15
class YammerAction(Action):
16
    def __init__(self, config):
17
        super(YammerAction, self).__init__(config)
18
        self.client_id = self.config['client_id']
19
        self.client_secret = self.config['client_secret']
20
        self.expected_redirect = self.config['expected_redirect']
21
        self.authenticator = yampy.Authenticator(
22
            client_id=self.client_id,
23
            client_secret=self.client_secret)
24
        self.access_code = self.config['access_code']
25
        self.user_info = None
26
        self.network_info = None
27
28
    def authenticate(self):
29
        access_token = self.authenticator.fetch_access_token(self.access_code)
30
        return yampy.Yammer(access_token=access_token)
31