コード例 #1
0
 /**
  * Get information about product using its UUID as parameter.###Response+ `uuid` - UUID of product+ `published` - true / false+ `title` - Title of product. Everytime on English+ `titleTranslated` - Title of product on requested language+ `description` - Description of product. Everytime on English+ `descriptionTranslated` - Description of product on requested language+ `highlights` - Highlights of product. Everytime on English+ `highlightsTranslated` - Highlights of product on requested language+ `additionalInfo` - Additional information of product. Everytime on English+ `additionalInfoTranslated` - Additional information of product on requested language+ `priceIncludes` - What's included in product price+ `priceIncludesTranslated` - Translated version of `priceIncludes`+ `itinerary` - Activity itinerary - only applicable for Package type, will be `NULL` for others+ `itineraryTranslated` - translated version of itinerary+ `warnings` - Warnings of the activity (related to safety and insurance)+ `warningsTranslated` - translated version of warnings+ `safety` - activity safety information+ `safetyTranslated` - translated version of safety information+ `latitude` - Latitude+ `longitude` - Longitude+ `minPax` - Minimum number of pax+ `maxPax` - Maximum number of pax+ `basePrice` - Base price of product (for list only)+ `currency` - Currency+ `isFlatPaxPrice` - `true/false` (An indication to tell if the `Product` has the same price for each pax in all of its `productTypes`)+ `reviewCount` - Number of reviews+ `reviewAverageScore` - Average score+ `typeName` - Type of product+ `typeUuid` - Type UUID+ `businessHoursFrom` - supplier business hours `from`+ `businessHoursTo` - supplier business hours `to`+ `meetingTime` - meeting time+ `hotelPickup` - false+ `meetingLocation` - instructions about meeting location with supplier+ `meetingLocationTranslated` - translated version of meeting location+ `photosUrl` - Base URL for images+ `photos` - Array of photos in different dimensions (Sizes: original, 75x50, 175x112, 680x325)+ `categories` - Array of categories+ `productTypes`    + `uuid` - UUID of Product Type    + `title` - Title of Product Type    + `titleTranslated` - Translated version of title    + `description` - Description of Product Type    + `descriptionTranslated` - translated version of description    + `durationDays` - duration in days    + `durationHours` - duration in hours    + `durationMinutes` - duration in  minutes    + `paxMin` - Minimum number of people    + `paxMax` - Maximum number of people    + `daysInAdvance` - how many days in advance booking can be made    + `isNonRefundable` - True if product not refundable    + `hasChildPrice` - Does product has child price    + `minAdultAge` - The minimum age allowed for an adult    + `maxAdultAge` - The maximum age allowed for an adult    + `allowChildren` - Is a child allowed for this product    + `minChildAge` - The minimum age allowed for a child    + `maxChildAge` - The maximum age allowed for a child    + `instantConfirmation` - if it's TRUE then booking this product should return new Booking status = `approved`, but if we're out of stock of e-tickets it can still return `waiting`     + `voucherUse` - instruction on how to use the voucher (Using what? Go to what palce? To redeem with who?)    + `voucherUseTranslated` - translated version of how to use voucher    + `voucherRedemptionAddress` - Voucher redemption address IF client needs to redeem a voucher.     + `voucherRedemptionAddressTranslated` - translated version of `voucherRedemptionAddress`    + `recommendedMarkup` - Apply this markup if you want to match with BMG's website prices    + `prices` - List of prices for Product Type for one month. The prices array consist of price for adults depending of number of adults and price for child.    + `timeSlots` - Available timeslots for product, might be `null`. If the `ProductType` has timeslots, the `timeslotUUID` of the product is REQUIRED in `Check a Booking` and `Create a new booking` methods.+ `addons` - Add-ons for product+ `locations` - Information about product location+ `url` - URL of product + `staticUrl` - Static URL of product+ `guideLanguages` - Available languages speak by tour guide.+ `audioHeadsetLanguages` - Available languages for Audio Headset material.+ `writtenLanguages` - Available written languages for reading material.If product has been deleted from BeMyGuest database response will be:        {          "error": {            "code": "GEN-GONE",            "http_code": 410,            "message": "Resource No Longer Available"          }        }### Promotional pricesExample of promotion data block:        "promotion": {              "type": "early_booking",              "daysInAdvance": 30,              "hoursInAdvance": null,              "name": "Early Bird",              "adult": {                "2": 93.45              },              "child": 0,              "discountPercent": 30,              "cancellationPolicy": []        }- If product type has promotional prices for selected date only one promotion (with best price) will be visible in API.- there are 3 types of promotions (`type` parameter) : `early_booking`, `last_minute` and `discount`- `early_booking` will have value for `daysInAdvance` parameter provided (`hoursInAdvance` will be `NULL`)- `last_minute` will have value for `hoursInAdvance` provided (`daysInAdvance` will be `NULL`)- `discount` type will have both `daysInAdvance` and `hoursInAdvance` set to `NULL`
  * @param  string     $uuid           Required parameter: UUID of product
  * @param  string     $currency       Optional parameter: currency UUID, also currency code may be provided in exchange
  * @param  string     $dateEnd        Optional parameter: product's prices end date, format YYYY-MM-DD
  * @param  string     $dateStart      Optional parameter: product's prices start date, format YYYY-MM-DD
  * @param  string     $language       Optional parameter: language UUID, also language code may be provided
  * @return mixed response from the API call
  * @throws APIException Thrown if API call fails
  */
 public function getProduct($uuid, $currency = NULL, $dateEnd = NULL, $dateStart = NULL, $language = NULL)
 {
     //the base uri for api requests
     $_queryBuilder = Configuration::$BASEURI;
     //prepare query string for API call
     $_queryBuilder = $_queryBuilder . '/v1/products/{uuid}/';
     //process optional query parameters
     APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array('uuid' => $uuid));
     //process optional query parameters
     APIHelper::appendUrlWithQueryParameters($_queryBuilder, array('currency' => $currency, 'date_end' => $dateEnd, 'date_start' => $dateStart, 'language' => $language));
     //validate and preprocess url
     $_queryUrl = APIHelper::cleanUrl($_queryBuilder);
     //prepare headers
     $_headers = array('user-agent' => 'BeMyGuest.SDK.v1', 'Accept' => 'application/json', 'X-Authorization' => Configuration::$xAuthorization);
     //call on-before Http callback
     $_httpRequest = new HttpRequest(HttpMethod::GET, $_headers, $_queryUrl);
     if ($this->getHttpCallBack() != null) {
         $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest);
     }
     //and invoke the API call request to fetch the response
     $response = Request::get($_queryUrl, $_headers);
     //call on-after Http callback
     if ($this->getHttpCallBack() != null) {
         $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body);
         $_httpContext = new HttpContext($_httpRequest, $_httpResponse);
         $this->getHttpCallBack()->callOnAfterRequest($_httpContext);
     }
     //Error handling using HTTP status codes
     if ($response->code == 410) {
         throw new APIException('Resource No Longer Available', $_httpContext);
     } else {
         if ($response->code == 400) {
             throw new APIException('Wrong Arguments', $_httpContext);
         } else {
             if ($response->code == 401) {
                 throw new APIException('Unauthorized', $_httpContext);
             } else {
                 if ($response->code == 403) {
                     throw new APIException('Forbidden', $_httpContext);
                 } else {
                     if ($response->code == 404) {
                         throw new APIException('Resource Not Found', $_httpContext);
                     } else {
                         if ($response->code == 405) {
                             throw new APIException('Method Not Allowed', $_httpContext);
                         } else {
                             if ($response->code < 200 || $response->code > 208) {
                                 //[200,208] = HTTP OK
                                 throw new APIException("HTTP Response Not OK", $_httpContext);
                             }
                         }
                     }
                 }
             }
         }
     }
     $mapper = $this->getJsonMapper();
     return $mapper->map($response->body, new Models\GETProductResponse());
 }