dealervault_api 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +22 -6
- data/lib/dealervault_api/api/delivery.rb +70 -3
- data/lib/dealervault_api/api_client.rb +5 -2
- data/lib/dealervault_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cba4e6b9ec3bfd80ed8bcbb5d3eeafc28d74a75e1f9cc75b7830e800becd69a
|
4
|
+
data.tar.gz: 8a461038e8d272a00885cecd021d7ee26d69a58ee172dbf3aa80f6eebecd3703
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bfc175dee99d296973a043266e1958ebfe3bb1b0463c9ed368e5362b4af832c9ea37fa2ad69564ccab79ab9e8115f2ef1cb47338320b1b19fcc779420d87edd
|
7
|
+
data.tar.gz: 9400ad920880c1efe5cf148398452dd5d395b113ba794dce7aa84b39ab9e1ef7b28d8fae99a32adb262660c3f276f9bdeac06dbc180cb4d58ef3e6ee70832536
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,21 +12,37 @@ gem 'dealervault_api'
|
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
15
|
-
|
15
|
+
```shell
|
16
|
+
$ bundle install
|
17
|
+
```
|
16
18
|
|
17
19
|
Or install it yourself as:
|
18
20
|
|
19
|
-
|
21
|
+
```shell
|
22
|
+
$ gem install dealervault_api
|
23
|
+
```
|
20
24
|
|
21
25
|
## Usage
|
22
26
|
|
23
27
|
Initialize client
|
24
28
|
|
25
|
-
|
29
|
+
```ruby
|
30
|
+
client = DealervaultApi::Client.new('USER_EMAIL_HERE', 'API_KEY_HERE') # the token will be retrieved
|
31
|
+
```
|
32
|
+
|
33
|
+
Create a delivery request and retrieve id
|
34
|
+
```ruby
|
35
|
+
data = @client.delivery.create('PROGRAM_ID_DVV12345', 'ROOFTOP_ID_DVD12345', 'FILE_TYPE', 'TYPE')
|
36
|
+
data['requestId']
|
37
|
+
```
|
38
|
+
|
39
|
+
Check the data set
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
data = @client.delivery.data_set('REQUEST_ID', 500)
|
43
|
+
```
|
44
|
+
|
26
45
|
|
27
|
-
GET JWT TOKEN
|
28
|
-
|
29
|
-
response = client.delivery.get_jwt_token
|
30
46
|
|
31
47
|
## Development
|
32
48
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -2,14 +2,81 @@ module DealervaultApi
|
|
2
2
|
class Delivery
|
3
3
|
attr_accessor :api_client
|
4
4
|
|
5
|
+
VALID_PARAMETERS = {
|
6
|
+
feeds: [:fileTypeCode, :compareDate],
|
7
|
+
create: [:type, :historicalMonths, :catchupStartDate, :catchupEndDate]
|
8
|
+
}
|
9
|
+
|
10
|
+
VALID_VALUES = {
|
11
|
+
feeds: {
|
12
|
+
fileTypeCode: %w[SL]
|
13
|
+
},
|
14
|
+
create: {
|
15
|
+
type: %w[Sample Daily Historical Catchup],
|
16
|
+
historicalMonths: true,
|
17
|
+
catchupStartDate: true,
|
18
|
+
catchupEndDate: true
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
5
22
|
def initialize(api_client)
|
6
23
|
@api_client = api_client
|
24
|
+
@jwt = self.jwt_token
|
7
25
|
end
|
8
26
|
|
9
|
-
#
|
10
|
-
def
|
27
|
+
# GET - Acquires a JWT token for authentication. Token will be valid for 30 minutes.
|
28
|
+
def jwt_token
|
11
29
|
local_var_path = 'token'
|
12
|
-
@api_client.call_api(:GET, local_var_path)
|
30
|
+
body = @api_client.call_api(:GET, local_var_path)
|
31
|
+
body['token']
|
32
|
+
end
|
33
|
+
|
34
|
+
# GET - Gets information about a delivery.
|
35
|
+
def information(request_id)
|
36
|
+
local_var_path = "delivery/#{request_id}"
|
37
|
+
@api_client.call_api(:GET, local_var_path, headers: {'X-Jwt-Token' => @jwt})
|
38
|
+
end
|
39
|
+
|
40
|
+
# GET - Retrieve feeds which DealerVault received updated data since the provided compare date.
|
41
|
+
def feeds(program_id, compare_date, file_type_code='SL',params={} )
|
42
|
+
local_var_path = "vendor/#{program_id}/feeds/updated-data"
|
43
|
+
if compare_date.class == DateTime
|
44
|
+
compare_date = compare_date.to_time
|
45
|
+
end
|
46
|
+
|
47
|
+
params.merge!({fileTypeCode: file_type_code, compareDate: compare_date.utc.strftime("%FT%T%:z")})
|
48
|
+
params = whitelist_params(params, VALID_PARAMETERS, :feeds)
|
49
|
+
@api_client.call_api(:GET, local_var_path, headers: {'X-Jwt-Token' => @jwt}, query_params: params)
|
50
|
+
end
|
51
|
+
|
52
|
+
# GET - Retrieves a paged data set.
|
53
|
+
def data_set(request_id, page_size, params={})
|
54
|
+
local_var_path = "delivery"
|
55
|
+
params.merge!({requestId: request_id, pageSize: page_size})
|
56
|
+
@api_client.call_api(:GET, local_var_path, headers: {'X-Jwt-Token' => @jwt}, query_params: params)
|
57
|
+
end
|
58
|
+
|
59
|
+
# POST - Initiate a dealer delivery
|
60
|
+
def create(program_id, rooftop_id, file_type, delivery_type, options={})
|
61
|
+
local_var_path = "delivery"
|
62
|
+
options.merge!({type: delivery_type})
|
63
|
+
options = whitelist_params(options, VALID_PARAMETERS, :create)
|
64
|
+
|
65
|
+
body = {
|
66
|
+
programId: program_id,
|
67
|
+
rooftopId: rooftop_id,
|
68
|
+
fileType: file_type,
|
69
|
+
options: options
|
70
|
+
}
|
71
|
+
|
72
|
+
body = @api_client.call_api(:POST, local_var_path, headers: {'X-Jwt-Token' => @jwt}, body: body)
|
73
|
+
body
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
def whitelist_params(params, valid_params, key)
|
79
|
+
params.slice(*valid_params[key])
|
13
80
|
end
|
14
81
|
end
|
15
82
|
end
|
@@ -17,7 +17,10 @@ module DealervaultApi
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def call_api(http_method, path, opts = {})
|
20
|
-
headers = {'Content-Type' => "application/json", '
|
20
|
+
headers = {'X-User' => @user, 'Content-Type' => "application/json", 'Ocp-Apim-Subscription-Key': @subscription_key}
|
21
|
+
if opts[:headers]
|
22
|
+
headers.merge!(opts[:headers])
|
23
|
+
end
|
21
24
|
|
22
25
|
conn = Faraday.new(
|
23
26
|
url: @host,
|
@@ -29,7 +32,7 @@ module DealervaultApi
|
|
29
32
|
res = nil
|
30
33
|
case http_method.to_sym.downcase
|
31
34
|
when :post, :put, :patch, :delete
|
32
|
-
res = conn.run_request(http_method.to_sym.downcase, path, opts[:body], nil)
|
35
|
+
res = conn.run_request(http_method.to_sym.downcase, path, opts[:body].to_json, nil)
|
33
36
|
when :get
|
34
37
|
res = conn.run_request(:get, path, nil, nil)
|
35
38
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dealervault_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- marcus.salinas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|