fatsecret_lite 0.2.2 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36eaf7148c1397b728204bfedee7d091c219ad1c1eb65ef695c50f8e41073690
4
- data.tar.gz: ba55fa1869f9858aa55a563c56857574f3878a32d5fb61f480801b7926e79865
3
+ metadata.gz: 8a173a429e88edc9e5ce1532dc053e558e6c7618c4762f94e424611cdbbff411
4
+ data.tar.gz: c473ea90439d2d1d3b6cd23f87d0e516594a0515bc832d0efc8febbe2d4bc311
5
5
  SHA512:
6
- metadata.gz: a4b7f6dc249d9954a4d0c52e6fb02d1ec93788be923668383627991368aee059f096b9343312818f8c9a05adb128cac956d7e81a7dcb47be7065f51a8c6a5078
7
- data.tar.gz: d8472d6dd06b8b8488ce93b3a93c79f544a09a01001921bb88037eb9e39e41f8cf018b78bb5d91d156b670581eee629318f7da60c81ec91479cb26b2dc3e5aed
6
+ metadata.gz: 7f3464c9270330f3bac9f4d52a06d6ad44be44be3b8c42974f6ca1af42bf8cbb773245bf6bca8bbe05048995838ad78392005a79370876c749a8947f98397d91
7
+ data.tar.gz: 1348315971741c0cb110da9277d9487208eb460d391668306d0908cd87bd795a2eaafd0a6c00c9eb668b31f9ecb7a1a5693157cb57be420efaf84bd9b1f611bd
@@ -10,12 +10,12 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "A lightweight Ruby gem for interacting with the FatSecret API"
12
12
  spec.description = "This gem provides a simple interface to interact with the FatSecret API using OAuth2 and RestClient."
13
- spec.homepage = "https://github.com/KapilDevPal/fatsecret_lite"
13
+ # spec.homepage = "https://github.com/KapilDevPal/fatsecret_lite"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.5"
16
16
 
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
- spec.metadata["homepage_uri"] = spec.homepage
18
+ # spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/KapilDevPal/fatsecret_lite"
20
20
  spec.metadata["changelog_uri"] = "https://github.com/KapilDevPal/fatsecret_lite/CHANGELOG.md"
21
21
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FatsecretLite
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.5"
5
5
  end
@@ -2,10 +2,8 @@
2
2
  require "oauth2"
3
3
  require "rest-client"
4
4
  require "json"
5
- require_relative 'fatsecret_search'
6
5
 
7
6
  module FatsecretLite
8
- extend FatsecretSearch
9
7
  class Configuration
10
8
  attr_accessor :client_id, :client_secret
11
9
 
@@ -88,6 +86,29 @@ module FatsecretLite
88
86
  rescue StandardError => e
89
87
  puts "An error occurred: #{e.message}"
90
88
  end
89
+
90
+ def find_food_by_search(search_value, max_results= 10)
91
+ access_token = get_access_token
92
+
93
+ response = RestClient.post(
94
+ 'https://platform.fatsecret.com/rest/server.api',
95
+ {
96
+ method: 'foods.search.v3',
97
+ max_results: max_results,
98
+ search_expression: search_value,
99
+ format: 'json'
100
+ },
101
+ {
102
+ content_type: :json,
103
+ Authorization: "Bearer #{access_token}"
104
+ }
105
+ )
106
+
107
+ JSON.parse(response.body)
108
+ rescue RestClient::ExceptionWithResponse => e
109
+ puts "Error: #{e.response}"
110
+ rescue StandardError => e
111
+ puts "An error occurred: #{e.message}"
112
+ end
91
113
  end
92
- include FatsecretLite::Search
93
114
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fatsecret_lite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - KapilDevPal
@@ -71,12 +71,11 @@ files:
71
71
  - lib/fatsecret_lite/configuration.rb
72
72
  - lib/fatsecret_lite/version.rb
73
73
  - sig/fatsecret_lite.rbs
74
- homepage: https://github.com/KapilDevPal/fatsecret_lite
74
+ homepage:
75
75
  licenses:
76
76
  - MIT
77
77
  metadata:
78
78
  allowed_push_host: https://rubygems.org
79
- homepage_uri: https://github.com/KapilDevPal/fatsecret_lite
80
79
  source_code_uri: https://github.com/KapilDevPal/fatsecret_lite
81
80
  changelog_uri: https://github.com/KapilDevPal/fatsecret_lite/CHANGELOG.md
82
81
  post_install_message: |2