# Full field metapolicy_struct

URL: https://docs.emergingtravel.com/docs/how-tos/process-fields/full-metapolicy-struct/

---


> [!NOTE]
> This page:
> * Gives an example on working with the `metapolicy_struct` field.
> * Covers code samples in Node.js and Python.
> * Uses the <b>Retrieve hotel dump</b> call:
>   * [B2B](/docs/b2b-api/static-content/retrieve-hotel-dump/).
>   * [Affiliate](/docs/affiliate-api/static-content/retrieve-hotel-dump/).



> [!TIP]
> * Change the `unspecified` values to something that will work for you.
> * Change other values to a readable format.
> * Make sure you process nullable or empty objects.





## Process the dump

Use the [instruction](/docs/how-tos/process-dump/).

## Read the `deposit` object and show its data to the user


**Node.js**

```js {linenos=inline}
// hotel is the hotel object
async function showDeposit(hotel) {
  const deposits = hotel.metapolicy_struct.deposit;
  if (deposits.length == 0) {
    console.log('No deposit');
    return;
  }
  // TODO: your logic
  console.log('Deposits');
  for (const deposit of deposits) {
    let unspecified = false;
    let depositType = deposit.deposit_type;
    if (depositType == 'unspecified') {
      depositType = 'No deposit type.';
      unspecified = true;
    } else {
      depositType = String(depositType).charAt(0).toUpperCase()
      + String(depositType).slice(1) + '.';
    }
    let depositPaymentType = deposit.payment_type;
    if (depositPaymentType == 'unspecified') {
      depositPaymentType = 'No deposit payment type.';
      unspecified = true;
    } else {
      depositPaymentType = 'The deposit is made by ' + depositPaymentType + '.';
    }
    let depositPriceUnit = deposit.price_unit;
    if (depositPriceUnit == 'unspecified') {
      depositPriceUnit = '(no price unit)';
      unspecified = true;
    } else {
      depositPriceUnit = String(depositPriceUnit).replaceAll('_', ' ');
    }
    let depositPricingMethod = deposit["pricing_method"];
    if (depositPricingMethod == 'unspecified') {
      depositPricingMethod = 'No pricing method.';
      unspecified = true;
    } else {
      depositPricingMethod = 'The deposit has the ' + depositPricingMethod + ' pricing method.';
    }
    const depositUnspecified = unspecified == true ? ' Contact the provider to know more.' : '';
    const depositAvailability = deposit.availability;
    if (depositAvailability == 'unspecified') {
      console.log('No information on the deposit availability. '+
        '%s %s %s The price is %s %s %s. %s ',
        depositType, depositPaymentType, depositPricingMethod, deposit.price, deposit.currency, depositPriceUnit, ' Contact the provider to know more.');
    } else if (depositAvailability == 'available') {
      console.log('Deposit is available to have. ' +
        '%s %s %s The price is %s %s %s. %s',
        depositType, depositPaymentType, depositPricingMethod, deposit.price, deposit.currency, depositPriceUnit, depositUnspecified);
    }
    else {
      console.log('Deposit isn’t available to have. ' +
        '%s %s %s The price is %s %s %s. %s',
        depositType, depositPaymentType, depositPricingMethod, deposit.price, deposit.currency, depositPriceUnit, depositUnspecified);
    }
  }
}

await function showDeposit(hotel);
```

**Python**

