poptart 0.0.6 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f25834bcd5de7c7d86e441b4d9e4934db4beb1b4
4
- data.tar.gz: f5778a090c1b45c9e433763533c1227f439fcfcb
3
+ metadata.gz: 51e0f75b30a939cea82b52d482f51d586b2287bf
4
+ data.tar.gz: b1b3ec6398baa588562fe3add59bf73dc75fd2df
5
5
  SHA512:
6
- metadata.gz: b1742e82de647cae81f9d9e4eb91e737b44e7b708df50810830e8ca8677d390b709a511bec4d331aa9a3d0d45be6fac8f4be74505852d4e0e8fae2f9ed0ada36
7
- data.tar.gz: 76a51e841b06c6df233cafea45d3701a3c2f6eeb1821090167cb4afc923e0c4d366e734adf1d54b2e6071b6b6b96f40778e19a29590d2ca4c04e1880a333201e
6
+ metadata.gz: dbfc6a4f084112f76c30d8662fa8d38a14c1495f7217ed07ea6f90a5862d5711b9a107b28be326194649c593b1a637c495e86818e8f6174fe352d76555bdd1f8
7
+ data.tar.gz: 6d727efd65dd0d2695af39da9d094d1ff5f7914c145e2b15ffd65b4dc4d6b291537e4c81eb4ac40ed57bd8e2d50e7ee5ca65a0b523a38bbb7e616931a5707e84
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- poptart (0.0.5)
4
+ poptart (0.0.6)
5
5
  activesupport
6
6
  addressable
7
7
  faraday
data/README.md CHANGED
@@ -0,0 +1,35 @@
1
+ # Poptart
2
+
3
+ The gem used to consume the REST API provided by [Happiness Service](https://github.com/austenito/happiness_service)
4
+
5
+ # Usage
6
+
7
+ The gem provides ActiveRecord-y like models exposing service endpoint attributes.
8
+
9
+ ## User
10
+
11
+ To create a user:
12
+
13
+ ```
14
+ user = User.create(14)
15
+ user.id # => 14
16
+ ```
17
+
18
+ Users have a 1-many relationship to `surveys`. A user has read/write access to surveys as such:
19
+
20
+ ```
21
+ user.create_survey
22
+ user.create_random_survey
23
+ user.survey_for_id(id)
24
+ user.survey_for_url #=> Do I want to get rid of this?
25
+ ```
26
+
27
+
28
+ ## Question
29
+
30
+ To find all questions:
31
+
32
+ ```
33
+ questions = Question.all
34
+
35
+ ```
@@ -1,11 +1,11 @@
1
1
  module Poptart
2
2
  class Survey < Model
3
3
  include Poptart::Request
4
- attr_accessor :user_id, :survey_questions
4
+ attr_accessor :service_user_id, :survey_questions
5
5
 
6
6
  def initialize(response)
7
7
  super
8
- @user_id = params['user_id']
8
+ @service_user_id = params['service_user_id']
9
9
  @completed = params['completed']
10
10
 
11
11
  @survey_questions = params['survey_questions'].map do |survey_question|
data/lib/poptart/user.rb CHANGED
@@ -22,13 +22,13 @@ module Poptart
22
22
  end
23
23
 
24
24
  def create_survey
25
- response = post(root.surveys_url, survey: { user_id: id })
25
+ response = post(root.surveys_url, survey: { service_user_id: service_user_id })
26
26
  Poptart::Survey.new(response)
27
27
  end
28
28
 
29
29
  def create_random_survey
30
30
  url = root.surveys_url(query: {random: true})
31
- response = post(url, survey: { user_id: id })
31
+ response = post(url, survey: { service_user_id: service_user_id })
32
32
  Poptart::Survey.new(response)
33
33
  end
34
34
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Poptart
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -4,14 +4,14 @@ describe 'Answering survey questions' do
4
4
  it "creates and returns an empty survey", :vcr do
5
5
  user = Poptart::User.create
6
6
  survey = user.create_survey
7
- survey.user_id.should == user.id
7
+ survey.service_user_id.should == user.service_user_id
8
8
  survey.survey_questions.count.should == 0
9
9
  end
10
10
 
11
11
  it "creates and returns a random question survey", :vcr do
12
12
  user = Poptart::User.create
13
13
  survey = user.create_random_survey
14
- survey.user_id.should == user.id
14
+ survey.service_user_id.should == user.service_user_id
15
15
  survey.survey_questions.count.should == 5
16
16
  end
17
17