Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEFE API - Edit a unit #13

Open
franck-boullier opened this issue Mar 29, 2019 · 10 comments
Open

MEFE API - Edit a unit #13

franck-boullier opened this issue Mar 29, 2019 · 10 comments
Assignees

Comments

@franck-boullier
Copy link
Member

This describes the MEFE API to edit a Unee-T unit.
unee-t/frontend#740 for more details.

The Payload needed by the MEFE API:

{
	"actionType": "EDIT_UNIT",
	"requestorUserId": "R4vBD6BZRCNx8JwnM",
	"unitId": "FuFMO1O1ISXPmwtMB",
	"creatorId": "R4vBD6BZRCNx8JwnM",
	"type": "Hotel",
	"name": "Unit test yyyyyy",
	"moreInfo": "More info",
	"streetAddress": "123 asdjdsj",
	"city": "Singapore",
	"state": "---",
	"zipCode": "11111111",
	"country": "Singapore"
}

Example response:

{
    "timestamp": "2019-03-28T02:54:02.345Z"
}

The Payload generated by the SQL via Lambda:

{
	"updateUnitRequestId": 1,
	"actionType": "EDIT_UNIT",
	"requestorUserId": "R4vBD6BZRCNx8JwnM",
	"unitId": "FuFMO1O1ISXPmwtMB",
	"creatorId": "R4vBD6BZRCNx8JwnM",
	"type": "Hotel",
	"name": "Unit test yyyyyy",
	"moreInfo": "More info",
	"streetAddress": "123 asdjdsj",
	"city": "Singapore",
	"state": "---",
	"zipCode": "11111111",
	"country": "Singapore"
}

The SQL to run after the API returns a success:

SET @update_unit_request_id = `updateUnitRequestId` ;
SET @updated_datetime = `timestamp` ;  [(the SQL formatted timestamp of the reply from the MEFE API)]
CALL `ut_update_success_mefe_unit`;

@kaihendry Let me know when all is ready on your side (Golang) so I can test end to end.

kaihendry pushed a commit that referenced this issue Mar 29, 2019
@kaihendry
Copy link
Contributor

I'm getting from @nbiton MEFE Unrecognized actionType EDIT_UNIT btw in the dev environment.

@kaihendry
Copy link
Contributor

This depends on unee-t/frontend@6133544 and it's not deployed yet due to my mistake.

@kaihendry
Copy link
Contributor

There is an issue with unee-t/frontend@6133544 in the sense that is doesn't allow updateUnitRequestId.

@kaihendry
Copy link
Contributor

Ok, it should now be working, the error is "No unit found for unitId FuFMO1O1ISXPmwtMB, but I am assuming that's because of the payload.

@franck-boullier
Copy link
Member Author

This does not work as intended - Re-opening

The test:

  • Update a unit in the Unee-T Enterprise database. PASSED
  • Lambda is generated by the SQL PASSED

The payload:

{"city": "Singapore", "name": "Seahill - 119 - Updated", "type": "Condominium", "state": null, "unitId": "ytso09kIqPu9wON64", "country": "Singapore", "zipCode": "126777", "moreInfo": "Seahill is a 99-Year Leasehold Condominium located at 119, West Coast Crescent, 126777 in District 05. It comprises of 338 Units. Seahill is close to Clementi MRT (EW23). It is completed in 2016. Schools close to Seahill include Farrer Park Primary School, Saint Joseph’s Institution Junior and Stamford Primary School.\r\n\r\nFacilities in Seahill\r\n\r\nFacilities at Seahill include Sky Pool, Water Feature with Sunken Planter, 50M Lap Pool, Spa Island, Kids Pool, Dining Pavilion, Spa Pool, Massage Pavilion and Lounge Deck, Aqua Gym, Sea Mist Spa Pool, Function Deck, Meeting Pavilion, Jogging Track, Outdoor Fitness, Children Playground, Viewing Pavilion, Fitness Balcony and Plunge Pool.\r\n\r\nAmenities near Seahill\r\n\r\nResidents at Seahill can get to nearby supermarkets or shopping mall within the area for an array of amenities such as grocery and retail shopping, bank, eateries and more.\r\n\r\nSeahill is near to NTUC Fairprice, Cold Storage and Sheng Siong Supermarket. It is also close to West Coast Plaza.\r\n\r\nVehicle owners can take West Coast Highway, Clementi Road and Ayer Rajah Expressway (AYE) to get to the business hub or shopping district in the city. ", "creatorId": "hF4AxDx6r6ue2TgFD", "actionType": "EDIT_UNIT", "streetAddress": "119 West Coast Crescent  \n", "requestorUserId": "MEFE API - Create Unit", "updateUnitRequestId": 1047}

Expected result:

  • The unit name is changed in the Mongo database from Seahill - 119 to Seahill - 119 - Updated - FAILED
  • The table ut_map_external_source_units in the Unee-T Enterprise database is updated - FAILED

@kaihendry
Copy link
Contributor

What env are you testing with? https://case.demo.unee-t.com/ ?

@franck-boullier
Copy link
Member Author

Still not working as it should...

The test:

  • In the DEV/STaging environment
  • Update the name of a unit - PASSED
  • The SQL generates the payload - PASSED

Expected Result:

  • Unit name is updated in the MEFE - FAILED

The payload:

{"city": "Singapore", "name": "One North Updated - K", "type": "Condominium", "state": null, "unitId": "EOlSJMSdx8Hfx5D6Y", "country": "Singapore", "zipCode": "138642", "moreInfo": null, "creatorId": "YYeAutqzDY3MeqbNC", "actionType": "EDIT_UNIT", "streetAddress": "7 One North Gate Way \n", "requestorUserId": "MEFE API - Create Unit", "updateUnitRequestId": 1054}

@kaihendry, any insight?

@kaihendry
Copy link
Contributor

Initially I had issue with the carriage return in the street address oddly. But this is the error requestorUserId MEFE API - Create Unit is not allowed to edit unit EOlSJMSdx8Hfx5D6Y from the logs:

/aws/lambda/alambda_simple {"fields":{},"level":"info","timestamp":"2019-04-01T07:56:32.454480044Z","message":"Posting to: https://case.dev.unee-t.com/api/process-api-payload?accessToken=secret, payload {\"city\":\"Singapore\",\"name\":\"One North Updated - K\",\"type\":\"Condominium\",\"state\":null,\"unitId\":\"EOlSJMSdx8Hfx5D6Y\",\"country\":\"Singapore\",\"zipCode\":\"138642\",\"moreInfo\":null,\"creatorId\":\"YYeAutqzDY3MeqbNC\",\"actionType\":\"EDIT_UNIT\",\"streetAddress\":\"7 One North Gate Way\",\"requestorUserId\":\"MEFE API - Create Unit\",\"updateUnitRequestId\":1054}"}
/aws/lambda/alambda_simple {"fields":{},"level":"info","timestamp":"2019-04-01T07:56:32.533256372Z","message":"Response code 403, Body: \"requestorUserId MEFE
API - Create Unit is not allowed to edit unit EOlSJMSdx8Hfx5D6Y\""}

@nbiton
Copy link

nbiton commented Apr 1, 2019

This JSON payload is messed up. "requestorUserId" shoyld be an ID. Of a user. Definitely not "MEFE API - Create Unit"

@franck-boullier
Copy link
Member Author

This JSON payload is messed up. "requestorUserId" shoyld be an ID. Of a user. Definitely not "MEFE API - Create Unit"

Ah! yep I need to fix that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants