Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

add Enabling an App functionality #24

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 3, 2012
  1. @bebef1987
This page is out of date. Refresh to see the latest.
View
11 example/commands.py
@@ -150,3 +150,14 @@ def get_categories(client):
message += '%s: %s\n' % (cat['id'], cat['name'])
return {'success': True,
'message': message}
+
+def app_state(client, app_id, status=None, disabled_by_user=None):
+ response = client.app_state(app_id, status, disabled_by_user)
+ if response.status_code != 202:
+ return {'success': False,
+ 'message': 'Error, status code: %d, \nMessage: %s' % (
+ response.status_code, response.content)}
+ content = json.loads(response.content)
+ return {'success': True,
+ 'message': '\n'.join(
+ ['%s: %s' % (k, v) for k, v in content.items()])}
View
3  example/main.py
@@ -15,7 +15,8 @@
'add_screenshot': commands.add_screenshot,
'get_screenshot': commands.get_screenshot,
'del_screenshot': commands.del_screenshot,
- 'get_categories': commands.get_categories}
+ 'get_categories': commands.get_categories,
+ 'app_state': commands.app_state}
def main():
parser = argparse.ArgumentParser(
View
33 marketplace/client.py
@@ -29,7 +29,8 @@
'app': '/apps/app/%s/',
'create_screenshot': '/apps/preview/?app=%s',
'screenshot': '/apps/preview/%s/',
- 'categories': '/apps/category/'}
+ 'categories': '/apps/category/',
+ 'enable': '/apps/status/%s/'}
class Client:
@@ -224,3 +225,33 @@ def get_categories(self):
"""Get all categories from Marketplae
"""
return self.conn.fetch('GET', self.url('categories'))
+
+ def app_state(self, app_id, status=None, disabled_by_user=None):
+ """Once all the data has been completed and at least one screenshot created,
+ you can push the app to the review queue
+ status (optional): key statuses are
+
+ incomplete: incomplete
+ pending: pending
+ public: public
+ waiting: waiting to be public
+
+ disabled_by_user (optional): True or False
+
+ Valid transitions that users can initiate are:
+
+ waiting to be public to public: occurs when the app has been reviewed, but not yet been made public.
+
+ incomplete to pending: call this once your app has been completed and it will be added to the Marketplace review queue.
+ This can only be called if all the required data is there. If not, you'll get an error containing the reason
+ disabled_by_user: by changing this value from True to False you can enable or disable an app
+ """
+ assert status is not None or disabled_by_user is not None
+ data = {}
+ if status:
+ data['status'] = status
+ if disabled_by_user:
+ data['disabled_by_user'] = disabled_by_user
+
+ return self.conn.fetch('PATCH',
+ self.url('enable') % app_id, data)
View
8 marketplace/tests/test_client.py
@@ -214,3 +214,11 @@ def test_add_screenshot(self):
data = json.loads(requests.post.call_args[1]['data'])
eq_(data['position'], 2)
eq_(data['file']['type'], 'image/jpeg')
+
+ def test_enable(self):
+ resp = {"status": "pending",
+ "disabled_by_user":True}
+ requests.patch = Mock(return_value=Response(202, json.dumps(resp)))
+
+ response = self.marketplace.app_state(123, status='pending', disabled_by_user='True')
+ eq_(response.status_code,202)
View
2  setup.py
@@ -2,7 +2,7 @@
setup(
name='Marketplace',
- version='0.1.3a',
+ version='0.1.4a',
packages=['marketplace', ],
license='Mozilla Public License (MPL 2.0)',
author='Piotr Zalewa',
Something went wrong with that request. Please try again.