open_fda_api 0.0.3 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 10a12a605aa07fbd3dfa75f7fdb9e909fc9eaa7b18f2add3449db666110c7d3f
4
- data.tar.gz: 79207bf839e4a82f2a6a1f374645cc4e2a25cfa2923d4726aaf856d779b667dd
3
+ metadata.gz: adc99f4c0266329d56ee1cbc6592789908b09a98580136813e3d8033e33c2328
4
+ data.tar.gz: 6fc8dc376b266e216e5f263248cbae5342c655a50ba3aa1c9d37245a6b521bdf
5
5
  SHA512:
6
- metadata.gz: 1a172a5bd14024af9dff624f3bf0c5cd22d09cb43cd7b5901b43d7b328e88d6cfbbabc8097be14ec456fe64b4e6ff661334687c24cb7141f217be52b4808ccfd
7
- data.tar.gz: 375be0de9fbf21279fd5b0d00ebd16375455d99a3d1e672bfc6cdf3373aa04c3cc2c824b7deddb6104c8b39856365b2a54c8ef5ae04243682d830a72782f04f3
6
+ metadata.gz: 95da4769cc677e55b92f682bc4b7f05d98543cfcfa05f2d4786c8254e52a6399235e3850a11c7d70ba63dd61ea28e42fda25fc336e8ac1fb3710e9e9a4dc29ca
7
+ data.tar.gz: f93d3fa2ffc26fad6f9460333326d32f97f51f99dcd567b85ddd62b5ed4e5f868d4aff4bcc8183b37214927e7a03ff4e64fee534c8a98a1c2f5ffc3fe7ee619c
data/.rubocop.yml CHANGED
@@ -12,3 +12,7 @@ Style/StringLiteralsInInterpolation:
12
12
 
13
13
  Layout/LineLength:
14
14
  Max: 120
15
+
16
+ Metrics/BlockLength:
17
+ Exclude:
18
+ - spec/**/*
data/CHANGELOG.md CHANGED
@@ -1,6 +1,31 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.0.2] - 2022-01-19
3
+ ## [0.0.9] - 2022-01-24
4
+ - Filled out the following Drug endpoints:
5
+ - product_labeling
6
+ - ndc_directory
7
+ - recall_enforcement_reports
8
+ - drugs_at_fda
9
+
10
+ ## [0.0.8] - 2022-01-24
11
+ - Delete the `OpenFdaApi.client` method since its only function was to forward messages
12
+
13
+ ## [0.0.7] - 2022-01-23
14
+ - Use Faraday instead of using Net::HTTP directly
15
+ - Introduce `QueryInputs` to group query params passed in together
16
+
17
+ ## [0.0.6] - 2022-01-21
18
+ - Support for more query fields
19
+
20
+ ## [0.0.5] - 2022-01-20
21
+ - Validate, against search fields given to us from openFDA API, when building queries.
22
+
23
+ ## [0.0.4] - 2022-01-19
24
+ - Fix version string in changelog.
25
+ - Update Query Builder to group search arguments properly.
26
+ - Update Query Builder to replace spaces with pluses in search values as openFDA API documentation requires.
27
+
28
+ ## [0.0.3] - 2022-01-19
4
29
  - Update version again because CHANGELOG wasn't updated along with the 0.0.2 release.
5
30
 
6
31
  ## [0.0.2] - 2022-01-19
data/Gemfile.lock CHANGED
@@ -1,16 +1,49 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- open_fda_api (0.0.1)
4
+ open_fda_api (0.0.9)
5
+ faraday (~> 1.9)
6
+ faraday_middleware (~> 1.2)
5
7
 
6
8
  GEM
7
9
  remote: https://rubygems.org/
8
10
  specs:
9
11
  ast (2.4.2)
12
+ coderay (1.1.3)
10
13
  diff-lcs (1.5.0)
