foureyes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5c834b5a55146770175794ae9ea1b9ccc82a65b3
4
+ data.tar.gz: 29102a3d2bbc72ac8989da1cde44467d6b8f2c5d
5
+ SHA512:
6
+ metadata.gz: 34a120eb47f20915e2d08f7403af5036c5bc778643baabd5bba1a45bdb508c642f72545d0d44e912a7b2adf9b1769092dc8cbf56f555d2962c4c3982d9978aa3
7
+ data.tar.gz: 4037af34d340fa1b6e467d2b1e867f966969c4d24ec4ac4dc4eed52ff076b1b4a2860ae1818a2489fe9953a35d08572df5e8f6797d263546af0668e048bd22f3
@@ -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
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,16 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=e512d9b3fe7f94b426597bdf80746bb0e1d0802f6d3b841a315d30d9290e5175
4
+ sudo: false
5
+ language: ruby
6
+ rvm:
7
+ - 2.3.4
8
+ before_install: gem install bundler -v 1.16.1
9
+ before_script:
10
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
11
+ - chmod +x ./cc-test-reporter
12
+ - ./cc-test-reporter before-build
13
+ script:
14
+ - bundle exec rspec
15
+ after_script:
16
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ gemspec
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ foureyes (0.1.0)
5
+ graphql-client (~> 0.12)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (5.2.0)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ coderay (1.1.2)
16
+ concurrent-ruby (1.0.5)
17
+ diff-lcs (1.3)
18
+ docile (1.3.1)
19
+ ffi (1.9.25)
20
+ formatador (0.2.5)
21
+ graphql (1.8.4)
22
+ graphql-client (0.12.3)
23
+ activesupport (>= 3.0, < 6.0)
24
+ graphql (~> 1.6)
25
+ guard (2.14.2)
26
+ formatador (>= 0.2.4)
27
+ listen (>= 2.7, < 4.0)
28
+ lumberjack (>= 1.0.12, < 2.0)
29
+ nenv (~> 0.1)
30
+ notiffany (~> 0.0)
31
+ pry (>= 0.9.12)
32
+ shellany (~> 0.0)
33
+ thor (>= 0.18.1)
34
+ guard-compat (1.2.1)
35
+ guard-rspec (4.7.3)
36
+ guard (~> 2.1)
37
+ guard-compat (~> 1.1)
38
+ rspec (>= 2.99.0, < 4.0)
39
+ i18n (1.0.1)
40
+ concurrent-ruby (~> 1.0)
41
+ json (2.1.0)
42
+ listen (3.1.5)
43
+ rb-fsevent (~> 0.9, >= 0.9.4)
44
+ rb-inotify (~> 0.9, >= 0.9.7)
45
+ ruby_dep (~> 1.2)
46
+ lumberjack (1.0.13)
47
+ method_source (0.9.0)
48
+ minitest (5.11.3)
49
+ nenv (0.3.0)
50
+ notiffany (0.1.1)
51
+ nenv (~> 0.1)
52
+ shellany (~> 0.0)
53
+ pry (0.11.3)
54
+ coderay (~> 1.1.0)
55
+ method_source (~> 0.9.0)
56
+ rake (10.5.0)
57
+ rb-fsevent (0.10.3)
58
+ rb-inotify (0.9.10)
59
+ ffi (>= 0.5.0, < 2)
60
+ rspec (3.7.0)
61
+ rspec-core (~> 3.7.0)
62
+ rspec-expectations (~> 3.7.0)
63
+ rspec-mocks (~> 3.7.0)
64
+ rspec-core (3.7.1)
65
+ rspec-support (~> 3.7.0)
66
+ rspec-expectations (3.7.0)
67
+ diff-lcs (>= 1.2.0, < 2.0)
68
+ rspec-support (~> 3.7.0)
69
+ rspec-mocks (3.7.0)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.7.0)
72
+ rspec-support (3.7.1)
73
+ ruby_dep (1.5.0)
74
+ shellany (0.0.1)
75
+ simplecov (0.16.1)
76
+ docile (~> 1.1)
77
+ json (>= 1.8, < 3)
78
+ simplecov-html (~> 0.10.0)
79
+ simplecov-html (0.10.2)
80
+ thor (0.20.0)
81
+ thread_safe (0.3.6)
82
+ tzinfo (1.2.5)
83
+ thread_safe (~> 0.1)
84
+
85
+ PLATFORMS
86
+ ruby
87
+
88
+ DEPENDENCIES
89
+ bundler (~> 1.16)
90
+ foureyes!
91
+ guard-rspec (~> 4.7)
92
+ rake (~> 10.0)
93
+ rspec (~> 3.0)
94
+ simplecov (~> 0.16)
95
+
96
+ BUNDLED WITH
97
+ 1.16.1
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Rashaad R. Randall
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.
@@ -0,0 +1,50 @@
1
+ [![Build Status](https://travis-ci.org/rrandall91/foureyes-ruby.svg?branch=master)](https://travis-ci.org/rrandall91/foureyes-ruby)
2
+ [![Maintainability](https://api.codeclimate.com/v1/badges/dd15fc5e8a09df3309b4/maintainability)](https://codeclimate.com/repos/5b439c76eba5b7023f000cdb/maintainability)
3
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/dd15fc5e8a09df3309b4/test_coverage)](https://codeclimate.com/repos/5b439c76eba5b7023f000cdb/test_coverage)
4
+
5
+ # Foureyes
6
+
7
+ The Foureyes Ruby Library is an GraphQL API client for the Foureyes API.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'foureyes'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install foureyes
24
+
25
+ ## Usage
26
+
27
+ The library needs to be configured with your account's API key. Set `Foureyes.api_key` to its value:
28
+
29
+ ``` ruby
30
+ require "foureyes"
31
+ Foureyes.api_key = "..."
32
+
33
+ # list accounts
34
+ Foureyes::Account.list
35
+
36
+ # retrieve single account
37
+ Foureyes::Account.retrieve(ID)
38
+ ```
39
+
40
+ ## Development
41
+
42
+ TODO
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rrandall91/foureyes.
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "foureyes"
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__)
@@ -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,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "foureyes/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "foureyes"
8
+ spec.version = Foureyes::VERSION
9
+ spec.authors = ["Rashaad R. Randall"]
10
+ spec.email = ["rrandall@poweredbyvivid.com"]
11
+
12
+ spec.summary = %q{FourEyes Ruby Client}
13
+ spec.description = %q{A GraphQL client for the FourEyes API}
14
+ spec.homepage = "https://github.com/rrandall91/foureyes-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.required_ruby_version = ">= 2.3.4"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.16"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rspec", "~> 3.0"
29
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
30
+ spec.add_development_dependency "simplecov", "~> 0.16"
31
+
32
+ spec.add_dependency "graphql-client", "~> 0.12"
33
+ end
@@ -0,0 +1,22 @@
1
+ ## Foureyes Ruby Bindings
2
+ require "graphql/client"
3
+ require "graphql/client/http"
4
+
5
+ ## Version
6
+ require "foureyes/version"
7
+
8
+ ## API Resource Support Classes
9
+ require "foureyes/resource"
10
+
11
+ ## Named API Resources
12
+ require "foureyes/account"
13
+
14
+ module Foureyes
15
+ @api_base = 'https://backend-staging.foureyes.io/api' #'https://backend.foureyes.io/api'
16
+ @environment = 'staging' #'production'
17
+ @api_key = '7dcce95d-fe41-49cc-875d-378a6f6e2762'
18
+
19
+ class << self
20
+ attr_accessor :api_key, :api_base, :environment
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ module Foureyes
2
+ class Account < Resource
3
+ QUERY = CLIENT.parse <<-GraphQL
4
+ query($api_key: String!, $id: [ID!]) {
5
+ viewer(apiKey: $api_key){
6
+ Accounts(options:{statusFilter:[ACTIVE], ids: $id}){
7
+ edges{
8
+ node{
9
+ id
10
+ account_name
11
+ dealer_code
12
+ created
13
+ updated_at
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ GraphQL
20
+ end
21
+ end
@@ -0,0 +1,46 @@
1
+ module Foureyes
2
+ class Resource
3
+ include Enumerable
4
+
5
+ CONNECTION = GraphQL::Client::HTTP.new('https://backend-staging.foureyes.io/api')
6
+ SCHEMA = GraphQL::Client.load_schema(CONNECTION)
7
+ CLIENT = GraphQL::Client.new(schema: SCHEMA, execute: CONNECTION)
8
+
9
+ attr_reader :id, :account_name, :dealer_code, :created_at, :updated_at
10
+
11
+ def initialize(attributes = {})
12
+ attributes.map do |k, v|
13
+ instance_variable_set "@#{k}".to_sym, v
14
+ self.class_eval{ attr_reader "k".to_sym}
15
+ end
16
+
17
+ self
18
+ end
19
+
20
+ def self.class_name
21
+ self.name.constantize
22
+ end
23
+
24
+ def self.execute_request(args = {})
25
+ arguments = { api_key: Foureyes.api_key }
26
+ arguments.merge!(args) if args
27
+
28
+ CLIENT.query("#{self.class_name}".constantize::QUERY, variables: arguments)
29
+ end
30
+
31
+ def self.list
32
+ response = self.execute_request
33
+ edges = response.data.viewer.accounts.edges
34
+ edges.map do |edge|
35
+ attrs = edge.node.to_h
36
+ instance = new attrs
37
+ end
38
+ end
39
+
40
+ def self.retrieve(id)
41
+ response = self.execute_request({id: id})
42
+ attrs = response.data.viewer.accounts.edges.first.node.to_h
43
+ instance = new attrs
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module Foureyes
2
+ VERSION = "0.1.0".freeze
3
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foureyes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Rashaad R. Randall
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-10 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: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: graphql-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.12'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.12'
97
+ description: A GraphQL client for the FourEyes API
98
+ email:
99
+ - rrandall@poweredbyvivid.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - Gemfile.lock
109
+ - Guardfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - bin/console
114
+ - bin/setup
115
+ - foureyes.gemspec
116
+ - lib/foureyes.rb
117
+ - lib/foureyes/account.rb
118
+ - lib/foureyes/resource.rb
119
+ - lib/foureyes/version.rb
120
+ homepage: https://github.com/rrandall91/foureyes-ruby
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 2.3.4
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.6.14
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: FourEyes Ruby Client
144
+ test_files: []