Module: Gratitude::Client::Tips

Included in:
Gratitude::Client
Defined in:
lib/gratitude/tips.rb

Instance Method Summary collapse

Instance Method Details

#current_tipsObject



6
7
8
9
10
# File 'lib/gratitude/tips.rb', line 6

def current_tips
  response = faraday.get(tips_path)
  raise_any_errors_based_upon(response)
  response.body
end

#current_tips_totalObject



12
13
14
# File 'lib/gratitude/tips.rb', line 12

def current_tips_total
  current_tips.inject(0) { |total, tip| total + tip["amount"].to_f }
end

#update_tips(array_of_hashes_with_usernames_and_amounts) ⇒ Object



16
17
18
# File 'lib/gratitude/tips.rb', line 16

def update_tips(array_of_hashes_with_usernames_and_amounts)
  post_tips_to_gratipay(array_of_hashes_with_usernames_and_amounts)
end

#update_tips_and_prune(array_of_hashes_with_usernames_and_amounts) ⇒ Object



20
21
22
23
24
# File 'lib/gratitude/tips.rb', line 20

def update_tips_and_prune(array_of_hashes_with_usernames_and_amounts)
  post_tips_to_gratipay(
    array_of_hashes_with_usernames_and_amounts, prune: true
  )
end