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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40d934824d3e25fcc65341b37ebdc52f5e859f6a6b8fa43c0bb3818bc7fe7722
4
- data.tar.gz: 87c202e396dfc575a0b9642f25e2d96834d8710d30d5a1c862c88a1437b55779
3
+ metadata.gz: 2ea22c1b29ab377f2d5147282a85a2862fb0ab9736322c038f3e697994c7fd02
4
+ data.tar.gz: 6507cb0005195e4ea567ba27ab217da7d7116777eb0cea8eb5d205d1c9acc78e
5
5
  SHA512:
6
- metadata.gz: a1719ebc2baa5a26d20321bd02952fc0866f9e75baf63a25e89c4d8b389bdf9d317072a96594d270f0d8154eb12b16c7b5008bef1d67b8ae6cb0de2cc14b3947
7
- data.tar.gz: 93786fa33285cf1f30bff3c606ef03e52e5d9b4bb64c6dcacde69010fe8dbaf74ec7ca23338879039a7de2c51fddbd18d6ed12ccedfc500c2bb12a96388902a3
6
+ metadata.gz: e2c72e5e329d8145a499ee5b067943cf1d7ecf431c257a71a98e7a36a9a8a2937a7ccba49ed62a714f7607ef62c28af1e6ec07002b0285e9f94ea4b9fb08e6f0
7
+ data.tar.gz: a0d71fcf725bc974dc49b29ac7678d234b7480ce8d84233208e7de7a0590e3bef2f4033906d8c9bd0421aaf74c638a89fd90e69416bb2f568189e8070e3a4fa1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ballparc (0.1.0)
4
+ ballparc (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -39,4 +39,4 @@ DEPENDENCIES
39
39
  rubocop (~> 1.21)
40
40
 
41
41
  BUNDLED WITH
42
- 2.3.26
42
+ 2.5.5
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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ballparc`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
8
+ gem ballparc
6
9
 
7
- ## Installation
10
+ In console run this command after adding gem in gemfile:
8
11
 
9
- Install the gem and add to the application's Gemfile by executing:
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
- TODO: Write usage instructions here
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
- ## Development
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
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
- ## Contributing
60
+ c). Data is data required by the ballparc API.
61
+ Example:
28
62
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ballparc.
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).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ballparc
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
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.header.each do |key, value|
21
- req[key] = value
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.header.each do |key, value|
41
- req[key] = value
42
- end
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.header.each do |key, value|
60
- req[key] = value
61
- end
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.0
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-02 00:00:00.000000000 Z
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: