Create trello card before purchasing
This commit is contained in:
@@ -42,23 +42,10 @@ get '/cart/delivery_destination' do
|
||||
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
||||
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!
|
||||
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 report_to_trello(cart)
|
||||
Thread.new do
|
||||
@cart = cart
|
||||
board = Trello::Board.find(RibicaConfig.TRELLO_BOARD_NAME)
|
||||
board = Trello::Board.find(RibicaConfig::TRELLO_BOARD_NAME)
|
||||
list = board.lists.first
|
||||
card = Trello::Card.new
|
||||
card.list_id = list.id
|
||||
@@ -69,6 +56,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(
|
||||
@@ -98,7 +101,7 @@ post '/cart/confirmation' do
|
||||
# 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)
|
||||
#report_to_trello(cart)
|
||||
send_order_email(cart)
|
||||
"OK".to_json
|
||||
end
|
||||
@@ -120,7 +123,7 @@ post '/payment/confirmation' do
|
||||
end
|
||||
|
||||
Cart.find_or_create(anonymous, user)
|
||||
report_to_trello(cart)
|
||||
#report_to_trello(cart)
|
||||
send_order_email(cart)
|
||||
"OK".to_json
|
||||
end
|
||||
@@ -138,7 +141,7 @@ get '/pikpay/confirmation' do
|
||||
end
|
||||
|
||||
Cart.find_or_create(anonymous, user)
|
||||
report_to_trello(cart)
|
||||
#report_to_trello(cart)
|
||||
send_order_email(cart)
|
||||
|
||||
redirect "#{RibicaConfig::ROOT_ADDRESS}/hvala"
|
||||
|
||||
Reference in New Issue
Block a user