core-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/publish-gem.yml +19 -0
  3. data/.gitignore +12 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +6 -0
  6. data/.travis.yml +7 -0
  7. data/CHANGELOG.md +6 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +4 -0
  10. data/Gemfile.lock +113 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +95 -0
  13. data/Rakefile +6 -0
  14. data/bin/console +14 -0
  15. data/bin/setup +8 -0
  16. data/core-client.gemspec +41 -0
  17. data/lefthook.yml +5 -0
  18. data/lib/core/client.rb +16 -0
  19. data/lib/core/client/v1/base.rb +59 -0
  20. data/lib/core/client/v1/product.rb +10 -0
  21. data/lib/core/client/v1/product_allocation.rb +10 -0
  22. data/lib/core/client/v1/product_assignment.rb +10 -0
  23. data/lib/core/client/v1/product_investment.rb +10 -0
  24. data/lib/core/client/v1/product_revenue.rb +10 -0
  25. data/lib/core/client/v1/project.rb +10 -0
  26. data/lib/core/client/v1/project_allocation.rb +10 -0
  27. data/lib/core/client/v1/project_role.rb +10 -0
  28. data/lib/core/client/v1/role.rb +10 -0
  29. data/lib/core/client/v1/user.rb +10 -0
  30. data/lib/core/client/v2/base.rb +21 -0
  31. data/lib/core/client/v2/product.rb +10 -0
  32. data/lib/core/client/v2/product_assignment.rb +13 -0
  33. data/lib/core/client/v2/product_investment.rb +13 -0
  34. data/lib/core/client/v2/product_revenue.rb +13 -0
  35. data/lib/core/client/v2/project.rb +10 -0
  36. data/lib/core/client/v2/project_allocation.rb +13 -0
  37. data/lib/core/client/v2/project_role.rb +13 -0
  38. data/lib/core/client/v2/role.rb +10 -0
  39. data/lib/core/client/v2/user.rb +10 -0
  40. data/lib/core/client/version.rb +5 -0
  41. metadata +226 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7dda13fa264b10472b7db87768d3c40d9302a50998026d0943e16797d619132a
