Exemplo n.º 1
0
 def test_access_token(self):
     service = zendesk.Zendesk('mydomain', access_token='foo')
     service.users().get()
     self.expect(headers={
         'Authorization': 'Bearer foo',
         'Accept': 'application/json',
         'Content-Type': 'application/json'})
Exemplo n.º 2
0
def main():
    parser = create_parser()

    opts, args = parser.parse_args()
    if opts.verbose:
        logging.getLogger('libsaas').setLevel(logging.DEBUG)

    zservice = zendesk.Zendesk(opts.domain, opts.username, opts.password)
    dservice = ducksboard.Ducksboard(opts.api_key)

    tickets = get_tickets(zservice, opts.days_ago)
    board = make_board(zservice, tickets)
    dservice.data_source(opts.label).push({'value': board})
Exemplo n.º 3
0
    def setUp(self):
        self.executor = test_executor.use()
        self.executor.set_response(b'{}', 200, {})

        self.service = zendesk.Zendesk('mydomain', 'user', 'pass')
Exemplo n.º 4
0
from datetime import datetime, timedelta

from libsaas.services import mailchimp, zendesk

# create Zendesk and Mailchimp services
zd = zendesk.Zendesk('mycompany', 'username', 'password')
mc = mailchimp.Mailchimp('8ac789caf98879caf897a678fa76daf-us2')

# get tickets solved yesterday
yesterday = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
tickets = zd.search('updated>{0} status:solved type:ticket'.format(yesterday))

# get emails of users who requested those tickets
user_ids = [ticket['requester_id'] for ticket in tickets['results']]
emails = [zd.user(user_id).get()['user']['email'] for user_id in user_ids]

# grab the ID of the "Users" list
lists = mc.lists(filters={'list_name': 'Users'})
list_id = lists['data'][0]['id']

# set the SOLVED variable for those users in Mailchimp to yesterday
batch = [{'EMAIL': email, 'SOLVED': yesterday} for email in emails]
mc.listBatchSubscribe(list_id, batch, double_optin=False, update_existing=True)