11from fivehundredpx import settings
22from fivehundredpx .auth import *
33from fivehundredpx .bind import bind_api
4- from fivehundredpx .utils import *
4+ from fivehundredpx .utils import FileUtil
55
66class FiveHundredPXAPI (object ):
77
@@ -15,61 +15,60 @@ def __init__(self,auth_handler=None,host=None,secure=True,version=None,retry_cou
1515 self .retry_delay = retry_delay or settings .RETRY_DELAY
1616 self .retry_errors = retry_errors
1717
18+ #### Photo API
19+ # https://github.com/500px/api-documentation/tree/master/endpoints/photo
1820 photos = bind_api (path = '/photos' )
19- photos_search = bind_api (path = '/photos/search' )
21+ photos_search = bind_api (path = '/photos/search' , require_auth = True )
2022 photos_id = bind_api (path = '/photos/{id}' , allowed_params = ['id' ])
2123 photos_post = bind_api (path = '/photos' , method = 'POST' , require_auth = True )
24+ photos_update = bind_api (path = '/photos/{id}' , method = 'PUT' , require_auth = True , as_query = False )
2225 photos_delete = bind_api (path = '/photos/{id}' , method = 'DELETE' , allowed_params = ['id' ],require_auth = True )
2326 photos_comments = bind_api (path = '/photos/{id}/comments' , allowed_params = ['id' ])
2427 photos_comments_post = bind_api (path = '/photos/{id}/comments' , method = 'POST' , allowed_params = ['id' ], require_auth = True )
28+ photos_favorites = bind_api (path = '/photos/{id}/favorites' , allowed_params = ['id' ], require_auth = True )
2529 photos_favorite_post = bind_api (path = '/photos/{id}/favorite' , method = 'POST' , allowed_params = ['id' ], require_auth = True )
2630 photos_favorite_delete = bind_api (path = '/photos/{id}/favorite' , method = 'DELETE' , allowed_params = ['id' ], require_auth = True )
2731 photos_tags_post = bind_api (path = '/photos/{id}/tags' , method = 'POST' , allowed_params = ['id' ], require_auth = True )
28- photos_tags_delete = bind_api (path = '/photos/{id}/tags' , method = 'DELETE' , allowed_params = ['id' ], require_auth = True )
29- photos_vote_post = bind_api (path = '/photos/{id}/vote' , method = 'POST' , allowed_params = ['id' ], require_auth = True )
32+ photos_tags_delete = bind_api (path = '/photos/{id}/tags' , method = 'DELETE' , allowed_params = ['id' ], require_auth = True , as_query = True )
33+ photos_votes = bind_api (path = '/photos/{id}/votes' , allowed_params = ['id' ], require_auth = True )
34+ photos_vote_post = bind_api (path = '/photos/{id}/vote' , method = 'POST' , allowed_params = ['id' ], require_auth = True , as_query = True )
35+ photos_report = bind_api (path = '/photos/{id}/report' , method = 'POST' , allowed_params = ['id' ], require_auth = True )
3036
3137 def upload_photo (self , filename = None ,fp = None ,file_type = None , ** kwargs ):
32- headers ,body = create_body_by_filepath (filename ,'file' ,kwargs ) if fp == None else create_body_by_fp (fp , 'file' , file_type , kwargs )
38+ headers ,body = FileUtil . create_body_by_filepath (filename ,'file' ,kwargs ) if fp == None else FileUtil . create_body_by_fp (fp , 'file' , file_type , kwargs )
3339 return bind_api (
3440 path = '/upload' ,
35- method = 'POST' ,
36- require_auth = True
41+ method = 'POST'
3742 )(self ,http_body = body , headers = headers )
3843
39- def photos_update (self , id , ** kwargs ):
40- headers ,body = create_body (kwargs )
41- return bind_api (
42- path = '/photos/{id}' ,
43- method = 'PUT' ,
44- allowed_params = ['id' ],
45- require_auth = True
46- )(self ,id = id , http_body = body , headers = headers )
47-
44+ #### User API
45+ # https://github.com/500px/api-documentation/tree/master/endpoints/user
4846 users = bind_api (path = '/users' , require_auth = True )
4947 users_show = bind_api (path = '/users/show' )
48+ users_search = bind_api (path = '/users/search' )
5049 users_friends = bind_api (path = '/users/{id}/friends' , allowed_params = ['id' ])
5150 users_followers = bind_api (path = '/users/{id}/followers' , allowed_params = ['id' ])
5251 users_friends_post = bind_api (path = '/users/{id}/friends' , method = 'POST' , allowed_params = ['id' ])
5352 users_friends_delete = bind_api (path = '/users/{id}/friends' , method = 'DELETE' , allowed_params = ['id' ])
5453
54+ #### Blog API
55+ # https://github.com/500px/api-documentation/tree/master/endpoints/blog
5556 blogs = bind_api (path = '/blogs' )
5657 blogs_id = bind_api (path = '/blogs/{id}' , allowed_params = ['id' ])
5758 blogs_comments = bind_api (path = '/blogs/{id}/comments' , allowed_params = ['id' ])
5859 blogs_comments_post = bind_api (path = '/blogs/{id}/comments' , require_auth = True , allowed_params = ['id' ], method = 'POST' )
5960 blogs_post = bind_api (path = '/blogs' , require_auth = True , method = 'POST' )
61+ blogs_update = bind_api (path = '/blogs/{id}' , require_auth = True , allowed_params = ['id' ], method = 'PUT' )
6062 blogs_delete = bind_api (path = '/blogs/{id}' , require_auth = True , allowed_params = ['id' ], method = 'DELETE' )
63+
64+ #### Comment API
65+ # https://github.com/500px/api-documentation/tree/master/endpoints/comments
66+ comments_post = bind_api (path = '/comments/{id}/comments' , require_auth = True , allowed_params = ['id' ], method = 'POST' )
6167
62- def blogs_update (self , id , ** kwargs ):
63- headers ,body = create_body (kwargs )
64- return bind_api (
65- path = '/blogs/{id}' ,
66- method = 'PUT' ,
67- allowed_params = ['id' ],
68- require_auth = True
69- )(self ,id = id , http_body = body , headers = headers )
70-
71- collections = bind_api (path = '/collections' )
72- collections_id = bind_api (path = '/collections/{id}' , allowed_params = ['id' ])
73- collections_post = bind_api (path = '/collections' , require_auth = True , method = 'POST' )
74- collections_update = bind_api (path = '/collections/{id}' , require_auth = True , method = 'POST' , allowed_params = ['id' ])
75- collections_delete = bind_api (path = '/collections/{id}' , require_auth = True , method = 'DELETE' , allowed_params = ['id' ])
68+ #### Collection API
69+ # https://github.com/500px/api-documentation/tree/master/endpoints/collections
70+ collections = bind_api (path = '/collections' , require_auth = True )
71+ collections_id = bind_api (path = '/collections/{id}' , require_auth = True , allowed_params = ['id' ])
72+ collections_post = bind_api (path = '/collections' , require_auth = True , method = 'POST' , as_query = True )
73+ collections_update = bind_api (path = '/collections/{id}' , require_auth = True , method = 'PUT' , allowed_params = ['id' ], as_query = True )
74+ collections_delete = bind_api (path = '/collections/{id}' , require_auth = True , method = 'DELETE' , allowed_params = ['id' ], as_query = True )
0 commit comments