Class: EpoOps::Register
- Inherits:
-
Object
- Object
- EpoOps::Register
- Defined in:
- lib/epo_ops/register.rb
Overview
Access to the register endpoint of the EPO OPS API.
By now you can search and retrieve patents by using the type ‘application` in the `epodoc` format.
Search queries are limited by size, not following these limits will result in errors. You should probably use Register.search which handles the limits itself.
For more fine grained control use Register.raw_search and raw_biblio
Class Method Summary collapse
-
.all_queries(ipc_class = nil, date = nil) ⇒ Array
builds all queries necessary to find all patent references on a given date.
-
.patent_counts_per_ipc_class(date) ⇒ Hash
Makes the requests to find how many patents are in each top level ipc class on a given date.
-
.published_patents_counts(ipc_class = nil, date = nil) ⇒ Integer
Number of patents with given parameters.
- .raw_search(query, raw = false) ⇒ RegisterSearchResult
-
.search(ipc_class = nil, date = nil) ⇒ Array
Search method returning all unique register references on a given date, with optional ipc_class.
-
.split_by_size_limits(ipc_class, date, patent_count) ⇒ Array
A helper method which creates queries that take API limits into account.
Class Method Details
.all_queries(ipc_class = nil, date = nil) ⇒ Array
builds all queries necessary to find all patent references on a given date.
75 76 77 78 79 80 81 82 |
# File 'lib/epo_ops/register.rb', line 75 def self.all_queries(ipc_class = nil, date = nil) count = published_patents_counts(ipc_class, date) if count > Limits::MAX_QUERY_RANGE IpcClassUtil.children(ipc_class).flat_map { |ic| all_queries(ic, date) } else split_by_size_limits(ipc_class, date, count) end end |
.patent_counts_per_ipc_class(date) ⇒ Hash
Makes the requests to find how many patents are in each top level ipc class on a given date.
42 43 44 45 46 47 |
# File 'lib/epo_ops/register.rb', line 42 def self.patent_counts_per_ipc_class(date) %w( A B C D E F G H ).inject({}) do |mem, icc| mem[icc] = published_patents_counts(icc, date) mem end end |
.published_patents_counts(ipc_class = nil, date = nil) ⇒ Integer
Returns number of patents with given parameters.
52 53 54 55 56 |
# File 'lib/epo_ops/register.rb', line 52 def self.published_patents_counts(ipc_class = nil, date = nil) query = SearchQueryBuilder.build(ipc_class, date, 1, 2) minimum_result_set = Register.raw_search(query) minimum_result_set.count end |
.raw_search(query, raw = false) ⇒ RegisterSearchResult
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/epo_ops/register.rb', line 89 def self.raw_search(query, raw = false) data = Client.request( :get, '/3.1/rest-services/register/search?' + query ).parsed EpoOps::Factories::RegisterSearchResultFactory.build(data) rescue EpoOps::Error::NotFound raw ? nil : EpoOps::RegisterSearchResult::NullResult.new end |
.search(ipc_class = nil, date = nil) ⇒ Array
This method does more than one query; it may happen that you exceed your API limits
Search method returning all unique register references on a given date, with optional ipc_class.
63 64 65 66 67 68 69 |
# File 'lib/epo_ops/register.rb', line 63 def self.search(ipc_class = nil, date = nil) queries = all_queries(ipc_class, date) search_entries = queries.map { |query| raw_search(query) } applications = search_entries.collect(&:patents) EpoOps::RegisterSearchResult.new(applications,applications.count) end |
.split_by_size_limits(ipc_class, date, patent_count) ⇒ Array
A helper method which creates queries that take API limits into account.
29 30 31 32 33 34 35 |
# File 'lib/epo_ops/register.rb', line 29 def self.split_by_size_limits(ipc_class, date, patent_count) max_interval = Limits::MAX_QUERY_INTERVAL (1..patent_count).step(max_interval).map do |start| range_end = [start + max_interval - 1, patent_count].min EpoOps::SearchQueryBuilder.build(ipc_class, date, start, range_end) end end |