acuitydata 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc211a7f6fb29e84ed8ed05d737cfdd418e20d3c3894281205712aefe017e59f
4
- data.tar.gz: a3f0e6192ef8d500035cf8287446c76a34307d76ada594192985e98fa573c48a
3
+ metadata.gz: 83fa915b9218cc72fce45e4ed2e9c29bcc8384f2f5e02a5aba283b03dcb8561a
4
+ data.tar.gz: beeda1ee638c6dd78de6c941c2017e861935708e6459c59dca95177451931f69
5
5
  SHA512:
6
- metadata.gz: 59043be3a18863175ba13d518cf3ab38a2b7754e4354a4327a86a87272171c78369d8c18d6e1280e37f62086dbfcaf357ec6f7a9d972275ff7a6dce380b2c5e0
7
- data.tar.gz: 5c3d7594c51910668fc564f1cf93ebc5343feec70b55bc507ccf9620f2c7f85d794650bcc9ccf8ed425bec0bf37838ec198d5e48536f7de4fff77c8125cc178c
6
+ metadata.gz: 209c38dedca45a28d4ebae02b343038c59214cb27f4bd93359dc43d2a02bb3ce3a5e6d7053552193e387c5bc6ca8b9eee89a19d74c6fb37b811f12a93c13ecb8
7
+ data.tar.gz: 97dfe79e1384ea0c2771f5f891745f8632be0dfe3ffe7023816500d31a127919c323735faf61cdfa086a627844ed987d5d72b3d70b4b9d303c627b1605a8a135
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behaviour that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behaviour by participants include:
24
+
25
+ * The use of sexualised language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behaviour and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behaviour.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviours that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behaviour may be
58
+ reported by contacting the project team at contact@jasonchalom.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/TRex22/acuitydata" }
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,142 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ acuitydata (0.0.2)
5
+ active_attr (~> 0.16.0)
6
+ httparty (~> 0.21.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actionpack (7.1.3.2)
12
+ actionview (= 7.1.3.2)
13
+ activesupport (= 7.1.3.2)
14
+ nokogiri (>= 1.8.5)
15
+ racc
16
+ rack (>= 2.2.4)
17
+ rack-session (>= 1.0.1)
18
+ rack-test (>= 0.6.3)
19
+ rails-dom-testing (~> 2.2)
20
+ rails-html-sanitizer (~> 1.6)
21
+ actionview (7.1.3.2)
22
+ activesupport (= 7.1.3.2)
23
+ builder (~> 3.1)
24
+ erubi (~> 1.11)
25
+ rails-dom-testing (~> 2.2)
26
+ rails-html-sanitizer (~> 1.6)
27
+ active_attr (0.16.0)
28
+ actionpack (>= 3.0.2, < 7.2)
29
+ activemodel (>= 3.0.2, < 7.2)
30
+ activesupport (>= 3.0.2, < 7.2)
31
+ activemodel (7.1.3.2)
32
+ activesupport (= 7.1.3.2)
33
+ activesupport (7.1.3.2)
34
+ base64
35
+ bigdecimal
36
+ concurrent-ruby (~> 1.0, >= 1.0.2)
37
+ connection_pool (>= 2.2.5)
38
+ drb
39
+ i18n (>= 1.6, < 2)
40
+ minitest (>= 5.1)
41
+ mutex_m
42
+ tzinfo (~> 2.0)
43
+ addressable (2.8.6)
44
+ public_suffix (>= 2.0.2, < 6.0)
45
+ ansi (1.5.0)
46
+ base64 (0.2.0)
47
+ bigdecimal (3.1.7)
48
+ builder (3.2.4)
49
+ coderay (1.1.3)
50
+ concurrent-ruby (1.2.3)
51
+ connection_pool (2.4.1)
52
+ crack (1.0.0)
53
+ bigdecimal
54
+ rexml
55
+ crass (1.0.6)
56
+ drb (2.2.1)
57
+ erubi (1.12.0)
58
+ hashdiff (1.1.0)
59
+ httparty (0.21.0)
60
+ mini_mime (>= 1.0.0)
61
+ multi_xml (>= 0.5.2)
62
+ i18n (1.14.4)
63
+ concurrent-ruby (~> 1.0)
64
+ loofah (2.22.0)
65
+ crass (~> 1.0.2)
66
+ nokogiri (>= 1.12.0)
67
+ method_source (1.0.0)
68
+ mini_mime (1.1.5)
69
+ minitest (5.22.3)
70
+ minitest-focus (1.4.0)
71
+ minitest (>= 4, < 6)
72
+ minitest-reporters (1.6.1)
73
+ ansi
74
+ builder
75
+ minitest (>= 5.0)
76
+ ruby-progressbar
77
+ mocha (2.1.0)
78
+ ruby2_keywords (>= 0.0.5)
79
+ multi_xml (0.6.0)
80
+ mutex_m (0.2.0)
81
+ nokogiri (1.16.3-aarch64-linux)
82
+ racc (~> 1.4)
83
+ nokogiri (1.16.3-arm-linux)
84
+ racc (~> 1.4)
85
+ nokogiri (1.16.3-arm64-darwin)
86
+ racc (~> 1.4)
87
+ nokogiri (1.16.3-x86-linux)
88
+ racc (~> 1.4)
89
+ nokogiri (1.16.3-x86_64-darwin)
90
+ racc (~> 1.4)
91
+ nokogiri (1.16.3-x86_64-linux)
92
+ racc (~> 1.4)
93
+ pry (0.14.2)
94
+ coderay (~> 1.1)
95
+ method_source (~> 1.0)
96
+ public_suffix (5.0.4)
97
+ racc (1.7.3)
98
+ rack (3.0.9.1)
99
+ rack-session (2.0.0)
100
+ rack (>= 3.0.0)
101
+ rack-test (2.1.0)
102
+ rack (>= 1.3)
103
+ rails-dom-testing (2.2.0)
104
+ activesupport (>= 5.0.0)
105
+ minitest
106
+ nokogiri (>= 1.6)
107
+ rails-html-sanitizer (1.6.0)
108
+ loofah (~> 2.21)
109
+ nokogiri (~> 1.14)
110
+ rake (13.1.0)
111
+ rexml (3.2.6)
112
+ ruby-progressbar (1.13.0)
113
+ ruby2_keywords (0.0.5)
114
+ timecop (0.9.8)
115
+ tzinfo (2.0.6)
116
+ concurrent-ruby (~> 1.0)
117
+ webmock (3.23.0)
118
+ addressable (>= 2.8.0)
119
+ crack (>= 0.3.2)
120
+ hashdiff (>= 0.4.0, < 2.0.0)
121
+
122
+ PLATFORMS
123
+ aarch64-linux
124
+ arm-linux
125
+ arm64-darwin
126
+ x86-linux
127
+ x86_64-darwin
128
+ x86_64-linux
129
+
130
+ DEPENDENCIES
131
+ acuitydata!
132
+ minitest (~> 5.22.3)
133
+ minitest-focus (~> 1.4.0)
134
+ minitest-reporters (~> 1.6.1)
135
+ mocha (~> 2.1.0)
136
+ pry (~> 0.14.2)
137
+ rake (~> 13.1.0)
138
+ timecop (~> 0.9.8)
139
+ webmock (~> 3.23.0)
140
+
141
+ BUNDLED WITH
142
+ 2.5.5
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # api.acuitydata.co.za API Client
2
+ An API client for AcuityData
3
+ This is an unofficial project and still a work in progress (WIP)
4
+
5
+ Based on this website: api.acuitydata.co.za
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'acuitydata'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install acuitydata
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require 'acuitydata'
27
+ client = AcuityData::Client.new
28
+
29
+
30
+ ```
31
+
32
+ ### Endpoints
33
+ -
34
+
35
+ Other endpoints have not been implemented.
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ### Tests
44
+ To run tests execute:
45
+
46
+ $ rake test
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/trex22/acuitydata. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
55
+
56
+ ## Code of Conduct
57
+
58
+ Everyone interacting in the AcuityData: project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/trex22/acuitydata/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "acuitydata/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "acuitydata"
7
+ spec.version = AcuityData::VERSION
8
+ spec.authors = ["trex22"]
9
+ spec.email = ["contact@jasonchalom.com"]
10
+
11
+ spec.summary = "A client for using api.acuitydata.co.za API in Ruby."
12
+ spec.description = "A client for using api.acuitydata.co.za API in Ruby. This is an unofficial project."
13
+ spec.homepage = "https://github.com/TRex22/acuitydata"
14
+ spec.license = "MIT"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_dependency "httparty", "~> 0.21.0"
26
+ spec.add_dependency "active_attr", "~> 0.16.0"
27
+
28
+ # Development dependancies
29
+ spec.add_development_dependency "rake", "~> 13.1.0"
30
+ spec.add_development_dependency "minitest", "~> 5.22.3"
31
+ spec.add_development_dependency "minitest-focus", "~> 1.4.0"
32
+ spec.add_development_dependency "minitest-reporters", "~> 1.6.1"
33
+ spec.add_development_dependency "timecop", "~> 0.9.8"
34
+ spec.add_development_dependency "mocha", "~> 2.1.0"
35
+ spec.add_development_dependency "pry", "~> 0.14.2"
36
+ spec.add_development_dependency "webmock", "~> 3.23.0"
37
+ end
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "acuitydata"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,137 @@
1
+ module AcuityData
2
+ class Client
3
+ include ::AcuityData::Constants
4
+
5
+ attr_reader :auth_token, :base_path, :port
6
+
7
+ def initialize(auth_token, base_path: BASE_PATH, port: BASE_PORT)
8
+ @base_path = base_path
9
+ @port = port
10
+ @auth_token = auth_token
11
+ end
12
+
13
+ def self.compatible_api_version
14
+ 'v1'
15
+ end
16
+
17
+ # This is the version of the API docs this client was built off-of
18
+ def self.api_version
19
+ 'v1 2024-03-19'
20
+ end
21
+
22
+ # Endpoints
23
+ # /lookup/make
24
+ # Retrieve make information
25
+ def make
26
+ send_request(http_method: :get, path: "lookup/make")
27
+ end
28
+
29
+ # /lookup/model/{make}
30
+ # Retrieve model information for make
31
+ def model(make, year = nil)
32
+ if year
33
+ send_request(http_method: :get, path: "lookup/model2/#{make}/#{year}")
34
+ else
35
+ send_request(http_method: :get, path: "lookup/model/#{make}")
36
+ end
37
+ end
38
+
39
+ # /lookup/year/{make}/{model}
40
+ # Retrieve year information for make and model
41
+ def year(make, model = nil)
42
+ if model
43
+ send_request(http_method: :get, path: "lookup/year/#{make}/#{model}")
44
+ else
45
+ send_request(http_method: :get, path: "lookup/year2/#{make}")
46
+ end
47
+ end
48
+
49
+ # /lookup/variant/{make}/{model}/{year}
50
+ # Retrieve variant information for make, model and year
51
+ def variant(make, model, year)
52
+ send_request(http_method: :get, path: "lookup/variant/#{make}/#{model}/#{year}")
53
+ end
54
+
55
+ # /report/{make}/{model}/{variant}/{year}/{mileage}
56
+ # Retrieve vehicle report using make, model, year, variant and mileage
57
+ def report(make, model, variant, year, mileage)
58
+ send_request(http_method: :get, path: "report/#{make}/#{model}/#{variant}/#{year}/#{mileage}")
59
+ end
60
+
61
+ private
62
+
63
+ def send_request(http_method:, path:, body: {}, params: {}, headers: {}, port: @port, port_in_path: false)
64
+ start_time = micro_second_time
65
+
66
+ response = HTTParty.send(
67
+ http_method.to_sym,
68
+ construct_base_path(path, params, port, port_in_path),
69
+ body: body,
70
+ headers: headers.merge({ 'Content-Type': 'application/json', 'Authorization': "Basic #{@auth_token}" }),
71
+ port: port,
72
+ format: :json
73
+ )
74
+
75
+ end_time = micro_second_time
76
+ construct_response_object(response, path, start_time, end_time)
77
+ end
78
+
79
+ # Quick n dirty time parsing
80
+ def parse_time(str_time)
81
+ time_components = str_time.to_s.split(' ')
82
+
83
+ # Have to leave out the timezone - #{time_components[2]}
84
+ "#{time_components[0]}T#{time_components[1]}"
85
+ end
86
+
87
+ def construct_response_object(response, path, start_time, end_time)
88
+ {
89
+ 'body' => parse_body(response, path),
90
+ 'code' => response.code,
91
+ 'cookies' => response.headers.dig('set-cookie'),
92
+ 'headers' => response.headers,
93
+ 'metadata' => construct_metadata(response, start_time, end_time)
94
+ }
95
+ end
96
+
97
+ def construct_metadata(response, start_time, end_time)
98
+ total_time = end_time - start_time
99
+
100
+ {
101
+ 'start_time' => start_time,
102
+ 'end_time' => end_time,
103
+ 'total_time' => total_time
104
+ }
105
+ end
106
+
107
+ def micro_second_time
108
+ (Time.now.to_f * 1_000_000).to_i
109
+ end
110
+
111
+ def construct_base_path(path, params, port, port_in_path)
112
+ if port_in_path
113
+ constructed_path = "#{base_path}:#{port}/#{path}"
114
+ else
115
+ constructed_path = "#{base_path}/#{path}"
116
+ end
117
+
118
+ if params == {}
119
+ constructed_path.gsub(" ", "%20")
120
+ else
121
+ "#{constructed_path}?#{process_params(params)}".gsub(" ", "%20")
122
+ end
123
+ end
124
+
125
+ def parse_body(response, path)
126
+ JSON.parse(response.body) # Purposely not using HTTParty
127
+ rescue JSON::ParserError => _e
128
+ response.body
129
+ rescue TypeError => _e
130
+ nil
131
+ end
132
+
133
+ def process_params(params)
134
+ params.keys.map { |key| "#{key}=#{params[key]}" }.join('&')
135
+ end
136
+ end
137
+ end
@@ -0,0 +1,8 @@
1
+ module AcuityData
2
+ module Constants
3
+ BASE_URI = 'api.acuitydata.co.za/api'
4
+ BASE_PATH = "https://#{BASE_URI}"
5
+
6
+ BASE_PORT = 443
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module AcuityData
2
+ VERSION = "0.0.2"
3
+ end
data/lib/acuitydata.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'httparty'
2
+
3
+ require 'acuitydata/constants'
4
+ require 'acuitydata/version'
5
+
6
+ require 'acuitydata/client'
7
+
8
+ module AcuityData
9
+ class Error < StandardError; end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acuitydata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - trex22
@@ -159,7 +159,19 @@ extensions: []
159
159
  extra_rdoc_files: []
160
160
  files:
161
161
  - ".gitignore"
162
+ - CODE_OF_CONDUCT.md
163
+ - Gemfile
164
+ - Gemfile.lock
162
165
  - LICENSE
166
+ - README.md
167
+ - Rakefile
168
+ - acuitydata.gemspec
169
+ - bin/console
170
+ - bin/setup
171
+ - lib/acuitydata.rb
172
+ - lib/acuitydata/client.rb
173
+ - lib/acuitydata/constants.rb
174
+ - lib/acuitydata/version.rb
163
175
  homepage: https://github.com/TRex22/acuitydata
164
176
  licenses:
165
177
  - MIT