iAuditor 0.1.1 → 0.1.2.14
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 +3 -0
- data/iAuditor.gemspec +2 -2
- data/lib/iAuditor.rb +23 -18
- data/lib/iAuditor/actions.rb +26 -0
- data/lib/iAuditor/audit.rb +52 -0
- data/lib/iAuditor/base.rb +20 -73
- data/lib/iAuditor/base_modules.rb +27 -0
- data/lib/iAuditor/export.rb +11 -0
- data/lib/iAuditor/template.rb +14 -0
- data/lib/iAuditor/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e16df3e4f8f2d977696c542fa40f70919c0248d
|
4
|
+
data.tar.gz: 4949d4537e1d5a13312290f592aed43b6a89f136
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 184f2fe4ff74be38d2f5b367ab9ccd4a865171773f12badf8507e95bc56772b32edeac2e3f974fda91178e4387b9a10ce0ec886e9c3c598a2a3a999621562d4d
|
7
|
+
data.tar.gz: fe569d220e08e8cbe17c4ee28f12f686059ee053a97be88ad774f50037dec7f7bfabc537be1478ae4dd8392b2d145bbe9551140d4afb70eaba4eb6ac6cb191f6
|
data/Gemfile
CHANGED
data/iAuditor.gemspec
CHANGED
@@ -6,8 +6,8 @@ require "iAuditor/version"
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "iAuditor"
|
8
8
|
spec.version = IAuditor::VERSION
|
9
|
-
spec.authors = ["Daniel Wetteroth"]
|
10
|
-
spec.email = ["danielcw@gmail.com"]
|
9
|
+
spec.authors = ["Daniel Wetteroth", "Pradeep Kumar"]
|
10
|
+
spec.email = ["danielcw@gmail.com", "velrangitham.ms@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = "A Ruby Wrapper for the iAuditor API"
|
13
13
|
spec.description = "iAuditor API wrapper - https://developer.safetyculture.io"
|
data/lib/iAuditor.rb
CHANGED
@@ -1,33 +1,38 @@
|
|
1
|
-
require 'net/http'
|
1
|
+
# require 'net/http'
|
2
2
|
require 'uri'
|
3
3
|
require 'httparty'
|
4
4
|
|
5
|
-
require "iAuditor
|
6
|
-
|
5
|
+
%w(base version audit export template actions).each {|package| require "iAuditor/#{package}"}
|
6
|
+
|
7
7
|
|
8
8
|
module IAuditor
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
12
|
-
def client(
|
13
|
-
IAuditor::Base.new(
|
12
|
+
def client(token)
|
13
|
+
IAuditor::Base.new(token)
|
14
|
+
end
|
15
|
+
|
16
|
+
def token(user, pass, grant)
|
17
|
+
IAuditor::Base.token(user, pass, grant)
|
14
18
|
end
|
15
19
|
|
16
20
|
end
|
17
21
|
|
18
22
|
end
|
19
23
|
|
20
|
-
#
|
21
|
-
# a.audits -- This will give the array of audits..
|
22
|
-
# a.audits({ field: "audit_id",field: "modified_at" }) --- retrieve any specific fields
|
23
|
-
# a.audits({ field: "audit_id",field: "modified_at", modified_at: "2018-04-03T11:15:26.644Z" }) --- retrieve any specific fields
|
24
|
-
# a.audits({ field: "audit_id",field: "modified_at", modified_at: "2018-04-03T11:15:26.644Z" }) --- retrieve any specific fields
|
25
|
-
# a.audits({ field: "audit_id",field: "modified_at", modified_after: "2018-04-03T11:15:26.644Z" }) --- Searching by modification date:
|
26
|
-
# a.audits({ template: "template_37afc5890aa94e778bbcde4fc4cbe480" }) --- Searching by template:
|
27
|
-
# a.audits({ archived: "both" }) --- Including archived audits:
|
28
|
-
# a.audits({ completed: "true" }) --- Including only completed audits:
|
29
|
-
# a.audit(audit_c4fa538a4a11478584478913eee40d3b) -- retrieving an audit
|
30
|
-
# a.actions({audit_id: ["audit_0d7de5501565420d9fca02cb1f2cda5a", "audit_c25e7a5c130a41788b1ccb24c002e934"]})
|
31
|
-
|
32
|
-
|
24
|
+
#
|
33
25
|
|
26
|
+
# a=IAuditor.client("49b71c0652aa2507091e1312453a6e73e54237037645da0ffcb44dbfd5c85308")
|
27
|
+
# a.audits.search -- This will give the array of audits..
|
28
|
+
# a.audits.search({ field: "audit_id",field: "modified_at" }) --- retrieve any specific fields
|
29
|
+
# a.audits.search({ field: "audit_id",field: "modified_at", modified_at: "2018-04-03T11:15:26.644Z" }) --- retrieve any specific fields
|
30
|
+
# a.audits.search({ field: "audit_id",field: "modified_at", modified_at: "2018-04-03T11:15:26.644Z" }) --- retrieve any specific fields
|
31
|
+
# a.audits.search({ field: "audit_id",field: "modified_at", modified_after: "2018-04-03T11:15:26.644Z" }) --- Searching by modification date:
|
32
|
+
# a.audits.search({ template: "template_37afc5890aa94e778bbcde4fc4cbe480" }) --- Searching by template:
|
33
|
+
# a.audits.search({ archived: "both" }) --- Including archived audits:
|
34
|
+
# a.audits.search({ completed: "true" }) --- Including only completed audits:
|
35
|
+
# a.audits.fetch(audit_c4fa538a4a11478584478913eee40d3b) -- retrieving an audit
|
36
|
+
# a.actions.search({audit_id: ["audit_0d7de5501565420d9fca02cb1f2cda5a", "audit_c25e7a5c130a41788b1ccb24c002e934"]})
|
37
|
+
# a.templates.search()
|
38
|
+
# a.export.profiles()
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module IAuditor
|
2
|
+
class Actions
|
3
|
+
include BaseModules::Methods
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
# Retrieving actions
|
8
|
+
def search(options={})
|
9
|
+
@options.merge!(body: options.to_json) if options.present?
|
10
|
+
@actions = self.class.post("/actions/search", @options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def fetch(action_id)
|
14
|
+
@audits = self.class.get("/actions/#{action_id}", @options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def create(options)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
def update(options)
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module IAuditor
|
2
|
+
class Audit
|
3
|
+
include BaseModules::Methods
|
4
|
+
|
5
|
+
|
6
|
+
# Retrieving all audits with the given search criteria
|
7
|
+
def search(options={})
|
8
|
+
@options.merge!(query: options) if options.present?
|
9
|
+
@audits = self.class.get("/audits/search", @options)
|
10
|
+
@audits.parsed_response
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieving audit detailed information
|
14
|
+
def fetch(audit)
|
15
|
+
@audit = self.class.get("/audits/#{audit}", @options)
|
16
|
+
@audit.parsed_response
|
17
|
+
end
|
18
|
+
|
19
|
+
# Retrieving audit link
|
20
|
+
def audit_link(audit)
|
21
|
+
@audits = self.class.get("/audits/#{audit}/deep_link", @options)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Retrieving audit link
|
25
|
+
def audit_web_report_link(audit)
|
26
|
+
@audits = self.class.get("/audits/#{audit}/web_report_link", @options)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Need to be add based on checklist
|
30
|
+
# def start_audit
|
31
|
+
#
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Retrieving audit media
|
35
|
+
def audit_media(audit,media)
|
36
|
+
@audits = self.class.get("/audits/#{audit}/media/#{media}", @options)
|
37
|
+
end
|
38
|
+
|
39
|
+
# format. timezone, export_profile
|
40
|
+
def start_audit_export(audit,options={})
|
41
|
+
@options.merge!(query: options) if options.present?
|
42
|
+
@audits = self.class.get("/audits/#{audit}/export", @options)
|
43
|
+
end
|
44
|
+
|
45
|
+
# format. timezone, export_profile
|
46
|
+
def audit_export(audit, export, file)
|
47
|
+
@audits = self.class.get("/audits/#{audit}/exports/#{export}/#{file}", @options)
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
data/lib/iAuditor/base.rb
CHANGED
@@ -1,90 +1,37 @@
|
|
1
|
+
require "iAuditor/base_modules"
|
1
2
|
module IAuditor
|
2
3
|
class Base
|
3
|
-
include HTTParty
|
4
|
-
base_uri "https://api.safetyculture.io"
|
5
4
|
|
6
|
-
|
7
|
-
@options = {
|
8
|
-
headers: {
|
9
|
-
"Content-Type": "application/json",
|
10
|
-
"Authorization": "Bearer #{token}"
|
11
|
-
}
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
def audits(options={})
|
16
|
-
@options.merge!(query: options) if options.present?
|
17
|
-
@audits = self.class.get("/audits/search", @options)
|
18
|
-
@audits.parsed_response
|
19
|
-
end
|
20
|
-
|
21
|
-
def audit(audit)
|
22
|
-
@audit = self.class.get("/audits/#{audit}", @options)
|
23
|
-
@audit.parsed_response
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
def audit_link(audit)
|
28
|
-
@audits = self.class.get("/audits/#{audit}/deep_link", @options)
|
29
|
-
end
|
30
|
-
|
31
|
-
|
32
|
-
def audit_web_report_link(audit)
|
33
|
-
@audits = self.class.get("/audits/#{audit}/web_report_link", @options)
|
34
|
-
end
|
5
|
+
include BaseModules::Methods
|
35
6
|
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
# end
|
40
|
-
|
41
|
-
def audit_media(audit,media)
|
42
|
-
@audits = self.class.get("/audits/#{audit}/media/#{media}", @options)
|
43
|
-
end
|
44
|
-
|
45
|
-
# format. timezone, export_profile
|
46
|
-
def start_audit_export(audit,options={})
|
47
|
-
@options.merge!(query: options) if options.present?
|
48
|
-
@audits = self.class.get("/audits/#{audit}/export", @options)
|
7
|
+
def audits
|
8
|
+
IAuditor::Audit.new(@options)
|
49
9
|
end
|
50
10
|
|
51
|
-
|
52
|
-
|
53
|
-
@audits = self.class.get("/audits/#{audit}/exports/#{export}/#{file}", @options)
|
11
|
+
def templates
|
12
|
+
IAuditor::Template.new(@options)
|
54
13
|
end
|
55
14
|
|
56
|
-
|
57
|
-
|
58
|
-
@options.merge!(query: options) if options.present?
|
59
|
-
@profiles = self.class.get("/export_profiles/search", @options)
|
15
|
+
def actions
|
16
|
+
IAuditor::Actions.new(@options)
|
60
17
|
end
|
61
18
|
|
62
|
-
|
63
|
-
|
64
|
-
@options.merge!(query: options) if options.present?
|
65
|
-
@templates = self.class.get("/templates/search", @options)
|
66
|
-
@templates.parsed_response
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
# Actions
|
71
|
-
def actions(options={})
|
72
|
-
@options.merge!(body: options.to_json) if options.present?
|
73
|
-
@actions = self.class.post("/actions/search", @options)
|
19
|
+
def export
|
20
|
+
IAuditor::Export.new(@options)
|
74
21
|
end
|
75
22
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
23
|
+
def self.token(username, password, grant_type)
|
24
|
+
token = HTTParty.post('https://api.safetyculture.io/auth',
|
25
|
+
:body => {
|
26
|
+
"username": username,
|
27
|
+
"password": password,
|
28
|
+
"grant_type":"password"
|
84
29
|
|
85
|
-
|
30
|
+
}
|
31
|
+
).parsed_response["access_token"]
|
86
32
|
|
33
|
+
token
|
87
34
|
end
|
88
35
|
|
89
36
|
end
|
90
|
-
end
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'pry'
|
2
|
+
class BaseModules
|
3
|
+
module Methods
|
4
|
+
|
5
|
+
def initialize(token)
|
6
|
+
|
7
|
+
@options = token.is_a?(String) ? {
|
8
|
+
headers: {
|
9
|
+
"Content-Type": "application/json",
|
10
|
+
"Authorization": "Bearer #{token}"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
: token
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
def self.included(base)
|
22
|
+
base.send :include, "HTTParty".constantize
|
23
|
+
base.send(:base_uri, "https://api.safetyculture.io")
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module IAuditor
|
2
|
+
class Template
|
3
|
+
include BaseModules::Methods
|
4
|
+
|
5
|
+
|
6
|
+
# Retrieving all audits with the given search criteria
|
7
|
+
def search(options={})
|
8
|
+
@options.merge!(query: options) if options.present?
|
9
|
+
@templates = self.class.get("/templates/search", @options)
|
10
|
+
@templates.parsed_response
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/lib/iAuditor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iAuditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Wetteroth
|
8
|
+
- Pradeep Kumar
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
12
|
+
date: 2018-04-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -69,6 +70,7 @@ dependencies:
|
|
69
70
|
description: iAuditor API wrapper - https://developer.safetyculture.io
|
70
71
|
email:
|
71
72
|
- danielcw@gmail.com
|
73
|
+
- velrangitham.ms@gmail.com
|
72
74
|
executables: []
|
73
75
|
extensions: []
|
74
76
|
extra_rdoc_files: []
|
@@ -85,7 +87,12 @@ files:
|
|
85
87
|
- bin/setup
|
86
88
|
- iAuditor.gemspec
|
87
89
|
- lib/iAuditor.rb
|
90
|
+
- lib/iAuditor/actions.rb
|
91
|
+
- lib/iAuditor/audit.rb
|
88
92
|
- lib/iAuditor/base.rb
|
93
|
+
- lib/iAuditor/base_modules.rb
|
94
|
+
- lib/iAuditor/export.rb
|
95
|
+
- lib/iAuditor/template.rb
|
89
96
|
- lib/iAuditor/version.rb
|
90
97
|
homepage: https://github.com/Mashey/iAuditor
|
91
98
|
licenses:
|