coordsafe_api 0.1.0 → 0.1.1
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 +8 -8
- data/README.md +30 -0
- data/lib/coordsafe_api/configuration.rb +3 -3
- data/lib/coordsafe_api/version.rb +1 -1
- data/spec/coordsafe_api/locator_spec.rb +8 -6
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWM0ZDIyZTk4MWU4YzIwZTJkMzVjMDY5NmNjNGEzZWRkYzM4ODQwMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDZhZTI3MTA2ZWM0NjY5ZTY5YzUxZDYwY2I5ZDRmZDkzY2FkNGM4Yg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGFkYWM3MWFiOTQ0YTdkZGNjMTRjN2VmMWM2ODE4OTZlN2RhMmI5ZjMxNzRk
|
10
|
+
Njg5ZWJjN2FhNWQ0NzVhMjQ5MWQ2MTYwNWY5OWZmNDkwOWQ4MTliY2FhNjU0
|
11
|
+
ZDdkMTZjMjlmNDBmMDk4ZTczMzU5ODRhNDMyN2MwZWI4M2UxYTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTA1YjBjNGUzMGU4MzZmOGQ2NTBjNzc0NzRlYzVkMzFjYTZhNzIzM2MxNGQw
|
14
|
+
NmM2MjZkODcyMDM2M2EwZDBlMDdmODJiZTlmZTliY2ZmYjMzZTQxY2EyNTU0
|
15
|
+
YmUwMDNmODkwMDBjNzhhYjRjNmU0OTNjMDljOGQzODFhMTU1MDA=
|
data/README.md
CHANGED
@@ -5,3 +5,33 @@ Coordsafe Api
|
|
5
5
|
[](https://coveralls.io/r/EdeyaLabs/coordsafe_api?branch=master)
|
6
6
|
|
7
7
|
Ruby wrapper for the Coordsafe locator API
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
|
12
|
+
Add to your Gemfile `gem 'coordsafe_api'`
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
|
17
|
+
Initialize your request. It takes `company_name` and `key` as parameters.
|
18
|
+
|
19
|
+
@api = CoordsafeApi::Locator.new({:company_name => "EdeyaLabs", :secret => "test-1234qwer"})
|
20
|
+
|
21
|
+
Use `locate` to get a list of all locators
|
22
|
+
|
23
|
+
request = @api.locate
|
24
|
+
results = request.body #=> Returns an Array of Hashes
|
25
|
+
|
26
|
+
Use `locate_history` with the `locator_id` and `date_from` to get the path of the locator at that particular date.
|
27
|
+
|
28
|
+
date_from = DateTime.parse("2013-01-27 9:30")
|
29
|
+
request = @api.locate_history(18, date_from)
|
30
|
+
results = request.body #=> Returns an Array of Hashes
|
31
|
+
|
32
|
+
Use `locate_history` with the `locator_id`, `date_from` and `date_to` to get the path of a locator within the dates.
|
33
|
+
|
34
|
+
date_from = DateTime.parse("2013-01-27 9:30")
|
35
|
+
date_to = DateTime.parse("2013-01-27 10:00")
|
36
|
+
request = @api.locate_history(18, date_from, date_to)
|
37
|
+
results = request.body #=> Returns a Hash
|
@@ -4,9 +4,9 @@ module CoordsafeApi
|
|
4
4
|
VALID_OPTIONS_KEYS = [:secret, :company_name, :format].freeze
|
5
5
|
VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
|
6
6
|
|
7
|
-
DEFAULT_LOCATOR_ENDPOINT = "http://www.coordsafe.com.sg/
|
8
|
-
DEFAULT_HISTORY_ENDPOINT = "http://www.coordsafe.com.sg/
|
9
|
-
DEFAULT_SINGLE_HISTORY_ENDPOINT = "http://www.coordsafe.com.sg/
|
7
|
+
DEFAULT_LOCATOR_ENDPOINT = "http://www.coordsafe.com.sg/geoready/api/locator/company"
|
8
|
+
DEFAULT_HISTORY_ENDPOINT = "http://www.coordsafe.com.sg/geoready/api/history"
|
9
|
+
DEFAULT_SINGLE_HISTORY_ENDPOINT = "http://www.coordsafe.com.sg/geoready/api/location"
|
10
10
|
DEFAULT_METHOD = :get
|
11
11
|
DEFAULT_USER_AGENT = "CoordsafeApi Ruby Gem #{CoordsafeApi::VERSION}".freeze
|
12
12
|
|
@@ -3,7 +3,8 @@ require 'spec_helper'
|
|
3
3
|
describe CoordsafeApi::Locator do
|
4
4
|
context "on utilizing the API" do
|
5
5
|
before(:each) do
|
6
|
-
@api = CoordsafeApi::Locator.new({:company_name => "
|
6
|
+
@api = CoordsafeApi::Locator.new({:company_name => "2", :secret => "test-1234qwer"})
|
7
|
+
<<-DOC
|
7
8
|
stub_request(:get, "http://www.coordsafe.com.sg/CoordSafePortalApp/locators/lc/company/Sypher%20Labs%20Pte.%20Ltd.?key=").to_return(
|
8
9
|
:body => '[ {"location":null,"imeiCode":"353301057336682","gpsLocation":{"time":0,"accuracy":0.0,"altitude":0.0,"bearing":0.0,
|
9
10
|
"distance":0.0,"hasAccuracy":false,"hasAltitude":false,"hasBearing":false,"hasSpeed":false,"initialBearing":0.0,"latitude":1.5296516666666666,
|
@@ -20,6 +21,7 @@ describe CoordsafeApi::Locator do
|
|
20
21
|
:body => ' {"id":209869,"accuracy":0.0,"altitude":0.0,"bearing":178.89999389648438,"distance":0.0,"speed":37.900001525878906,
|
21
22
|
"lat":1.3253249999999999,"lng":103.76431833333332,"location_time":1359250196802,"locator_id":18}',
|
22
23
|
:content_type => 'application/json')
|
24
|
+
DOC
|
23
25
|
end
|
24
26
|
|
25
27
|
it "should respond with the CoordsafeApi::Response object on #locate" do
|
@@ -49,10 +51,7 @@ describe CoordsafeApi::Locator do
|
|
49
51
|
it "should respond with JSON on #locate_history with date_from" do
|
50
52
|
request = @api.locate_history(18, DateTime.parse("2013-01-27 09:30"))
|
51
53
|
results = request.body
|
52
|
-
results.class.should eq(
|
53
|
-
results.each do |r|
|
54
|
-
r.class.should eq(Hash)
|
55
|
-
end
|
54
|
+
results.class.should eq(Hash)
|
56
55
|
end
|
57
56
|
|
58
57
|
it "should return true for success" do
|
@@ -68,7 +67,10 @@ describe CoordsafeApi::Locator do
|
|
68
67
|
it "should respond with JSON on #locate_history with date_from and date_to" do
|
69
68
|
request = @api.locate_history(18, DateTime.parse("2013-01-27 09:00"), DateTime.parse("2013-01-27 10:00"))
|
70
69
|
results = request.body
|
71
|
-
results.class.should eq(
|
70
|
+
results.class.should eq(Array)
|
71
|
+
results.each do |r|
|
72
|
+
r.class.should eq(Hash)
|
73
|
+
end
|
72
74
|
end
|
73
75
|
|
74
76
|
it "should return true for success" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coordsafe_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Paca
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|