How to use the africastalking.Service.Service function in africastalking

To help you get started, we’ve selected a few africastalking examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AfricasTalkingLtd / africastalking-python / africastalking / Voice.py View on Github external
from . Service import Service, validate_phone


class VoiceService(Service):
    def __init__(self, username, api_key):
        super(VoiceService, self).__init__(username, api_key)

    def _init_service(self):
        self._baseUrl = 'https://voice.'
        if self._is_sandbox():
            self._baseUrl += self._SANDBOX_DOMAIN
        else:
            self._baseUrl += self._PRODUCTION_DOMAIN

    def call(self, source, destination, callback=None):

        phone_numbers = destination.split(',')

        for index, phone_number in enumerate(phone_numbers):
            phone_number = phone_number.replace(' ', '')
github AfricasTalkingLtd / africastalking-python / africastalking / Payment.py View on Github external
import re
import json
from schema import Schema, And, Optional
from . Service import Service, validate_phone, validate_data_units, validate_data_validity


class PaymentService(Service):
    BANK = {
        'FCMB_NG': 234001,
        'Zenith_NG': 234002,
        'Access_NG': 234003,
        'GTBank_NG': 234004,
        'Ecobank_NG': 234005,
        'Diamond_NG': 234006,
        'Providus_NG': 234007,
        'Unity_NG': 234008,
        'Stanbic_NG': 234009,
        'Sterling_NG': 234010,
        'Parkway_NG': 234011,
        'Afribank_NG': 234012,
        'Enterprise_NG': 234013,
        'Fidelity_NG': 234014,
        'Heritage_NG': 234015,
github AfricasTalkingLtd / africastalking-python / africastalking / Service.py View on Github external
else:
                    callback(AfricasTalkingException(response.text), None)

            if method == 'GET':
                _target = self.__make_get_request
            elif method == 'POST':
                _target = self.__make_post_request
            else:
                raise AfricasTalkingException('Unexpected HTTP method: ' + method)

            thread = threading.Thread(target=_target, args=(url, headers, data, params, cb))
            thread.start()
            return thread


class APIService(Service):

    def __init__(self, username, api_key):
        super(APIService, self).__init__(username, api_key)

    def _init_service(self):
        self._baseUrl = 'https://api.'
        if self._is_sandbox():
            self._baseUrl += self._SANDBOX_DOMAIN
        else:
            self._baseUrl += self._PRODUCTION_DOMAIN