def call_create_collection(self, collection=None): ''' Create a new collection using the provided article_ids :type collection: CollectionCreate :param collection: the collection to create :return: the link to the new collection :rtype: str ''' if not collection: collection = create_collection(api=self) payload = collection.to_json() if self.verbose: print print "--------------------" print "Generated json:" print print payload print "--------------------" print response = self.post('/account/collections', headers=get_headers(token=self.token), payload=payload) loc = ArticleLocation(**json.loads(response.body_string())) return loc
def call_create_collection(self, collection=None): ''' Create a new collection using the provided article_ids :type collection: CollectionCreate :param collection: the collection to create :return: the link to the new collection :rtype: str ''' if not collection: collection = create_collection(api=self) payload = collection.to_json() if self.verbose: print print "--------------------" print "Generated json:" print print payload print "--------------------" print response = self.post( '/account/collections', headers=get_headers(token=self.token), payload=payload) 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