pillfyi 0.1.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/pillfyi.rb +116 -0
  3. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d67e6e9b2ff4117207944cdb3bf8e7ba8b96b21a691b23b45c5f44fd98e71618
4
+ data.tar.gz: 9ccc496d0a2c499213a438055581672ee07e74006f0e4fc96161f98232d12919
5
+ SHA512:
6
+ metadata.gz: 8c26b68443fe69bdf4157f5034cdf167a5a35ad130e62f38bd372eeba90d3e3963800df03ece4002075365f48a5e09d7a047563dc785d65782c7687042a99f20
7
+ data.tar.gz: 40e49bbb1d6081d7a4c84dd25d569f610cd260c5e431a4f0bfacad11cbb186979e3d668c597518c8896894c4ce5498a9af88f1a41466108e3aa1aa2ff47f451a
data/lib/pillfyi.rb ADDED
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "json"
5
+ require "uri"
6
+
7
+ # Ruby client for PillFYI REST API (pillfyi.com).
8
+ #
9
+ # client = PillFYI::Client.new
10
+ # result = client.search("query")
11
+ #
12
+ module PillFYI
13
+ class Client
14
+ BASE_URL = "https://pillfyi.com"
15
+
16
+ def initialize(base_url: BASE_URL)
17
+ @base_url = base_url
18
+ end
19
+
20
+ def search(query)
21
+ get("/api/v1/search/", q: query)
22
+ end
23
+
24
+ # List all conditions.
25
+ def list_conditions
26
+ get("/api/v1/conditions/")
27
+ end
28
+
29
+ # Get condition by slug.
30
+ def get_condition(slug)
31
+ get("/api/v1/conditions/#{slug}/")
32
+ end
33
+ # List all drug classes.
34
+ def list_drug_classes
35
+ get("/api/v1/drug-classes/")
36
+ end
37
+
38
+ # Get drug classe by slug.
39
+ def get_drug_classe(slug)
40
+ get("/api/v1/drug-classes/#{slug}/")
41
+ end
42
+ # List all drug conditions.
43
+ def list_drug_conditions
44
+ get("/api/v1/drug-conditions/")
45
+ end
46
+
47
+ # Get drug condition by slug.
48
+ def get_drug_condition(slug)
49
+ get("/api/v1/drug-conditions/#{slug}/")
50
+ end
51
+ # List all drug side effects.
52
+ def list_drug_side_effects
53
+ get("/api/v1/drug-side-effects/")
54
+ end
55
+
56
+ # Get drug side effect by slug.
57
+ def get_drug_side_effect(slug)
58
+ get("/api/v1/drug-side-effects/#{slug}/")
59
+ end
60
+ # List all drugs.
61
+ def list_drugs
62
+ get("/api/v1/drugs/")
63
+ end
64
+
65
+ # Get drug by slug.
66
+ def get_drug(slug)
67
+ get("/api/v1/drugs/#{slug}/")
68
+ end
69
+ # List all faqs.
70
+ def list_faqs
71
+ get("/api/v1/faqs/")
72
+ end
73
+
74
+ # Get faq by slug.
75
+ def get_faq(slug)
76
+ get("/api/v1/faqs/#{slug}/")
77
+ end
78
+ # List all interactions.
79
+ def list_interactions
80
+ get("/api/v1/interactions/")
81
+ end
82
+
83
+ # Get interaction by slug.
84
+ def get_interaction(slug)
85
+ get("/api/v1/interactions/#{slug}/")
86
+ end
87
+ # List all manufacturers.
88
+ def list_manufacturers
89
+ get("/api/v1/manufacturers/")
90
+ end
91
+
92
+ # Get manufacturer by slug.
93
+ def get_manufacturer(slug)
94
+ get("/api/v1/manufacturers/#{slug}/")
95
+ end
96
+ # List all side effects.
97
+ def list_side_effects
98
+ get("/api/v1/side-effects/")
99
+ end
100
+
101
+ # Get side effect by slug.
102
+ def get_side_effect(slug)
103
+ get("/api/v1/side-effects/#{slug}/")
104
+ end
105
+
106
+ private
107
+
108
+ def get(path, **params)
109
+ uri = URI.join(@base_url, path)
110
+ uri.query = URI.encode_www_form(params) unless params.empty?
111
+ response = Net::HTTP.get_response(uri)
112
+ raise "HTTP #{response.code}" unless response.is_a?(Net::HTTPSuccess)
113
+ JSON.parse(response.body)
114
+ end
115
+ end
116
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pillfyi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - FYIPedia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Ruby client for the PillFYI REST API at pillfyi.com. Zero external dependencies.
14
+ email: dev@fyipedia.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/pillfyi.rb
20
+ homepage: https://pillfyi.com
21
+ licenses:
22
+ - MIT
23
+ metadata:
24
+ source_code_uri: https://github.com/fyipedia/pillfyi-rb
25
+ documentation_uri: https://pillfyi.com/api/v1/schema/
26
+ homepage_uri: https://pillfyi.com
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '3.0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubygems_version: 3.0.3.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Ruby client for PillFYI API
46
+ test_files: []