/
avatars.py
87 lines (66 loc) 路 2.4 KB
/
avatars.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from ..service import Service
class Avatars(Service):
def __init__(self, client):
super(Avatars, self).__init__(client)
def get_browser(self, code, width=100, height=100, quality=100):
"""Get Browser Icon"""
params = {}
path = '/avatars/browsers/{code}'
path = path.replace('{code}', code)
params['width'] = width
params['height'] = height
params['quality'] = quality
return self.client.call('get', path, {
'content-type': 'application/json',
}, params)
def get_credit_card(self, code, width=100, height=100, quality=100):
"""Get Credit Card Icon"""
params = {}
path = '/avatars/credit-cards/{code}'
path = path.replace('{code}', code)
params['width'] = width
params['height'] = height
params['quality'] = quality
return self.client.call('get', path, {
'content-type': 'application/json',
}, params)
def get_favicon(self, url):
"""Get Favicon"""
params = {}
path = '/avatars/favicon'
params['url'] = url
return self.client.call('get', path, {
'content-type': 'application/json',
}, params)
def get_flag(self, code, width=100, height=100, quality=100):
"""Get Country Flag"""
params = {}
path = '/avatars/flags/{code}'
path = path.replace('{code}', code)
params['width'] = width
params['height'] = height
params['quality'] = quality
return self.client.call('get', path, {
'content-type': 'application/json',
}, params)
def get_image(self, url, width=400, height=400):
"""Get Image from URL"""
params = {}
path = '/avatars/image'
params['url'] = url
params['width'] = width
params['height'] = height
return self.client.call('get', path, {
'content-type': 'application/json',
}, params)
def get_q_r(self, text, size=400, margin=1, download=0):
"""Get QR Code"""
params = {}
path = '/avatars/qr'
params['text'] = text
params['size'] = size
params['margin'] = margin
params['download'] = download
return self.client.call('get', path, {
'content-type': 'application/json',
}, params)