SOlved conflict

This commit is contained in:
Senad Uka
2016-03-16 12:12:26 +01:00
4 changed files with 26 additions and 15 deletions

View File

@@ -52,6 +52,7 @@ end
put '/cart/delivery_destination', &update_delivery_destination
post '/cart/delivery_destination', &update_delivery_destination
def report_to_trello(cart)
Thread.new do
@cart = cart
@@ -66,6 +67,22 @@ def report_to_trello(cart)
end
end
update_delivery_destination = ->() {
cart = Cart.just_find(anonymous_id, logged_in_user_id)
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note", "payment_method", "gift",
"recipient_name", "recipient_address", "recipient_place", "recipient_postal_code", "recipient_phone", "recipient_email"]
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
cart.delivery_destination.update_attributes(params)
cart.delivery_destination.save!
report_to_trello(cart)
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
}
put '/cart/delivery_destination', &update_delivery_destination
post '/cart/delivery_destination', &update_delivery_destination
def send_order_email(cart)
Thread.new do
client = SendGrid::Client.new(
@@ -91,13 +108,11 @@ post '/cart/confirmation' do
cart.ordered = true
cart.save!
end
report_to_trello(cart)
send_order_email(cart)
# since there is no more ordered cart this needs to be done
# in order for next call of Cart#just_find to be ready
Cart.find_or_create(anonymous, logged_in_user_id)
report_to_trello(cart)
send_order_email(cart)
'OK'.to_json
end