Skip to content

Commit 0d481b2

Browse files
committed
adding support for /v3/bitly_pro_domain
1 parent a40d455 commit 0d481b2

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

bitly_api/bitly_api.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,25 @@ def lookup(self, url):
183183
data = self._call(self.host, 'v3/lookup', params, self.secret)
184184
return data['data']['lookup']
185185

186+
def pro_domain(self, domain, format='json'):
187+
""" is the domain assigned for bitly.pro? """
188+
end_point = 'v3/bitly_pro_domain'
189+
190+
if not domain:
191+
raise BitlyError(500, 'MISSING_ARG_DOMAIN')
192+
193+
protocol_prefix = ('http://', 'https://')
194+
if domain.lower().startswith(protocol_prefix):
195+
raise BitlyError(500, 'INVALID_BARE_DOMAIN')
196+
params = {
197+
'domain': domain,
198+
'login' : self.login,
199+
'apiKey' : self.api_key,
200+
'format': format,
201+
}
202+
data = self._call(self.host, end_point, params, self.secret)
203+
return data['data']['bitly_pro_domain']
204+
186205
@classmethod
187206
def _generateSignature(self, params, secret):
188207
if not params or not secret:

test/test_bitly_api.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,20 @@ def testReferrer():
2525
data = bitly.referrers(hash='a')
2626
assert data != None
2727
assert len(data) > 1
28+
29+
def testProDomain():
30+
bitly = bitly_api.Connection('bitlyapidemo','R_0da49e0a9118ff35f52f629d2d71bf07')
31+
test_data = {
32+
'cnn.com': False,
33+
'nyti.ms': True,
34+
'g.co': False,
35+
'j.mp': False,
36+
'pep.si': True,
37+
'http://pep.si': 'INVALID_BARE_DOMAIN',
38+
}
39+
for domain in test_data:
40+
try:
41+
result = bitly.pro_domain(domain)
42+
assert result == test_data[domain], domain
43+
except bitly_api.BitlyError, e:
44+
assert str(e) == test_data[domain]

0 commit comments

Comments
 (0)