4
+ data.tar.gz: 637e0c307bd02fea6f9faba4980dd4237f7b4e8830a16320ecdc0e36e3c69a71
5
+ SHA512:
6
+ metadata.gz: 7aec65e47b12de803433a1506c31a24d2c69c8b146e3ff1cff36b9cba592487e73e3ebc27fdfc03b6a707bbe2cc75a36c74e7c10f98c7d38d78ecda13e4f558b
7
+ data.tar.gz: 3f4b316b009de32b75f133db3505cef779301dc92d19b3076363001aaa074b2d4de761b4e2a592182e526f612b2647350b11fe1fbd083f15bf6127d45298ed4b
@@ -0,0 +1,19 @@
1
+ name: Publish to rubygems
2
+ on:
3
+ release:
4
+ types: [published]
5
+ jobs:
6
+ publish-gem:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v1
10
+ - uses: actions/setup-ruby@v1
11
+ - run: |
12
+ mkdir ~/.gem
13
+ echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
14
+ chmod 0600 ~/.gem/credentials
15
+ env:
16
+ RUBYGEMS_API_KEY: ${{secrets.rubygems_api_key}}
17
+ - run: |
18
+ gem build core-client.gemspec
19
+ gem push core-client-*.gem
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ .env
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_gem:
2
+ rubocop-able:
3
+ - config/default.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.6
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.2
7
+ before_install: gem install bundler -v 2.0.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## [0.1.0] 2020-02-19
4
+
5
+ ### Changed/Added
6
+ - Initial release
@@ -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 behavior 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 behavior by participants include:
24
+
25
+ * The use of sexualized 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
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
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 behaviors 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 behavior may be
58
+ reported by contacting the project team at hpneo@hotmail.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,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in core-client.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,113 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ core-client (0.1.0)
5
+ activesupport (= 6.0.2.1)
6
+ dotenv (~> 2.7)
7
+ json_api_client (~> 1.16)
8
+ rack (~> 2.2)
9
+ rest-client (~> 2.1)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ activemodel (6.0.2.1)
15
+ activesupport (= 6.0.2.1)
16
+ activesupport (6.0.2.1)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ zeitwerk (~> 2.2)
22
+ addressable (2.7.0)
23
+ public_suffix (>= 2.0.2, < 5.0)
24
+ ast (2.4.0)
25
+ concurrent-ruby (1.1.6)
26
+ diff-lcs (1.3)
27
+ domain_name (0.5.20190701)
28
+ unf (>= 0.0.5, < 1.0.0)
29
+ dotenv (2.7.5)
30
+ faraday (0.17.3)
31
+ multipart-post (>= 1.2, < 3)
32
+ faraday_middleware (0.14.0)
33
+ faraday (>= 0.7.4, < 1.0)
34
+ http-accept (1.7.0)
35
+ http-cookie (1.0.3)
36
+ domain_name (~> 0.5)
37
+ i18n (1.8.2)
38
+ concurrent-ruby (~> 1.0)
39
+ jaro_winkler (1.5.4)
40
+ json_api_client (1.16.1)
41
+ activemodel (>= 3.2.0)
42
+ activesupport (>= 3.2.0)
43
+ addressable (~> 2.2)
44
+ faraday (~> 0.15, >= 0.15.2)
45
+ faraday_middleware (~> 0.9)
46
+ rack (>= 0.2)
47
+ mime-types (3.3.1)
48
+ mime-types-data (~> 3.2015)
49
+ mime-types-data (3.2019.1009)
50
+ minitest (5.14.0)
51
+ multipart-post (2.1.1)
52
+ netrc (0.11.0)
53
+ parallel (1.19.1)
54
+ parser (2.7.0.2)
55
+ ast (~> 2.4.0)
56
+ public_suffix (4.0.3)
57
+ rack (2.2.2)
58
+ rainbow (3.0.0)
59
+ rake (10.5.0)
60
+ rest-client (2.1.0)
61
+ http-accept (>= 1.7.0, < 2.0)
62
+ http-cookie (>= 1.0.2, < 2.0)
63
+ mime-types (>= 1.16, < 4.0)
64
+ netrc (~> 0.8)
65
+ rspec (3.9.0)
66
+ rspec-core (~> 3.9.0)
67
+ rspec-expectations (~> 3.9.0)
68
+ rspec-mocks (~> 3.9.0)
69
+ rspec-core (3.9.1)
70
+ rspec-support (~> 3.9.1)
71
+ rspec-expectations (3.9.0)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.9.0)
74
+ rspec-mocks (3.9.1)
75
+ diff-lcs (>= 1.2.0, < 2.0)
76
+ rspec-support (~> 3.9.0)
77
+ rspec-support (3.9.2)
78
+ rubocop (0.79.0)
79
+ jaro_winkler (~> 1.5.1)
80
+ parallel (~> 1.10)
81
+ parser (>= 2.7.0.1)
82
+ rainbow (>= 2.2.2, < 4.0)
83
+ ruby-progressbar (~> 1.7)
84
+ unicode-display_width (>= 1.4.0, < 1.7)
85
+ rubocop-able (0.2.0)
86
+ rubocop (~> 0.76)
87
+ rubocop-rails (~> 2.3.0)
88
+ rubocop-rails (2.3.2)
89
+ rack (>= 1.1)
90
+ rubocop (>= 0.72.0)
91
+ ruby-progressbar (1.10.1)
92
+ thread_safe (0.3.6)
93
+ tzinfo (1.2.6)
94
+ thread_safe (~> 0.1)
95
+ unf (0.1.4)
96
+ unf_ext
97
+ unf_ext (0.0.7.6)
98
+ unicode-display_width (1.6.1)
99
+ zeitwerk (2.2.2)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ bundler (~> 2.0)
106
+ core-client!
107
+ rake (~> 10.0)
108
+ rspec (~> 3.0)
109
+ rubocop (~> 0.76)
110
+ rubocop-able (~> 0.2.0)
111
+
112
+ BUNDLED WITH
113
+ 2.0.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 hpneo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Core::Client
2
+
3
+ `Core::Client` is a Ruby gem for the [Core](https://core.able.co) API.
4
+
5
+ It includes read-only access for both API versions (v1 and v2) of the following resources:
6
+
7
+ - Product
8
+ - Project
9
+ - Role
10
+ - Project Role
11
+ - User
12
+ - Product Allocation
13
+ - Product Assignment
14
+ - Project Allocation
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'core-client'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install core-client
31
+
32
+ ## Usage
33
+
34
+ To use the Core API you need a token, which can be request via Slack in the `#core` channel. This token needs to be set in an ENV variable called `CORE_API_TOKEN`. `Core::Client` will automatically use that ENV variable to sign all the requests sent through the gem.
35
+
36
+ Both versions (v1 and v2) share similar methods to access the resources:
37
+ - `.all` returns an array of resources
38
+ - `.first` returns the first element of `.all`
39
+ - `.last` returns the last element of `.all`
40
+ - `.count` returns the size of `.all`
41
+ - `.find(id)` returns the resource identified by `id`. **This method is available on all the v2 resources, and only in `Project` and `User` for v1.**
42
+
43
+ ### V1
44
+
45
+ Core v1 API resources are available through the `Core::Client::V1` namespace. For example:
46
+
47
+ ```ruby
48
+ user = Core::Client::V1::User.find(1)
49
+ #=> #<Core::Client::V1::User id=1, roleId=2, managerId=nil, email="mike@able.co", fullName="Mike Potter", firstName="Michael", preferredName="Mike", lastName="Potter", title="CEO", avatarUrl="https://able.bamboohr.com/employees/photos/?h=8dbba2f5a71161a6e01e411edb655ac3">
50
+
51
+ user.fullName
52
+ #=> "Mike Potter"
53
+ ```
54
+
55
+ For more usage examples, check the [specs](https://github.com/ableco/core-client-rb/tree/master/spec/core/client/v1/).
56
+
57
+ ### V2
58
+
59
+ Core v2 API resources are available through the `Core::Client::V2` namespace. For example:
60
+
61
+ ```ruby
62
+ Core::Client::V2::User.find(1)
63
+ #=> #<Core::Client::V2::User:@attributes={"type"=>"users", "id"=>"1", "fullName"=>"Mike Potter", "preferredName"=>"Mike", "firstName"=>"Michael", "avatarUrl"=>"https://able.bamboohr.com/employees/photos/?h=8dbba2f5a71161a6e01e411edb655ac3", "active"=>true, "isManager"=>true, "email"=>"mike@able.co"}>
64
+
65
+ user.fullName
66
+ #=> "Mike Potter"
67
+ ```
68
+
69
+ `Core::Client::V2` resources use [`JsonApiClient`](https://github.com/JsonApiClient/json_api_client) behind the scenes, so any feature from `JsonApiClient` can be used in `Core::Client::V2`. For example:
70
+
71
+ ```ruby
72
+ project = Core::Client::V2::Project.includes(:product).where(product_id: 1).first
73
+ project.product.id
74
+ #=> "1"
75
+ ```
76
+
77
+ For more usage examples, check the [specs](https://github.com/ableco/core-client-rb/tree/master/spec/core/client/v2/).
78
+
79
+ ## Development
80
+
81
+ 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.
82
+
83
+ 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).
84
+
85
+ ## Contributing
86
+
87
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ableco/core-client-rb. 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.
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
92
+
93
+ ## Code of Conduct
94
+
95
+ Everyone interacting in the Core::Client project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ableco/core-client-rb/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "core/client"
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
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
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,41 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "core/client/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "core-client"
7
+ spec.version = Core::Client::VERSION
8
+ spec.authors = ["Able"]
9
+ spec.email = ["engineering@able.co"]
10
+
11
+ spec.summary = %q{Core API client for Ruby.}
12
+ spec.description = %q{Core API client for Ruby. Supports v1 and v2.}
13
+ spec.homepage = "https://core.able.co"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/ableco/core-client-rb"
20
+ spec.metadata["changelog_uri"] = "https://github.com/ableco/core-client-rb/blob/master/CHANGELOG.md"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 2.0"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "rubocop", "~> 0.76"
35
+ spec.add_development_dependency "rubocop-able", "~> 0.2.0"
36
+ spec.add_dependency "dotenv", "~> 2.7"
37
+ spec.add_dependency "json_api_client", "~> 1.16"
38
+ spec.add_dependency "rest-client", "~> 2.1"
39
+ spec.add_dependency "activesupport", "6.0.2.1"
40
+ spec.add_dependency "rack", "~> 2.2"
41
+ end
data/lefthook.yml ADDED
@@ -0,0 +1,5 @@
1
+ pre-commit:
2
+ commands:
3
+ rubocop:
4
+ glob: "*.rb"
5
+ run: rubocop --safe-auto-correct --disable-uncorrectable --force-exclusion {staged_files}
@@ -0,0 +1,16 @@
1
+ require "core/client/version"
2
+
3
+ Dir[File.join(__dir__, "client", "v1", "*.rb")].each do |file|
4
+ require file
5
+ end
6
+
7
+ Dir[File.join(__dir__, "client", "v2", "*.rb")].each do |file|
8
+ require file
9
+ end
10
+
11
+ module Core
12
+ module Client
13
+ class Error < StandardError; end
14
+ # Your code goes here...
15
+ end
16
+ end
@@ -0,0 +1,59 @@
1
+ require "ostruct"
2
+ require "rest-client"
3
+ require "rack/utils"
4
+ require "active_support/inflector"
5
+
6
+ module Core
7
+ module Client
8
+ module V1
9
+ class Base < OpenStruct
10
+ class << self
11
+ def client
12
+ @client ||= RestClient::Resource.new(
13
+ "https://core.able.co/api",
14
+ headers: { "Authorization" => "Bearer #{ENV['CORE_API_TOKEN']}" }
15
+ )
16
+ end
17
+
18
+ def all
19
+ where({})
20
+ end
21
+
22
+ def first
23
+ all.first
24
+ end
25
+
26
+ def last
27
+ all.last
28
+ end
29
+
30
+ def count
31
+ all.count
32
+ end
33
+
34
+ def find(id)
35
+ new(get("#{table_name}/#{id}"))
36
+ end
37
+
38
+ def where(conditions)
39
+ get(table_name, conditions).map do |item|
40
+ new(item)
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ def get(path, params = {})
47
+ suburl = "#{path}?#{Rack::Utils.build_query(params)}"
48
+
49
+ JSON.parse(client[suburl].get.body)
50
+ end
51
+
52
+ def table_name
53
+ ActiveSupport::Inflector.tableize(self.name).split("/").pop
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class Product < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class ProductAllocation < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class ProductAssignment < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class ProductInvestment < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class ProductRevenue < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class Project < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class ProjectAllocation < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class ProjectRole < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class Role < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V1
6
+ class User < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ require "json_api_client"
2
+ require "dotenv/load"
3
+
4
+ module Core
5
+ module Client
6
+ module V2
7
+ class Base < JsonApiClient::Resource
8
+ self.site = "https://core.able.co/api/v2"
9
+ self.raise_on_blank_find_param = true
10
+
11
+ class << self
12
+ def find(id)
13
+ super(id).first
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ Core::Client::V2::Base.connection_options[:headers] = { "Authorization" => "Bearer #{ENV['CORE_API_TOKEN']}" }
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class Product < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class ProductAssignment < Base
7
+ def self.table_name
8
+ "product-assignments"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class ProductInvestment < Base
7
+ def self.table_name
8
+ "product-investments"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class ProductRevenue < Base
7
+ def self.table_name
8
+ "product-revenues"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class Project < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class ProjectAllocation < Base
7
+ def self.table_name
8
+ "project-allocations"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class ProjectRole < Base
7
+ def self.table_name
8
+ "project-roles"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class Role < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "./base"
2
+
3
+ module Core
4
+ module Client
5
+ module V2
6
+ class User < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Core
2
+ module Client
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,226 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: core-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Able
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.76'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.76'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-able
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.2.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: dotenv
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.7'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json_api_client
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.16'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.16'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rest-client
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.1'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: activesupport
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 6.0.2.1
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 6.0.2.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: rack
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '2.2'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '2.2'
153
+ description: Core API client for Ruby. Supports v1 and v2.
154
+ email:
155
+ - engineering@able.co
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".github/workflows/publish-gem.yml"
161
+ - ".gitignore"
162
+ - ".rspec"
163
+ - ".rubocop.yml"
164
+ - ".travis.yml"
165
+ - CHANGELOG.md
166
+ - CODE_OF_CONDUCT.md
167
+ - Gemfile
168
+ - Gemfile.lock
169
+ - LICENSE.txt
170
+ - README.md
171
+ - Rakefile
172
+ - bin/console
173
+ - bin/setup
174
+ - core-client.gemspec
175
+ - lefthook.yml
176
+ - lib/core/client.rb
177
+ - lib/core/client/v1/base.rb
178
+ - lib/core/client/v1/product.rb
179
+ - lib/core/client/v1/product_allocation.rb
180
+ - lib/core/client/v1/product_assignment.rb
181
+ - lib/core/client/v1/product_investment.rb
182
+ - lib/core/client/v1/product_revenue.rb
183
+ - lib/core/client/v1/project.rb
184
+ - lib/core/client/v1/project_allocation.rb
185
+ - lib/core/client/v1/project_role.rb
186
+ - lib/core/client/v1/role.rb
187
+ - lib/core/client/v1/user.rb
188
+ - lib/core/client/v2/base.rb
189
+ - lib/core/client/v2/product.rb
190
+ - lib/core/client/v2/product_assignment.rb
191
+ - lib/core/client/v2/product_investment.rb
192
+ - lib/core/client/v2/product_revenue.rb
193
+ - lib/core/client/v2/project.rb
194
+ - lib/core/client/v2/project_allocation.rb
195
+ - lib/core/client/v2/project_role.rb
196
+ - lib/core/client/v2/role.rb
197
+ - lib/core/client/v2/user.rb
198
+ - lib/core/client/version.rb
199
+ homepage: https://core.able.co
200
+ licenses:
201
+ - MIT
202
+ metadata:
203
+ allowed_push_host: https://rubygems.org
204
+ homepage_uri: https://core.able.co
205
+ source_code_uri: https://github.com/ableco/core-client-rb
206
+ changelog_uri: https://github.com/ableco/core-client-rb/blob/master/CHANGELOG.md
207
+ post_install_message:
208
+ rdoc_options: []
209
+ require_paths:
210
+ - lib
211
+ required_ruby_version: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - ">="
214
+ - !ruby/object:Gem::Version
215
+ version: '0'
216
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ requirements: []
222
+ rubygems_version: 3.1.2
223
+ signing_key:
224
+ specification_version: 4
225
+ summary: Core API client for Ruby.
226
+ test_files: []