```python {linenos=inline}
# hotel is the hotel object
def show_deposit(hotel):
    deposits = hotel['metapolicy_struct']['deposit']
    if len(deposits) == 0:
        print("No deposit")
        return
    # TODO: your logic
    print("Deposits")
    for deposit in deposits:
        unspecified = False
        deposit_type = deposit['deposit_type']
        if deposit_type == "unspecified":
          deposit_type = "No deposit type."
          unspecified = True
        else:
          deposit_type = deposit_type[0:1].capitalize() + deposit_type[1:] + "."
        deposit_payment_type = deposit['payment_type']
        if deposit_payment_type == "unspecified":
          deposit_payment_type = "No deposit payment type."
          unspecified = True
        else:
          deposit_payment_type = "The deposit is made by " + deposit_payment_type + "."
        deposit_price_unit = deposit['price_unit']
        if deposit_price_unit == "unspecified":
          deposit_price_unit = "(no price unit)"
          unspecified = True
        else:
          deposit_price_unit = deposit_price_unit.replace("_", " ")
        deposit_pricing_method = deposit.pricing_method
        if deposit_pricing_method == "unspecified":
          deposit_pricing_method = "No pricing method."
          unspecified = True
        else:
          deposit_pricing_method = "The deposit has the " + deposit_pricing_method + " pricing method."
        deposit_unspecified = " Contact the provider to know more." if unspecified == True else ""
        deposit_availability = deposit['availability']
        if deposit_availability == "unspecified":
            print(
                f"No information on the deposit availability. " +
                f"{deposit_type} {deposit_payment_type} {deposit_pricing_method} " +
                f"The price is {deposit['price']} {deposit['currency']} {deposit_price_unit}. Contact the provider to know more."
                )
        elif deposit_availability == 'available':
            print(
                f"Deposit is available to have. " +
                f"{deposit_type} {deposit_payment_type} {deposit_pricing_method} " +
                f"The price is {deposit['price']} {deposit['currency']} {deposit_price_unit}.{deposit_unspecified}"
            )
        else:
            print('Deposit isn’t available to have. ' +
                f"{deposit_type} {deposit_payment_type} {deposit_pricing_method} " +
                f"The price is {deposit['price']} {deposit['currency']} {deposit_price_unit}.{deposit_unspecified}"
            )


if __name__ == "__main__":
    show_deposit(hotel)
```




## Read the `internet` object and show its data to the user


**Node.js**

```js {linenos=inline}
// hotel is the hotel object
async function showInternet(hotel) {
  const internets = hotel.metapolicy_struct.internet;
  if (internets.length == 0) {
    console.log('No internet');
    return;
  }
  // TODO: your logic
  console.log('Internet');
  for (const internet of internets) {
    let unspecified = false;
    let internetType = internet.internet_type;
    if (internetType == 'unspecified') {
      internetType = 'No internet type.';
      unspecified = true;
    } else {
      internetType = 'Internet is ' + internetType + '.';
    }
    let internetPriceUnit = internet.price_unit;
    if (internetPriceUnit == 'unspecified') {
      internetPriceUnit = '(no price unit)';
      unspecified = true;
    } else {
      internetPriceUnit = String(internetPriceUnit).replaceAll('_', ' ');
    }
    let internetWorkArea = internet.work_area;
    if (internetWorkArea == 'unspecified') {
      internetWorkArea = 'No internet coverage.';
      unspecified = true;
    } else {
      internetWorkArea = 'The internet covers the ' + internetWorkArea + '.';
    }
    const internetUnspecified = unspecified == true ? ' Contact the provider to know more.' : '';
    const internetInclusion = internet.inclusion;
    if (internetInclusion == 'unspecified') {
      console.log('%s The price is %s %s %s. %s ' +
        'No information on the internet inclusion to the overall price.%s',
        internetType, internet.price, internet.currency, internetPriceUnit, internetWorkArea, ' Contact the provider to know more.');
    } else if (internetInclusion == 'included') {
      console.log('%s The price is %s %s %s. %s ' +
        'The internet is included to the overall price.%s',
        internetType, internet.price, internet.currency, internetPriceUnit, internetWorkArea, internetUnspecified);
    }
    else {
      console.log('%s The price is %s %s %s. %s ' +
        'The internet isn’t included to the overall price.%s',
        internetType, internet.price, internet.currency, internetPriceUnit, internetWorkArea, internetUnspecified);
    }
  }
}

await function showInternet(hotel);
```

