def call_create_article(self, article=None): ''' Upload a new article. :type article: ArticleCreate :param article: the article to create :return: whether the creation process was successful :rtype: bool ''' if not article: article = create_article(api=self) payload = article.to_json() if self.verbose: print print "--------------------" print "Generated json:" print print payload print "--------------------" print response = self.post(path='/account/articles', payload=payload, headers=get_headers(token=self.token)) loc = ArticleLocation(**json.loads(response.body_string())) return loc
def call_create_json(self, model): ''' Creates a json string by interactively asking the user questions about field values. :type model: str :param model: the model type to create json for (one of: article, collection) :return: the initiated model :rtype: Model ''' if model == 'article': result = create_article(api=self) elif model == 'collection': result = create_collection(api=self) else: raise Exception("Model type '{}' not supported".format(model)) print print "Result json for {}:".format(model) print return result