<commit_before><?php

/*
 * Copyright (c) 2014, <NAME>
 * All rights reserved.
 * Distributed under the BSD 3-Clause license (http://opensource.org/licenses/BSD-3-Clause).
 */
namespace EtienneLamoureux\DurmandScriptorium;

use EtienneLamoureux\DurmandScriptorium\v2\CollectionApiConsumer;
use EtienneLamoureux\DurmandScriptorium\v2\CollectionApiRequestFactory;

class DurmandScriptorium
{

    protected $quaggans;

    public function __construct()
    {
	$this->quaggans = new CollectionApiConsumer(new CollectionApiRequestFactory('/v2/quaggans'));
    }

    public function getAllQuaggans($expanded = false)
    {
	if ($expanded)
	{
	    $data = $this->quaggans->getAllExpanded();
	}
	else
	{
	    $data = $this->quaggans->getAll();
	}

	return $data;
    }

    public function getQuaggan($id)
    {
	return $this->quaggans->get($id);
    }

    public function getQuaggans($ids)
    {
	return $this->quaggans->getSome($ids);
    }

}<commit_msg>Added listings api consumption<commit_after><?php

/*
 * Copyright (c) 2014, <NAME>
 * All rights reserved.
 * Distributed under the BSD 3-Clause license (http://opensource.org/licenses/BSD-3-Clause).
 */
namespace EtienneLamoureux\DurmandScriptorium;

use EtienneLamoureux\DurmandScriptorium\v2\CollectionApiConsumer;
use EtienneLamoureux\DurmandScriptorium\v2\CollectionApiRequestFactory;

class DurmandScriptorium
{

    public static $quaggansEndpointUrl = '/v2/quaggans';
    public static $listingsEndpointUrl = '/v2/commerce/listings';
    protected $quaggans;
    protected $listings;

    public function __construct()
    {
	$quaggansRequestFactory = new CollectionApiRequestFactory(DurmandScriptorium::$quaggansEndpointUrl);
	$this->quaggans = new CollectionApiConsumer($quaggansRequestFactory);

	$listingsRequestFactory = new CollectionApiRequestFactory(DurmandScriptorium::$listingsEndpointUrl);
	$this->listings = new CollectionApiConsumer($listingsRequestFactory);
    }

    public function getAllQuaggans($expanded = false)
    {
	return $this->getAllElements($this->quaggans);
    }

    public function getQuaggan($id)
    {
	return $this->getElement($this->quaggans, $id);
    }

    public function getQuaggans($ids)
    {
	return $this->getElements($this->quaggans, $ids);
    }

    public function getAllListings($expanded = false)
    {
	return $this->getAllElements($this->listings);
    }

    public function getListing($id)
    {
	return $this->getElement($this->listings, $id);
    }

    public function getListings($ids)
    {
	return $this->getElements($this->listings, $ids);
    }

    private function getAllElements($apiConsumer, $expanded = false)
    {
	if ($expanded)
	{
	    $data = $apiConsumer->getAllExpanded();
	}
	else
	{
	    $data = $apiConsumer->getAll();
	}

	return $data;
    }

    private function getElement($apiConsumer, $id)
    {
	return $apiConsumer->get($id);
    }

    private function getElements($apiConsumer, $ids)
    {
	return $apiConsumer->getSome($ids);
    }

}
{'fraction_non_alphanumeric': 0.1260053619302949, 'fraction_numerical': 0.006367292225201072, 'mean_word_length': 4.164359861591696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2943701', 'n_tokens_mistral': 1010, 'n_tokens_neox': 964, 'n_words': 170}