/**
  * Add a offer to the response.
  *
  * @param string $type
  * @param string $condition
  * @param Offer $offer
  *
  * @throws InvalidArgumentException
  */
 public function addOffer($type, $condition, Offer $offer)
 {
     Arguments::contain(Boa::in(OfferType::getValues()), Boa::in(OfferCondition::getValues()), Boa::instance(Offer::class))->check($type, $condition, $offer);
     if ($type === OfferType::TYPE_FBA) {
         if ($condition === OfferCondition::CONDITION_NEW) {
             $this->fbaNewOffers[] = $offer;
         } elseif ($condition === OfferCondition::CONDITION_USED) {
             $this->fbaUsedOffers[] = $offer;
         }
     } elseif ($type === OfferType::TYPE_MERCHANT_FULFILLED) {
         if ($condition === OfferCondition::CONDITION_NEW) {
             $this->merchantNewOffers[] = $offer;
         } elseif ($condition === OfferCondition::CONDITION_USED) {
             $this->merchantUsedOffers[] = $offer;
         }
     }
 }
Beispiel #2
0
 public function testComplexSpec()
 {
     $graph = new SpecGraph();
     $graph->add('input', [], Spec::define(['sleepy' => Boa::boolean(), 'tennis_balls' => Boa::integer(), 'message' => Boa::either(Boa::string(), Boa::integer())], [], ['message']));
     $graph->add('allowedMessage', ['input'], Spec::define(['message' => [Boa::in(['hi', 'how are you?', 'you dumb']), Boa::in(['hi', 'how are you?', 'you are smart'])]], [], ['message']));
     $graph->add('validBallCount', ['input'], Spec::define(['tennis_balls' => Boa::between(1, 10)]));
     $graph->add('additionalBallProps', ['validBallCount'], Spec::define(['ball_color' => [Boa::string(), Boa::in(['blue', 'red', 'yellow'])]], [], ['ball_color']));
     $result = $graph->check(['sleepy' => true, 'tennis_balls' => 3, 'message' => 'hi', 'ball_color' => 'blue']);
     $this->assertTrue($result->passed());
     $result2 = $graph->check(['sleepy' => 1, 'tennis_balls' => 3]);
     $this->assertEqualsMatrix([[true, $result2->failed()], [1, count($result2->getFailed())], [['message'], $result2->getMissing()]]);
     $result3 = $graph->check(['sleepy' => true, 'tennis_balls' => -30, 'message' => 'hello']);
     $this->assertEqualsMatrix([[true, $result3->failed()], [2, count($result3->getFailed())], [[], $result3->getMissing()]]);
     $result4 = $graph->check(['sleepy' => true, 'tennis_balls' => 3, 'message' => 'how are you?']);
     $this->assertEqualsMatrix([[true, $result4->failed()], [0, count($result4->getFailed())], [['ball_color'], $result4->getMissing()]]);
     $result5 = $graph->check(['sleepy' => true, 'tennis_balls' => 3, 'message' => 'how are you?', 'ball_color' => 'liquid_gold']);
     $this->assertEqualsMatrix([[true, $result5->failed()], [1, count($result5->getFailed())], [[], $result5->getMissing()]]);
 }
 /**
  * Search the catalog and return the response
  *
  * @param string $idType
  * @param string $idCode
  *
  * @return SearchResponse
  */
 public function getSearch($idType, $idCode)
 {
     Arguments::contain(Boa::in(CodeType::getValues()), Boa::string())->check($idType, $idCode);
     return (new SearchResponseFactory())->makeFromResponse($this->client->get('/v1/search', ['query' => [$idType => $idCode, 'format' => 'pretty']]));
 }
Beispiel #4
0
 /**
  * Set the new status for this response.
  *
  * @param string $newStatus
  *
  * @throws InvalidArgumentException
  */
 public function setStatus($newStatus)
 {
     Arguments::contain(Boa::in($this->getValidStatuses()))->check($newStatus);
     $this->status = $newStatus;
 }
 /**
  * Set the HTTP method using the request.
  *
  * @param $method
  *
  * @throws InvalidArgumentException
  * @return $this
  */
 public function usingMethod($method)
 {
     Arguments::contain(Boa::in(HttpMethods::getValues()))->check($method);
     $this->method = $method;
     return $this;
 }
 /**
  * @param string $type
  *
  * @return RamlParameter
  */
 public function setType($type)
 {
     Arguments::define(Boa::in(RamlTypes::getValues()))->check($type);
     $new = clone $this;
     $new->type = $type;
     return $new;
 }