hypertrack 0.1.0 → 0.1.3
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 +4 -4
- data/lib/hypertrack.rb +3 -0
- data/lib/hypertrack/api_client.rb +9 -3
- data/lib/hypertrack/api_operations/action_api.rb +4 -0
- data/lib/hypertrack/api_operations/common/get.rb +16 -0
- data/lib/hypertrack/api_operations/common/nearby.rb +23 -0
- data/lib/hypertrack/api_operations/common/patch.rb +31 -0
- data/lib/hypertrack/api_operations/user_api.rb +4 -0
- data/lib/hypertrack/shared_resource.rb +3 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b53fdfbda4836c6e9930a69b51216a55da9f377
|
4
|
+
data.tar.gz: 8e2b3e558025a024d19151170adc0339a041a498
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18fd12c1d2367732e5c1eb47ebab4cf21df8c9af630acdb62512435e51f7264cd368725f3f4208fe4d55b0f72a11eb25ad54a00e73eb3e5639cd8308965839a3
|
7
|
+
data.tar.gz: 04f24aac4f4352c82e247071b85f2ec19ee96400d12b8843ccecbd58acd3be0256611a78a7f009b19d67d845878a214fa9fd62aac714ce711fae4d279c287d10
|
data/lib/hypertrack.rb
CHANGED
@@ -9,6 +9,9 @@ require_relative "hypertrack/errors/hypertrack_errors"
|
|
9
9
|
|
10
10
|
# API Operations
|
11
11
|
require_relative "hypertrack/api_operations/common/create"
|
12
|
+
require_relative "hypertrack/api_operations/common/patch"
|
13
|
+
require_relative "hypertrack/api_operations/common/get"
|
14
|
+
require_relative "hypertrack/api_operations/common/nearby"
|
12
15
|
require_relative "hypertrack/api_operations/common/retrieve"
|
13
16
|
require_relative "hypertrack/api_operations/common/list"
|
14
17
|
require_relative "hypertrack/api_operations/common/update"
|
@@ -6,7 +6,8 @@ module HyperTrack
|
|
6
6
|
|
7
7
|
VERB_MAP = {
|
8
8
|
:get => Net::HTTP::Get,
|
9
|
-
:post => Net::HTTP::Post
|
9
|
+
:post => Net::HTTP::Post,
|
10
|
+
:patch => Net::HTTP::Patch
|
10
11
|
}
|
11
12
|
|
12
13
|
ACCEPTED_RESPONSE_CODES = [200, 201]
|
@@ -21,6 +22,13 @@ module HyperTrack
|
|
21
22
|
end
|
22
23
|
alias_method :update, :create
|
23
24
|
|
25
|
+
def patch(api_path, data={})
|
26
|
+
api_uri = get_uri(api_path)
|
27
|
+
request_object = create_request_object(api_uri, :patch)
|
28
|
+
request_object.body = data.to_json
|
29
|
+
make_request(api_uri, request_object)
|
30
|
+
end
|
31
|
+
|
24
32
|
def fetch(api_path, query_params={})
|
25
33
|
api_path = path_with_params(api_path, query_params) if query_params.is_a?(Hash) && query_params.keys.length > 0
|
26
34
|
api_uri = get_uri(api_path)
|
@@ -28,8 +36,6 @@ module HyperTrack
|
|
28
36
|
make_request(api_uri, request_object)
|
29
37
|
end
|
30
38
|
|
31
|
-
private
|
32
|
-
|
33
39
|
def path_with_params(path, params)
|
34
40
|
encoded_params = URI.encode_www_form(params)
|
35
41
|
[path, encoded_params].join("?")
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module HyperTrack
|
2
|
+
module ApiOperations
|
3
|
+
module Common
|
4
|
+
module Get
|
5
|
+
|
6
|
+
def get(path, params, required_params=[])
|
7
|
+
if HyperTrack::ParamsValidator.valid_args?(params, required_params, self.class::VALID_ATTRIBUTE_VALUES)
|
8
|
+
api_path = "#{self.class::API_BASE_PATH}#{self.id}/" + path
|
9
|
+
result = HyperTrack::ApiClient.fetch(api_path, params)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module HyperTrack
|
2
|
+
module ApiOperations
|
3
|
+
module Common
|
4
|
+
module Nearby
|
5
|
+
|
6
|
+
def nearby(params, required_params=[:action_id])
|
7
|
+
if HyperTrack::ParamsValidator.valid_args?(params, required_params, get_class_name::VALID_ATTRIBUTE_VALUES)
|
8
|
+
api_path = "#{get_class_name::API_BASE_PATH}" + "nearby/"
|
9
|
+
response = HyperTrack::ApiClient.fetch(api_path, params)
|
10
|
+
result = []
|
11
|
+
|
12
|
+
response["results"].each do |user|
|
13
|
+
result.push(get_class_name.new(user['id'], user))
|
14
|
+
end
|
15
|
+
|
16
|
+
result
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module HyperTrack
|
2
|
+
module ApiOperations
|
3
|
+
module Common
|
4
|
+
module Patch
|
5
|
+
|
6
|
+
def patch(params={})
|
7
|
+
api_path = "#{self.class::API_BASE_PATH}#{self.id}/"
|
8
|
+
result = HyperTrack::ApiClient.patch(api_path, params)
|
9
|
+
update_attributes_in_object(result)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def update_attributes_in_object(result)
|
15
|
+
result = Util.symbolize_keys(result)
|
16
|
+
|
17
|
+
self_keys = self.keys
|
18
|
+
|
19
|
+
result.each do |key, value|
|
20
|
+
if self_keys.include?(key) && self[key] != value
|
21
|
+
self[key] = value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -3,6 +3,9 @@ module HyperTrack
|
|
3
3
|
extend HyperTrack::ApiOperations::Common::Create
|
4
4
|
extend HyperTrack::ApiOperations::Common::Retrieve
|
5
5
|
extend HyperTrack::ApiOperations::Common::List
|
6
|
+
extend HyperTrack::ApiOperations::Common::Nearby
|
7
|
+
include HyperTrack::ApiOperations::Common::Patch
|
8
|
+
include HyperTrack::ApiOperations::Common::Get
|
6
9
|
include HyperTrack::ApiOperations::Common::Update
|
7
10
|
|
8
11
|
VALID_VEHICLE_TYPES = [:walking, :bicycle, :motorcycle, :car, :'3-wheeler', :van] #[:flight, :train, :ship]
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hypertrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Utsav Kesharwani
|
8
|
+
- Amit Rathi
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2017-
|
12
|
+
date: 2017-06-26 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: json
|
@@ -26,7 +27,7 @@ dependencies:
|
|
26
27
|
version: '1.8'
|
27
28
|
description: Ruby wrapper around HyperTrack's API. Refer http://docs.hypertrack.com/
|
28
29
|
for more information.
|
29
|
-
email: utsav.kesharwani@gmail.com
|
30
|
+
email: utsav.kesharwani@gmail.com, amit@hypertrack.io
|
30
31
|
executables: []
|
31
32
|
extensions: []
|
32
33
|
extra_rdoc_files: []
|
@@ -35,7 +36,10 @@ files:
|
|
35
36
|
- lib/hypertrack/api_client.rb
|
36
37
|
- lib/hypertrack/api_operations/action_api.rb
|
37
38
|
- lib/hypertrack/api_operations/common/create.rb
|
39
|
+
- lib/hypertrack/api_operations/common/get.rb
|
38
40
|
- lib/hypertrack/api_operations/common/list.rb
|
41
|
+
- lib/hypertrack/api_operations/common/nearby.rb
|
42
|
+
- lib/hypertrack/api_operations/common/patch.rb
|
39
43
|
- lib/hypertrack/api_operations/common/retrieve.rb
|
40
44
|
- lib/hypertrack/api_operations/common/update.rb
|
41
45
|
- lib/hypertrack/api_operations/user_api.rb
|