lib/fatsecret_lite.rb in fatsecret_lite-0.2.0 vs lib/fatsecret_lite.rb in fatsecret_lite-0.2.1

- old
+ new

@@ -42,11 +42,37 @@ access_token = get_access_token response = RestClient.post( 'https://platform.fatsecret.com/rest/server.api', { - method: 'food.get.v2', + method: 'food.get.v4', food_id: food_id, + include_food_images: true, + include_food_attributes: true, + format: 'json' + }, + { + content_type: :json, + Authorization: "Bearer #{access_token}" + } + ) + + JSON.parse(response.body) + rescue RestClient::ExceptionWithResponse => e + puts "Error: #{e.response}" + rescue StandardError => e + puts "An error occurred: #{e.message}" + end + + # find food id by barcode + def find_food_by_barcode(barcode) + access_token = get_access_token + + response = RestClient.post( + 'https://platform.fatsecret.com/rest/server.api', + { + method: 'food.find_id_for_barcode', + barcode: barcode, format: 'json' }, { content_type: :json, Authorization: "Bearer #{access_token}"