dalia_api_survey_platform 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rvmrc +1 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +18 -0
  7. data/Rakefile +11 -0
  8. data/dalia_api_survey_platform.gemspec +28 -0
  9. data/etc/fake_responses/create_query.json +23 -0
  10. data/etc/fake_responses/fetch_completion.json +17 -0
  11. data/etc/fake_responses/fetch_completions.csv +8 -0
  12. data/etc/fake_responses/fetch_completions.json +49 -0
  13. data/etc/fake_responses/fetch_survey.json +65 -0
  14. data/etc/fake_responses/fetch_survey_price.json +115 -0
  15. data/etc/fake_responses/fetch_surveys.json +56 -0
  16. data/etc/fake_responses/send_survey.json +24 -0
  17. data/etc/fake_responses/update_survey.json +23 -0
  18. data/lib/dalia_api_survey_platform.rb +15 -0
  19. data/lib/dalia_api_survey_platform/client.rb +136 -0
  20. data/lib/dalia_api_survey_platform/exception.rb +2 -0
  21. data/lib/dalia_api_survey_platform/http_client.rb +4 -0
  22. data/lib/dalia_api_survey_platform/json_extension.rb +5 -0
  23. data/lib/dalia_api_survey_platform/log.rb +41 -0
  24. data/lib/dalia_api_survey_platform/mock_client.rb +79 -0
  25. data/lib/dalia_api_survey_platform/version.rb +7 -0
  26. data/test/client_test.rb +138 -0
  27. data/test/fixtures/fake_responses/create_query.json +23 -0
  28. data/test/fixtures/fake_responses/fetch_completion.json +10 -0
  29. data/test/fixtures/fake_responses/fetch_completions.csv +8 -0
  30. data/test/fixtures/fake_responses/fetch_completions.json +28 -0
  31. data/test/fixtures/fake_responses/fetch_survey.json +64 -0
  32. data/test/fixtures/fake_responses/fetch_survey_price.json +115 -0
  33. data/test/fixtures/fake_responses/fetch_surveys.json +56 -0
  34. data/test/fixtures/fake_responses/send_survey.json +23 -0
  35. data/test/mock_client_test.rb +63 -0
  36. data/test/test_helper.rb +11 -0
  37. metadata +174 -0
