qualtrics_api 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3989bd675ef7fdd3d656332a25415f2531ab8d0d
4
- data.tar.gz: 6ac2c42f3b7243b0a5079eb693c085793b9d7bc2
3
+ metadata.gz: a3bf9143b4c37cceea6b973651341c7d22a51adf
4
+ data.tar.gz: 435d996160fa0f5eb8b8c6c73e30ee9f60c5d006
5
5
  SHA512:
6
- metadata.gz: 99b339083e65224cd22f62bf3aa23ee391e96443b2d8dbf94525e6f81159fd612974babf7f54fcdfa0af97b75604215069b56715e63f41588ecab7c578889979
7
- data.tar.gz: d70be5772c5612bbab692aafc34a150a971a6dbfd6f25e50eb63fd2549a345649c6d70760a697cb76434aac58d9c4c6c7ad4692682bf94ef745e1f82852dce94
6
+ metadata.gz: 3aa43a3d8216203905e042156a272cccc79dac959c3a690529ffa4d8e1eab61552aab8cc28adbbcf15204c59296623a432e5eb0bc6eae784ec25e21db6f1bc34
7
+ data.tar.gz: 66d4225b2e86180e52102b3bfba52392b2a3c0c53a036e02a64c47d9bc24b60f9f811d69cac14bb76b83fee342655aa801f2b0bb854a4e82658b7e32ca85d760
@@ -1,10 +1,11 @@
1
1
  module QualtricsAPI
2
2
  class Panel < BaseModel
3
-
4
- attribute :id, String
5
- attribute :library_id, String
6
- attribute :name, String
7
- attribute :category, String
3
+ values do
4
+ attribute :id, String
5
+ attribute :library_id, String
6
+ attribute :name, String
7
+ attribute :category, String
8
+ end
8
9
 
9
10
  def members(options = {})
10
11
  @members ||= QualtricsAPI::PanelMemberCollection.new(options.merge(id: id))
@@ -5,7 +5,9 @@ module QualtricsAPI
5
5
  include Virtus.value_object
6
6
  include QualtricsAPI::Extensions::SerializableCollection
7
7
 
8
- attribute :all, Array, :default => []
8
+ values do
9
+ attribute :all, Array, :default => []
10
+ end
9
11
 
10
12
  def_delegator :all, :each
11
13
  def_delegator :all, :size
@@ -2,8 +2,10 @@ module QualtricsAPI
2
2
  class PanelImport
3
3
  include Virtus.value_object
4
4
 
5
- attribute :id, String
6
- attribute :panel_id, String
5
+ values do
6
+ attribute :id, String
7
+ attribute :panel_id, String
8
+ end
7
9
 
8
10
  def update_status
9
11
  res = QualtricsAPI.connection.get("panels/#{panel_id}/members/panelImports/#{id}").body["result"]
@@ -1,13 +1,15 @@
1
1
  module QualtricsAPI
2
2
  class PanelMember < BaseModel
3
- attribute :id, String
4
- attribute :first_name, String
5
- attribute :last_name, String
6
- attribute :email, String
7
- attribute :language, String
8
- attribute :unsubscribed, Integer
9
- attribute :external_reference, String
10
- attribute :embeded_data, Hash
3
+ values do
4
+ attribute :id, String
5
+ attribute :first_name, String
6
+ attribute :last_name, String
7
+ attribute :email, String
8
+ attribute :language, String
9
+ attribute :unsubscribed, Integer
10
+ attribute :external_reference, String
11
+ attribute :embeded_data, Hash
12
+ end
11
13
 
12
14
  def to_json(_options = {})
13
15
  attributes.to_json
@@ -16,23 +18,30 @@ module QualtricsAPI
16
18
  alias_method :super_attributes, :attributes
17
19
 
18
20
  def attributes
19
- Hash[super_attributes.map { |k, v| [mapped_and_uppercased_attribute(k), v] }].delete_if { |_k, v| v.nil? }
21
+ Hash[super_attributes.map { |k, v| [attributes_for_save[k], v] }].delete_if { |_k, v| v.nil? }
20
22
  end
21
23
 
22
24
  private
23
25
 
