def create (**args): """ Create new update. """ if not args.get ('body'): raise ValueError ('Update body is missing.') if args.get ('user'): if args.get ('private'): args['private'] = '>' else: args['private'] = '' args['body'] = u'>%s%s %s' % (args['private'], args['user'], args['body']) fields = { 'update[body]': args['body'], } if args.get ('image') and os.path.isfile (args['image']): fields['update[picture]'] = (args['image'], args['image'], ) data, boundary = encode_multipart (fields) return dict ( url = '/updates', method = 'post', data = data, boundary = boundary, )
def create(**args): """ Create new status. """ if not args.get("body"): raise ValueError("Status body is missing.") fields = {"status[body]": args["body"]} if args.get("image") and os.path.isfile(args["image"]): fields["status[picture]"] = (args["image"], args["image"]) data, boundary = encode_multipart(fields) return dict(url="/statuses", method="post", data=data, boundary=boundary)
def update (**args): """ Update current user background. """ if not args.get ('image') or not os.path.isfile (args['image']): raise ValueError ('Background path is missing or file not found.') data, boundary = encode_multipart ({ 'background[file]': (args['image'], args['image'], ) }) return dict ( url = '/background', method = 'post', boundary = boundary, data = data, )
def create (**args): """ Create new shortened link. """ if not args.get('link'): raise ValueError ('Url is missing.') url = '/shortlinks' fields = { 'shortlink[original_link]': args['link'] } data, boundary = encode_multipart (fields) return dict ( url = url, method = 'post', data = data, boundary = boundary, )
def create (**args): """ Create new directed message. """ if not args.get ('body') or not args.get ('user'): raise ValueError ('Directed_message body or recipient is missing.') fields = { 'directed_message[body]': args['body'], 'directed_message[recipient]': args['user'], } if args.get ('image') and os.path.isfile (args['image']): fields['directed_message[picture]'] = (args['image'], args['image'], ) data, boundary = encode_multipart (fields) return dict ( url = '/directed_messages', method = 'post', data = data, boundary = boundary, )
def create(**args): """ Create new private message. """ if not args.get('body') or not args.get('user'): raise ValueError('Private_message body or recipient is missing.') fields = { 'private_message[body]': args['body'], 'private_message[recipient]': args['user'], } if args.get('image') and os.path.isfile(args['image']): fields['private_message[picture]'] = ( args['image'], args['image'], ) data, boundary = encode_multipart(fields) return dict( url='/private_messages', method='post', data=data, boundary=boundary, )
def create(**args): """ Create new status. """ if not args.get('body'): raise ValueError('Status body is missing.') fields = { 'status[body]': args['body'], } if args.get('image') and os.path.isfile(args['image']): fields['status[picture]'] = ( args['image'], args['image'], ) data, boundary = encode_multipart(fields) return dict( url='/statuses', method='post', data=data, boundary=boundary, )