@@ -0,0 +1,23 @@
1
+ {
2
+ "question_id": "Qb5faf2",
3
+ "question_title": "What is your immediate reaction to the advertisement?",
4
+ "question_kind": "multiple_sole",
5
+ "values": [
6
+ {
7
+ "value": "Rather boring",
8
+ "frequency": 9
9
+ },
10
+ {
11
+ "value": "Don’t know",
12
+ "frequency": 6
13
+ },
14
+ {
15
+ "value": "Somewhat confusing",
16
+ "frequency": 8
17
+ },
18
+ {
19
+ "value": "I found it interesting",
20
+ "frequency": 11
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "completion": {
3
+ "id": "C001",
4
+ "survey_id": "S002",
5
+ "state": "completed",
6
+ "prequalification_fail_at": null,
7
+ "completed_at": "2013-10-01 10:11:12",
8
+ "data": {}
9
+ }
10
+ }
@@ -0,0 +1,8 @@
1
+ "[dem] annual_income","[dem] birth_year","[dem] city_name","[dem] city_name_2","[dem] country_code","[dem] country_code_2","[dem] device_kind","[dem] device_platform","[dem] device_version","[dem] education_level","[dem] gender","[dem] hispanic_background","[dem] household_income","[dem] ip","[dem] latitude","[dem] latitude_2","[dem] longitude","[dem] longitude_2","[dem] postal_code","[dem] postal_code_2","[dem] publisher_user_id","[dem] region_iso_code_2","[dem] region_name","[dem] region_name_2","[dem] traits","[dem] user_agent","[meta] Completed at","[meta] Created at","[meta] Duration","[meta] ID","[meta] PanelUser ID","[meta] PanelUser ID kind","[meta] Publisher ID","[meta] State","[meta] Survey ID","[question][CS00020][OPTION_ID]","[question][CS00020][VALUE]","[question][CS00130][OPTION_ID]","[question][CS00130][VALUE]","[question][CS00150][OPTION_ID]","[question][CS00150][VALUE]","[question][CS00240][OPTION_ID]","[question][CS00240][VALUE]","[question][CS00290][OPTION_ID]","[question][CS00290][VALUE]","[question][CS00310][OPTION_ID]","[question][CS00310][VALUE]","[question][CS00340][OPTION_ID]","[question][CS00340][VALUE]","[question][CS00360][OPTION_ID]","[question][CS00360][VALUE]","[question][CS00420][OPTION_ID]","[question][CS00420][VALUE]","[question][CS00440][OPTION_ID]","[question][CS00440][VALUE]","[question][CS00450][OPTION_ID]","[question][CS00450][VALUE]","[question][CS00470][OPTION_ID]","[question][CS00470][VALUE]","[question][CS00480][OPTION_ID]","[question][CS00480][VALUE]","[question][CS00490][OPTION_ID]","[question][CS00490][VALUE]","[question][CS00500][OPTION_ID]","[question][CS00500][VALUE]","[question][CS00505][OPTION_ID]","[question][CS00505][VALUE]","[question][CS00510][OPTION_ID]","[question][CS00510][VALUE]","[question][CS00520][OPTION_ID]","[question][CS00520][VALUE]","[question][CS00530][OPTION_ID]","[question][CS00530][VALUE]","[question][CS00540][OPTION_ID]","[question][CS00540][VALUE]","[question][CS00550][OPTION_ID]","[question][CS00550][VALUE]","[question][CS00600][OPTION_ID]","[question][CS00600][VALUE]","[question][CS00610][OPTION_ID]","[question][CS00610][VALUE]","[question][CS00620][OPTION_ID]","[question][CS00620][VALUE]","[question][CS00650][OPTION_ID]","[question][CS00650][VALUE]","[question][CS00700][OPTION_ID]","[question][CS00700][VALUE]","[question][CS00740][OPTION_ID]","[question][CS00740][VALUE]","[question][CS00760][OPTION_ID]","[question][CS00760][VALUE]","[question][CS00770][OPTION_ID]","[question][CS00770][VALUE]","[question][CS00780][OPTION_ID]","[question][CS00780][VALUE]","[question][CS00800][OPTION_ID]","[question][CS00800][VALUE]","[question][CS00805][OPTION_ID]","[question][CS00805][VALUE]","[question][CS00810][OPTION_ID]","[question][CS00810][VALUE]","[question][CS00820][OPTION_ID]","[question][CS00820][VALUE]","[question][CS00830][OPTION_ID]","[question][CS00830][VALUE]","[question][CS00850][OPTION_ID]","[question][CS00850][VALUE]","[question][CS00860][OPTION_ID]","[question][CS00860][VALUE]","[question][CS00940][OPTION_ID]","[question][CS00940][VALUE]","[question][CS00950][OPTION_ID]","[question][CS00950][VALUE]","[question][CS00960][OPTION_ID]","[question][CS00960][VALUE]","[question][CS00970][OPTION_ID]","[question][CS00970][VALUE]","[question][CS00980][OPTION_ID]","[question][CS00980][VALUE]","[question][CS00990][OPTION_ID]","[question][CS00990][VALUE]","[question][CS01000][OPTION_ID]","[question][CS01000][VALUE]","[question][CS01010][OPTION_ID]","[question][CS01010][VALUE]","[question][CS01020][OPTION_ID]","[question][CS01020][VALUE]","[question][CS01030][OPTION_ID]","[question][CS01030][VALUE]","[question][CS01040][OPTION_ID]","[question][CS01040][VALUE]","[question][CS01050][OPTION_ID]","[question][CS01050][VALUE]","[trap] car_owner","[trap] gender","[trap] has_children","[trap] is_attentive","[trap] total_score","[trap] younger_39"
2
+ "","","","","","","","","","","","","","","","","","","","","","","","","","","","2014-07-18 11:25:01","","281349","02ce9ec0-f09c-0131-be1e-0a81e8b09a82","PublisherPluginUser","2","pending","81","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
3
+ "very_high","1997","Red Bank","","US","","mobile","android","4","no","male","no","very_high","96.240.11.45","40.360299999999995","","-74.0728","","07701","","3","","New Jersey","","","Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; T-Mobile myTouch Build/HuaweiU8680) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1","2014-07-18 12:54:59","2014-07-18 12:50:51","248","281399","e83e76c0-f0a7-0131-bfc8-0a81e8b09a82","PublisherPluginUser","2","completed","81","O0050","There are more than four people in the household","O0050","more than $ 8801","O0030","No","O0010","I don’t have a formal education","O0010","It was very good","O0020","Yes, Qatar is the right place for the World Cup","O0010","Only physical books","O0030","More than 20","O0020","Between 3 and 5 minutes","","","O0010","I always answer all questions honestly in a survey","O0020 | O0090 | O0080","CNN | Twitter | Facebook","O0040","Disagree","O0010","""We need to innovate more, do things differently and embrace change now, even if this is difficult. I’m ready to make the effort.""","O0050","Strongly disagree","O0030","... institutional factors (for example, some countries have better laws and political and economic arrangements).","O0010","For the most part, YES.","O0010","For the most part, YES.","O0020","... a fairly positive effect on our way of life","O0050","Not at all important","O0010","Yes, I agree","O0010","Very favorable/positive","O0010","Very favorable/positive","O0010","Very favorable/positive","O0020","Laptop computer","O0040 | O0030 | O0060","Infectious diseases | Economic or financial crises | Organized crime","O0020 | O0030","Apps of cooking magazines | Communities/ Forums of cooking magazines","O0020","If a survey is short, interesting and meaningful, I would complete it without a reward","","it was gear","","","O0040 | O0010 | O0050 | O0070 | O0030","WWF | Unicef | Greenpeace | Red Cross / Red Crescent | Save the Children","O0040","WWF","O0040","TLC","O0030","Politics and diplomacy","O0010","BMW","O0040","I believe in God, and my belief in God influences my behavior somewhat","O0010 | O0110 | O0080 | O0060","Improving housing conditions | Improving work-life balance | Improving healthcare | Protecting the environment","Oyes","Yes","Ono","No","Ono","No","Ono","No","Ono","No","Ono","No","Oyes","Yes","Ono","No","Ono","No","Oyes","Yes","Ono","No","Ono","No","0","2","0","1","0","0"
4
+ "","1998","Chicago","","US","","mobile","android","4","low","female","yes","","66.87.76.249","41.849999999999994","","-87.65","","","","3","","Illinois","","","Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; SPH-L710 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","2014-07-18 13:00:26","2014-07-18 12:53:29","417","281429","4c43ab90-f0a8-0131-bffe-0a81e8b09a82","PublisherPluginUser","2","completed","81","O0040","There are four of us in the household","O0060","I’d prefer not to answer this question","O0010","Yes","O0020","I have some high school or secondary school education","O0010","It was very good","O0010","No, Qatar is not the right place for the World Cup","O0010","Only physical books","O0040","None/does not apply","O0020","Between 3 and 5 minutes","","","O0010","I always answer all questions honestly in a survey","O0020 | O0030 | O0040","CNN | BBC News | New York Times","O0010","Strongly agree","O0010","""We need to innovate more, do things differently and embrace change now, even if this is difficult. I’m ready to make the effort.""","O0030","Undecided","O0020","... cultural factors (for example, some countries have a better work ethic).","O0010","For the most part, YES.","O0010","For the most part, YES.","O0010","... a very positive effect on our way of life","O0010","Extremely important","O0020","No, I don't agree","O0020","Somewhat favorable/positive","O0020","Somewhat favorable/positive","O0020","Somewhat favorable/positive","O0040","Mobile phone","O0010 | O0020 | O0070","Environmental degradation and climate change | International conflicts and wars | Poverty and malnutrition","O0040 | O0050","Cooking Books | TV Shows","O0030","I’m really interested about what other people answered to this survey","","i think it's perfect already","","","O0040 | O0050 | O0070 | O0030 | O0010","WWF | Greenpeace | Red Cross / Red Crescent | Save the Children | Unicef","O0040 | O0030 | O0050 | O0070","WWF | Save the Children | Greenpeace | Red Cross / Red Crescent","O0030 | O0020 | O0040 | O0010 | O0060 | O0050","History Channel | National Geographic Channel | TLC | Discovery Channel | NatGeo WILD | Animal Planet","O0050","I don't know very well what the European Union is or does.","O0050","Porsche","O0040","I believe in God, and my belief in God influences my behavior somewhat","O0090 | O0100 | O0050 | O0060","Increasing public happiness | Reducing crime | Improving education | Protecting the environment","Ono","No","Ono","No","Ono","No","Oyes","Yes","Ono","No","Ono","No","Oyes","Yes","Oyes","Yes","Oyes","Yes","Ono","No","Ono","No","Ono","No","0","2","0","1","0","0"
5
+ "medium_low","1973","Knoxville","","US","","mobile","android","4","medium","male","no","low","174.237.9.71","35.9606","","-83.9207","","","","3","","Tennessee","","","Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; LG-L38C Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MMS/LG-Android-MMS-V1.0/1.2","2014-07-18 13:05:18","2014-07-18 12:54:36","642","281445","32778cc0-f0a8-0131-bfed-0a81e8b09a82","PublisherPluginUser","2","completed","81","O0050","There are more than four people in the household","O0020","$ 1701 - $ 3300","O0010","Yes","O0030","I completed high school or obtained an equivalent diploma","O0030","It was ok","O0030","I don't have a strong opinion on this.","O0060","I haven’t read any books","O0010","Less than 5","O0040","Between 8 and 12 minutes","","","O0020","I usually try to be as honest as possible in surveys","O0020 | O0030 | O0080","CNN | BBC News | Facebook","O0020","Agree","O0010","""We need to innovate more, do things differently and embrace change now, even if this is difficult. I’m ready to make the effort.""","O0020","Agree","O0030 | O0040","... institutional factors (for example, some countries have better laws and political and economic arrangements). | ... leadership (for example, some countries have smarter, more enlightened or more honest leaders).","O0010","For the most part, YES.","O0020","For the most part, NO.","O0050","... a very negative effect on our way of life","O0030","Moderately important","O0020","No, I don't agree","O0030","Somewhat unfavorable/negative","O0020","Somewhat favorable/positive","O0030","Somewhat unfavorable/negative","O0040","Mobile phone","O0020 | O0050 | O0080","International conflicts and wars | Terrorism | Weapons of mass destruction","O0070","None of these","O0020","If a survey is short, interesting and meaningful, I would complete it without a reward","","shorter","","","O0010 | O0050 | O0070","Unicef | Greenpeace | Red Cross / Red Crescent","O0070 | O0050","Red Cross / Red Crescent | Greenpeace","O0020 | O0060 | O0040 | O0030 | O0050 | O0010","National Geographic Channel | NatGeo WILD | TLC | History Channel | Animal Planet | Discovery Channel","O0030","Politics and diplomacy","O0020","Mercedes-Benz","O0060","I would rather not answer this question.","O0020 | O0030 | O0070 | O0050","Increasing household income | Reducing unemployment | Improving politics | Improving education","Oyes","Yes","Oyes","Yes","Ono","No","Oyes","Yes","Ono","No","Ono","No","Ono","No","Oyes","Yes","Ono","No","Ono","No","Oyes","Yes","Ono","No","0","2","0","1","0","1"
6
+ "","1994","Pittsburgh","","US","","mobile","iphone","7","medium","female","no","","71.126.43.26","40.44059999999999","","-79.9959","","","","3","","Pennsylvania","","","Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53","2014-07-18 13:11:35","2014-07-18 13:04:38","417","281530","b81156f0-f0a9-0131-c0d4-0a81e8b09a82","PublisherPluginUser","2","completed","81","O0010","I live alone","O0060","I’d prefer not to answer this question","O0020","Maybe","O0030","I completed high school or obtained an equivalent diploma","O0030","It was ok","O0010","No, Qatar is not the right place for the World Cup","O0040","Mostly eBooks","O0020","Between 5 and 20","O0070","Don't know","","","O0020","I usually try to be as honest as possible in surveys","O0090 | O0060 | O0020","Twitter | Yahoo News | CNN","O0030","Undecided","O0020","""Changes are for the next generation and for future jobs. I'm personally NOT ready to make an effort now.""","O0030","Undecided","O0030","... institutional factors (for example, some countries have better laws and political and economic arrangements).","O0020","For the most part, NO.","O0030","There will not be much change.","O0030","... no effect on our way of life","O0020","Very important","O0020","No, I don't agree","O0020","Somewhat favorable/positive","O0010","Very favorable/positive","O0040","Very unfavorable/negative","O0020","Laptop computer","O0030 | O0080 | O0020","Economic or financial crises | Weapons of mass destruction | International conflicts and wars","O0060","Other","O0020","If a survey is short, interesting and meaningful, I would complete it without a reward","","It needs to be a tad shorter","","","O0030","Save the Children","O0010","Unicef","O0040","TLC","O0060","None of the above.","O0030","Volkswagen","O0060","I would rather not answer this question.","O0010 | O0070 | O0100 | O0090","Improving housing conditions | Improving politics | Reducing crime | Increasing public happiness","Ono","No","Ono","No","Oyes","Yes","Ono","No","Ono","No","Ono","No","Ono","No","Ono","No","Ono","No","Ono","No","Ono","No","Ono","No","0","2","0","1","0","0"
7
+ "","","","","","","","","","","","","","","","","","","","","","","","","","","","2014-07-18 13:04:49","","281531","bdfdc980-f0a9-0131-c0da-0a81e8b09a82","PublisherPluginUser","2","pending","81","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","",""
8
+ "medium_low","1952","Van Buren","","US","","mobile","android","4","high","female","no","low","184.180.251.47","35.483000000000004","","-94.3469","","72956","","3","","Arkansas","","","Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; Z750C Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30","2014-07-18 13:29:29","2014-07-18 13:08:48","1241","281579","3c743350-f0aa-0131-c128-0a81e8b09a82","PublisherPluginUser","2","completed","81","O0030","There are three of us in the household","O0020","$ 1701 - $ 3300","O0030","No","O0040","I have completed a university or equivalent degree","O0020","It was good","O0030","I don't have a strong opinion on this.","O0040","Mostly eBooks","O0040","None/does not apply","O0040","Between 8 and 12 minutes","","","O0020","I usually try to be as honest as possible in surveys","O0050 | O0020 | O0060","Huffington Post | CNN | Yahoo News","O0020","Agree","O0010","""We need to innovate more, do things differently and embrace change now, even if this is difficult. I’m ready to make the effort.""","O0020","Agree","O0030","... institutional factors (for example, some countries have better laws and political and economic arrangements).","O0010","For the most part, YES.","O0010","For the most part, YES.","O0010","... a very positive effect on our way of life","O0020","Very important","O0020","No, I don't agree","O0010","Very favorable/positive","O0020","Somewhat favorable/positive","O0030","Somewhat unfavorable/negative","O0010","Desktop computer","O0010 | O0020 | O0050","Environmental degradation and climate change | International conflicts and wars | Terrorism","O0060","Other","O0060","I am a human and I'm currently doing a survey","","it was different from other surveys and i enjoyed it. just because it made me think about my answers.","","","O0010 | O0030 | O0050 | O0060 | O0070","Unicef | Save the Children | Greenpeace | Amnesty International | Red Cross / Red Crescent","O0030 | O0010 | O0050","Save the Children | Unicef | Greenpeace","O0010 | O0030 | O0050","Discovery Channel | History Channel | Animal Planet","O0050","I don't know very well what the European Union is or does.","O0020","Mercedes-Benz","O0050","I believe in God, and my belief in God influences my behavior very much","O0060 | O0050 | O0080 | O0030","Protecting the environment | Improving education | Improving healthcare | Reducing unemployment","Ono","No","Oyes","Yes","Ono","No","Oyes","Yes","Ono","No","Ono","No","Ono","No","Ono","No","Oyes","Yes","Ono","No","Ono","No","Ono","No","0","2","0","1","0","1"
@@ -0,0 +1,28 @@
1
+ {
2
+ "completions": [
3
+ {
4
+ "id": "C001",
5
+ "survey_id": "S002",
6
+ "state": "completed",
7
+ "prequalification_fail_at": null,
8
+ "completed_at": "2013-10-01 10:11:12",
9
+ "data": {}
10
+ },
11
+ {
12
+ "id": "C002",
13
+ "survey_id": "S002",
14
+ "state": "completed",
15
+ "prequalification_fail_at": null,
16
+ "completed_at": "2013-10-01 10:11:12",
17
+ "data": {}
18
+ },
19
+ {
20
+ "id": "C003",
21
+ "survey_id": "S002",
22
+ "state": "completed",
23
+ "prequalification_fail_at": null,
24
+ "completed_at": "2013-10-01 10:11:12",
25
+ "data": {}
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,64 @@
1
+ {
2
+ "devive_id": "XXX1",
3
+ "survey": {
4
+ "id": "001",
5
+ "title": "The survey 001",
6
+ "tagline": "This is the tagline",
7
+ "kind": "mr_survey",
8
+ "published": false,
9
+ "credits": {
10
+ "kind": "stars",
11
+ "amount": "10"
12
+ },
13
+ "questions": [
14
+ {
15
+ "id": "Q32d04b",
16
+ "kind": "multiple_sole",
17
+ "title": "Fill the question",
18
+ "body": {
19
+ "options": [
20
+ {
21
+ "text": "New option 1",
22
+ "branch_to": "Qb006c2"
23
+ },
24
+ {
25
+ "text": "New option 2",
26
+ "branch_to": ""
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "id": "Qc8e3a0",
33
+ "kind": "multiple",
34
+ "title": "Fill the question",
35
+ "body": {
36
+ "options": [
37
+ {
38
+ "text": "New option 1"
39
+ },
40
+ {
41
+ "text": "New option 2"
42
+ }
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "id": "Qb006c2",
48
+ "kind": "range",
49
+ "title": "Fill the question",
50
+ "body": {
51
+ "min": "0",
52
+ "max": "100"
53
+ }
54
+ },
55
+ {
56
+ "id": "Qa01e47",
57
+ "kind": "page",
58
+ "body": {
59
+ "page": "This is the **presentation** page. \n\nLorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. "
60
+ }
61
+ }
62
+ ]
63
+ }
64
+ }
@@ -0,0 +1,115 @@
1
+ {
2
+ "account_id": "RESEARCHER_ACCOUNT_ID",
3
+ "survey": {
4
+ "id": null,
5
+ "title": "Ad Test",
6
+ "tagline": "Check the video and describe your experience",
7
+ "prequalification": "",
8
+ "kind": "media_test",
9
+ "published": true,
10
+ "cap_completions": 10,
11
+ "demographics": [
12
+ {
13
+ "key": "gender",
14
+ "value": [
15
+ "male"
16
+ ]
17
+ }
18
+ ],
19
+ "credits": {
20
+ "kind": "stars",
21
+ "amount": "220.0"
22
+ },
23
+ "questions": [
24
+ {
25
+ "id": "Qa828f7",
26
+ "kind": "page",
27
+ "body": {
28
+ "page": "The following page displays an **advertisement** for few minutes. \n\nYou will be asked to answer questions on that advertisement later on."
29
+ }
30
+ },
31
+ {
32
+ "id": "Qbc8435",
33
+ "kind": "page",
34
+ "body": {
35
+ "page": "Please watch the video **until the end**\n\n<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/6tCtM8UEQv8\" frameborder=\"0\" allowfullscreen></iframe>"
36
+ }
37
+ },
38
+ {
39
+ "id": "Qb5faf2",
40
+ "kind": "multiple_sole",
41
+ "title": "What is your immediate reaction to the advertisement?",
42
+ "demographic_key": "gender",
43
+ "body": {
44
+ "options": [
45
+ {
46
+ "text": "I found it interesting",
47
+ "demographic_value": "male"
48
+ },
49
+ {
50
+ "text": "Somewhat confusing",
51
+ "demographic_value": "female"
52
+ },
53
+ {
54
+ "text": "Rather boring",
55
+ "demographic_value": "trans"
56
+ },
57
+ {
58
+ "text": "Don’t know",
59
+ "demographic_value": "other"
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "id": "Q9df425",
66
+ "kind": "multiple_sole",
67
+ "title": "Which product does the advertisement try to sell?",
68
+ "body": {
69
+ "options": [
70
+ {
71
+ "text": "A movie"
72
+ },
73
+ {
74
+ "text": "A car"
75
+ },
76
+ {
77
+ "text": "A cheese"
78
+ },
79
+ {
80
+ "text": "Don’t know"
81
+ }
82
+ ]
83
+ }
84
+ },
85
+ {
86
+ "id": "Qe776d4",
87
+ "kind": "multiple_sole",
88
+ "title": "Do you know the company that created this ad?",
89
+ "body": {
90
+ "options": [
91
+ {
92
+ "text": "Yes"
93
+ },
94
+ {
95
+ "text": "Not sure"
96
+ },
97
+ {
98
+ "text": "No"
99
+ }
100
+ ]
101
+ }
102
+ }
103
+ ]
104
+ },
105
+ "price": {
106
+ "survey_questions": 5,
107
+ "survey_demographics": 1,
108
+ "price_by_question": 0.1,
109
+ "price_by_demographic": 0.5,
110
+ "total_price_by_questions": 0.5,
111
+ "total_price_by_demographics": 0.5,
112
+ "total": 1.0,
113
+ "panel_users_count": 1
114
+ }
115
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "account_id": "422c9c50-59e2-0131-785c-0a424708edaa",
3
+ "surveys": [
4
+ {
5
+ "id": 17,
6
+ "uuid": "UUID_1",
7
+ "title": "The survey 001",
8
+ "tagline": "This is an explanation of the survey",
9
+ "prequalification": null,
10
+ "kind": "mr_survey",
11
+ "published": true,
12
+ "body": {
13
+ "screens": [
14
+ {
15
+ "id": "S00010",
16
+ "questions": []
17
+ }
18
+ ]
19
+ }
20
+ },
21
+ {
22
+ "id": 18,
23
+ "uuid": "UUID_2",
24
+ "title": "The survey 002",
25
+ "tagline": "This is an explanation of the survey",
26
+ "prequalification": null,
27
+ "kind": "mr_survey",
28
+ "published": true,
29
+ "body": {
30
+ "screens": [
31
+ {
32
+ "id": "S00011",
33
+ "questions": []
34
+ }
35
+ ]
36
+ }
37
+ },
38
+ {
39
+ "id": 19,
40
+ "uuid": "UUID_3",
41
+ "title": "The survey 003",
42
+ "tagline": "This is an explanation of the survey",
43
+ "prequalification": null,
44
+ "kind": "mr_survey",
45
+ "published": true,
46
+ "body": {
47
+ "screens": [
48
+ {
49
+ "id": "S00012",
50
+ "questions": []
51
+ }
52
+ ]
53
+ }
54
+ }
55
+ ]
56
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "survey": {
3
+ "id": "001",
4
+ "title": "The survey 001",
5
+ "tagline": "This is an explanation of the survey",
6
+ "prequalification": "This survey require you to be a sport man older than 40",
7
+ "kind": "mr_survey",
8
+ "published": false,
9
+ "credits": {
10
+ "kind": "stars",
11
+ "amount": "280"
12
+ },
13
+ "questions": [
14
+ {
15
+ "id": "Qa01e47",
16
+ "kind": "page",
17
+ "body": {
18
+ "page": "The page"
19
+ }
20
+ }
21
+ ]
22
+ }
23
+ }
@@ -0,0 +1,63 @@
1
+ require_relative "test_helper"
2
+
3
+ class MockClientTest < MiniTest::Unit::TestCase
4
+ def setup
5
+ FakeWeb.allow_net_connect = false
6
+
7
+ @client = Dalia::Api::SurveyPlatform::MockClient.new({ :account_id => "RESEARCHER_ACCOUNT_UUID_MOCK" })
8
+ end
9
+
10
+ def test_fetch_surveys
11
+ response = @client.fetch_surveys
12
+
13
+ assert_equal(3, response[:surveys].length)
14
+ end
15
+
16
+ def test_fetch_survey
17
+ response = @client.fetch_survey(:survey_id => "SURVEY_UUID")
18
+
19
+ assert_equal(4, response[:survey][:questions].length)
20
+ end
21
+
22
+ def test_send_survey
23
+ response = @client.send_survey(:data => "DATA")
24
+
25
+ assert_equal("280", response[:survey][:credits][:amount])
26
+ end
27
+
28
+ def test_update_survey
29
+ response = @client.update_survey(:survey_id => "SURVEY_UUID", :data => "DATA")
30
+
31
+ assert_equal("280", response[:survey][:credits][:amount])
32
+ end
33
+
34
+ def test_fetch_completions
35
+ response = @client.fetch_completions(:survey_id => "SURVEY_UUID")
36
+
37
+ assert_equal(3, response[:completions].length)
38
+ end
39
+
40
+ def test_fetch_completions_csv
41
+ response = @client.fetch_completions_csv(:survey_id => "SURVEY_UUID")
42
+
43
+ assert_equal(8, response.lines.length)
44
+ end
45
+
46
+ def test_fetch_completion
47
+ response = @client.fetch_completion(:survey_id => "SURVEY_UUID", :completion_id => "COMPLETION_UUID")
48
+
49
+ assert_equal("completed", response[:completion][:state])
50
+ end
51
+
52
+ def test_fetch_survey_price
53
+ response = @client.fetch_survey_price(:account_id => "RESEARCHER_ACCOUNT_UUID_MOCK")
54
+
55
+ assert_equal(1.0, response[:price][:total])
56
+ end
57
+
58
+ def test_create_query
59
+ response = @client.create_query(:survey_id => "SURVEY_UUID", :question_id => "QUESTION_UUID")
60
+
61
+ assert_equal("Qb5faf2", response[:question_id])
62
+ end
63
+ end
@@ -0,0 +1,11 @@
1
+ require "fakeweb"
2
+ require "minitest/unit"
3
+ require "minitest/autorun"
4
+ require "mocha/setup"
5
+
6
+ require_relative "../lib/dalia_api_survey_platform"
7
+
8
+ class MiniTest::Unit::TestCase
9
+ FIXTURES = File.expand_path("#{File.dirname(__FILE__)}/fixtures")
10
+ end
11
+
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dalia_api_survey_platform
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Fernando Guillen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: recursive-open-struct
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: fakeweb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mocha
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Ruby wrapper for the Dalia's API
98
+ email:
99
+ - fguillen.mail@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rvmrc
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - dalia_api_survey_platform.gemspec
111
+ - etc/fake_responses/create_query.json
112
+ - etc/fake_responses/fetch_completion.json
113
+ - etc/fake_responses/fetch_completions.csv
114
+ - etc/fake_responses/fetch_completions.json
115
+ - etc/fake_responses/fetch_survey.json
116
+ - etc/fake_responses/fetch_survey_price.json
117
+ - etc/fake_responses/fetch_surveys.json
118
+ - etc/fake_responses/send_survey.json
119
+ - etc/fake_responses/update_survey.json
120
+ - lib/dalia_api_survey_platform.rb
121
+ - lib/dalia_api_survey_platform/client.rb
122
+ - lib/dalia_api_survey_platform/exception.rb
123
+ - lib/dalia_api_survey_platform/http_client.rb
124
+ - lib/dalia_api_survey_platform/json_extension.rb
125
+ - lib/dalia_api_survey_platform/log.rb
126
+ - lib/dalia_api_survey_platform/mock_client.rb
127
+ - lib/dalia_api_survey_platform/version.rb
128
+ - test/client_test.rb
129
+ - test/fixtures/fake_responses/create_query.json
130
+ - test/fixtures/fake_responses/fetch_completion.json
131
+ - test/fixtures/fake_responses/fetch_completions.csv
132
+ - test/fixtures/fake_responses/fetch_completions.json
133
+ - test/fixtures/fake_responses/fetch_survey.json
134
+ - test/fixtures/fake_responses/fetch_survey_price.json
135
+ - test/fixtures/fake_responses/fetch_surveys.json
136
+ - test/fixtures/fake_responses/send_survey.json
137
+ - test/mock_client_test.rb
138
+ - test/test_helper.rb
139
+ homepage: https://github.com/DaliaResearch/DaliaApiSurveyPlatform
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.0.3
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Ruby wrapper for the Dalia's API
163
+ test_files:
164
+ - test/client_test.rb
165
+ - test/fixtures/fake_responses/create_query.json
166
+ - test/fixtures/fake_responses/fetch_completion.json
167
+ - test/fixtures/fake_responses/fetch_completions.csv
168
+ - test/fixtures/fake_responses/fetch_completions.json
169
+ - test/fixtures/fake_responses/fetch_survey.json
170
+ - test/fixtures/fake_responses/fetch_survey_price.json
171
+ - test/fixtures/fake_responses/fetch_surveys.json
172
+ - test/fixtures/fake_responses/send_survey.json
173
+ - test/mock_client_test.rb
174
+ - test/test_helper.rb