Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# Install the AMEEconnect Ruby SDK with 'gem install amee' # See https://github.com/AMEE/amee-ruby require 'rubygems' require 'amee' # Server connection details SERVER = "stage.amee.com" USERNAME = "your_api_key" PASSWORD = "your_api_key" # The path and drill to identify the correct calculation CATEGORY = "/metadata/hotel" DRILL = "type=normal" # Create a connection to the server amee = AMEE::Connection.new(SERVER, USERNAME, PASSWORD) # Create a new profile profile = AMEE::Profile::Profile.create(amee) # Get the UID of the data item uid = AMEE::Data::DrillDown.get(amee, "/data#{CATEGORY}/drill?#{DRILL}").data_item_uid # Prepare the values for the calculation # The following values MUST be provided for this usage required_values = { :averageOccupancyRate => 'SOME_VALUE', :floorspaceUnits => 'SOME_VALUE', :hasCeilingFan => 'SOME_VALUE', :hasCentrallyControlledAirCon => 'SOME_VALUE', :hasCentrallyControlledVentilation => 'SOME_VALUE', :hasFitnessCentre => 'SOME_VALUE', :hasFitnessRoom => 'SOME_VALUE', :hasIndividuallyControlledVentilation => 'SOME_VALUE', :hasIndoorPool => 'SOME_VALUE', :hasOutdoorPool => 'SOME_VALUE', :hasRoomTempControl => 'SOME_VALUE', :hasSauna => 'SOME_VALUE', :hasSolarium => 'SOME_VALUE', :hasTurkishBath => 'SOME_VALUE', :numberOfMeetingRooms => 'SOME_VALUE', :numberOfRooms => 'SOME_VALUE', :proportionFloorspaceMeetingRooms => 'SOME_VALUE', :proportionFloorspaceRemaining => 'SOME_VALUE', :proportionFloorspaceaccommodation => 'SOME_VALUE', :rating => 'SOME_VALUE', :refrigerantVolume => 'SOME_VALUE', :totalFloorspace => 'SOME_VALUE' } # Store profile item and perform calculation item = AMEE::Profile::Item.create_without_category(amee, "/profiles/#{profile.uid}#{CATEGORY}", uid, required_values ) # Print results puts 'Result:' item.amounts.each do |amt| puts "#{amt[:type]}: #{amt[:value]} #{amt[:unit]}#{'/'+amt[:per_unit] if amt[:per_unit].present?}" end |
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
<?php // Install the AMEEconnect PHP SDK with 'pear install pearhub/Services_AMEE' // See https://github.com/AMEE/amee-lib-php // Include required files require_once 'Services/AMEE/DataItem.php'; require_once 'Services/AMEE/Profile.php'; require_once 'Services/AMEE/ProfileItem.php'; // Server connection details define('AMEE_API_URL', 'stage.amee.com'); define('AMEE_API_PROJECT_KEY', 'your_api_key'); define('AMEE_API_PROJECT_PASSWORD', 'your_api_password'); // The path and drill to identify the correct calculation $sProfileCategory = "metadata/hotel"; $aProfileCategory = array( "type" => "normal" ); try { // Create a new profile $oProfile = new Services_AMEE_Profile(); // Get the data item $oDataItem = new Services_AMEE_DataItem($sProfileCategory, $aProfileCategory); // Prepare the values for the calculation // The following values MUST be provided for this usage $aRequiredProfileItemValues = array( 'averageOccupancyRate' => 'SOME_VALUE', 'floorspaceUnits' => 'SOME_VALUE', 'hasCeilingFan' => 'SOME_VALUE', 'hasCentrallyControlledAirCon' => 'SOME_VALUE', 'hasCentrallyControlledVentilation' => 'SOME_VALUE', 'hasFitnessCentre' => 'SOME_VALUE', 'hasFitnessRoom' => 'SOME_VALUE', 'hasIndividuallyControlledVentilation' => 'SOME_VALUE', 'hasIndoorPool' => 'SOME_VALUE', 'hasOutdoorPool' => 'SOME_VALUE', 'hasRoomTempControl' => 'SOME_VALUE', 'hasSauna' => 'SOME_VALUE', 'hasSolarium' => 'SOME_VALUE', 'hasTurkishBath' => 'SOME_VALUE', 'numberOfMeetingRooms' => 'SOME_VALUE', 'numberOfRooms' => 'SOME_VALUE', 'proportionFloorspaceMeetingRooms' => 'SOME_VALUE', 'proportionFloorspaceRemaining' => 'SOME_VALUE', 'proportionFloorspaceaccommodation' => 'SOME_VALUE', 'rating' => 'SOME_VALUE', 'refrigerantVolume' => 'SOME_VALUE', 'totalFloorspace' => 'SOME_VALUE' ); // Store profile item and perform calculation $oProfileItem = new Services_AMEE_ProfileItem(array( $oProfile, $oDataItem, $aRequiredProfileItemValues )); // Display the result $aInfo = $oProfileItem->getInfo(); echo "Result:\n"; echo "CO2 ({$aInfo['unit']}/{$aInfo['perUnit']}): {$aInfo['amount']}\n"; } catch (Exception $oException) { // An error occured echo "Error: " . $oException->getMessage() . "\n"; } ?> |
Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
// First, get the AMEEconnect Java SDK and add to your CLASSPATH // See https://github.com/AMEE/amee-lib-java import java.util.List; import java.util.ArrayList; import com.amee.client.AmeeException; import com.amee.client.service.*; import com.amee.client.model.base.*; import com.amee.client.model.profile.*; import com.amee.client.model.data.*; import com.amee.client.util.Choice; public class CreateProfileItem { public static void main(String[] args) throws AmeeException { // Set up connection to the server AmeeContext.getInstance().setUsername("your_api_key"); AmeeContext.getInstance().setPassword("your_api_password"); AmeeContext.getInstance().setBaseUrl("http://stage.amee.com"); AmeeObjectFactory objectFactory = AmeeObjectFactory.getInstance(); // The path and drill to identify the correct calculation String profileCategory = "metadata/hotel"; AmeeDrillDown drillDown = objectFactory.getDrillDown("metadata/hotel/drill"); drillDown.addSelection("type","normal"); // Create a new profile AmeeProfile profile = objectFactory.getProfile(); // Get the UID of the data item drillDown.fetch(); String dataItemUID = drillDown.getDataItem().getUid(); // Set options for new item List<Choice> values = new ArrayList<Choice>(); // The following values MUST be provided for this usage values.add(new Choice("averageOccupancyRate", SOME_VALUE)); values.add(new Choice("floorspaceUnits", SOME_VALUE)); values.add(new Choice("hasCeilingFan", SOME_VALUE)); values.add(new Choice("hasCentrallyControlledAirCon", SOME_VALUE)); values.add(new Choice("hasCentrallyControlledVentilation", SOME_VALUE)); values.add(new Choice("hasFitnessCentre", SOME_VALUE)); values.add(new Choice("hasFitnessRoom", SOME_VALUE)); values.add(new Choice("hasIndividuallyControlledVentilation", SOME_VALUE)); values.add(new Choice("hasIndoorPool", SOME_VALUE)); values.add(new Choice("hasOutdoorPool", SOME_VALUE)); values.add(new Choice("hasRoomTempControl", SOME_VALUE)); values.add(new Choice("hasSauna", SOME_VALUE)); values.add(new Choice("hasSolarium", SOME_VALUE)); values.add(new Choice("hasTurkishBath", SOME_VALUE)); values.add(new Choice("numberOfMeetingRooms", SOME_VALUE)); values.add(new Choice("numberOfRooms", SOME_VALUE)); values.add(new Choice("proportionFloorspaceMeetingRooms", SOME_VALUE)); values.add(new Choice("proportionFloorspaceRemaining", SOME_VALUE)); values.add(new Choice("proportionFloorspaceaccommodation", SOME_VALUE)); values.add(new Choice("rating", SOME_VALUE)); values.add(new Choice("refrigerantVolume", SOME_VALUE)); values.add(new Choice("totalFloorspace", SOME_VALUE)); // Store profile item and perform calculation AmeeProfileCategory cat = objectFactory.getProfileCategory(profile, profileCategory); AmeeProfileItem item = cat.addProfileItem(dataItemUID, values); // Print results System.out.println("Result:"); System.out.format("CO2 (kg/year): %s\n", item.getAmount()); } } |
cURL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# These commands assume a bash shell and that # you have curl and xpath available. # Create profile and get UID curl 'https://stage.amee.com/profiles' \ -X POST \ -d 'profile=true' \ -H 'Accept: application/xml' \ -u your_api_key:your_api_password \ | xpath '//Profile/@uid' # Get data item UID curl 'https://stage.amee.com/data/metadata/hotel/drill?type=normal' \ -H 'Accept: application/xml' \ -u your_api_key:your_api_password \ | xpath '//Choices/Choice/Name/text()' # Perform calculation curl 'https://stage.amee.com/profiles/PROFILE_UID/metadata/hotel' \ -X POST \ -d 'dataItemUid=DATA_ITEM_UID&representation=full&averageOccupancyRate=SOME_VALUE&floorspaceUnits=SOME_VALUE&hasCeilingFan=SOME_VALUE&hasCentrallyControlledAirCon=SOME_VALUE&hasCentrallyControlledVentilation=SOME_VALUE&hasFitnessCentre=SOME_VALUE&hasFitnessRoom=SOME_VALUE&hasIndividuallyControlledVentilation=SOME_VALUE&hasIndoorPool=SOME_VALUE&hasOutdoorPool=SOME_VALUE&hasRoomTempControl=SOME_VALUE&hasSauna=SOME_VALUE&hasSolarium=SOME_VALUE&hasTurkishBath=SOME_VALUE&numberOfMeetingRooms=SOME_VALUE&numberOfRooms=SOME_VALUE&proportionFloorspaceMeetingRooms=SOME_VALUE&proportionFloorspaceRemaining=SOME_VALUE&proportionFloorspaceaccommodation=SOME_VALUE&rating=SOME_VALUE&refrigerantVolume=SOME_VALUE&totalFloorspace=SOME_VALUE' \ -H 'Accept: application/xml' \ -u username:password \ | xpath '//Amounts/Amount' |