24
- def mapped_and_uppercased_attribute(attribute)
25
- (attributes_mappings[attribute] || attribute).to_s.tap do |a|
26
- a[0] = a[0].upcase
27
- end
26
+ def attributes_for_save
27
+ {
28
+ :id => "RecipientID",
29
+ :first_name => "FirstName",
30
+ :last_name => "LastName",
31
+ :email => "Email",
32
+ :language => "Language",
33
+ :unsubscribed => 'Unsubscribed',
34
+ :external_reference => "ExternalReference",
35
+ :embeded_data => "EmbeddedData"
36
+ }
28
37
  end
29
38
 
30
39
  def attributes_mappings
31
40
  {
32
- :id => "recipientID",
41
+ :id => "panelMemberId",
33
42
  :first_name => "firstName",
34
43
  :last_name => "lastName",
35
- :external_reference => "externalReference",
44
+ :external_reference => "externalDataReference",
36
45
  :embeded_data => "embeddedData"
37
46
  }
38
47
  end
@@ -4,8 +4,10 @@ module QualtricsAPI
4
4
  include Enumerable
5
5
  include Virtus.value_object
6
6
 
7
- attribute :id, String
8
- attribute :all, Array, :default => []
7
+ values do
8
+ attribute :id, String
9
+ attribute :all, Array, :default => []
10
+ end
9
11
 
10
12
  def_delegator :all, :each
11
13
  def_delegator :all, :size
@@ -2,7 +2,9 @@ module QualtricsAPI
2
2
  class ResponseExport
3
3
  include Virtus.value_object
4
4
 
5
- attribute :id, String
5
+ values do
6
+ attribute :id, String
7
+ end
6
8
 
7
9
  def update_status
8
10
  res = QualtricsAPI.connection.get('surveys/responseExports/' + id).body["result"]
@@ -4,7 +4,9 @@ module QualtricsAPI
4
4
  include Enumerable
5
5
  include Virtus.value_object
6
6
 
7
- attribute :all, Array, :default => []
7
+ values do
8
+ attribute :all, Array, :default => []
9
+ end
8
10
 
9
11
  def_delegator :all, :each
10
12
  def_delegator :all, :size
@@ -1,12 +1,13 @@
1
1
  module QualtricsAPI
2
2
  class Survey < BaseModel
3
-
4
- attribute :id, String
5
- attribute :name, String
6
- attribute :owner_id, String
7
- attribute :last_modified, String
8
- attribute :created_at, String
9
- attribute :status, String
3
+ values do
4
+ attribute :id, String
5
+ attribute :name, String
6
+ attribute :owner_id, String
7
+ attribute :last_modified, String
8
+ attribute :created_at, String
9
+ attribute :status, String
10
+ end
10
11
 
11
12
  def export_responses(export_options = {})
12
13
  QualtricsAPI::Services::ResponseExportService.new(export_options.merge(survey_id: id))
@@ -4,8 +4,10 @@ module QualtricsAPI
4
4
  include Enumerable
5
5
  include Virtus.value_object
6
6
 
7
- attribute :scope_id, String
8
- attribute :all, Array, :default => []
7
+ values do
8
+ attribute :scope_id, String
9
+ attribute :all, Array, :default => []
10
+ end
9
11
 
10
12
  attr_writer :scope_id
11
13
 
@@ -1,3 +1,3 @@
1
1
  module QualtricsAPI
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -57,4 +57,19 @@ describe QualtricsAPI::PanelCollection do
57
57
  end
58
58
  end
59
59
  end
60
+
61
+ describe 'equality' do
62
+ subject { described_class.new(all: [QualtricsAPI::Panel.new("panelId" => "p1"), QualtricsAPI::Panel.new("panelId" => "p2")]) }
63
+ context 'when same' do
64
+ it 'returns true' do
65
+ expect(subject).to eq(described_class.new(all: subject.all))
66
+ end
67
+ end
68
+
69
+ context 'when different' do
70
+ it 'returns false' do
71
+ expect(subject).not_to eq(described_class.new)
72
+ end
73
+ end
74
+ end
60
75
  end
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe QualtricsAPI::PanelImport do
4
- describe "integration" do
5
- subject { described_class.new(id: 'PGRS_bEJLYLkqMBs8Bwx', panel_id: 'ML_bC2c5xBz1DxyOYB') }
4
+ subject { described_class.new(id: 'PGRS_bEJLYLkqMBs8Bwx', panel_id: 'ML_bC2c5xBz1DxyOYB') }
6
5
 