**Python**

```python {linenos=inline}
# hotel is the hotel object
def show_internet(hotel):
    internets = hotel["metapolicy_struct"]["internet"]
    if len(internets) == 0:
        print("No internet")
        return
    # TODO: your logic
    print("Internet")
    for internet in internets:
        unspecified = False
        internet_type = internet["internet_type"]
        if internet_type == "unspecified":
            internet_type = "No internet type."
            unspecified = True
        else:
            internet_type = "Internet is " + internet_type
        internet_price_unit = internet["price_unit"]
        if internet_price_unit == "unspecified":
            internet_price_unit = "(no price unit)"
            unspecified = True
        else:
            internet_price_unit = internet_price_unit.replace("_", " ")
        internet_work_area = internet["work_area"]
        if internet_work_area == "unspecified":
            internet_work_area = "No internet coverage."
            unspecified = True
        else:
            internet_work_area = "The internet covers the " + internet_work_area + "."
        internet_unspecified = " Contact the provider to know more." if unspecified == True else ""
        internet_inclusion = internet["inclusion"]
        if internet_inclusion == "unspecified":
            print(
                f"{internet_type} The price is {internet['price']} {internet['currency']} {internet_price_unit}. {internet_work_area} " +
                f"No information on the internet inclusion to the overall price. Contact the provider to know more."
            )
        elif internet_inclusion == "included":
            print(
                f"{internet_type} The price is {internet['price']} {internet['currency']} {internet_price_unit}. {internet_work_area} " +
                f"The internet is included to the overall price.{internet_unspecified}"
            )
        else:
            print(
                f"{internet_type} The price is {internet['price']} {internet['currency']} {internet_price_unit}. {internet_work_area} " +
                f"The internet isn’t included to the overall price.{internet_unspecified}"
            )


if __name__ == "__main__":
    show_internet(hotel)
```




## Read the `meal` object and show its data to the user


**Node.js**

```js {linenos=inline}
// hotel is the hotel object
async function showMeal(hotel) {
  const meals = hotel.metapolicy_struct.meal;
  if (meals.length == 0) {
    console.log('No meals for adults');
    return;
  }
  // TODO: your logic
  console.log('Meals for adults');
  for (const meal of meals) {
    let unspecified = false;
    let mealType = meal.meal_type;
    if (mealType == 'unspecified') {
      mealType = 'No meal type.';
      unspecified = true;
    } else {
      mealType = String(mealType).charAt(0).toUpperCase()
        + String(mealType).slice(1);
      mealType = String(mealType).replaceAll('-', ' ') + '.';
    }
    const mealUnspecified = unspecified == true ? ' Contact the provider to know more.' : '';
    const mealInclusion = meal.inclusion;
    if (mealInclusion == 'unspecified') {
      console.log('%s The price is %s %s per a person. ' +
        'No information on the meal inclusion to the overall price.%s',
        mealType, meal.price, meal.currency, ' Contact the provider to know more.');
    }
    else if (mealInclusion == 'included') {
      console.log('%s The price is %s %s per a person. ' +
        'The meal is included to the overall price.%s',
        mealType, meal.price, meal.currency, mealUnspecified);
    }
    else {
      console.log('%s The price is %s %s per a person. ' +
        'The meal isn’t included to the overall price.%s',
        mealType, meal.price, meal.currency, mealUnspecified);
    }
  }
}

await function showMeal(hotel);
```

**Python**

