traitify 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -7
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -0
- data/README.md +58 -69
- data/lib/traitify/client.rb +3 -9
- data/lib/traitify/client/assessments.rb +6 -6
- data/lib/traitify/client/decks.rb +12 -0
- data/lib/traitify/client/results.rb +14 -2
- data/lib/traitify/client/slides.rb +12 -19
- data/lib/traitify/error.rb +3 -5
- data/lib/traitify/version.rb +1 -1
- data/spec/support/mocks/decks.json +12 -0
- data/spec/support/mocks/personality_traits.json +82 -0
- data/spec/support/mocks/slide.json +1 -1
- data/spec/support/mocks/slides.json +1 -1
- data/spec/support/mocks/slides_complete.json +1 -1
- data/spec/traitify-ruby/client/deck_spec.rb +28 -0
- data/spec/traitify-ruby/client/result_spec.rb +27 -1
- data/spec/traitify-ruby/client/slide_spec.rb +18 -23
- data/traitify.gemspec +1 -0
- metadata +44 -34
- data/lib/traitify/assessments.rb +0 -36
- data/lib/traitify/badges.rb +0 -43
- data/lib/traitify/client/users.rb +0 -17
- data/lib/traitify/personality_blends.rb +0 -55
- data/lib/traitify/personality_types.rb +0 -39
- data/lib/traitify/results.rb +0 -31
- data/lib/traitify/slides.rb +0 -95
- data/lib/traitify/users.rb +0 -39
- data/spec/support/mocks/user.json +0 -8
- data/spec/traitify-ruby/client/user_spec.rb +0 -41
data/lib/traitify/assessments.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class Assessment
|
3
|
-
attr_accessor :id, :deck_id, :user_id, :created_at, :completed_at
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
self.id = options[:id]
|
7
|
-
self.deck_id = options[:deck_id]
|
8
|
-
self.user_id = options[:user_id]
|
9
|
-
self.created_at = options[:created_at]
|
10
|
-
self.completed_at = options[:completed_at]
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.parse_json(assessment)
|
14
|
-
created_at = assessment["created_at"] ? Time.at(assessment["created_at"]) : nil
|
15
|
-
completed_at = assessment["completed_at"] ? Time.at(assessment["completed_at"]) : nil
|
16
|
-
|
17
|
-
Assessment.new(
|
18
|
-
id: assessment["id"],
|
19
|
-
deck_id: assessment["deck_id"],
|
20
|
-
user_id: assessment["user_id"],
|
21
|
-
created_at: created_at,
|
22
|
-
completed_at: completed_at
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_hash
|
27
|
-
{
|
28
|
-
id: id,
|
29
|
-
deck_id: deck_id,
|
30
|
-
user_id: user_id,
|
31
|
-
created_at: created_at,
|
32
|
-
completed_at: completed_at
|
33
|
-
}
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
data/lib/traitify/badges.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class Badge
|
3
|
-
attr_accessor :image_small, :image_medium, :image_large, :font_color, :color_1, :color_2, :color_3
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
self.image_small = options[:image_small]
|
7
|
-
self.image_medium = options[:image_medium]
|
8
|
-
self.image_large = options[:image_large]
|
9
|
-
self.font_color = options[:font_color]
|
10
|
-
self.color_1 = options[:color1]
|
11
|
-
self.color_2 = options[:color2]
|
12
|
-
self.color_3 = options[:color3]
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.parse_json(badge)
|
16
|
-
if badge
|
17
|
-
Badge.new(
|
18
|
-
image_small: badge["image_small"],
|
19
|
-
image_medium: badge["image_medium"],
|
20
|
-
image_large: badge["image_large"],
|
21
|
-
font_color: badge["font_color"],
|
22
|
-
color_1: badge["color_1"],
|
23
|
-
color_2: badge["color_2"],
|
24
|
-
color_3: badge["color_3"]
|
25
|
-
)
|
26
|
-
else
|
27
|
-
nil
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_hash
|
32
|
-
{
|
33
|
-
image_small: image_small,
|
34
|
-
image_medium: image_medium,
|
35
|
-
image_large: image_large,
|
36
|
-
font_color: font_color,
|
37
|
-
color_1: color1,
|
38
|
-
color_2: color2,
|
39
|
-
color_3: color3
|
40
|
-
}
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class Client
|
3
|
-
module User
|
4
|
-
def create_user(user_params)
|
5
|
-
response = post("/users", user: user_params)
|
6
|
-
|
7
|
-
Traitify::User.parse_json(response)
|
8
|
-
end
|
9
|
-
|
10
|
-
def find_user(user_id)
|
11
|
-
response = get("/users/#{user_id}")
|
12
|
-
|
13
|
-
Traitify::User.parse_json(response)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class PersonalityBlend
|
3
|
-
attr_accessor :personality_type_1, :personality_type_2, :name, :description, :compliments, :conflicts, :compatible_work_environment_1, :compatible_work_environment_2, :compatible_work_environment_3, :compatible_work_environment_4
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
self.personality_type_1 = options[:personality_type_1]
|
7
|
-
self.personality_type_2 = options[:personality_type_2]
|
8
|
-
self.name = options[:name]
|
9
|
-
self.description = options[:description]
|
10
|
-
self.compliments = options[:compliments]
|
11
|
-
self.conflicts = options[:conflicts]
|
12
|
-
self.compatible_work_environment_1 = options[:compatible_work_environment_1]
|
13
|
-
self.compatible_work_environment_2 = options[:compatible_work_environment_2]
|
14
|
-
self.compatible_work_environment_3 = options[:compatible_work_environment_3]
|
15
|
-
self.compatible_work_environment_4 = options[:compatible_work_environment_4]
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.parse_json(personality_blend)
|
19
|
-
if personality_blend
|
20
|
-
personality_type_1 = PersonalityType.parse_json(personality_blend["personality_type_1"])
|
21
|
-
personality_type_2 = PersonalityType.parse_json(personality_blend["personality_type_2"])
|
22
|
-
|
23
|
-
PersonalityBlend.new(
|
24
|
-
personality_type_1: personality_type_1,
|
25
|
-
personality_type_2: personality_type_2,
|
26
|
-
name: personality_blend["name"],
|
27
|
-
description: personality_blend["description"],
|
28
|
-
compliments: personality_blend["compliments"],
|
29
|
-
conflicts: personality_blend["conflicts"],
|
30
|
-
compatible_work_environment_1: personality_blend["compatible_work_environment_1"],
|
31
|
-
compatible_work_environment_2: personality_blend["compatible_work_environment_2"],
|
32
|
-
compatible_work_environment_3: personality_blend["compatible_work_environment_3"],
|
33
|
-
compatible_work_environment_4: personality_blend["compatible_work_environment_4"]
|
34
|
-
)
|
35
|
-
else
|
36
|
-
nil
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def to_hash
|
41
|
-
{
|
42
|
-
personality_type_1: personality_type_1.to_hash,
|
43
|
-
personality_type_2: personality_type_2.to_hash,
|
44
|
-
name: name,
|
45
|
-
description: description,
|
46
|
-
compliments: compliments,
|
47
|
-
conflicts: conflicts,
|
48
|
-
compatible_work_environment_1: compatible_work_environment_1,
|
49
|
-
compatible_work_environment_2: compatible_work_environment_2,
|
50
|
-
compatible_work_environment_3: compatible_work_environment_3,
|
51
|
-
compatible_work_environment_4: compatible_work_environment_4
|
52
|
-
}
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class PersonalityType
|
3
|
-
attr_accessor :id, :name, :description, :badge, :score
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
self.id = options[:id]
|
7
|
-
self.name = options[:name]
|
8
|
-
self.description = options[:description]
|
9
|
-
self.badge = options[:badge]
|
10
|
-
self.score = options[:score]
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.parse_json(personality_type)
|
14
|
-
if personality_type
|
15
|
-
badge = Badge.parse_json(personality_type["badge"])
|
16
|
-
|
17
|
-
PersonalityType.new(
|
18
|
-
id: personality_type["id"],
|
19
|
-
name: personality_type["name"],
|
20
|
-
description: personality_type["description"],
|
21
|
-
badge: badge,
|
22
|
-
score: personality_type["score"]
|
23
|
-
)
|
24
|
-
else
|
25
|
-
nil
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def to_hash
|
30
|
-
{
|
31
|
-
id: id,
|
32
|
-
name: name,
|
33
|
-
description: description,
|
34
|
-
badge: badge.to_hash,
|
35
|
-
score: score
|
36
|
-
}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/lib/traitify/results.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class Result
|
3
|
-
attr_accessor :personality_blend, :personality_types
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
self.personality_blend = options[:personality_blend]
|
7
|
-
self.personality_types = options[:personality_types]
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.parse_json(result)
|
11
|
-
if result
|
12
|
-
personality_blend = PersonalityBlend.parse_json(result["personality_blend"])
|
13
|
-
personality_types = result["personality_types"].collect { |p| p && p["personality_type"] ? PersonalityType.parse_json(p["personality_type"].merge!("score" => p["score"])) : nil }
|
14
|
-
|
15
|
-
Result.new(
|
16
|
-
personality_blend: personality_blend,
|
17
|
-
personality_types: personality_types
|
18
|
-
)
|
19
|
-
else
|
20
|
-
nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_hash
|
25
|
-
{
|
26
|
-
personality_blend: personality_blend.to_hash,
|
27
|
-
personality_types: personality_types.collect { |p| p.to_hash }
|
28
|
-
}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/lib/traitify/slides.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class Slide
|
3
|
-
attr_accessor :id, :position, :caption, :image_desktop, :image_desktop_retina, :image_phone_landscape, :image_phone_portrait, :response, :time_taken, :completed_at, :created_at
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
self.id = options[:id]
|
7
|
-
self.position = options[:position]
|
8
|
-
self.caption = options[:caption]
|
9
|
-
self.image_desktop = options[:image_desktop]
|
10
|
-
self.image_desktop_retina = options[:image_desktop_retina]
|
11
|
-
self.image_phone_landscape = options[:image_phone_landscape]
|
12
|
-
self.image_phone_portrait = options[:image_phone_portrait]
|
13
|
-
self.response = options[:response]
|
14
|
-
self.time_taken = options[:time_taken]
|
15
|
-
self.completed_at = options[:completed_at]
|
16
|
-
self.created_at = options[:created_at]
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.parse_json(slide)
|
20
|
-
created_at = slide["created_at"] ? Time.at(slide["created_at"]) : nil
|
21
|
-
completed_at = slide["completed_at"] ? Time.at(slide["completed_at"]) : nil
|
22
|
-
|
23
|
-
Slide.new(
|
24
|
-
id: slide["id"],
|
25
|
-
position: slide["position"],
|
26
|
-
caption: slide["caption"],
|
27
|
-
image_desktop: slide["image_desktop"],
|
28
|
-
image_desktop_retina: slide["image_desktop_retina"],
|
29
|
-
image_phone_landscape: slide["image_phone_landscape"],
|
30
|
-
image_phone_portrait: slide["image_phone_portrait"],
|
31
|
-
response: slide["response"],
|
32
|
-
time_taken: slide["time_taken"],
|
33
|
-
completed_at: completed_at,
|
34
|
-
created_at: created_at
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
def to_hash
|
39
|
-
{
|
40
|
-
id: id,
|
41
|
-
position: position,
|
42
|
-
caption: caption,
|
43
|
-
image_desktop: image_desktop,
|
44
|
-
image_desktop_retina: image_desktop_retina,
|
45
|
-
image_phone_landscape: image_phone_landscape,
|
46
|
-
image_phone_portrait: image_phone_portrait,
|
47
|
-
response: response,
|
48
|
-
time_taken: time_taken,
|
49
|
-
completed_at: completed_at,
|
50
|
-
created_at: created_at
|
51
|
-
}
|
52
|
-
end
|
53
|
-
|
54
|
-
def to_update_params
|
55
|
-
{
|
56
|
-
id: id,
|
57
|
-
response: response,
|
58
|
-
time_taken: time_taken
|
59
|
-
}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class Slides
|
64
|
-
attr_accessor :assessment_id, :all
|
65
|
-
|
66
|
-
def initialize(options = {})
|
67
|
-
self.assessment_id = options[:assessment_id]
|
68
|
-
self.all = options[:all]
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.parse_json(assessment_id, slides)
|
72
|
-
Slides.new(
|
73
|
-
assessment_id: assessment_id,
|
74
|
-
all: slides.collect { |slide| Traitify::Slide.parse_json(slide) }
|
75
|
-
)
|
76
|
-
end
|
77
|
-
|
78
|
-
def to_hash
|
79
|
-
{
|
80
|
-
assessment_id: assessment_id,
|
81
|
-
all: all.collect { |slide| slide.to_hash }
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
def to_update_params
|
86
|
-
all.collect { |slide| slide.to_update_params }
|
87
|
-
end
|
88
|
-
|
89
|
-
# Allows slides to forward Array methods to all
|
90
|
-
def method_missing(method, *args)
|
91
|
-
return all.send(method, *args) if all.respond_to?(method)
|
92
|
-
super
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
data/lib/traitify/users.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Traitify
|
2
|
-
class User
|
3
|
-
attr_accessor :id, :first_name, :last_name, :email, :created_at, :updated_at
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
self.id = options[:id]
|
7
|
-
self.first_name = options[:first_name]
|
8
|
-
self.last_name = options[:last_name]
|
9
|
-
self.email = options[:email]
|
10
|
-
self.created_at = options[:created_at]
|
11
|
-
self.updated_at = options[:updated_at]
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.parse_json(user)
|
15
|
-
created_at = user["created_at"] ? Time.at(user["created_at"]) : nil
|
16
|
-
updated_at = user["updated_at"] ? Time.at(user["updated_at"]) : nil
|
17
|
-
|
18
|
-
User.new(
|
19
|
-
id: user["id"],
|
20
|
-
first_name: user["first_name"],
|
21
|
-
last_name: user["last_name"],
|
22
|
-
email: user["email"],
|
23
|
-
created_at: created_at,
|
24
|
-
updated_at: updated_at
|
25
|
-
)
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_hash
|
29
|
-
{
|
30
|
-
id: id,
|
31
|
-
first_name: first_name,
|
32
|
-
last_name: last_name,
|
33
|
-
email: email,
|
34
|
-
created_at: created_at,
|
35
|
-
updated_at: updated_at,
|
36
|
-
}
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Traitify::Client do
|
4
|
-
before do
|
5
|
-
Traitify.configure do |tom|
|
6
|
-
tom.secret = "secret"
|
7
|
-
tom.api_host = "https://example.com"
|
8
|
-
tom.api_version = "v1"
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:tom) { Traitify.new }
|
13
|
-
|
14
|
-
describe ".create_user" do
|
15
|
-
let(:user) { tom.create_user(
|
16
|
-
first_name: "Tom",
|
17
|
-
last_name: "Prats",
|
18
|
-
email: "tom@tomprats.com"
|
19
|
-
)}
|
20
|
-
|
21
|
-
before(:each) do
|
22
|
-
stub_it(:post, "/users", "user")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "returns a user" do
|
26
|
-
expect(user.first_name).to eq("Tom")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe ".find_user" do
|
31
|
-
let(:user) { tom.find_user("toms-uuid") }
|
32
|
-
|
33
|
-
before(:each) do
|
34
|
-
stub_it(:get, "/users/toms-uuid", "user")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "returns a user" do
|
38
|
-
expect(user.id).to eq("toms-uuid")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|