forked from sns-sdks/python-facebook
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapplication.py
More file actions
73 lines (63 loc) · 2.57 KB
/
application.py
File metadata and controls
73 lines (63 loc) · 2.57 KB
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
"""
Apis for application.
"""
from typing import Dict, Optional, Union
import pyfacebook.utils.constant as const
from pyfacebook.api.base_resource import BaseResource
from pyfacebook.models.application import Application, ApplicationAccountsResponse
from pyfacebook.utils.params_utils import enf_comma_separated
class FacebookApplication(BaseResource):
def get_info(
self,
fields: Optional[Union[str, list, tuple]] = None,
return_json: bool = False,
) -> Union[Application, dict]:
"""
Get information for current facebook Application. Need app token.
:param fields: Comma-separated id string for data fields which you want.
You can also pass this with an id list, tuple.
:param return_json: Set to false will return a dataclass for Application.
Or return json data. Default is false.
:return: Application information.
"""
if fields is None:
fields = const.APPLICATION_PUBLIC_FIELDS
data = self.client.get_object(
object_id=self.client.app_id,
fields=enf_comma_separated(field="fields", value=fields),
)
if return_json:
return data
else:
return Application.new_from_json_dict(data=data)
def get_accounts(
self,
fields: Optional[Union[str, list, dict]] = None,
count: Optional[int] = 10,
limit: Optional[int] = 10,
return_json: bool = False,
) -> Union[ApplicationAccountsResponse, dict]:
"""
Represents a collection of test users on an app.
:param fields: Comma-separated id string for data fields which you want.
You can also pass this with an id list, tuple.
:param count: The total count for you to get data.
:param limit: Each request retrieve objects count.
It should no more than 100. Default is None will use api default limit.
:param return_json: Set to false will return a dataclass for post.
Or return json data. Default is false.
:return: Application accounts information.
"""
if fields is None:
fields = const.APPLICATION_ACCOUNT_PUBLIC_FIELDS
data = self.client.get_full_connections(
object_id=self.client.app_id,
connection="accounts",
count=count,
limit=limit,
fields=enf_comma_separated(field="fields", value=fields),
)
if return_json:
return data
else:
return ApplicationAccountsResponse.new_from_json_dict(data)