```python {linenos=inline}
# hotel is the hotel object
def show_meal(hotel):
    meals = hotel["metapolicy_struct"]["meal"]
    if len(meals) == 0:
        print("No meals for adults")
        return
    # TODO: your logic
    print("Meals for adults")
    for meal in meals:
        unspecified = False
        meal_type = meal["meal_type"]
        if meal_type == "unspecified":
            meal_type = "No meal type."
            unspecified = True
        else:
            meal_type = meal_type[0:1].capitalize() + meal_type[1:]
            meal_type = meal_type.replace("-", " ") + "."
        meal_unspecified = " Contact the provider to know more." if unspecified == True else ""
        meal_inclusion = meal["inclusion"]
        if meal_inclusion == "unspecified":
            print(
                f"{meal_type} The price is {meal['price']} {meal['currency']} per a person. "
                f"No information on the meal inclusion to the overall price. Contact the provider to know more."
            )
        elif meal_inclusion == "included":
            print(
                f"{meal_type} The price is {meal['price']} {meal['currency']} per a person. " +
                f"The meal is included to the overall price.{meal_unspecified}"
            )
        else:
            print(
                f"{meal_type} The price is {meal['price']} {meal['currency']} per a person. " +
                f"The meal isn’t included to the overall price.{meal_unspecified}"
            )


if __name__ == "__main__":
    show_meal(hotel)
```




## Read the `children_meal` object and show its data to the user


**Node.js**

```js {linenos=inline}
// hotel is the hotel object
async function showChildrenMeal(hotel) {
  const childrenMeals = hotel.metapolicy_struct.children_meal;
  if (childrenMeals.length == 0) {
    console.log('No meals for children');
    return;
  }
  // TODO: your logic
  console.log('Meals for children');
  for (const meal of childrenMeals) {
    let unspecified = false;
    let mealType = meal.meal_type;
    if (mealType == 'unspecified') {
      mealType = 'No meal type.';
      unspecified = true;
    } else {
      mealType = String(mealType).charAt(0).toUpperCase()
        + String(mealType).slice(1);
      mealType = String(mealType).replaceAll('-', ' ') + '.';
    }
    let mealAgeStart = meal.age_start;
    let mealAgeEnd = meal.age_end;
    let mealAge = mealAgeStart == mealAgeEnd ? String(mealAgeStart) : String(mealAgeStart) + '-' + String(mealAgeEnd);
    const mealUnspecified = unspecified == true ? ' Contact the provider to know more.' : '';
    const mealInclusion = meal.inclusion;
    if (mealInclusion == 'unspecified') {
      console.log('%s For children of %s y.o. The price is %s %s per a child. ' +
        'No information on the meal inclusion to the overall price.%s',
        mealType, mealAge, meal.price, meal.currency, ' Contact the provider to know more.');
    }
    else if (mealInclusion == 'included') {
      console.log('%s For children of %s y.o. The price is %s %s per a child. ' +
        'The meal is included to the overall price.%s',
        mealType, mealAge, meal.price, meal.currency, mealUnspecified);
    }
    else {
      console.log('%s For children of %s y.o. The price is %s %s per a child. ' +
        'The meal isn’t included to the overall price.%s',
        mealType, mealAge, meal.price, meal.currency, mealUnspecified);
    }
  }
}

await function showChildrenMeal(hotel);
```

**Python**

```python {linenos=inline}
# hotel is the hotel object
def show_children_meal(hotel):
    children_meals = hotel["metapolicy_struct"]["children_meal"]
    if len(children_meals) == 0:
        print("No meals for children")
        return
    # TODO: your logic
    print("Meals for children")
    for meal in children_meals:
        unspecified = False
        meal_type = meal["meal_type"]
        if meal_type == "unspecified":
            meal_type = "No meal type."
            unspecified = True
        else:
            meal_type = meal_type[0:1].capitalize() + meal_type[1:]
            meal_type = meal_type.replace("-", " ") + "."
        meal_age_start = meal["age_start"]
        meal_age_end = meal["age_end"]
        meal_age = f"{meal_age_start}" if meal_age_start == meal_age_end else f"{meal_age_start}-{meal_age_end}"
        meal_unspecified = " Contact the provider to know more." if unspecified == True else ""
        meal_inclusion = meal["inclusion"]
        if meal_inclusion == "unspecified":
            print(
                f"{meal_type} For children of {meal_age} y.o. The price is {meal['price']} {meal['currency']} per a child. "
                f"No information on the meal inclusion to the overall price.{meal_unspecified}"
            )
        elif meal_inclusion == "included":
            print(
                f"{meal_type} For children of {meal_age} y.o. The price is {meal['price']} {meal['currency']} per a child. " +
                f"The meal is included to the overall price.{meal_unspecified}"
            )
        else:
            print(
                f"{meal_type} For children of {meal_age} y.o. The price is {meal['price']} {meal['currency']} per a child. " +
                f"The meal isn’t included to the overall price.{meal_unspecified}"
            )


if __name__ == "__main__":
    show_children_meal(hotel)
```




