Ejemplo n.º 1
0
class TwilioCarriers(object):
    def __init__(self, sid, token):
        self.pricing_client = TwilioPricingClient(sid, token)
        self.carrier_reference = []

    def initialize_carrier_reference(self, country_code):
        self.carrier_reference = self.get_providers_for_country("US")
        return

    def get_carrier_name(self, mcc, mnc):
        carrier = "Unrecognized Carrier"
        for ref_row in self.carrier_reference:
            if mcc == ref_row["mcc"] and mnc == ref_row["mnc"]:
                carrier = ref_row["carrier"]
                break
        return carrier

    def get_providers_for_country(self, iso_country):
        """Use an ISO country code to get all MCC/MNC for a country"""
        retval = []
        country = self.pricing_client.messaging_countries().get(iso_country)
        for provider in country.outbound_sms_prices:
            interesting_data = {"mcc": provider["mcc"],
                                "mnc": provider["mnc"],
                                "carrier": provider["carrier"]}
            retval.append(interesting_data)
        return retval
Ejemplo n.º 2
0
def price():
    account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
    auth_token = os.environ.get("AUTH_TOKEN", AUTH_TOKEN)

    resp = twilio.twiml.Response()
    from_value = request.values.get('From')
    to = request.values.get('To')

    client = TwilioPricingClient(account_sid, auth_token)
    number = client.voice.numbers.get("+12176154633")

    resp.say("Price outbound " + number.outbound_call_price['current_price'])
    return str(resp)
Ejemplo n.º 3
0
class TwilioCarriers(object):
    def __init__(self, sid, token):
        self.pricing_client = TwilioPricingClient(sid, token)

    def get_providers_for_country(self, iso_country):
        """Use an ISO country code to get all MCC/MNC for a country"""
        retval = []
        country = self.pricing_client.messaging_countries().get(iso_country)
        for provider in country.outbound_sms_prices:
            interesting_data = {"mcc": provider["mcc"],
                                "mnc": provider["mnc"],
                                "carrier": provider["carrier"]}
            retval.append(interesting_data)
        return retval
Ejemplo n.º 4
0
class TwilioCarriers(object):
    def __init__(self, sid, token):
        self.pricing_client = TwilioPricingClient(sid, token)

    def get_providers_for_country(self, iso_country):
        """Use an ISO country code to get all MCC/MNC for a country"""
        retval = []
        country = self.pricing_client.messaging_countries().get(iso_country)
        for provider in country.outbound_sms_prices:
            interesting_data = {
                "mcc": provider["mcc"],
                "mnc": provider["mnc"],
                "carrier": provider["carrier"]
            }
            retval.append(interesting_data)
        return retval
Ejemplo n.º 5
0
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioPricingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "{{ account_sid }}"
auth_token = "{{ auth_token }}"
client = TwilioPricingClient(account_sid, auth_token)

countries = client.phone_numbers.countries.list()

for c in countries:
    print c.iso_country
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioPricingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = TwilioPricingClient(account_sid, auth_token)
countries = client.messaging_countries().get("EE")

for p in countries.inbound_sms_prices:
    print("{} {}".format(p['number_type'], p['current_price']))

for op in countries.outbound_sms_prices:
    print("{}: {}".format(op['carrier'], op['prices']))
Ejemplo n.º 7
0
 def __init__(self, sid, token):
     self.pricing_client = TwilioPricingClient(sid, token)
Ejemplo n.º 8
0
 def __init__(self, sid, token):
     self.pricing_client = TwilioPricingClient(sid, token)
Ejemplo n.º 9
0
 def __init__(self, sid, token):
     self.pricing_client = TwilioPricingClient(sid, token)
     self.carrier_reference = []
# Download the Python helper library from twilio.com/docs/python/install
from twilio.rest import TwilioPricingClient

# Your Account Sid and Auth Token from twilio.com/user/account
account_sid = "{{ account_sid }}"
auth_token = "{{ auth_token }}"
client = TwilioPricingClient(account_sid, auth_token)

countries = client.messaging_countries().list()

for c in countries:
    print c.iso_country