6
+ describe "integration" do
7
7
  describe "#update_status" do
8
8
  let(:result) do
9
9
  VCR.use_cassette('panel_import_update_success') do
@@ -24,4 +24,18 @@ describe QualtricsAPI::PanelImport do
24
24
  end
25
25
  end
26
26
  end
27
+
28
+ describe 'equality' do
29
+ context 'when same' do
30
+ it 'returns true' do
31
+ expect(subject).to eq(described_class.new(subject.attributes))
32
+ end
33
+ end
34
+
35
+ context 'when different' do
36
+ it 'returns false' do
37
+ expect(subject).not_to eq(described_class.new)
38
+ end
39
+ end
40
+ end
27
41
  end
@@ -6,8 +6,8 @@ describe QualtricsAPI::PanelMemberCollection do
6
6
  end
7
7
 
8
8
  describe "#find, #[]" do
9
- let(:panel_member_1) { QualtricsAPI::PanelMember.new("recipientID" => "p1") }
10
- let(:panel_member_2) { QualtricsAPI::PanelMember.new("recipientID" => "p2") }
9
+ let(:panel_member_1) { QualtricsAPI::PanelMember.new("panelMemberId" => "p1") }
10
+ let(:panel_member_2) { QualtricsAPI::PanelMember.new("panelMemberId" => "p2") }
11
11
 
12
12
  it "finds the panel member by id" do
13
13
  subject.instance_variable_set :@all, [panel_member_1, panel_member_2]
@@ -93,4 +93,19 @@ describe QualtricsAPI::PanelMemberCollection do
93
93
  end
94
94
  end
95
95
  end
96
+
97
+ describe 'equality' do
98
+ subject { described_class.new(all: [QualtricsAPI::PanelMember.new("recipientID" => "p1"), QualtricsAPI::PanelMember.new("recipientID" => "p1")]) }
99
+ context 'when same' do
100
+ it 'returns true' do
101
+ expect(subject).to eq(described_class.new(all: subject.all))
102
+ end
103
+ end
104
+
105
+ context 'when different' do
106
+ it 'returns false' do
107
+ expect(subject).not_to eq(described_class.new)
108
+ end
109
+ end
110
+ end
96
111
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe QualtricsAPI::PanelMember do
4
4
  let(:panel_member) do