## Read the `extra_bed` object and show its data to the user


**Node.js**

```js {linenos=inline}
// hotel is the hotel object
async function showExtraBed(hotel) {
  const beds = hotel.metapolicy_struct.extra_bed;
  if (beds.length == 0) {
    console.log('No extra beds');
    return;
  }
  // TODO: your logic
  console.log('Extra beds');
  for (const bed of beds) {
    let unspecified = false;
    let bedPriceUnit = bed.price_unit;
    if (bedPriceUnit == 'unspecified') {
      bedPriceUnit = '(no price unit)';
      unspecified = true;
    } else {
      bedPriceUnit = String(bedPriceUnit).replaceAll('_', ' ');
    }
    const bedUnspecified = unspecified == true ? ' Contact the provider to know more.' : '';
    const bedInclusion = bed.inclusion;
    if (bedInclusion == 'unspecified') {
      console.log('%s bed(s). The price is %s %s %s. ' +
        'No information on the extra beds’ inclusion to the overall price.%s',
        bed.amount, bed.price, bed.currency, bedPriceUnit, ' Contact the provider to know more.');
    }
    else if (bedInclusion == 'included') {
      console.log('%s bed(s). The price is %s %s %s. ' +
        'The extra beds are included to the overall price.%s',
        bed.amount, bed.price, bed.currency, bedPriceUnit, bedUnspecified);
    }
    else {
      console.log('%s bed(s). The price is %s %s %s. ' +
        'The extra beds aren’t included to the overall price.%s',
        bed.amount, bed.price, bed.currency, bedPriceUnit, bedUnspecified);
    }
  }
}

await function showExatraBed(hotel);
```

**Python**

```python {linenos=inline}
# hotel is the hotel object
def show_extra_bed(hotel):
    beds = hotel["metapolicy_struct"]["extra_bed"]
    if len(beds) == 0:
        print("No extra bed")
        return
    # TODO: your logic
    print("Extra beds")
    for bed in beds:
        unspecified = False
        bed_price_unit = bed["price_unit"]
        if bed_price_unit == "unspecified":
          bed_price_unit = "(no price unit)"
          unspecified = True
        else:
          bed_price_unit = bed_price_unit.replace('_', ' ')
        bed_unspecified = " Contact the provider to know more." if unspecified == True else ""
        bed_inclusion = bed["inclusion"]
        if bed_inclusion == "unspecified":
            print(f"{bed.amount} bed(s). The price is {bed.price} {bed.currency} {bed_price_unit}. " +
                  f"No information on the extra beds inclusion to the overall price. Contact the provider to know more."
            )
        elif bed_inclusion == 'included':
            print(f"{bed.amount} bed(s). The price is {bed.price} {bed.currency} {bed_price_unit}. " +
                  f"The extra beds are included to the overall price.{bed_unspecified}"
            )
        else:
            print(f"{bed.amount} bed(s). The price is {bed.price} {bed.currency} {bed_price_unit}. " +
                  f"The extra beds aren’t included to the overall price.{bed_unspecified}"
            )


if __name__ == "__main__":
    show_extra_bed(hotel)
```






