mapricot-api 0.11.0 → 0.12.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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -3
  3. data/lib/mapricot/api.rb +9 -5
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3aa156c2854ba75ee6f5277d91f46bc586e5c1807b47057a253fa7b0b117a930
4
- data.tar.gz: f321e6ebdbcceb3f94ae5b51e8af98da8aa1abc4fac9d05914f7377df6feb63c
3
+ metadata.gz: 9bc321819cc79bc1fa54ad0ea299a93c1e21362e25bf79c524f26af234ec1577
4
+ data.tar.gz: c0b7c20c95f41df1e2fdc85a3079eddfee2e8f1c46b2ac9b3672f1174f5c8651
5
5
  SHA512:
6
- metadata.gz: 25afe81cbda109fc6272517af7b6bf1b3d3b29ec2a6d81eda812830834da030a3c7bbb23e7ef644f63875771b1ff907a97870c56d930a448965ab34195ef3866
7
- data.tar.gz: 73c41d224dc22f7c5c90db74814fb7cb5202110bab0f0abc3610dced8adca8334c430887a28d4a02c279359eaf7a4c617d1baef53982ea5a61b754036dd9331c
6
+ metadata.gz: 429d97f2c96011452f19181d7335324735c4c7dbd7bc0cf50745e80c1552d3599efa05c1b91be66fe30f28bb0cc4bceca3e87d8f49daeeff8b0f13d113203c35
7
+ data.tar.gz: 39fedf7b581ada641578873f6048003e39ca82ce95a606c615be5c004017fa981ae26ac14644b5ba3126802a0d9e28904debda82c77810d4ed70c9839f7e1ef7
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Mapricot for Ruby
2
2
 
3
- The official Ruby client for the [Mapricot API](https://mapricot.com/): address and place search, reverse geocoding, nearby places, routing, and IP geolocation, with 250,000 free requests every month.
3
+ The official Ruby client for the [Mapricot API](https://mapricot.com/): address and place search, reverse geocoding, nearby places, routing, and IP geolocation, with 250,000 free requests every 30 days.
4
4
 
5
5
  ```sh
6
6
  gem install mapricot-api
@@ -28,7 +28,7 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
28
28
 
29
29
  | Method | Endpoint |
30
30
  | --- | --- |
31
- | `client.geocoding.search(q, focus:, country:, limit:, lang:)` | [`GET /geocoding/v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
31
+ | `client.geocoding.search(q, address:, locality:, county:, region:, postal_code:, focus:, country:, limit:, lang:)` | [`GET /geocoding/v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
32
32
  | `client.geocoding.search_batch(queries)` | [`POST /geocoding/v1/search/batch`](https://mapricot.com/docs/geocoding/#search-a-list-of-addresses) |
33
33
  | `client.geocoding.autocomplete(q, focus:, country:, limit:, lang:)` | [`GET /geocoding/v1/autocomplete`](https://mapricot.com/docs/geocoding/#suggest-as-people-type) |
34
34
  | `client.geocoding.reverse(lat, lon, limit:, lang:)` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
@@ -48,7 +48,13 @@ route = client.routing.route([{ lat: 45.5189, lon: -122.6793 }, { lat: 45.5214,
48
48
  puts route["routes"][0]["durationSeconds"]
49
49
  ```
50
50
 
51
- `search_batch` runs up to 100 searches in one request. Each query is a Hash of `search`'s parameters, and `"responses"` answers them in the same order, each with `"results"` and `"attribution"`, or an `"error"` with the `"code"` and `"message"` that search would get, without raising. Each completed search is billed as one request; errors aren't.
51
+ When you already have an address in parts, such as a spreadsheet's columns, pass them in place of `q`. Search ignores a blank part:
52
+
53
+ ```ruby
54
+ data = client.geocoding.search(address: "10 Downing Street", locality: "London", postal_code: "SW1A 2AA", country: "GB")
55
+ ```
56
+
57
+ `search_batch` runs up to 100 searches in one request. Each query is a Hash of `search`'s parameters, with `q` or the address parts named as in the API, such as `postalCode`, and `"responses"` answers them in the same order, each with `"results"` and `"attribution"`, or an `"error"` with the `"code"` and `"message"` that search would get, without raising. Each completed search is billed as one request; errors aren't.
52
58
 
53
59
  ```ruby
54
60
  batch = client.geocoding.search_batch([{ q: "128 SW 3rd Ave, Portland", limit: 1 }, { q: "10 Downing Street, London", limit: 1 }])
data/lib/mapricot/api.rb CHANGED
@@ -7,7 +7,7 @@ require "net/http"
7
7
  # The official client for the Mapricot API: address and place search, reverse geocoding, nearby places, routing,
8
8
  # and IP geolocation. See https://mapricot.com/docs/ruby/.
9
9
  module Mapricot
10
- VERSION = "0.11.0"
10
+ VERSION = "0.12.0"
11
11
 
12
12
  # An error response from the API.
13
13
  class Error < StandardError
@@ -110,12 +110,16 @@ module Mapricot
110
110
  @query_value = query_value
111
111
  end
112
112
 
113
- # Find addresses and places matching free text. focus is {lat:, lon:}; country is an Array or a String.
114
- def search(q, focus: nil, country: nil, limit: nil, lang: nil)
115
- @get.call("/geocoding/v1/search", q: q, focus: focus, country: country, limit: limit, lang: lang)
113
+ # Find addresses and places matching free text in q, or an address given in parts in place of q, as in
114
+ # search(address: "10 Downing Street", locality: "London"). focus is {lat:, lon:}; country is an Array or a String.
115
+ def search(q = nil, address: nil, locality: nil, county: nil, region: nil, postal_code: nil, focus: nil, country: nil,
116
+ limit: nil, lang: nil)
117
+ @get.call("/geocoding/v1/search", q: q, address: address, locality: locality, county: county, region: region,
118
+ postalCode: postal_code, focus: focus, country: country, limit: limit, lang: lang)
116
119
  end
117
120
 
118
- # Run up to 100 searches in one request, each a Hash of search's parameters, as in { q: "…", limit: 1 }. Each
121
+ # Run up to 100 searches in one request, each a Hash of search's parameters, as in { q: "…", limit: 1 } or
122
+ # { address: "…", postalCode: "…" }, with the API's names. Each
119
123
  # completed search is billed as one request. "responses" answers them in order, each with "results" and
120
124
  # "attribution", or an "error" with the code and message the search would get on its own, which isn't raised.
121
125
  def search_batch(queries)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mapricot-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mapricot