5
5
  {
6
- "recipientID" => "ML_abcdefg",
6
+ "panelMemberId" => "ML_abcdefg",
7
7
  "firstName" => "Thom",
8
8
  "lastName" => "Yorke",
9
9
  "email" => "thom@radiohead.com",
@@ -17,7 +17,7 @@ describe QualtricsAPI::PanelMember do
17
17
  subject { described_class.new panel_member }
18
18
 
19
19
  it "has a panel member id" do
20
- expect(subject.id).to eq(panel_member["recipientID"])
20
+ expect(subject.id).to eq(panel_member["panelMemberId"])
21
21
  end
22
22
 
23
23
  it "has a first name" do
@@ -41,7 +41,7 @@ describe QualtricsAPI::PanelMember do
41
41
  end
42
42
 
43
43
  it "has external data reference" do
44
- expect(subject.external_reference).to eq(panel_member["externalReference"])
44
+ expect(subject.external_reference).to eq(panel_member["externalDataReference"])
45
45
  end
46
46
 
47
47
  it "has embedded data" do
@@ -49,7 +49,21 @@ describe QualtricsAPI::PanelMember do
49
49
  end
50
50
 
51
51
  context "#to_json" do
52
+ let(:panel_member) do
53
+ {
54
+ "panelMemberId" => "ML_abcdefg",
55
+ "firstName" => "Thom",
56
+ "lastName" => "Yorke",
57
+ "email" => "thom@radiohead.com",
58
+ "language" => "EN",
59
+ "unsubscribed" => 1,
60
+ "externalDataReference" => "1234",
61
+ "embeddedData" => { "a" => "b", "b" => "c" }
62
+ }
63
+ end
64
+
52
65
  let(:members) { [subject].to_json }
66
+
53
67
  it "serialize array of panel members" do
54
68
  expect(JSON.parse(members)).to eq(
55
69
  [{ "RecipientID" => "ML_abcdefg",
@@ -62,4 +76,18 @@ describe QualtricsAPI::PanelMember do
62
76
  "EmbeddedData" => { "a" => "b", "b" => "c" } }])
63
77
  end
64
78
  end
79
+
80
+ describe 'equality' do
81
+ context 'when same' do
82
+ it 'returns true' do
83
+ expect(subject).to eq(described_class.new(panel_member))
84
+ end
85
+ end
86
+
87
+ context 'when different' do
88
+ it 'returns false' do
89
+ expect(subject).not_to eq(described_class.new)
90
+ end
91
+ end
92
+ end
65
93
  end
@@ -41,4 +41,18 @@ describe QualtricsAPI::Panel do
41
41
  expect(subject.members.object_id).to eq subject.members.object_id
42
42
  end
43
43
  end
44
+
45
+ describe 'equality' do
46
+ context 'when same' do
47
+ it 'returns true' do
48
+ expect(subject).to eq(described_class.new(subject.attributes))
49
+ end
50
+ end
51
+
52
+ context 'when different' do
53
+ it 'returns false' do
54
+ expect(subject).not_to eq(described_class.new)
55
+ end
56
+ end
57
+ end
44
58
  end
@@ -21,4 +21,19 @@ describe QualtricsAPI::ResponseExportCollection do
21
21
  expect(sut.id).to eq "eee 3"
22
22
  end
23
23
  end
24
+
25
+ describe 'equality' do
26
+ subject { described_class.new(all: [QualtricsAPI::ResponseExport.new(:id => "export1"), QualtricsAPI::ResponseExport.new(:id => "export2")]) }
27
+ context 'when same' do
28
+ it 'returns true' do
29
+ expect(subject).to eq(described_class.new(all: subject.all))
30
+ end
31
+ end
32
+
33
+ context 'when different' do
34
+ it 'returns false' do
35
+ expect(subject).not_to eq(described_class.new)
36
+ end
37
+ end
38
+ end
24
39
  end
@@ -87,4 +87,18 @@ describe QualtricsAPI::ResponseExport do
87
87
  end
88
88
  end
89
89
  end
90
+
91
+ describe 'equality' do
92
+ context 'when same' do
93
+ it 'returns true' do
94
+ expect(subject).to eq(described_class.new(subject.attributes))
95
+ end
96
+ end
97
+
98
+ context 'when different' do
99
+ it 'returns false' do
100
+ expect(subject).not_to eq(described_class.new)
101
+ end
102
+ end
103
+ end
90
104
  end
@@ -86,4 +86,19 @@ describe QualtricsAPI::SurveyCollection do
86
86
  end
87
87
  end
88
88
  end
89
+
90
+ describe 'equality' do
91
+ subject { described_class.new(all: [QualtricsAPI::Survey.new("id" => "s1"), QualtricsAPI::Survey.new("id" => "s2")]) }
92
+ context 'when same' do
93
+ it 'returns true' do
94
+ expect(subject).to eq(described_class.new(all: subject.all))
95
+ end
96
+ end
97
+
98
+ context 'when different' do
99
+ it 'returns false' do
100
+ expect(subject).not_to eq(described_class.new)
101
+ end
102
+ end
103
+ end
89
104
  end
@@ -52,4 +52,18 @@ describe QualtricsAPI::Survey do
52
52
  subject.export_responses(options)
53
53
  end
54
54
  end
55
+
56
+ describe 'equality' do
57
+ context 'when same' do
58
+ it 'returns true' do
59
+ expect(subject).to eq(described_class.new(subject.attributes))
60
+ end
61
+ end
62
+
63
+ context 'when different' do
64
+ it 'returns false' do
65
+ expect(subject).not_to eq(described_class.new)
66
+ end
67
+ end
68
+ end
55
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qualtrics_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yurui Zhang
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-07-29 00:00:00.000000000 Z
13
+ date: 2015-08-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday