ballparc 0.1.1 → 0.1.2
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 +30 -32
- data/lib/ballparc/version.rb +1 -1
- data/lib/ballparc.rb +27 -16
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf504281ce08b9faef0a59d1fddde69597a969746ec1e1f02b216e5c7a187eb6
|
4
|
+
data.tar.gz: ff5c93be2ea132f5c7cf5b665818b3d9e148439d08ad7fccdd1ad664c5cb6ba8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88af63c04e10bf963acf567febdc29f53fe4d4e033fd3b7d47a383f4e542e345cddeacb7d7e0bac735b9e8a046304edf6a76850f919add2d2a4eb681c9ea83ca
|
7
|
+
data.tar.gz: b9aa10aec6eebda09a64af6eebcf454bd70db5a80feb7b614de9e0432609d9782bc082871063d9d3975551a7723de691701a9486e2234d6cd7d18ff75e2bf43b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -23,55 +23,53 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
23
23
|
|
24
24
|
For creating parking_session in ballparc use this method:
|
25
25
|
|
26
|
-
Ballparc.create_parking_session(
|
26
|
+
Ballparc.create_parking_session(body_data, debug = true)
|
27
27
|
|
28
28
|
For deactivating parking_session in ballparc use this method:
|
29
29
|
|
30
|
-
Ballparc.deactivate_parking_session(
|
30
|
+
Ballparc.deactivate_parking_session(paid_vehicle_id, debug = true)
|
31
31
|
|
32
32
|
To view violation in ballparc use this method:
|
33
33
|
|
34
|
-
Ballparc.view_violation(
|
35
|
-
|
36
|
-
In above methods we pass
|
37
|
-
a).
|
34
|
+
Ballparc.view_violation(body_data, debug = true)
|
35
|
+
|
36
|
+
In above methods we pass 2 arguments:
|
37
|
+
a). Data is fields required by the ballparc API.
|
38
|
+
Example 1: For create parking session.
|
39
|
+
|
40
|
+
data:
|
41
|
+
{ 'location_id': "Ballparc Location ID",
|
42
|
+
'source': "Your Company API",
|
43
|
+
'start_time': "2019-02-02 14:39:20",
|
44
|
+
'end_time': "2019-02-03 14:39:20",
|
45
|
+
'space_number': Space number,
|
46
|
+
'plate_number': "123XYZ",
|
47
|
+
'plate_state': "TN",
|
48
|
+
'external_key': "A101"
|
49
|
+
}
|
38
50
|
|
39
|
-
|
51
|
+
Example 2: For view violation.
|
40
52
|
|
41
|
-
|
53
|
+
data = {start_date: '2024-01-21', end_date: '2024-01-23', plate_number: 'ABC12'}
|
42
54
|
|
43
|
-
|
55
|
+
Example 3: For deactivate parking_session, we need to pass the ballparc paid vehicle's id.
|
44
56
|
|
45
|
-
|
46
|
-
|
57
|
+
b). Debug is an optional argument and it's a boolean flag for testing purpose only.
|
58
|
+
If debug is true then it will use the Ballparc's mock server to return actual response data so we can see the response data structure.
|
47
59
|
|
48
|
-
|
60
|
+
Example: Ballparc.create_parking_session(body_data, debug = true)
|
49
61
|
|
50
|
-
|
62
|
+
If we will not pass the debug in argument then gem will use the Ballparc's production server.
|
51
63
|
|
52
|
-
|
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" }
|
64
|
+
Example: Ballparc.create_parking_session(body_data)
|
57
65
|
|
58
|
-
|
66
|
+
For making this gem work we need to add two environment variables in our application with these names:
|
59
67
|
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
}
|
68
|
+
BALLPARC_KEY=abcxyz
|
69
|
+
BALLPARC_SECRET=abcxyz
|
73
70
|
|
74
71
|
For more information please see the Ballparc documentation [here](https://developer.ballparc.com/)
|
72
|
+
|
75
73
|
## License
|
76
74
|
|
77
75
|
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
@@ -6,18 +6,22 @@ require 'json'
|
|
6
6
|
require 'uri'
|
7
7
|
|
8
8
|
module Ballparc
|
9
|
-
|
10
|
-
|
9
|
+
PROD_SERVER_DOMAIN = 'https://api.ballparc.com/enforcement'
|
10
|
+
MOCK_SERVER_DOMAIN = 'https://private-anon-b4097ff57b-ballparcv2.apiary-mock.com/enforcement'
|
11
|
+
|
12
|
+
def self.create_parking_session(body_data, for_debug = false)
|
13
|
+
check_endpoint(for_debug)
|
14
|
+
@endpoint += '/paid_vehicles?'
|
11
15
|
body_data.each do |key, value|
|
12
|
-
endpoint += "#{key}=#{value}&"
|
16
|
+
@endpoint += "#{key}=#{value}&"
|
13
17
|
end
|
14
|
-
endpoint.chop!
|
18
|
+
@endpoint.chop!
|
15
19
|
|
16
|
-
url = URI(endpoint)
|
20
|
+
url = URI(@endpoint)
|
17
21
|
http = Net::HTTP.new(url.host, url.port)
|
18
22
|
http.use_ssl = true
|
19
23
|
@req = Net::HTTP::Post.new(url)
|
20
|
-
add_headers
|
24
|
+
add_headers
|
21
25
|
response = http.request(@req)
|
22
26
|
|
23
27
|
result = JSON.parse(response.body)
|
@@ -30,12 +34,13 @@ module Ballparc
|
|
30
34
|
{ message: e.message, status: :internal_server_error }
|
31
35
|
end
|
32
36
|
|
33
|
-
def self.view_violation(
|
34
|
-
|
37
|
+
def self.view_violation(data, for_debug = false)
|
38
|
+
check_endpoint(for_debug)
|
39
|
+
url = URI("#{@endpoint}/violations?start_date=#{data[:start_date]}&end_date=#{data[:end_date]}&plate_number=#{data[:plate_number]}")
|
35
40
|
http = Net::HTTP.new(url.host, url.port)
|
36
41
|
http.use_ssl = true
|
37
42
|
@req = Net::HTTP::Get.new(url)
|
38
|
-
add_headers
|
43
|
+
add_headers
|
39
44
|
response = http.request(@req)
|
40
45
|
|
41
46
|
result = JSON.parse(response.body)
|
@@ -48,12 +53,13 @@ module Ballparc
|
|
48
53
|
{ message: e.message, status: :internal_server_error }
|
49
54
|
end
|
50
55
|
|
51
|
-
def self.deactivate_parking_session(
|
52
|
-
|
56
|
+
def self.deactivate_parking_session(paid_vehicle_id, for_debug = false)
|
57
|
+
check_endpoint(for_debug)
|
58
|
+
url = URI("#{@endpoint}/paid_vehicles/#{paid_vehicle_id}")
|
53
59
|
http = Net::HTTP.new(url.host, url.port)
|
54
60
|
http.use_ssl = true
|
55
61
|
@req = Net::HTTP::Delete.new(url)
|
56
|
-
add_headers
|
62
|
+
add_headers
|
57
63
|
response = http.request(@req)
|
58
64
|
|
59
65
|
if response.code == '204'
|
@@ -65,9 +71,14 @@ module Ballparc
|
|
65
71
|
{ message: e.message, status: :internal_server_error }
|
66
72
|
end
|
67
73
|
|
68
|
-
def self.add_headers
|
69
|
-
|
70
|
-
|
71
|
-
|
74
|
+
def self.add_headers
|
75
|
+
@req['accept'] = 'application/x.ballparc.v2+json'
|
76
|
+
@req['content_type'] = 'application/json'
|
77
|
+
@req['x-api-key'] = ENV['BALLPARC_KEY']
|
78
|
+
@req['x-api-secret'] = ENV['BALLPARC_SECRET']
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.check_endpoint(for_debug)
|
82
|
+
@endpoint = for_debug ? MOCK_SERVER_DOMAIN : PROD_SERVER_DOMAIN
|
72
83
|
end
|
73
84
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- PLECCO Technologies
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Will be used for the Ballparc API integration.
|
14
14
|
email:
|
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
requirements: []
|
49
|
-
rubygems_version: 3.
|
49
|
+
rubygems_version: 3.3.7
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: Will be used for the Ballparc API integration.
|