ballparc 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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +54 -10
- data/lib/ballparc/version.rb +1 -1
- data/lib/ballparc.rb +17 -15
- 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: 2ea22c1b29ab377f2d5147282a85a2862fb0ab9736322c038f3e697994c7fd02
|
4
|
+
data.tar.gz: 6507cb0005195e4ea567ba27ab217da7d7116777eb0cea8eb5d205d1c9acc78e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2c72e5e329d8145a499ee5b067943cf1d7ecf431c257a71a98e7a36a9a8a2937a7ccba49ed62a714f7607ef62c28af1e6ec07002b0285e9f94ea4b9fb08e6f0
|
7
|
+
data.tar.gz: a0d71fcf725bc974dc49b29ac7678d234b7480ce8d84233208e7de7a0590e3bef2f4033906d8c9bd0421aaf74c638a89fd90e69416bb2f568189e8070e3a4fa1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
# Ballparc
|
2
|
+
This gem is for implementing the ballparc API for managing vehicle in ballparc Parking Management System. We used the ballparc API in this gem to create, update and deactivate vehicles also we can view violation using this gem. For now this gem can only create, deactivate and can view violation event using this gem methods.
|
2
3
|
|
3
|
-
|
4
|
+
## Installation
|
5
|
+
For adding this gem in application you can add gem name in gemfile and run the bundle command.
|
6
|
+
In gemfile add this line:
|
4
7
|
|
5
|
-
|
8
|
+
gem ballparc
|
6
9
|
|
7
|
-
|
10
|
+
In console run this command after adding gem in gemfile:
|
8
11
|
|
9
|
-
|
12
|
+
bundle
|
13
|
+
|
14
|
+
Also you can install the gem and add to the application's Gemfile by executing:
|
10
15
|
|
11
16
|
$ bundle add ballparc
|
12
17
|
|
@@ -16,18 +21,57 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
21
|
|
17
22
|
## Usage
|
18
23
|
|
19
|
-
|
24
|
+
For creating parking_session in ballparc use this method:
|
25
|
+
|
26
|
+
Ballparc.create_parking_session(endpoint, integration, body_data)
|
27
|
+
|
28
|
+
For deactivating parking_session in ballparc use this method:
|
29
|
+
|
30
|
+
Ballparc.deactivate_parking_session(endpoint, integration, paid_vehicle_id)
|
31
|
+
|
32
|
+
To view violation in ballparc use this method:
|
33
|
+
|
34
|
+
Ballparc.view_violation(endpoint, integration, data)
|
35
|
+
|
36
|
+
In above methods we pass 3 arguments:
|
37
|
+
a). Endpoint is a ballparc API that we need to use, for testing we can use prefix mock server domain
|
38
|
+
|
39
|
+
https://private-anon-71ed75e81f-ballparcv2.apiary-mock.com/
|
40
|
+
|
41
|
+
Example for creating paid vehicle use this mock server endpoint:
|
42
|
+
|
43
|
+
https://private-anon-71ed75e81f-ballparcv2.apiary-mock.com/enforcement/paid_vehicles
|
44
|
+
|
45
|
+
For production you can replace mock server domain with the production domain.
|
46
|
+
Example:
|
47
|
+
|
48
|
+
production_domain/enforcement/paid_vehicles
|
20
49
|
|
21
|
-
|
50
|
+
b). Integration is a row of table that must contain a column with 'header' name, and header must contain these key and value:
|
22
51
|
|
23
|
-
|
52
|
+
header:
|
53
|
+
{ "accept"=>"application/x.ballparc.v2+json",
|
54
|
+
"x-api-key"=>"Your ballparc API key",
|
55
|
+
"content_type"=>"application/json",
|
56
|
+
"x-api-secret"=>"Your ballparc API secret key" }
|
24
57
|
|
25
|
-
|
58
|
+
Note: You can send these headers in a variable, but make sure key must be same as above so you don't require a table.
|
26
59
|
|
27
|
-
|
60
|
+
c). Data is data required by the ballparc API.
|
61
|
+
Example:
|
28
62
|
|
29
|
-
|
63
|
+
{
|
64
|
+
'location_id': "Ballparc Location ID",
|
65
|
+
'source': "Your Company API",
|
66
|
+
'start_time': "2019-02-02 14:39:20",
|
67
|
+
'end_time': "2019-02-03 14:39:20",
|
68
|
+
'space_number': Space number,
|
69
|
+
'plate_number': "123XYZ",
|
70
|
+
'plate_state': "TN",
|
71
|
+
'external_key': "A101"
|
72
|
+
}
|
30
73
|
|
74
|
+
For more information please see the Ballparc documentation [here](https://developer.ballparc.com/)
|
31
75
|
## License
|
32
76
|
|
33
77
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/ballparc/version.rb
CHANGED
data/lib/ballparc.rb
CHANGED
@@ -16,11 +16,9 @@ module Ballparc
|
|
16
16
|
url = URI(endpoint)
|
17
17
|
http = Net::HTTP.new(url.host, url.port)
|
18
18
|
http.use_ssl = true
|
19
|
-
req = Net::HTTP::Post.new(url)
|
20
|
-
integration
|
21
|
-
|
22
|
-
end
|
23
|
-
response = http.request(req)
|
19
|
+
@req = Net::HTTP::Post.new(url)
|
20
|
+
add_headers(integration)
|
21
|
+
response = http.request(@req)
|
24
22
|
|
25
23
|
result = JSON.parse(response.body)
|
26
24
|
if response.code == '200' && result['data'].present?
|
@@ -36,11 +34,10 @@ module Ballparc
|
|
36
34
|
url = URI("#{endpoint}?start_date=#{data[:start_date]}&end_date=#{data[:end_date]}&plate_number=#{data[:plate_number]}")
|
37
35
|
http = Net::HTTP.new(url.host, url.port)
|
38
36
|
http.use_ssl = true
|
39
|
-
req = Net::HTTP::Get.new(url)
|
40
|
-
integration
|
41
|
-
|
42
|
-
|
43
|
-
response = http.request(req)
|
37
|
+
@req = Net::HTTP::Get.new(url)
|
38
|
+
add_headers(integration)
|
39
|
+
response = http.request(@req)
|
40
|
+
|
44
41
|
result = JSON.parse(response.body)
|
45
42
|
if response.code == '200' && result['data'].present?
|
46
43
|
{ message: 'Violation found.', ballparc_result: result, status: :ok }
|
@@ -55,11 +52,10 @@ module Ballparc
|
|
55
52
|
url = URI("#{endpoint}/#{paid_vehicle_id}")
|
56
53
|
http = Net::HTTP.new(url.host, url.port)
|
57
54
|
http.use_ssl = true
|
58
|
-
req = Net::HTTP::Delete.new(url)
|
59
|
-
integration
|
60
|
-
|
61
|
-
|
62
|
-
response = http.request(req)
|
55
|
+
@req = Net::HTTP::Delete.new(url)
|
56
|
+
add_headers(integration)
|
57
|
+
response = http.request(@req)
|
58
|
+
|
63
59
|
if response.code == '204'
|
64
60
|
{ message: 'Successfully deactivated paid vehicle', result_code: response.code.to_i, status: :ok }
|
65
61
|
else
|
@@ -68,4 +64,10 @@ module Ballparc
|
|
68
64
|
rescue StandardError => e
|
69
65
|
{ message: e.message, status: :internal_server_error }
|
70
66
|
end
|
67
|
+
|
68
|
+
def self.add_headers(integration)
|
69
|
+
integration.header.each do |key, value|
|
70
|
+
@req[key] = value
|
71
|
+
end
|
72
|
+
end
|
71
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ballparc
|
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
|
- Plecco
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Will be used for the Ballparc API integration.
|
14
14
|
email:
|