trello integration finished

This commit is contained in:
Senad Uka
2015-09-26 11:58:01 +02:00
parent ae8e9b0081
commit 014416ca51
16 changed files with 867 additions and 81 deletions

View File

@@ -54,22 +54,36 @@ put '/cart/delivery_destination', &update_delivery_destination
post '/cart/delivery_destination', &update_delivery_destination
def send_order_email(cart)
def report_to_trello(cart)
Thread.new do
@cart = cart
board = Trello::Board.find('FqDO1eFL')
list = board.lists.first
card = Trello::Card.new
card.list_id = list.id
card.name = cart.title
card.pos = "bottom"
card.desc = erb(:cart_trello, :layout => false)
card.save
end
end
client = SendGrid::Client.new(api_user: "ribica",
api_key: "plava*kutija*svjetlo*torba07"
def send_order_email(cart)
Thread.new do
client = SendGrid::Client.new(
api_user: "ribica",
api_key: "plava*kutija*svjetlo*torba07"
)
email = SendGrid::Mail.new do |m|
m.to = "narudzbe@ribica.ba"
m.from = "draga@ribica.ba"
m.from_name = "Prodavnica Ribica"
m.subject = "Nova Narudžba: #{cart.id}"
m.html = "Mušterija naručila nešto. <br /> Pogledati https://www.ribica.ba/backoffice/carts/#{cart.id}"
email = SendGrid::Mail.new do |m|
m.to = "narudzbe@ribica.ba"
m.from = "draga@ribica.ba"
m.from_name = "Prodavnica Ribica"
m.subject = "Nova Narudžba: #{cart.id}"
m.html = "Mušterija naručila nešto. <br /> Pogledati https://www.ribica.ba/backoffice/carts/#{cart.id}"
end
client.send(email)
end
client.send(email)
end
@@ -83,6 +97,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)
send_order_email(cart)
"OK".to_json
end