14
+ faraday (1.9.3)
15
+ faraday-em_http (~> 1.0)
16
+ faraday-em_synchrony (~> 1.0)
17
+ faraday-excon (~> 1.1)
18
+ faraday-httpclient (~> 1.0)
19
+ faraday-multipart (~> 1.0)
20
+ faraday-net_http (~> 1.0)
21
+ faraday-net_http_persistent (~> 1.0)
22
+ faraday-patron (~> 1.0)
23
+ faraday-rack (~> 1.0)
24
+ faraday-retry (~> 1.0)
25
+ ruby2_keywords (>= 0.0.4)
26
+ faraday-em_http (1.0.0)
27
+ faraday-em_synchrony (1.0.0)
28
+ faraday-excon (1.1.0)
29
+ faraday-httpclient (1.0.1)
30
+ faraday-multipart (1.0.3)
31
+ multipart-post (>= 1.2, < 3)
32
+ faraday-net_http (1.0.1)
33
+ faraday-net_http_persistent (1.2.0)
34
+ faraday-patron (1.0.0)
35
+ faraday-rack (1.0.0)
36
+ faraday-retry (1.0.3)
37
+ faraday_middleware (1.2.0)
38
+ faraday (~> 1.0)
39
+ method_source (1.0.0)
40
+ multipart-post (2.1.1)
11
41
  parallel (1.21.0)
12
42
  parser (3.1.0.0)
13
43
  ast (~> 2.4.1)
44
+ pry (0.14.1)
45
+ coderay (~> 1.1)
46
+ method_source (~> 1.0)
14
47
  rainbow (3.1.1)
15
48
  rake (13.0.6)
16
49
  regexp_parser (2.2.0)
@@ -40,6 +73,7 @@ GEM
40
73
  rubocop-ast (1.15.1)
41
74
  parser (>= 3.0.1.1)
42
75
  ruby-progressbar (1.11.0)
76
+ ruby2_keywords (0.0.5)
43
77
  unicode-display_width (2.1.0)
44
78
 
45
79
  PLATFORMS
@@ -47,6 +81,7 @@ PLATFORMS
47
81
 
48
82
  DEPENDENCIES
49
83
  open_fda_api!
84
+ pry
50
85
  rake (~> 13.0)
51
86
  rspec (~> 3.0)
52
87
  rubocop (~> 1.7)
data/README.md CHANGED
@@ -16,37 +16,64 @@ And then execute:
16
16
  bundle install
17
17
  ```
18
18
 
19
- ## Documentation
19
+ ## Usage
20
20
 
21
- There are 5 main category of endpoints that openFDA API provides: Drug, Device, Food, Other, and Tobacco.
22
-
23
- Each category has further subcategories. Everything is accessible from the `OpenFdaApi.client`.
21
+ ```ruby
22
+ client = OpenFdaApi.client
24
23
 
24
+ # First 20 results where (fieldA=foo AND fieldB=bar) OR (fieldC=baz AND fieldA exists)
25
+ # Sorted by (fieldD) in descending order
26
+ # Skip the first 8 results
27
+ args = {
28
+ search: [{"fieldA" => "foo", "fieldB" => "bar"}, {"fieldC" => "baz", "_exists_" => "fieldA"}],
29
+ sort: [{"fieldD" => "desc"}],
30
+ skip: 8,
31
+ limit: 20
32
+ }
33
+
34
+ # Drug API
35
+ client.drugs.adverse_events(args)
36
+ client.drugs.product_labeling(args)
37
+ client.drugs.ndc_directory(args)
38
+ client.drugs.recall_enforcement_reports(args)
39
+ client.drugs.drugs_at_fda(args)
40
+
41
+ # Device API
42
+ client.device.premarket_501ks(args)
43
+ client.device.classification(args)
44
+ client.device.recall_enforcement_reports(args)
45
+ client.device.adverse_events(args)
46
+ client.device.premarket_approval(args)
47
+ client.device.recalls(args)
48
+ client.device.registrations_and_listings(args)
49
+ client.device.covid19_serological_tests(args)
50
+ client.device.unique_device_identifier(args)
51
+
52
+ # Food API
53
+ client.food.recall_enforcement_reports(args)
54
+ client.food.adverse_events(args)
55
+
56
+ # Other API
57
+ client.other.nsde(args)
58
+ client.other.substance_data_reports(args)
59
+
60
+ # Tobacco API
61
+ client.tobacco.problem_reports(args)
62
+ ```
25
63
 
26
- ### Drug
64
+ ### Querying
27
65
 
28
- The Drug API has the following endpoints: Adverse Events, Product Labeling, NDC Directory, Recall Enforcement Reports, and Drugs@FDA.
66
+ The openFDA API can be queried with these arguments: `search`, `sort`, `count`, `skip`, and `limit`.
29
67
 
30
- Here's how you interact with each:
68
+ `search`, `sort`, and `count` have the same format. They are arrays of hashes. Each hash has a set of fields and values
69
+ that are ANDed together and all the elements in the array are ORed together. Here are some examples to illustrate:
31
70
 
32
- #### Adverse Events
33
71
  ```ruby
