reivt 1.6.0 → 1.6.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 +4 -4
- data/Gemfile +11 -11
- data/README.md +5 -2
- data/Rakefile +22 -22
- data/bin/console +9 -9
- data/exe/revit +5 -5
- data/lib/reivt/api/mutations/document_create.mutation.rb +50 -50
- data/lib/reivt/api/mutations/document_delete.mutation.rb +36 -36
- data/lib/reivt/api/mutations/rev_create.mutation.rb +38 -38
- data/lib/reivt/api/mutations/rev_delete.mutation.rb +36 -36
- data/lib/reivt/api/mutations/user_create.mutation.rb +32 -32
- data/lib/reivt/api/mutations/user_signin.mutation.rb +39 -39
- data/lib/reivt/api.rb +64 -64
- data/lib/reivt/auth.rb +94 -96
- data/lib/reivt/cli.rb +167 -167
- data/lib/reivt/document.rb +67 -67
- data/lib/reivt/exception.rb +52 -48
- data/lib/reivt/util.rb +113 -112
- data/lib/reivt/version.rb +3 -3
- data/lib/reivt.rb +42 -42
- data/revit.gemspec +44 -44
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d83391b5e5482cc1ba8dc12fee5d660a3d8b377
|
4
|
+
data.tar.gz: d602cedbf5c97cd13580d62282058a79406f4453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fdf0dbe36948d65ac4f213a4f8c9b4ec1d88d01a9ed875e4488d8ecbee0bd4bb47bd0deea50ad0dbea8ce1c84258b9d0bcb9ded5129af497f4e7ddb10b28537
|
7
|
+
data.tar.gz: 9bbd1b0f55ae89bc687cf24fc666899faa6204ce959749f94950f6ba037b9996b2d5efcaf974758c0dad125a708d69a89b998970ce3e76b1100a452a3187e7c9
|
data/Gemfile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
# gem dependencies go in revit.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
gem 'rugged', git: 'git://github.com/libgit2/rugged.git', submodules: true
|
7
|
-
|
8
|
-
group :test do
|
9
|
-
gem 'codeclimate-test-reporter', '~> 1.0.0'
|
10
|
-
gem 'simplecov'
|
11
|
-
end
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# gem dependencies go in revit.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem 'rugged', git: 'git://github.com/libgit2/rugged.git', submodules: true
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'codeclimate-test-reporter', '~> 1.0.0'
|
10
|
+
gem 'simplecov'
|
11
|
+
end
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
[](https://codeclimate.com/repos/57d861ee01430a66ea000bed/feed) [](https://codeclimate.com/repos/57d861ee01430a66ea000bed/coverage) [](https://codeclimate.com/repos/57d861ee01430a66ea000bed/feed)
|
1
|
+
[](https://badge.fury.io/rb/reivt) [](https://codeclimate.com/repos/57d861ee01430a66ea000bed/feed) [](https://codeclimate.com/repos/57d861ee01430a66ea000bed/coverage) [](https://codeclimate.com/repos/57d861ee01430a66ea000bed/feed)
|
2
2
|
|
3
|
-
# Revit
|
3
|
+
# Revit (Gem name is Reivt)
|
4
4
|
## Rev's handy CLI sidekick
|
5
|
+
|
5
6
|
---
|
7
|
+
## ATTENTION
|
8
|
+
The gem name ```revit``` was taken by someone else but given back to rubygems and now we're waiting a few more days until it's available again! Until then the gem name is ```reivt``` only when installing (```gem install reivt```) , the cli command will still be ```revit```
|
6
9
|
Upload your documents/directories/git commits to rev for a code review session!
|
7
10
|
|
8
11
|
Conduct your code reviews with [rev](https://rev.vaemoi.co)!
|
data/Rakefile
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require 'rspec/core/rake_task'
|
2
|
-
require 'bundler/gem_tasks'
|
3
|
-
|
4
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
5
|
-
t.rspec_opts = '--format doc'
|
6
|
-
end
|
7
|
-
|
8
|
-
task :console do
|
9
|
-
require 'pry'
|
10
|
-
require 'gem_name'
|
11
|
-
|
12
|
-
def reload!
|
13
|
-
# Change 'gem_name' here too:
|
14
|
-
files = $LOADED_FEATURES.select { |feat| feat =~ %r{//gem_name} }
|
15
|
-
files.each { |file| load file }
|
16
|
-
end
|
17
|
-
|
18
|
-
ARGV.clear
|
19
|
-
Pry.start
|
20
|
-
end
|
21
|
-
|
22
|
-
task default: :spec
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
5
|
+
t.rspec_opts = '--format doc'
|
6
|
+
end
|
7
|
+
|
8
|
+
task :console do
|
9
|
+
require 'pry'
|
10
|
+
require 'gem_name'
|
11
|
+
|
12
|
+
def reload!
|
13
|
+
# Change 'gem_name' here too:
|
14
|
+
files = $LOADED_FEATURES.select { |feat| feat =~ %r{//gem_name} }
|
15
|
+
files.each { |file| load file }
|
16
|
+
end
|
17
|
+
|
18
|
+
ARGV.clear
|
19
|
+
Pry.start
|
20
|
+
end
|
21
|
+
|
22
|
+
task default: :spec
|
data/bin/console
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'paint'
|
5
|
-
require 'reivt'
|
6
|
-
|
7
|
-
require 'irb'
|
8
|
-
|
9
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'paint'
|
5
|
+
require 'reivt'
|
6
|
+
|
7
|
+
require 'irb'
|
8
|
+
|
9
|
+
IRB.start(__FILE__)
|
data/exe/revit
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'reivt'
|
4
|
-
|
5
|
-
Reivt::CLI.start(ARGV)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'reivt'
|
4
|
+
|
5
|
+
Reivt::CLI.start(ARGV)
|
@@ -1,50 +1,50 @@
|
|
1
|
-
# An extension of our main module Revit
|
2
|
-
#
|
3
|
-
# @author [brwnrclse]
|
4
|
-
#
|
5
|
-
module Reivt
|
6
|
-
# An extension of the RevAPI module
|
7
|
-
#
|
8
|
-
# @author [brwnrclse]
|
9
|
-
#
|
10
|
-
module RevAPI
|
11
|
-
CreateDocumentMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
-
mutation($blob: String!, $content_type: String!, $doc_name: String!, $has_diff: Boolean!, $rev_id: ID!) {
|
13
|
-
createDocument(blob: $blob, contentType: $content_type, name: $doc_name, hasDiff: $has_diff, revId: $rev_id) {
|
14
|
-
id
|
15
|
-
}
|
16
|
-
}
|
17
|
-
GRAPHQL
|
18
|
-
|
19
|
-
# API call to createDocument
|
20
|
-
# @param blob [String] The contents of the Document
|
21
|
-
# @param content_type [String] The kind of Document
|
22
|
-
# @param doc_name [String] The name of the Document
|
23
|
-
# @param rev_id [String] The id of the Rev this Document belongs to
|
24
|
-
#
|
25
|
-
# @return [String] The id of the Document
|
26
|
-
#
|
27
|
-
def self.create_doc(blob, content_type, doc_name, has_diff, rev_id)
|
28
|
-
blob = "That's all folks?" if blob.nil? || blob.strip.empty?
|
29
|
-
doc_name = 'Empty Doc' if doc_name.nil? || doc_name.strip.empty?
|
30
|
-
has_diff = false if has_diff.nil?
|
31
|
-
|
32
|
-
if content_type.nil? || content_type.strip.empty?
|
33
|
-
content_type = 'plain text'
|
34
|
-
end
|
35
|
-
|
36
|
-
if rev_id.length < 25
|
37
|
-
raise Reivt::GraphQLValidationException, 'Missing rev id'
|
38
|
-
end
|
39
|
-
|
40
|
-
result = CLIENT.query(CreateDocumentMutation, variables: {
|
41
|
-
blob: blob, content_type: content_type,
|
42
|
-
doc_name: doc_name, has_diff: has_diff,
|
43
|
-
rev_id: rev_id
|
44
|
-
})
|
45
|
-
data = RevAPI.retrieve(result)
|
46
|
-
|
47
|
-
data.createDocument.id
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
1
|
+
# An extension of our main module Revit
|
2
|
+
#
|
3
|
+
# @author [brwnrclse]
|
4
|
+
#
|
5
|
+
module Reivt
|
6
|
+
# An extension of the RevAPI module
|
7
|
+
#
|
8
|
+
# @author [brwnrclse]
|
9
|
+
#
|
10
|
+
module RevAPI
|
11
|
+
CreateDocumentMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
+
mutation($blob: String!, $content_type: String!, $doc_name: String!, $has_diff: Boolean!, $rev_id: ID!) {
|
13
|
+
createDocument(blob: $blob, contentType: $content_type, name: $doc_name, hasDiff: $has_diff, revId: $rev_id) {
|
14
|
+
id
|
15
|
+
}
|
16
|
+
}
|
17
|
+
GRAPHQL
|
18
|
+
|
19
|
+
# API call to createDocument
|
20
|
+
# @param blob [String] The contents of the Document
|
21
|
+
# @param content_type [String] The kind of Document
|
22
|
+
# @param doc_name [String] The name of the Document
|
23
|
+
# @param rev_id [String] The id of the Rev this Document belongs to
|
24
|
+
#
|
25
|
+
# @return [String] The id of the Document
|
26
|
+
#
|
27
|
+
def self.create_doc(blob, content_type, doc_name, has_diff, rev_id)
|
28
|
+
blob = "That's all folks?" if blob.nil? || blob.strip.empty?
|
29
|
+
doc_name = 'Empty Doc' if doc_name.nil? || doc_name.strip.empty?
|
30
|
+
has_diff = false if has_diff.nil?
|
31
|
+
|
32
|
+
if content_type.nil? || content_type.strip.empty?
|
33
|
+
content_type = 'plain text'
|
34
|
+
end
|
35
|
+
|
36
|
+
if rev_id.length < 25
|
37
|
+
raise Reivt::GraphQLValidationException, 'Missing rev id'
|
38
|
+
end
|
39
|
+
|
40
|
+
result = CLIENT.query(CreateDocumentMutation, variables: {
|
41
|
+
blob: blob, content_type: content_type,
|
42
|
+
doc_name: doc_name, has_diff: has_diff,
|
43
|
+
rev_id: rev_id
|
44
|
+
})
|
45
|
+
data = RevAPI.retrieve(result)
|
46
|
+
|
47
|
+
data.createDocument.id
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
# An extension of our main module
|
2
|
-
#
|
3
|
-
# @author [brwnrclse]
|
4
|
-
#
|
5
|
-
module Reivt
|
6
|
-
# An extension of the RevAPI module
|
7
|
-
#
|
8
|
-
# @author [brwnrclse]
|
9
|
-
#
|
10
|
-
module RevAPI
|
11
|
-
DeleteDocumentMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
-
mutation($id: ID!) {
|
13
|
-
deleteDocument(id: $id) {
|
14
|
-
id
|
15
|
-
}
|
16
|
-
}
|
17
|
-
GRAPHQL
|
18
|
-
|
19
|
-
# API call to deleteDocument
|
20
|
-
# @param id [String] The unique identifier of the Document
|
21
|
-
#
|
22
|
-
# @return [String, RevAPI::GraphQLValidationError] The id of the deleted
|
23
|
-
# Document or an error
|
24
|
-
#
|
25
|
-
def self.delete_doc(id)
|
26
|
-
if id.length < 25
|
27
|
-
raise raise Reivt::GraphQLValidationException, 'Missing id to delete'
|
28
|
-
end
|
29
|
-
|
30
|
-
result = CLIENT.query(DeleteDocumentMutation, variables: { id: id })
|
31
|
-
data = RevAPI.retrieve(result)
|
32
|
-
|
33
|
-
data.deleteDocument.id
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
1
|
+
# An extension of our main module
|
2
|
+
#
|
3
|
+
# @author [brwnrclse]
|
4
|
+
#
|
5
|
+
module Reivt
|
6
|
+
# An extension of the RevAPI module
|
7
|
+
#
|
8
|
+
# @author [brwnrclse]
|
9
|
+
#
|
10
|
+
module RevAPI
|
11
|
+
DeleteDocumentMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
+
mutation($id: ID!) {
|
13
|
+
deleteDocument(id: $id) {
|
14
|
+
id
|
15
|
+
}
|
16
|
+
}
|
17
|
+
GRAPHQL
|
18
|
+
|
19
|
+
# API call to deleteDocument
|
20
|
+
# @param id [String] The unique identifier of the Document
|
21
|
+
#
|
22
|
+
# @return [String, RevAPI::GraphQLValidationError] The id of the deleted
|
23
|
+
# Document or an error
|
24
|
+
#
|
25
|
+
def self.delete_doc(id)
|
26
|
+
if id.length < 25
|
27
|
+
raise raise Reivt::GraphQLValidationException, 'Missing id to delete'
|
28
|
+
end
|
29
|
+
|
30
|
+
result = CLIENT.query(DeleteDocumentMutation, variables: { id: id })
|
31
|
+
data = RevAPI.retrieve(result)
|
32
|
+
|
33
|
+
data.deleteDocument.id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,38 +1,38 @@
|
|
1
|
-
# An extension of our main module
|
2
|
-
#
|
3
|
-
# @author [brwnrclse]
|
4
|
-
#
|
5
|
-
module Reivt
|
6
|
-
# An extension of the RevAPI module
|
7
|
-
#
|
8
|
-
# @author [brwnrclse]
|
9
|
-
#
|
10
|
-
module RevAPI
|
11
|
-
CreateRevMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
-
mutation($description: String!, $title: String!, $user_id: ID!) {
|
13
|
-
createRev(description: $description, title: $title, userId: $user_id) {
|
14
|
-
id
|
15
|
-
}
|
16
|
-
}
|
17
|
-
GRAPHQL
|
18
|
-
|
19
|
-
# API call to createRev
|
20
|
-
# @param description [String] What the Rev is about
|
21
|
-
# @param title [String] The name of the Rev
|
22
|
-
#
|
23
|
-
# @return [String] The id of the created Rev
|
24
|
-
#
|
25
|
-
def self.create_rev(description, title)
|
26
|
-
description = 'Some rev' if description.nil? || description.strip.empty?
|
27
|
-
title = 'A rev, right?' if title.nil? || title.strip.empty?
|
28
|
-
|
29
|
-
result = CLIENT.query(RevAPI::CreateRevMutation, variables: {
|
30
|
-
description: description, title: title,
|
31
|
-
user_id: RevAPI::ID_TOKEN
|
32
|
-
})
|
33
|
-
data = RevAPI.retrieve(result)
|
34
|
-
|
35
|
-
data.createRev.id
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
1
|
+
# An extension of our main module
|
2
|
+
#
|
3
|
+
# @author [brwnrclse]
|
4
|
+
#
|
5
|
+
module Reivt
|
6
|
+
# An extension of the RevAPI module
|
7
|
+
#
|
8
|
+
# @author [brwnrclse]
|
9
|
+
#
|
10
|
+
module RevAPI
|
11
|
+
CreateRevMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
+
mutation($description: String!, $title: String!, $user_id: ID!) {
|
13
|
+
createRev(description: $description, title: $title, userId: $user_id) {
|
14
|
+
id
|
15
|
+
}
|
16
|
+
}
|
17
|
+
GRAPHQL
|
18
|
+
|
19
|
+
# API call to createRev
|
20
|
+
# @param description [String] What the Rev is about
|
21
|
+
# @param title [String] The name of the Rev
|
22
|
+
#
|
23
|
+
# @return [String] The id of the created Rev
|
24
|
+
#
|
25
|
+
def self.create_rev(description, title)
|
26
|
+
description = 'Some rev' if description.nil? || description.strip.empty?
|
27
|
+
title = 'A rev, right?' if title.nil? || title.strip.empty?
|
28
|
+
|
29
|
+
result = CLIENT.query(RevAPI::CreateRevMutation, variables: {
|
30
|
+
description: description, title: title,
|
31
|
+
user_id: RevAPI::ID_TOKEN
|
32
|
+
})
|
33
|
+
data = RevAPI.retrieve(result)
|
34
|
+
|
35
|
+
data.createRev.id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,36 +1,36 @@
|
|
1
|
-
# An extension of our main module Revit
|
2
|
-
#
|
3
|
-
# @author [brwnrclse]
|
4
|
-
#
|
5
|
-
module Reivt
|
6
|
-
# An extension of the RevAPI module
|
7
|
-
#
|
8
|
-
# @author [brwnrclse]
|
9
|
-
#
|
10
|
-
module RevAPI
|
11
|
-
DeleteRevMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
-
mutation($id: ID!) {
|
13
|
-
deleteRev(id: $id) {
|
14
|
-
id
|
15
|
-
}
|
16
|
-
}
|
17
|
-
GRAPHQL
|
18
|
-
|
19
|
-
# API call to deleteRev
|
20
|
-
# @param id [String] The unique identifier of the Rev
|
21
|
-
#
|
22
|
-
# @return [String, RevAPI::GraphQLValidationError] The id of the deleted Rev
|
23
|
-
# or an error
|
24
|
-
#
|
25
|
-
def self.delete_rev(id)
|
26
|
-
if id.length < 25
|
27
|
-
raise Reivt::GraphQLValidationException, 'Missing id to delete'
|
28
|
-
end
|
29
|
-
|
30
|
-
result = CLIENT.query(RevAPI::DeleteRevMutation, variables: { id: id })
|
31
|
-
data = RevAPI.retrieve(result)
|
32
|
-
|
33
|
-
data.deleteRev.id
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
1
|
+
# An extension of our main module Revit
|
2
|
+
#
|
3
|
+
# @author [brwnrclse]
|
4
|
+
#
|
5
|
+
module Reivt
|
6
|
+
# An extension of the RevAPI module
|
7
|
+
#
|
8
|
+
# @author [brwnrclse]
|
9
|
+
#
|
10
|
+
module RevAPI
|
11
|
+
DeleteRevMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
+
mutation($id: ID!) {
|
13
|
+
deleteRev(id: $id) {
|
14
|
+
id
|
15
|
+
}
|
16
|
+
}
|
17
|
+
GRAPHQL
|
18
|
+
|
19
|
+
# API call to deleteRev
|
20
|
+
# @param id [String] The unique identifier of the Rev
|
21
|
+
#
|
22
|
+
# @return [String, RevAPI::GraphQLValidationError] The id of the deleted Rev
|
23
|
+
# or an error
|
24
|
+
#
|
25
|
+
def self.delete_rev(id)
|
26
|
+
if id.length < 25
|
27
|
+
raise Reivt::GraphQLValidationException, 'Missing id to delete'
|
28
|
+
end
|
29
|
+
|
30
|
+
result = CLIENT.query(RevAPI::DeleteRevMutation, variables: { id: id })
|
31
|
+
data = RevAPI.retrieve(result)
|
32
|
+
|
33
|
+
data.deleteRev.id
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
# An extension of the main module, Revit
|
2
|
-
#
|
3
|
-
# @author [brwnrclse]
|
4
|
-
#
|
5
|
-
module Reivt
|
6
|
-
# An extension of the RevAPI module
|
7
|
-
#
|
8
|
-
# @author [brwnrclse]
|
9
|
-
#
|
10
|
-
module RevAPI
|
11
|
-
CreateUserMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
-
mutation($auth0_id: String!) {
|
13
|
-
createUser(authProvider:{auth0: {idToken: $auth0_id}}) {
|
14
|
-
id
|
15
|
-
}
|
16
|
-
}
|
17
|
-
GRAPHQL
|
18
|
-
|
19
|
-
# Authenticate the user against the api to receive a user id
|
20
|
-
# @param id [String] The users's id from Auth0
|
21
|
-
#
|
22
|
-
# @return [String] The user's id in the rev api
|
23
|
-
#
|
24
|
-
def self.create_user(auth0_id)
|
25
|
-
result = CLIENT.query(RevAPI::CreateUserMutation,
|
26
|
-
variables: { auth0_id: auth0_id })
|
27
|
-
data = RevAPI.retrieve(result)
|
28
|
-
|
29
|
-
data.createUser.id
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
# An extension of the main module, Revit
|
2
|
+
#
|
3
|
+
# @author [brwnrclse]
|
4
|
+
#
|
5
|
+
module Reivt
|
6
|
+
# An extension of the RevAPI module
|
7
|
+
#
|
8
|
+
# @author [brwnrclse]
|
9
|
+
#
|
10
|
+
module RevAPI
|
11
|
+
CreateUserMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
+
mutation($auth0_id: String!) {
|
13
|
+
createUser(authProvider:{auth0: {idToken: $auth0_id}}) {
|
14
|
+
id
|
15
|
+
}
|
16
|
+
}
|
17
|
+
GRAPHQL
|
18
|
+
|
19
|
+
# Authenticate the user against the api to receive a user id
|
20
|
+
# @param id [String] The users's id from Auth0
|
21
|
+
#
|
22
|
+
# @return [String] The user's id in the rev api
|
23
|
+
#
|
24
|
+
def self.create_user(auth0_id)
|
25
|
+
result = CLIENT.query(RevAPI::CreateUserMutation,
|
26
|
+
variables: { auth0_id: auth0_id })
|
27
|
+
data = RevAPI.retrieve(result)
|
28
|
+
|
29
|
+
data.createUser.id
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
# An extension of the main module, Revit
|
2
|
-
#
|
3
|
-
# @author [brwnrclse]
|
4
|
-
#
|
5
|
-
module Reivt
|
6
|
-
# An extension of the RevAPI module
|
7
|
-
#
|
8
|
-
# @author [brwnrclse]
|
9
|
-
#
|
10
|
-
module RevAPI
|
11
|
-
SigninMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
-
mutation($auth0_id: String!) {
|
13
|
-
signinUser(auth0:{idToken: $auth0_id}) {
|
14
|
-
user {
|
15
|
-
id
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
GRAPHQL
|
20
|
-
|
21
|
-
# Authenticate the user against the api to receive a user id
|
22
|
-
# @param id [String] The users's id from Auth0
|
23
|
-
#
|
24
|
-
# @return [String] The user's id in the rev api
|
25
|
-
#
|
26
|
-
def self.signin_user(auth0_id)
|
27
|
-
result = CLIENT.query(RevAPI::SigninMutation,
|
28
|
-
variables: { auth0_id: auth0_id })
|
29
|
-
|
30
|
-
if result.data.nil?
|
31
|
-
nil
|
32
|
-
else
|
33
|
-
data = RevAPI.retrieve(result)
|
34
|
-
|
35
|
-
data.signinUser.user.id
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
# An extension of the main module, Revit
|
2
|
+
#
|
3
|
+
# @author [brwnrclse]
|
4
|
+
#
|
5
|
+
module Reivt
|
6
|
+
# An extension of the RevAPI module
|
7
|
+
#
|
8
|
+
# @author [brwnrclse]
|
9
|
+
#
|
10
|
+
module RevAPI
|
11
|
+
SigninMutation = CLIENT.parse <<-'GRAPHQL'
|
12
|
+
mutation($auth0_id: String!) {
|
13
|
+
signinUser(auth0:{idToken: $auth0_id}) {
|
14
|
+
user {
|
15
|
+
id
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
GRAPHQL
|
20
|
+
|
21
|
+
# Authenticate the user against the api to receive a user id
|
22
|
+
# @param id [String] The users's id from Auth0
|
23
|
+
#
|
24
|
+
# @return [String] The user's id in the rev api
|
25
|
+
#
|
26
|
+
def self.signin_user(auth0_id)
|
27
|
+
result = CLIENT.query(RevAPI::SigninMutation,
|
28
|
+
variables: { auth0_id: auth0_id })
|
29
|
+
|
30
|
+
if result.data.nil?
|
31
|
+
nil
|
32
|
+
else
|
33
|
+
data = RevAPI.retrieve(result)
|
34
|
+
|
35
|
+
data.signinUser.user.id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|