public function buscarFrete($data, $returnType = self::RETURN_ARRAY) { $response = $this->request($data); $fetcher = new ParserContent($response); if ($error = $fetcher->checkError()) { return json_encode(['erro' => 1]); } $items = $fetcher->getParsedContent(); $parser = new ResponseBuilder($items); $response = $parser->parse(); switch ($returnType) { case self::RETURN_ARRAY: return $response; break; case self::RETURN_JSON: return json_encode($response, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); break; } }
public function postAnalyzer() { // return "wtf"; $payload = Input::get('query', 'default'); if ($payload == 'default') { return Response::make('you need to give an input', 405); } // $payload = json_encode(json_decode('{ // "keyword": "guns", // "posts": [ // { // "id": 1, // "text": "Guns are awesome!", // "tags": [ // "twitter" // ] // }, // { // "id": 2, // "text": "Guns don\'t kill people. People do.", // "tags": [ // "twitter", // "friends", // "Iasi" // ] // }, // { // "id": 3, // "text": "I don\'t own guns.", // "source": "facebook", // "tags": [ // "facebook", // "friends" // ] // } // ], // "tools": [ // "all" // ] // }')); // dd($payload); $response = ResponseBuilder::getAnalyzedResponse($payload); return Response::json($response); }
public function __construct($results, $req, $add = null) { parent::__construct($results, $req, $add); $this->to(self::TO_SENDER); }
/** * @param int $status * * @return \Mcustiel\Phiremock\Client\Utils\ResponseBuilder */ public static function withStatusCode($status) { return ResponseBuilder::create($status); }