34
- require 'open_fda_api'
72
+ search = [{"patient.drug.openfda.pharm_class_epc" => "nonsteroidal+anti-inflammatory+drug" }]
35
73
 
36
- client = OpenFdaApi.client
37
- drugs_api = client.drugs
38
-
39
- arguments = [{"patient.reaction.reactionmeddrapt"=>"fatigue"}, {"occurcountry"=>"ca"}]
40
- drugs_api.adverse_events(search_arguments: arguments) # => {"meta" => {...}, "results" => [...]}
74
+ # patient.drug.openfda.pharm_class_epc:"nonsteroidal+anti-inflammatory+drug"&count=patient.reaction.reactionmeddrapt.exact
41
75
  ```
42
76
 
43
- ### Device (Not Implemented Yet)
44
- ### Food (Not Implemented Yet)
45
- ### Other (Not Implemented Yet)
46
- ### Tobacco (Not Implemented Yet)
47
-
48
-
49
-
50
77
  ## Development
51
78
 
52
79
  After checking out the repo, run `bin/setup` to install dependencies.
data/bin/console CHANGED
@@ -11,5 +11,8 @@ require "open_fda_api"
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
+ client = OpenFdaApi::Client.new
15
+ puts "Client is ready: #{client}"
16
+
14
17
  require "irb"
15
18
  IRB.start(__FILE__)
@@ -1,18 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "./drugs"
3
+ require "faraday"
4
+ require "faraday_middleware"
4
5
 
5
6
  module OpenFdaApi
6
7
  # Gives you access to the main nouns in the openFDA API
7
8
  class Client
8
- attr_reader :api_key
9
+ attr_reader :api_key, :adapter
9
10
 
10
- def initialize(api_key: nil)
11
+ BASE_URL = "https://api.fda.gov"
12
+
13
+ def initialize(api_key: nil, adapter: Faraday.default_adapter, stubs: nil)
11
14
  @api_key = api_key
15
+ @adapter = adapter
16
+ @stubs = stubs
12
17
  end
13
18
 
14
19
  def drugs
15
- OpenFdaApi::Drugs.new
20
+ OpenFdaApi::Drugs.new(self)
21
+ end
22
+
23
+ def connection
24
+ @connection ||= Faraday.new(BASE_URL) do |conn|
25
+ conn.request :json
26
+
27
+ conn.response :dates
28
+ conn.response :json, content_type: "application/json"
29
+
30
+ conn.adapter adapter, @stubs
31
+ end
16
32
  end
17
33
  end
18
34
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "net/http"
4
4
  require "json"
5
- require "open_fda_api/query_builder"
5
+ require "yaml"
6
6
 
7
7
  module OpenFdaApi
8
8
  # Interact with the Drugs API Endpoint:
@@ -12,36 +12,100 @@ module OpenFdaApi
12
12
  # - Recall Enforcement Reports
13
13
  # - Drugs@FDA)
14
14
  class Drugs
15
- def initialize
15
+ attr_reader :client, :path_base
16
+
17
+ def initialize(client)
18
+ @client = client
16
19
  @host = "api.fda.gov"
17
20
  @path_base = "/drug"
18
21
  end
19
22
 
20
- # The openFDA drug adverse event API returns data that has been collected from the
21
- # FDA Adverse Event Reporting System (FAERS), a database that contains information on
22
- # adverse event and medication error reports submitted to FDA.
23
- #
24
- # @param search_arguments [Array<Hash>] Search fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
23
+ # @param search [Array<Hash>] Search fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
24
+ # @param sort [Array<Hash>] Sort fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
25
+ # @param count [Array<Hash>] Count fields defined https://open.fda.gov/apis/drug/event/searchable-fields/
26
+ # @param skip [Integer] Number of results to skip
27
+ # @param limit [Integer] Number of results to return
28
+ # @return Response from the API parsed as JSON
29
+ def adverse_events(search: [], sort: [], count: [], skip: 0, limit: 1)
30
+ endpoint = "event.json"
31
+ inputs = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
32
+ query = build_query(inputs, self.class.valid_adverse_events_fields)
33
+ make_request(endpoint, query)
34
+ end
35
+
36
+ # @param search [Array<Hash>] Search fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
37
+ # @param sort [Array<Hash>] Sort fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
38
+ # @param count [Array<Hash>] Count fields defined https://open.fda.gov/apis/drug/event/searchable-fields/
39
+ # @param skip [Integer] Number of results to skip
40
+ # @param limit [Integer] Number of results to return
25
41
  # @return Response from the API parsed as JSON
26
- def adverse_events(search_arguments: [])
27
- endpoint = "/event.json"
28
- query = build_query(search_arguments)
29
- url = build_url(endpoint, query)
30
- make_request(url)
42
+ def product_labeling(search: [], sort: [], count: [], skip: 0, limit: 1)
43
+ endpoint = "label.json"
44
+ inputs = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
45
+ query = build_query(inputs, {}) # TODO: Upload valid fields
46
+ make_request(endpoint, query)
47
+ end
48
+
49
+ # @param search [Array<Hash>] Search fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
50
+ # @param sort [Array<Hash>] Sort fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
51
+ # @param count [Array<Hash>] Count fields defined https://open.fda.gov/apis/drug/event/searchable-fields/
52
+ # @param skip [Integer] Number of results to skip
53
+ # @param limit [Integer] Number of results to return
54
+ # @return Response from the API parsed as JSON
55
+ def ndc_directory(search: [], sort: [], count: [], skip: 0, limit: 1)
56
+ endpoint = "ndc.json"
57
+ inputs = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
58
+ query = build_query(inputs, {}) # TODO: Upload valid fields
59
+ make_request(endpoint, query)
60
+ end
61
+
62
+ # @param search [Array<Hash>] Search fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
63
+ # @param sort [Array<Hash>] Sort fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
64
+ # @param count [Array<Hash>] Count fields defined https://open.fda.gov/apis/drug/event/searchable-fields/
65
+ # @param skip [Integer] Number of results to skip
66
+ # @param limit [Integer] Number of results to return
67
+ # @return Response from the API parsed as JSON
68
+ def recall_enforcement_reports(search: [], sort: [], count: [], skip: 0, limit: 1)
69
+ endpoint = "enforcement.json"
70
+ inputs = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
71
+ query = build_query(inputs, {}) # TODO: Upload valid fields
72
+ make_request(endpoint, query)
73
+ end
74
+
75
+ # @param search [Array<Hash>] Search fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
76
+ # @param sort [Array<Hash>] Sort fields defined in https://open.fda.gov/apis/drug/event/searchable-fields/
77
+ # @param count [Array<Hash>] Count fields defined https://open.fda.gov/apis/drug/event/searchable-fields/
78
+ # @param skip [Integer] Number of results to skip
79
+ # @param limit [Integer] Number of results to return
80
+ # @return Response from the API parsed as JSON
81
+ def drugs_at_fda(search: [], sort: [], count: [], skip: 0, limit: 1)
82
+ endpoint = "drugsfda.json"
83
+ inputs = build_inputs(search: search, sort: sort, count: count, skip: skip, limit: limit)
84
+ query = build_query(inputs, {}) # TODO: Upload valid fields
85
+ make_request(endpoint, query)
86
+ end
87
+
88
+ def self.valid_adverse_events_fields
89
+ @valid_adverse_events_fields ||= ::YAML.load_file("#{__dir__}/adverse_events_fields.yml")
31
90
  end
32
91
 
33
92
  private
34
93
 
35
- def build_url(endpoint, query)
36
- URI::HTTPS.build(host: @host, path: @path_base + endpoint, query: query)
94
+ def build_query(query_input, valid_search_fields)
95
+ QueryBuilder.new(query_input: query_input, valid_search_fields: valid_search_fields).build_query
37
96
  end
38
97
 
39
- def build_query(search_arguments)
40
- QueryBuilder.new(search: search_arguments).build_query
98
+ def build_inputs(search:, sort:, count:, skip:, limit:)
99
+ QueryInputs.new(search: search, sort: sort, count: count, skip: skip, limit: limit)
41
100
  end
42
101
 
43
- def make_request(url)
44
- JSON.parse(Net::HTTP.get(url))
102
+ def make_request(endpoint, query)
103
+ url = "#{path_base}/#{endpoint}"
104
+ if query.empty?
105
+ client.connection.get(url)
106
+ else
107
+ client.connection.get(url, query)
108
+ end.body
45
109
  end
46
110
  end
47
111
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenFdaApi
4
+ class InvalidQueryArgument < ArgumentError; end
5
+
4
6
  # A helper to build queries against the openFDA API
5
7
  #
6
8
  # The API supports five query parameters. The basic building block of queries is the search parameter.
@@ -23,34 +25,81 @@ module OpenFdaApi
23
25
  # Use in combination with limit to paginate results. Currently, the largest allowed value for the skip parameter
24
26
  # is 25000. See Paging if you require paging through larger result sets.
25
27
  class QueryBuilder
26
- # @param [Array<Hash>] search
27
- def initialize(search: [])
28
- @search = build_search_string(search)
28
+ # @param [Hash] valid_search_fields
29
+ # @param [QueryInput] query_input
30
+ def initialize(query_input:, valid_search_fields:)
31
+ # TODO: Turn validations back on once we get basic functionality working; need to flex on different field types
32
+ # validate_arguments!(valid_search_fields, query_input: query_input)
33
+ warn "You've passed in a valid_search_fields arg but it isn't being used right now..." if valid_search_fields
34
+ @search = build_query_string(query_fields: query_input.search)
35
+ @sort = build_query_string(query_fields: query_input.sort)
36
+ @count = build_query_string(query_fields: query_input.count)
37
+ @skip = build_skip_string(query_input.skip)
38
+ @limit = query_input.limit
29
39
  end
30
40
 
31
- # @return [String] the query string portion of a request
41
+ # @return [Hash] the query string portion of a request
32
42
  def build_query
33
- # TODO: We currently just build a very basic search string for simple examples like "search=a:b+AND+c:d",
34
- # but it is possible to construct more complex queries and we will need to support that. Sorting, counting,
35
- # setting limits, skipping records, pagination, converting spaces, phrase matching, grouping, and using dates and
36
- # ranges are examples of more complex queries that can be built.
37
- @search
43
+ {
44
+ search: @search,
45
+ sort: @sort,
46
+ count: @count,
47
+ skip: @skip,
48
+ limit: @limit
49
+ }.compact.reject { |_k, v| v.to_s.empty? }
38
50
  end
39
51
 
40
52
  private
41
53
 
42
- def build_search_string(search)
43
- return "" if search.empty?
54
+ def validate_arguments!(valid_search_fields, query_input:)
55
+ # `search` keys must exist in adverse_events_fields.yml
56
+ invalid_fields = get_invalid_fields(valid_search_fields: valid_search_fields, fields: query_input.search)
57
+ raise InvalidQueryArgument, "'search' has invalid fields: #{invalid_fields}" if invalid_fields.any?
58
+
59
+ # `sort` keys must exist in adverse_events_fields.yml
60
+ invalid_fields = get_invalid_fields(valid_search_fields: valid_search_fields, fields: query_input.sort)
61
+ raise InvalidQueryArgument, "'sort' has invalid fields: #{invalid_fields}" if invalid_fields.any?
62
+
63
+ # `count` keys must exist in adverse_events_fields.yml
64
+ invalid_fields = get_invalid_fields(valid_search_fields: valid_search_fields, fields: query_input.count)
65
+ raise InvalidQueryArgument, "'count' has invalid fields: #{invalid_fields}" if invalid_fields.any?
66
+
67
+ # `count` and `skip` cannot be set at the same time
68
+ return unless count_and_skip_set?(query_input.count, query_input.skip)
69
+
70
+ raise InvalidQueryArgument, "'count' and 'skip' cannot both be set at the same time!"
71
+ end
72
+
73
+ def build_query_string(query_fields:)
74
+ return "" if query_fields.empty?
44
75
 
45
- value = if search.count == 1 # AND case
46
- # Turns [{a: b, c: d}] into "a:b+AND+c:d"
47
- search.first.map { |k, v| "#{k}:#{v}" }.join("+AND+")
48
- else # OR case
49
- # Turns [{a: b}, {c: d}] into "a:b+c:d"
50
- search.map { |h| "#{h.keys.first}:#{h.values.first}" }.join("+")
51
- end
76
+ build_groupings(query_fields).to_s
77
+ end
78
+
79
+ def build_skip_string(skip)
80
+ skip.positive? ? skip.to_s : ""
81
+ end
82
+
83
+ def build_groupings(fields)
84
+ fields.map do |and_args|
85
+ "(#{and_args.map { |k, v| "#{k}:#{v.gsub(" ", "+")}" }.join("+AND+")})"
86
+ end.join("+")
87
+ end
88
+
89
+ def get_invalid_fields(valid_search_fields:, fields:)
90
+ # TODO: valid_search_fields define types and we need to check against those
91
+ fields.map(&:keys).flatten.select do |field|
92
+ if field.include?(".") # nested field (e.g. patient.patientagegroup)
93
+ dig_values = field.split(".").join(",properties,").split(",")
94
+ valid_search_fields["properties"].dig(*dig_values).nil?
95
+ else
96
+ !valid_search_fields["properties"].keys.include?(field.to_s)
97
+ end
98
+ end
99
+ end
52
100
 
53
- "search=#{value}"
101
+ def count_and_skip_set?(count, skip)
102
+ skip.positive? && !count.empty?
54
103
  end
55
104
  end
56
105
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenFdaApi
4
+ # Group of inputs to build the query against the API with
5
+ class QueryInputs
6
+ attr_reader :search, :sort, :count, :skip, :limit
7
+
8
+ def initialize(**params)
9
+ @search = params[:search] || []
10
+ @sort = params[:sort] || []
11
+ @count = params[:count] || []
12
+ @skip = params[:skip] || 0
13
+ @limit = params[:limit] || nil
14
+ end
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenFdaApi
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.9"
5
5
  end
data/lib/open_fda_api.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "open_fda_api/version"
4
- require_relative "open_fda_api/client"
5
4
 
6
5
  # A Ruby wrapper for the openFDA API: https://open.fda.gov/apis/
7
6
  module OpenFdaApi
8
7
  class Error < StandardError; end
9
8
 
10
- def self.client(api_key: nil)
11
- OpenFdaApi::Client.new(api_key: api_key)
12
- end
9
+ autoload :Client, "open_fda_api/client"
10
+ autoload :Drugs, "open_fda_api/drugs"
11
+ autoload :QueryInputs, "open_fda_api/query_inputs"
12
+ autoload :QueryBuilder, "open_fda_api/query_builder"
13
13
  end
data/open_fda_api.gemspec CHANGED
@@ -27,7 +27,10 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  # Uncomment to register a new dependency of your gem
30
- # spec.add_dependency "example-gem", "~> 1.0"
30
+ spec.add_dependency "faraday", "~> 1.9"
31
+ spec.add_dependency "faraday_middleware", "~> 1.2"
32
+
33
+ spec.add_development_dependency "pry"
31
34
 
32
35
  # For more information and examples about making a new gem, checkout our
33
36
  # guide at: https://bundler.io/guides/creating_gem.html
metadata CHANGED
@@ -1,15 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: open_fda_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hebron George
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-19 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2022-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  description:
14
56
  email:
15
57
  - hebrontgeorge@gmail.com
@@ -35,6 +77,7 @@ files:
35
77
  - lib/open_fda_api/client.rb
36
78
  - lib/open_fda_api/drugs.rb
37
79
  - lib/open_fda_api/query_builder.rb
80
+ - lib/open_fda_api/query_inputs.rb
38
81
  - lib/open_fda_api/version.rb
39
82
  - open_fda_api.gemspec
40
83
  homepage: https://github.com/hebron-george/open_fda_api